Sub topic 11
Common pitfalls
This chapter assumes you have read the earlier chapters. You should know how a rule-based router and a confidence cascade work, how to compute expected cost, and how to sweep a threshold on a labeled sample. Most routing failures come from a few predictable mistakes. Each one below comes with a way to catch it.
Trusting confidence scores you have not checked
A cascade is only as good as the confidence number it reads. Small models are often overconfident. A score of 0.9 may mean the answer is right only 70% of the time. If so, the threshold of 0.8 you chose lets wrong answers through.
Check calibration before you trust a score. Group your labeled records by confidence and compare each group's score with its measured accuracy.
def calibration_table(records, bins=5):
# Each record: {"confidence": float, "small_correct": bool}
rows = []
for i in range(bins):
lo, hi = i / bins, (i + 1) / bins
last = i == bins - 1
group = [
r for r in records
if lo <= r["confidence"] < hi or (last and r["confidence"] == 1.0)
]
if group:
accuracy = sum(r["small_correct"] for r in group) / len(group)
rows.append((lo, hi, len(group), accuracy))
return rowsIf the 0.8 to 1.0 bucket shows 70% accuracy, the score is not usable as a threshold signal. You can use a different signal, such as agreement between repeated samples, or fit a mapping from raw score to measured accuracy.
Assuming a cascade is always cheaper
A cascade pays for the small model on every request. When too many requests escalate, you pay for both models and the total can exceed the cost of always using the large model. The cascade beats "always large" only when the share answered by the small model is greater than cost_small / cost_large.
def cascade_beats_large(frac_small, cost_small, cost_large):
cascade = cost_small + (1 - frac_small) * cost_large
return cascade < cost_large
print(cascade_beats_large(0.05, 1, 10)) # False: break-even is 0.10
print(cascade_beats_large(0.60, 1, 10)) # TrueThe break-even point is low when the small model is much cheaper. It rises as the price gap narrows. Recompute it whenever prices change.
Forgetting that escalation adds latency
An escalated request waits for the small model, then waits for the large model. Its latency is the sum of both calls. Averages hide this, so a cascade can look fast overall while the slowest requests get much slower.
Track latency by route and look at the 95th and 99th percentiles. If the escalated tail breaks your latency budget, a router that pays for only one model may fit better than a cascade.
Brittle rules and proxy signals
The keyword router from earlier sends any prompt containing "analyze" to the large model. A user asking "analyze this word: cat" gets the expensive path for no reason. A short prompt such as "Prove the claim in the attached paper" may need the large model, but the length rule sends it to the small one.
Rules drift away from reality as users change how they write. Review a sample of routed requests regularly. Look for cases where the small model failed on a "simple" route and cases where the large model was wasted.
Tuning and testing on the same data
If you pick a threshold from sweep on one sample and then report quality on that same sample, the result is optimistic. The threshold is fitted to that data's quirks.
- Split your labeled data into a tuning set and a held-out set.
- Choose the threshold on the tuning set only.
- Report accuracy and escalation rate on the held-out set.
- Make sure the sample matches production traffic, not only the easy or memorable cases.
A sample that is too small also misleads. With 50 records, a single label change moves accuracy by two points.
Noisy labels and an unfair comparison
The sweep function assumes small_correct and large_correct are reliable. If labels come from another model acting as judge, that judge has its own bias, often favoring longer or more polished answers. Spot-check a subset by hand. Also, a policy that matches the large model's accuracy is not automatically safe. Check the worst categories separately, because an average can hide a segment where the small model fails often.
Missing visibility
If you do not log which model handled each request, you cannot debug any of the problems above. Record the route, the confidence score, latency, token counts, and whether a fallback fired. Without this, a quality drop and a cost spike look the same: something changed, and you cannot say what.
Summary table
| Pitfall | Symptom | Check |
|---|---|---|
| Uncalibrated confidence | Wrong answers accepted | Calibration table |
| High escalation rate | Cost above always-large | Break-even fraction |
| Summed latency | Slow tail | p95 and p99 by route |
| Brittle rules | Odd routing choices | Review sampled routes |
| Tuning on test data | Production worse than evaluation | Held-out set |
| No logging | Cannot explain changes | Per-request route record |
Exercise
Your small model costs 2 units per request and your large model costs 20. In a cascade, 8% of requests are answered by the small model. Is the cascade cheaper than always using the large model? What share would make it break even?
Show answer
No. The cascade costs 2 + 0.92 * 20 = 20.4, which is more than 20. Break-even is costsmall / costlarge = 2 / 20 = 0.10, so the small model must answer more than 10% of requests for the cascade to be cheaper.
Exercise
A calibration table shows that requests with confidence between 0.8 and 1.0 are correct only 68% of the time. Name one problem this causes in a cascade with threshold 0.8, and one fix.
Show answer
The cascade accepts many wrong small-model answers because the score overstates reliability. Fixes include raising the threshold, mapping raw scores to measured accuracy, or using a different confidence signal such as agreement across repeated samples.