Smart Support-Ticket Router
Routes support tickets to 1 of 10 queues and predicts priority, using TF-IDF and Logistic Regression.
Nov 2026
- Python
- scikit-learn
- fastembed
- Qdrant
- FastAPI
- Streamlit
- pytest
- Ruff
- uv
- GitHub Actions
- Docker
| Metric | Value | Condition | Source |
|---|---|---|---|
| Queue macro-F1 | 0.532 | 4,731-ticket held-out test set | source for Queue macro-F1 |
| Queue macro-F1, baseline | 0.045 | 4,731-ticket held-out test set | source for Queue macro-F1, baseline |
| Priority macro-F1 | 0.612 | 4,731-ticket held-out test set | source for Priority macro-F1 |
| Priority macro-F1, baseline | 0.195 | 4,731-ticket held-out test set | source for Priority macro-F1, baseline |
| Similar-ticket precision@5 | 0.460 | fastembed + Qdrant over 18,923 tickets | source for Similar-ticket precision@5 |
| API latency p50 | 67 ms | 200 sequential requests, top_k=5, laptop CPU, Docker | source for API latency p50 |
| API latency p95 | 111 ms | 200 sequential requests, top_k=5, laptop CPU, Docker | source for API latency p95 |
Dataset: Tobi-Bueck/customer-support-tickets by Tobias Bueck, CC BY-NC 4.0 (non-commercial), English rows only. The data appears to be synthetic.
Problem
Support teams get free-text tickets. Each one has to go to the right queue and get a priority before anyone can work on it. Doing that by hand is slow and inconsistent.
My router reads a ticket’s subject and body. It returns the most likely queue and priority, each with a confidence score, plus the most similar past tickets with their answers, so an agent has a head start.
It is a learning and portfolio project. I wanted one small repo that covers classic ML, vector search, an API, a UI, tests, Docker and CI.
Constraints
The data is the Tobi-Bueck/customer-support-tickets dataset, English rows only. After removing duplicate bodies there are 23,654 tickets. The queues are very imbalanced: 6,836 tickets in one queue against 341 in another.
The data appears to be synthetic, so real-world accuracy is unknown. I split it 80/20, stratified by queue, with seed 42. That leaves 4,731 held-out English tickets for testing.
The spec sets these rules. Seeds are fixed, the dataset commit is pinned, and dependency versions are locked. Tests run offline: no network, no Docker, no real dataset. The latency target is p95 under 300 ms on a local CPU after warm-up, with top_k = 5.
Decision
I used TF-IDF with Logistic Regression, as two separate models: one for queue, one for priority. It trains in about 20 seconds, it is explainable, and it is a strong baseline for text. Separate models can be tuned or replaced on their own.
For similar tickets I embed the text with fastembed (BAAI/bge-small-en-v1.5, 384 dimensions). It runs on CPU through ONNX, with no PyTorch. Qdrant stores the vectors and supports payload filters, for example “only tickets from queue X”.
To avoid leakage, I remove duplicates before the split, so a ticket cannot be in both train and test. I also index only the train split, so no test ticket can find itself. Macro-F1 is the headline metric, because accuracy would hide bad small classes. A most-frequent baseline runs on the same split.
Trade-off
Only the train split is indexed, so precision@5 is honest: 18,923 of the 23,654 tickets are searchable and the 4,731 test tickets are not.
fastembed runs on CPU through ONNX with no PyTorch, so the Docker image stays small, about 330 MB.
Building the 18,923-ticket index took about 25 minutes (1,488.7 s) on my laptop CPU.
Result
On the 4,731-ticket held-out test set, queue macro-F1 is 0.532 against 0.045 for the most-frequent baseline. Priority macro-F1 is 0.612 against 0.195.
Similar-ticket precision@5 is 0.460 (same queue, 18,923 indexed train tickets). The spec’s target was p95 under 300 ms on a local CPU after warm-up. The measured API latency is p50 67 ms and p95 111 ms (200 sequential requests, top_k=5, laptop CPU, Docker).
Most queue errors are between Technical Support, IT Support, Product Support and Customer Service. These queues share most of their vocabulary in this dataset. Distinct queues such as Billing, HR and Service Outages score much higher.
What I’d do next
Queue overlap caps macro-F1. These ideas might help, and nothing is promised: combine the embeddings with TF-IDF features, use a kNN vote from Qdrant as a second opinion, and run a hyperparameter search with GridSearchCV.
The confidence is the highest predict_proba value. It is not a calibrated probability. I read 0.75 as “fairly sure”, not “75% correct”.
Calibrate the confidence scores. Merge the overlapping queues into one, if the business allows it. Cache the embeddings to disk so re-indexing is fast.