a builder's codex
codex · operators · Hamel Husain · ins_husain-model-cascade-routing

Route classification tasks to a small model when confident and a large model when uncertain to preserve accuracy while cutting inference cost

By Hamel Husain · AI product advisor and ML educator; co-creator of AI Evals for Engineers course · 2026-08-12 · essay · AI Product Engineering Notes

Tier B · TL;DR
Route classification tasks to a small model when confident and a large model when uncertain to preserve accuracy while cutting inference cost

Claim

Routing classification tasks to a small model for high-confidence inputs and a large model for uncertain ones preserves large-model accuracy on the full task while materially reducing average inference cost.

Mechanism

Most classification inputs cluster near the high-confidence end of a small model's probability distribution. For those inputs, the small model's prediction matches the large model's output, so the expensive call adds no value. The small model's confidence score acts as a routing gate: pass through when confidence exceeds a calibrated threshold, escalate when it does not. The large model processes only the subset of inputs where its additional capability changes the result. Total cost falls because the fraction requiring escalation is typically small.

Conditions

Holds when: the small model produces a reliable confidence or probability signal; the task has sufficient volume that two-model routing infrastructure is justified; the confidence threshold can be calibrated on held-out eval data that confirms the signal is predictive.

Fails when: the small model is overconfident and its high-confidence outputs are wrong at meaningful rates; the task is open-ended and does not reduce to a classification framing; volume is too low to justify the routing complexity.

Evidence

Husain documents the technique in his AI Product Engineering Notes (August 12, 2026): "a technique to route classification tasks to a small model when it's confident and to a large model when it's not, while preserving the large model's accuracy." He places this in the Systems section of his 13-session framework, the second stage after retrieval optimization.

Signals

Counter-evidence

Confidence calibration is a known weak point in classification models. A small model that is overconfident routes inputs to itself with high stated confidence even when wrong, defeating the accuracy preservation goal. Teams must validate on held-out eval data that the small model's confidence score is genuinely predictive before deploying to production.

Cross-references

Open the interactive view → View original source → Markdown source →