Learning path: AI System Design: Reliable, Fast and Affordable LLM Apps · Step 7 of 15
LLM Model Routing: Rules, a Classifier or a Cascade, Judged on Cost per Win and Every Topic
Send easy tickets to a small model and the bill drops from 21.39 to 4.31 units per solved ticket, while refund disputes fall from 0.93 to 0.64. A 1,200-ticket simulation compares rules, a classifier and a cascade on cost per win, the confidence dial, and a per-topic gate.
What you will learn
- Start a routing design from an all-large baseline and a hard rule for restricted data
- Compare rules, a classifier and a cascade on cost per successful ticket, not cost per call
- Treat the escalation threshold as a dial and pick it on separate tickets
- Prove a router topic by topic against a limit set in advance, then keep sampling in production
Before you start
- LLM Tokens, Context Windows and Cost
- Why You Cannot Ship an LLM Feature Without an Eval
Here's a senior interview question: 70% of your support tickets are simple. Design a router that cuts cost without a measurable quality drop, and show the evaluation that proves it. The 70% is the question's premise. We'll compare three ways to route, see what sends a ticket up to the large model, and prove it topic by topic. The tickets and models come from a small simulation, and costs are illustrative units, not prices: one unit for a small-model call, twenty for a large one.
Four steps
- A baseline: every ticket goes to the large model, so you have something to beat.
- Pick a way to route.
- Pick the signal that sends a ticket up.
- Prove it per topic against that baseline, because an average hides things.
The triage nurse
A hospital has one senior specialist, expensive and always busy. Not every patient needs her. Some signs go straight up: chest pain goes to the specialist. That's rules. Otherwise a triage nurse looks at you for a minute and makes a call before any treatment starts. That's a classifier. Or a junior doctor actually sees you, and if she's unsure, she calls the specialist. That's a cascade.
Rules and the nurse decide up front; the junior decides after doing some of the work. And the hospital's real worry is the patient sent home with the wrong call. That's what we have to catch.
The bill drops, and one topic falls
In a simulation with 1,200 tickets, sending everything to the large model costs 21.39 units per solved ticket. Call that cost per win. Now a cascade with a low confidence bar, 0.5, so the small model keeps most tickets. Cost per win falls to 4.31. It looks like a huge success. Then look at topics (open tickets only):
Rules, classifier or cascade
Now the three routes with a sensible bar (0.7 for the cascade). One rule comes first for all of them: restricted tickets stay on the small private model, and if it's unsure, they go to a human.
restricted tickets: 158 of 1200
all-large violations= 158 human= 0
rules violations= 0 human= 70
classifier violations= 0 human= 70
cascade violations= 0 human= 85
The all-large baseline broke that rule 158 times. Here is the comparison. Note the two quality columns: the simulator's table prints overall quality on all 1,200 tickets, and the numbers people quote for routing are quality on open (non-restricted) tickets.
simulated tickets: 1200 (cost in units)
route quality cost per win large
all-large 0.935 24000 21.39 1.00
rules 0.805 5380 5.57 0.18
classifier 0.833 7698 7.70 0.28
cascade 0.863 9100 8.79 0.33
| Route | Cost per win (units) | Quality, open tickets | Quality, all tickets |
|---|---|---|---|
| All large | 21.39 | 0.94 | 0.935 |
| Rules | 5.57 | 0.85 | 0.805 |
| Classifier | 7.70 | 0.88 | 0.833 |
| Cascade (bar 0.7) | 8.79 | 0.93 | 0.863 |
Rules are cheapest, and the cascade is closest to the baseline. Its cost per win is about 59% below all-large. That saving comes from what we assumed, like the large model costing twenty times the small one. Change that, and the saving moves.
The signal that sends a ticket up
In the cascade, the signal is the small model's confidence, and it works like a dial:
Confidence only helps if right answers score higher than wrong ones, and the simulation assumed that. A production model can be confident and wrong. So measure it, and add other signals: no document found, a tool that failed, or a customer asking again. And pick the bar on separate tickets, not the ones you report on.
Prove it against all-large
Each route is compared with all-large, overall and per topic, against a limit chosen beforehand:
rules FAIL: overall -0.09, invoice copy -0.08, password reset -0.09, account recovery -0.27, api error trace -0.23
classifier FAIL: overall -0.06
cascade pass
Rules miss the limit on five lines. The classifier misses it once, overall, by about 0.06. The cascade passes. But read that carefully: on open tickets it's still 0.93 against 0.94, and API error traces go from 0.85 to 0.77. So don't say "no quality drop". Say it stayed inside a limit you chose before you saw results. The same idea of a gate written in advance is in Regression Testing an LLM Bot in CI.
Catching a regression in production
This part is a design answer; it wasn't simulated. Tickets change after launch, so:
- Log every routing decision with the topic, the signal and the model.
- Send a small sample of the tickets the small model kept to the large one too, and compare.
- Watch customer satisfaction per topic, not just overall.
- Watch the escalation rate. A sudden move means something changed, even if the average looks fine.
- Keep a flag that sends one topic back to the large model, so one bad topic doesn't mean turning the whole router off.
The follow-ups
- Classifier or cascade? A classifier spends nothing before deciding, but it's a guess. A cascade sees an answer, but a hard ticket pays twice, 1 unit and then 20, and waits longer. The simulation doesn't measure time, so say that.
- A topic turns up that you never evaluated. Send it to the large model until you have cases for it.
- Why cost per win, not cost per call? Because a cheap wrong answer isn't cheap.
| Level | What the answer has |
|---|---|
| Weak | "Send the easy tickets to the small model and save money" |
| Good | An all-large baseline, restricted data handled first, routes compared on cost per win |
| Strong | Also checks every topic, names the signal and how the bar is picked, and labels the saving as depending on its assumptions |
What to do when the large model is down altogether is a different pattern: Fallback Models.
Recap
| Idea | What to remember |
|---|---|
| Baseline | All-large first, plus a hard rule for restricted data |
| Routes | Rules, classifier, cascade, each scored on cost per win |
| Signal | A dial; pick it on separate tickets and add signals besides confidence |
| Proof | Topic by topic, inside a limit set first, then keep sampling in production |
Try it yourself
Pick a product you use that gets easy and hard requests. Name the signal you'd trust to send a request up to the bigger model, and how you'd find out it was wrong.
Related course on Udemy
Machine Learning Engineer: From First Model to ML Engineer
Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (paid course, opens in a new tab)Related posts
Fallback Models for an LLM App: A Chain That Checks Region and Fit, Flags Degraded Answers and Gets Rehearsed
When the main model goes down, the backup has to be allowed to take the data, able to read the whole request and tested before the bad day. A simulated four-model chain for an EU customer: a 6,000-token request lands on mid-eu, flagged degraded; a 10,000-token request is served by nobody, on purpose.
Back Pressure for LLM Traffic: Bound the Queue, Give Chat Its Own Lane, Count Tokens, Cancel When the Caller Leaves
A bulk upload buries the chat. In a small simulation, one shared queue grows to 199 waiting and the middle chat answer takes 80.2 s. A bound plus a chat lane brings it to 0.35 s while 178 bulk jobs are told to retry in 10 s, and cancelling abandoned calls saves 21,000 wasted tokens.
Load Balancing LLM Traffic: Count the Work, Weigh the Prefix Cache, Check Real Health, Drain Before Deploys
Six GPU replicas, two at 95% and four at 30%: round robin counts requests, and requests aren't equal. In a small simulation, least outstanding requests cuts p95 from 6.52 s to 3.05 s, prefix affinity lifts cache hits to 95% but pushes p95 to 11.45 s, a real health check takes errors from 48 to 2, and draining cuts 0 answers instead of 4.
A Message Queue for Document Ingestion: At Least Once, Leases, an Idempotent Consumer and a Dead Letter Queue
A queue doesn't lose a document, but it can hand one out twice. In a small simulation, a worker crash makes document two go from 3 to 6 chunks and the index holds 11 when the documents hold 8. An idempotent consumer brings it back to 8 with the same two deliveries, and a limit of three tries moves a poison file to a dead letter queue.