Ticket Router models
Trained models for a customer support ticket router, built for the SWE015 homework (Use Case 2). A free-text support message is classified into one of 155 intents or out of scope. The routed team is the intent's domain. Out-of-scope and low-confidence messages go to a human agent.
The repository holds the four models of the comparison ladder, plus the distilled student before quantization. The application runs the quantized student (student_int8/) and shows the other three models side by side.
Code, app and training scripts: github.com/ata-sesli/llm-homework
Files
| Path | Model | Framework and precision | Size (MB) | τ | τ_appliance |
|---|---|---|---|---|---|
baseline.joblib |
tf-idf (word 1–2-grams + char 2–5-grams) + logistic regression | scikit-learn, float64 | 67.3 | 0.65 | 0.35 |
ffn.pt, ffn_vectors.kv* |
Feedforward net (300 → 512 → 156) on the mean of fastText word vectors | PyTorch, fp32 | 123.6 | 0.80 | 0.50 |
bert_teacher/ |
bert-base-uncased, fine-tuned (teacher) |
PyTorch, fp32 | 439.2 | 0.75 | 0.55 |
bert_student/ |
distilbert-base-uncased, distilled from the teacher |
PyTorch, fp32 | 269.0 | 0.75 | 0.50 |
student_int8/ |
The student, exported to ONNX and quantized | ONNX Runtime, INT8 weights | 68.1 | 0.80 | 0.40 |
Sizes are the files each model needs at inference time, including the tokenizer or the word vectors. The FFN's word vectors are the 100k most frequent words of the pretrained fastText vectors (123 of its 124 MB). Each Transformer folder has a meta.json with the label order, the thresholds and the validation metrics. baseline.joblib and ffn.pt store their thresholds with the model.
Labels and decision rule
There are 156 classes: the 150 CLINC150 intents, 5 home-appliance intents (appliance_repair, appliance_spare_parts, appliance_warranty, appliance_installation, appliance_usage) and oos. The team is the intent's domain: one of the 10 CLINC domains or appliance_support. Small-talk intents get a canned reply instead of a team.
A message is out of scope if the top class is oos or its probability is below τ. When the top class is an appliance intent, τ_appliance is used instead, because each appliance intent has only 12 training examples. Both thresholds were tuned on the validation set only.
Training
- Data: CLINC150 (the "plus" version) and 100 home-appliance messages. Splits: train 15,310, validation 3,120, test 5,520 (1,000 out of scope). The appliance messages are split 60/20/20.
- Preprocessing: every model is trained and run on normalized text. The steps are model-code extraction (
DW-6534), NFKC, lowercasing, Turkish letter folding, mapping Turkish product names to English, and correcting misspelled product names. The models expect this normalized text. - Baseline: logistic regression with balanced class weights. C = 100 was chosen on validation.
- Feedforward net: SGD (lr 0.1, momentum 0.9, batch 64) on class-weighted cross-entropy. The best validation epoch out of up to 150 was kept.
- Teacher: AdamW (lr 5e-5, weight decay 0.01), 10% linear warmup then linear decay, batch 32, 5 epochs, class-weighted cross-entropy, at most 64 tokens. Epoch 4 was kept.
- Student: the same optimizer and schedule. The loss is α·T²·KL(teacher ‖ student) + (1 − α)·class-weighted cross-entropy, with α = 0.5 and T = 2. Epoch 4 was kept.
- Quantization: the student was exported to ONNX (TorchScript exporter, opset 17) and quantized with onnxruntime dynamic quantization: QInt8 weights, with activations quantized at run time. Its thresholds were tuned again on validation.
Results
Test set, 5,520 messages. Each model was evaluated once, with the thresholds tuned on validation.
| Model | Accuracy | OOS recall | In-scope accuracy | Appliance (20) | Size (MB) | Latency (ms) |
|---|---|---|---|---|---|---|
| tf-idf + logistic regression | 0.8707 | 0.890 | 0.8664 | 9/20 | 67.3 | 0.66 |
| Feedforward net on fastText | 0.8250 | 0.859 | 0.8175 | 11/20 | 123.6 | 0.07 |
| BERT-base (teacher) | 0.9217 | 0.893 | 0.9281 | 11/20 | 439.2 | 55.96 |
| DistilBERT student, fp32 | 0.9165 | 0.878 | 0.9250 | 11/20 | 269.0 | 27.16 |
| DistilBERT student, INT8 ONNX | 0.9074 | 0.926 | 0.9033 | 13/20 | 68.1 | 2.14 |
- Hardware: Apple M1, 16 GB RAM, macOS 15.7.8, CPU only.
- Latency: one message per call. After 20 warm-up calls, the mean of 200 timed calls on validation messages. Each model's own featurization (tf-idf, word vectors or tokenizer) is included; the shared preprocessing is not.
- INT8 measurement: the INT8 model was first measured in batches of 128 (accuracy 0.9111, OOS recall 0.904). Its outputs depend on the other messages in the batch, so its thresholds were tuned again at batch size 1 and the test row was measured again. The table shows the batch-size-1 result.
Usage
Follow the Quick start in the GitHub README. It downloads every file into the project's <storage>/models/ folder:
hf download atasesli/ticket-router --local-dir "$(python -c 'from src.paths import MODELS_DIR; print(MODELS_DIR)')"
The models are loaded by the project's src/models.py (load_models()), which also applies the thresholds. To use them on their own:
- Normalize first. Apply the project's
preprocess()to every message before it reaches a model. - One message per call for the INT8 model. Dynamic quantization picks activation scales per batch, padding included.
- Pickle formats.
baseline.joblib,ffn.ptandffn_vectors.kvuse Python pickle. Load them only if you trust this repository.
Limitations
- Small appliance test set: only 20 test messages, so the appliance accuracy (9 to 13 of 20) is a rough estimate.
- Washing and drying words: out-of-scope messages about washing or drying, such as a shampoo question, can be routed to appliance support.
- Spelling correction errors: the name "Owen" is corrected to "oven".
- English only: the models are English. Turkish messages work only through the product names that preprocessing maps to English.
Data sources and licenses
- CLINC150: Larson et al., 2019, An Evaluation Dataset for Intent Classification and Out-of-Scope Prediction, EMNLP-IJCNLP. github.com/clinc/oos-eval, commit
828f809, CC BY 3.0. - Home-appliance examples: 100 messages written for this project. The first draft was written with an AI assistant.
- Base models:
google-bert/bert-base-uncasedanddistilbert/distilbert-base-uncased, Apache 2.0. - Word vectors: fastText
wiki-news-300d-1M-subwordthrough gensim-data (fasttext-wiki-news-subwords-300). Mikolov et al., 2018, Advances in Pre-Training Distributed Word Representations, LREC. CC BY-SA 3.0.ffn_vectors.kv*is a subset of these vectors and is under the same license.