Mini-project: Domain-specialist support classifier

Build, validate, and verify the end-to-end training pipeline

Put every step of this course together: prepare labeled support tickets, enforce strict train/val splitting with zero leakage, validate JSON targets, and test the resulting Agent contract.

Example

from pydantic import BaseModel
from praisonai import Agent

class TicketRoute(BaseModel):
    queue: str
    priority: str

dataset = [
    ('Invoice charged twice', 'billing'),
    ('SSO login throws 500', 'security'),
    ('How do I export CSV?', 'product'),
    ('Need VAT number updated on invoice', 'billing'),
]
train_rows, val_rows = dataset[:3], dataset[3:]
assert not (set(p for p, _ in train_rows) & set(p for p, _ in val_rows)), 'Data leak!'

classifier = Agent(instructions='Classify tickets into queue (billing, security, product) and priority (high, low).')
pred = classifier.chat(val_rows[0][0], output_pydantic=TicketRoute)
print('Split OK -> train:', len(train_rows), '| val:', len(val_rows))
print('Prediction:', pred.model_dump())

Try it Yourself

Example explained

  • assert not (… & …) — Verifies zero prompt overlap between train and validation splits.
  • TicketRoute.model_validate_json(raw) — Enforces strict JSON contract matching on the fine-tuned model's output.

Ship command checklist

Run these four commands locally when you have 500+ curated examples to train, benchmark, and deploy your private classifier.

Example

praisonai train data validate --input data/train.jsonl
praisonai train --config train.yaml
praisonai train benchmark --base Qwen/Qwen2.5-3B-Instruct --tuned ./checkpoints/support-router --eval data/val.jsonl
praisonai train serve --checkpoint ./checkpoints/support-router --name support-router --quant Q4_K_M

Example explained

  • validate -> train -> benchmark -> serve — The repeatable 4-step lifecycle for every production fine-tuning iteration.

Reference: documentation