We will build a domain-specific support ticket classifier using few-shot transfer learning with an Oxlo.ai-hosted LLM. This approach is for teams that need customized model behavior immediately without managing GPU fine-tuning infrastructure.
What you'll need
- Python 3.10 or newer
- An Oxlo.ai API key from https://portal.oxlo.ai
- The OpenAI SDK:
pip install openai
Step 1: Verify connectivity
Set up the OpenAI-compatible client and confirm you can reach Oxlo.ai. I use llama-3.3-70b here because it follows formatting instructions reliably.
from openai import OpenAI
import os
client = OpenAI(
base_url="https://api.oxlo.ai/v1",
api_key=os.environ.get("OXLO_API_KEY")
)
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[{"role": "user", "content": "Say OK"}],
)
print(response.choices[0].message.content)
Step 2: Design the transfer learning prompt
Instead of training new weights from scratch, we adapt a frozen foundation model by embedding task-specific examples in the system prompt. This is in-context transfer learning. The prompt below defines the classification schema and the few-shot adaptation layer.
SYSTEM_PROMPT = """You are a support ticket classifier. Read the customer message and classify it into exactly one category.
Categories:
- billing: payment, invoices, refunds
- technical: bugs, errors, feature questions
- account: login, security, profile changes
Respond ONLY with a JSON object in this format:
{"category": "<category>", "urgency": "low|medium|high", "reason": "<one sentence>"}
Examples:
User: I was charged twice for my subscription this month.
Assistant: {"category": "billing", "urgency": "high", "reason": "Duplicate charge requires immediate refund review."}
User: How do I reset my password?
Assistant: {"category": "account", "urgency": "medium", "reason": "Standard account recovery request."}
User: The API returns a 500 error when I post to /v1/items.
Assistant: {"category": "technical", "urgency": "high", "reason": "Server error indicates a bug in production."}
"""
Step 3: Build the inference wrapper
We enforce structured output by setting response_format to json_object. The function below assembles the system prompt and the new user message into a single Oxlo.ai API call.
import json
def classify_ticket(user_message: str) -> dict:
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_message},
],
response_format={"type": "json_object"},
temperature=0.1,
)
raw = response.choices[0].message.content
return json.loads(raw)
Step 4: Test on unseen inputs
These tickets are not in the few-shot examples, so they test whether the model has actually transferred the classification concept or is simply memorizing.
test_tickets = [
"My invoice shows the wrong tax rate. Can you fix it?",
"I get a timeout every time I upload a file larger than 10MB.",
"I want to update my email address but the confirmation link is broken.",
"Do you offer yearly billing instead of monthly?",
]
for ticket in test_tickets:
result = classify_ticket(ticket)
print(f"Ticket: {ticket}")
print(f"Result: {json.dumps(result, indent=2)}")
print()
Run it
Here is the complete script. Save it as ticket_classifier.py, set your OXLO_API_KEY, and run it.
from openai import OpenAI
import os
import json
client = OpenAI(
base_url="https://api.oxlo.ai/v1",
api_key=os.environ.get("OXLO_API_KEY")
)
SYSTEM_PROMPT = """You are a support ticket classifier. Read the customer message and classify it into exactly one category.
Categories:
- billing: payment, invoices, refunds
- technical: bugs, errors, feature questions
- account: login, security, profile changes
Respond ONLY with a JSON object in this format:
{"category": "<category>", "urgency": "low|medium|high", "reason": "<one sentence>"}
Examples:
User: I was charged twice for my subscription this month.
Assistant: {"category": "billing", "urgency": "high", "reason": "Duplicate charge requires immediate refund review."}
User: How do I reset my password?
Assistant: {"category": "account", "urgency": "medium", "reason": "Standard account recovery request."}
User: The API returns a 500 error when I post to /v1/items.
Assistant: {"category": "technical", "urgency": "high", "reason": "Server error indicates a bug in production."}
"""
def classify_ticket(user_message: str) -> dict:
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_message},
],
response_format={"type": "json_object"},
temperature=0.1,
)
raw = response.choices[0].message.content
return json.loads(raw)
if __name__ == "__main__":
test_tickets = [
"My invoice shows the wrong tax rate. Can you fix it?",
"I get a timeout every time I upload a file larger than 10MB.",
"I want to update my email address but the confirmation link is broken.",
"Do you offer yearly billing instead of monthly?",
]
for ticket in test_tickets:
result = classify_ticket(ticket)
print(f"Ticket: {ticket}")
print(f"Result: {json.dumps(result, indent=2)}")
print()
Example output:
Ticket: My invoice shows the wrong tax rate. Can you fix it?
Result: {
"category": "billing",
"urgency": "high",
"reason": "Incorrect tax calculation affects invoice accuracy."
}
Ticket: I get a timeout every time I upload a file larger than 10MB.
Result: {
"category": "technical",
"urgency": "medium",
"reason": "Upload timeout suggests a performance issue."
}
Ticket: I want to update my email address but the confirmation link is broken.
Result: {
"category": "account",
"urgency": "medium",
"reason": "Broken confirmation link blocks profile update."
}
Ticket: Do you offer yearly billing instead of monthly?
Result: {
"category": "billing",
"urgency": "low",
"reason": "General billing plan inquiry with no immediate impact."
}
Wrap-up
If your ticket volume grows, expand the few-shot examples in the system prompt or switch to qwen-3-32b for multilingual classification. Because Oxlo.ai charges a flat rate per request rather than per token, adding more context examples does not increase your inference cost, which makes this transfer learning pattern especially practical at scale. See the details at https://oxlo.ai/pricing.
Top comments (0)