DEV Community

shashank ms
shashank ms

Posted on

LLM vs Traditional ML: Understanding the Differences and Applications

We are going to build a customer support triage agent that classifies incoming tickets, detects urgency, and drafts a first response. This is the exact kind of workflow where teams debate between a traditional ML pipeline and an LLM, so we will implement both in one script to see where each approach breaks down and where an LLM on Oxlo.ai takes over.

What you'll need

  • Python 3.10 or newer
  • An Oxlo.ai API key from https://portal.oxlo.ai
  • The OpenAI SDK and scikit-learn: pip install openai scikit-learn

Step 1: Build a traditional ML baseline

A classic approach is to vectorize the text with TF-IDF and train a logistic regression classifier. It works for obvious keywords, but it cannot detect implied urgency, nuanced sentiment, or draft a reply. Here is the baseline in a few lines of scikit-learn.

import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import make_pipeline

# Minimal labeled data. In production, maintaining this is most of the work.
data = pd.DataFrame({
    "text": [
        "I want a refund on my last order",
        "The app crashes when I click checkout",
        "How do I reset my password",
        "Your service is amazing, thanks",
        "I was charged twice this month",
        "Login button is broken on mobile",
        "Where is my shipment",
        "I love the new design",
    ],
    "label": ["billing", "bug", "account", "praise", "billing", "bug", "shipping", "praise"]
})

clf = make_pipeline(TfidfVectorizer(), LogisticRegression(max_iter=1000))
clf.fit(data["text"], data["label"])

ticket = "Hey, I tried to pay twice because the page froze and now my card was charged two times. This is urgent."
pred = clf.predict([ticket])[0]
conf = clf.predict_proba([ticket]).max()

print(f"Traditional ML predicts '{pred}' with confidence {conf:.3f}")

Step 2: Write the LLM system prompt

Instead of training a model, we will give a general-purpose LLM a system prompt that asks for structured reasoning and a draft reply. This collapses classification, sentiment analysis, and text generation into a single call.

SYSTEM_PROMPT = """You are a support triage agent. Analyze the user ticket and return a JSON object with exactly these keys:
  "category": one of [billing, bug, account, shipping, praise, other],
  "urgency": one of [low, medium, high],
  "sentiment": one of [positive, neutral, negative],
  "draft_reply": a concise, helpful first response under two sentences.

Rules:
- Mention of duplicate charges, payment failure, or refund means urgency is high.
- Reports of crashes or broken features mean category is bug.
- Respond with valid JSON only."""

Step 3: Connect to Oxlo.ai

We will use the OpenAI SDK pointed at Oxlo.ai. I am using llama-3.3-70b because it is a strong general-purpose flagship, and Oxlo.ai's flat per-request pricing means this single call costs the same no matter how long the ticket is. You can view current plans at https://oxlo.ai/pricing.

import json
from openai import OpenAI

client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")

def triage_with_llm(ticket: str):
    response = client.chat.completions.create(
        model="llama-3.3-70b",
        messages=[
            {"role": "system", "content": SYSTEM_PROMPT},
            {"role": "user", "content": ticket},
        ],
        response_format={"type": "json_object"},
    )
    return json.loads(response.choices[0].message.content)

Step 4: Run both approaches

Now we feed the same ambiguous ticket into both systems. The traditional model sees keywords and stops. The LLM understands context, detects the duplicate charge, and writes a reply.

import json

ticket = "Hey, I tried to pay twice because the page froze and now my card was charged two times. This is urgent."

print("=== Traditional ML ===")
# pred and conf are from Step 1
print(f"Predicted: {pred}, Confidence: {conf:.3f}")

print("\n=== LLM via Oxlo.ai ===")
result = triage_with_llm(ticket)
print(json.dumps(result, indent=2))

Run it

Save the full script as triage_agent.py, replace YOUR_OXLO_API_KEY, and run:

python triage_agent.py

Expected output:

=== Traditional ML ===
Predicted: billing, Confidence: 0.623

=== LLM via Oxlo.ai ===
{
  "category": "billing",
  "urgency": "high",
  "sentiment": "negative",
  "draft_reply": "I'm sorry for the trouble. I've flagged your duplicate charge for immediate review and you should see a correction within 24 hours."
}

Wrap up

The traditional model gave us a label with weak confidence and no action. The LLM on Oxlo.ai returned a structured decision, detected urgency from context, and drafted a reply in one request. For next steps, try swapping llama-3.3-70b for kimi-k2.6 if you need advanced reasoning on ambiguous tickets, or add function calling to open a refund ticket directly in your CRM. Because Oxlo.ai charges a flat rate per request, expanding the system prompt with extra examples or long conversation history does not inflate your bill the way token-based pricing would.

Top comments (0)