Agentic Pattern Libraryby Vikas Goyal
Patterns / Math models / Model cascades
No. M11 Multi-model Established Decision Coordination

Model cascades

Expected cost \(c_1 + e\,c_2\), and accuracy set by the confidence signal

Takeaway

Sending every request to the large model gets 95% at full cost. Escalating only the % the small model is least sure of gets 93.7% at 37% of the cost.

Change the blue number. Every figure on this page updates with it.

Why care

Most requests don't need your most expensive model.

Frontier models can cost ten to fifty times more per call than small ones, yet on routine traffic the small model is right most of the time. A cascade answers with the small model, checks how confident that answer is, and escalates only the doubtful ones. Done well, it keeps most of the large model's accuracy for a fraction of its cost. Done badly, with a confidence score that can't tell right answers from wrong ones, it pays for escalations at random. This page shows the trade-off, and why the confidence signal is the part worth engineering.

The intuition

A junior analyst handles every case and passes the ones they are unsure of to a senior colleague. If the junior is good at knowing what they don't know, the senior sees mostly the cases that need them, and the team's accuracy approaches the senior's at a fraction of the senior's time. If the junior can't tell which cases they got wrong, they pass up cases at random: the senior's time is spent, and most of the junior's mistakes still go out.

So a cascade has three ingredients, and the third is easy to overlook:

  • how good the small model is,
  • how good the large model is on the cases it receives, which are the hard ones,
  • how well the small model's confidence separates its right answers from its wrong ones.

The math

The small model answers every request at cost \(c_1\). A confidence score \(x\) decides: accept if \(x \ge t\), escalate otherwise at extra cost \(c_2\). With \(e\) the share escalated,

$$\text{cost} = c_1 + e\,c_2, \qquad \text{accuracy} = p_1\,\Pr(x\ge t \mid \text{right}) + e\,\big(p_2 - h\,(1-e)\big)$$

To model the confidence score, assume scores for right answers and wrong answers are normally distributed and separated by \(\mu\), set from the score's AUC, the chance a random right answer scores above a random wrong one:

$$\mu = \sqrt2\,\Phi^{-1}(\text{AUC}), \qquad \Pr(x\ge t\mid\text{right}) = 1-\Phi(t-\mu), \qquad \Pr(x\ge t\mid\text{wrong}) = 1-\Phi(t)$$
\(p_1,\ p_2\)
accuracy of the small and the large model on all traffic
\(h\)
how much worse the large model does on the hardest cases; escalated cases are harder than average, less so as \(e\) grows, and at \(e = 1\) they are simply all traffic
\(c_1,\ c_2\)
cost per request of the small and the large model
AUC
quality of the confidence score: 0.5 is a coin flip, 1.0 separates right from wrong perfectly
\(e\)
share of requests escalated, set by the threshold \(t\)
  • Random escalation is a straight line: with AUC 0.5, escalated cases are a random sample, no harder than average, and accuracy rises linearly from \(p_1\) to \(p_2\) as \(e\) grows. Every point above that line is value from the confidence signal.
  • Escalate in order of doubt: the best rule escalates a request when its chance of being right, given its score, is below what the large model would achieve, adjusted for cost.
  • Accepted answers get better as you escalate more: the answers you keep are the confident ones, so their accuracy can exceed \(p_1\) by a wide margin.

Where each of these comes from is worked through in Derivations at the end of the page.

Interactive calculator

Describe the two models and the confidence signal, then choose how much to escalate. The first view traces every possible cascade from "small only" to "large only".

0.5 is random. Raw log-probabilities: often 0.65–0.75. Checks plus a verifier: 0.85–0.95.
–
Cascade accuracy
–
Cost, share of large-only
–
Versus large model alone
–
Accuracy of answers the small model keeps
–
Same escalation, chosen at random
–
Escalation to come within 1 point of the large model
Cascade, escalating the least confident Escalating at random Large model alone

Worked example: invoice extraction

An accounts-payable agent extracts fields from 2 million invoices a month. A small model gets every field right on 86% of invoices at $0.002 each; a frontier model gets 95% at $0.03, fifteen times more, and about 90% on the messy invoices a cascade would send it. Running everything on the frontier model costs $60,000 a month.

The team escalated the 30% of invoices with the lowest confidence and compared three confidence signals:

SetupAccuracyMonthly cost
Small model only86.0%$4,000
Frontier model only95.0%$60,000
Cascade, confidence from token log-probabilities (AUC 0.70)90.6%$22,000
Cascade, plus field checks: totals add up, dates and tax IDs parse (AUC 0.85)93.7%$22,000
Cascade, plus a small verifier model (AUC 0.95)96.0%$22,000 + verifier

All three cascades cost the same, because they escalate the same share. What separated them was the confidence signal alone: from 90.6% to 96.0%, the difference between a cascade that loses to the frontier model and one that beats it. The deterministic field checks were a few dozen lines of code and recovered most of the gap; the team shipped those first and added the verifier for high-value invoices.

Assumptions and where it breaks

  • The binormal confidence model is an approximation. Real scores are skewed and clumped. Measure the actual accuracy at each threshold on held-out data rather than trusting the curve's exact shape.
  • The large model's accuracy on hard cases is a guess until measured. \(h\) can be large: escalated cases are the ambiguous ones. Run the large model on a sample of escalated cases to estimate it.
  • Latency adds up. Escalated requests pay for both calls in sequence. For interactive paths, consider escalating in parallel when confidence is borderline.
  • Confidence drifts. A model update or a shift in traffic changes the score distribution, and a fixed threshold then escalates a different share. Monitor the escalation rate and re-tune.
  • Errors are not equal. A wrong invoice total costs more than a wrong vendor address. Escalate by expected cost of error, not just probability of error.

How to apply it

  1. Label a few hundred requests and run both models on all of them, so you know each one's accuracy and where they differ.
  2. Build the best confidence signal you can afford. Start with cheap deterministic checks, then add agreement between samples (M10) or a small verifier.
  3. Measure the signal's AUC on the labeled set. Below 0.7, fix the signal before tuning thresholds.
  4. Pick the threshold from the frontier. Choose the escalation share where the curve flattens, or the cheapest point that meets your accuracy target.
  5. Monitor escalation rate and spot-check accepted answers weekly; both drift.

How to explain it to a stakeholder

"The small model handles the routine invoices and hands the doubtful ones to the expensive model. We get almost all of the expensive model's accuracy for about a third of the bill, and the better the small model is at knowing when it's unsure, the closer we get."

For coding agents

A machine-readable summary and a reference implementation. The same spec is embedded in this page as <script type="application/json" id="model-spec">, and the whole series is listed in models.json.

Model spec (YAML)
id: model-cascades
number: M11
name: Model cascades (confidence-based escalation)
family: multi-model
answers: "How much accuracy can a cheap-then-expensive cascade keep, and at what cost?"
formula:
  cost: "c1 + e * c2"
  accuracy: "p1 * P(accept | right) + e * (p2 - h*(1 - e))"
  separation: "mu = sqrt(2) * PhiInv(AUC)"
  accept_right: "1 - Phi(t - mu)"
  accept_wrong: "1 - Phi(t)"
inputs:
  p1: {type: float, meaning: small model accuracy}
  p2: {type: float, meaning: large model accuracy}
  h: {type: float, meaning: "large model accuracy drop on the hardest cases, applied as h*(1-e)"}
  auc: {type: float, meaning: confidence score AUC for small-model correctness}
  c1: {type: float, meaning: small model cost per request}
  c2: {type: float, meaning: large model cost per request}
  e: {type: float, meaning: share escalated}
assumptions:
  - binormal confidence scores
  - large-model accuracy on escalated cases is p2 - h*(1 - e)
  - binary correctness
use_when:
  - deciding whether a cascade is worth building
  - choosing an escalation threshold
related_patterns: [fast-slow-escalation, routing, draft-verify, metacognitive-monitor]
Reference implementation (Python, SciPy)
import math
from scipy.stats import norm
from scipy.optimize import brentq

def cascade(p1, p2, auc, escalate, c1=1.0, c2=15.0, h=0.0):
    """Accuracy and cost when the least-confident share `escalate` goes to the large model."""
    mu = math.sqrt(2) * norm.ppf(auc)
    def esc_at(t):
        accept = p1 * (1 - norm.cdf(t - mu)) + (1 - p1) * (1 - norm.cdf(t))
        return 1 - accept
    if escalate <= 0:
        return p1, c1
    if escalate >= 1:
        return p2, c1 + c2
    t = brentq(lambda t: esc_at(t) - escalate, -10, 10)
    acc = p1 * (1 - norm.cdf(t - mu)) + escalate * (p2 - h * (1 - escalate))
    return acc, c1 + escalate * c2

if __name__ == "__main__":
    for auc in (0.70, 0.85, 0.95):
        acc, cost = cascade(0.86, 0.95, auc, escalate=0.30, h=0.07)
        print(auc, round(acc, 3), round(cost / 15, 3))
    # 0.70 0.906 0.367 | 0.85 0.937 0.367 | 0.95 0.960 0.367

Derivations

For the math-curious: where each result in The math comes from. Nothing above depends on reading this.

Cost and accuracy of a cascade

Every request pays \(c_1\); the escalated share \(e\) also pays \(c_2\). A request ends up right if the small model is right and its answer is kept, which happens with probability \(p_1\Pr(x\ge t\mid\text{right})\), or if it is escalated and the large model is right on it. Escalated cases are the hardest ones, so the large model does worse on them than its overall \(p_2\). The page models that drop as \(h(1-e)\): largest when only a few cases are escalated, and zero at \(e = 1\), when the escalated set is all traffic. This also assumes the large model's success on an escalated case does not depend on whether the small model happened to be right.

From AUC to the binormal separation

If right answers score \(X_1 \sim N(\mu,1)\) and wrong ones \(X_0 \sim N(0,1)\), independently, then \(X_1 - X_0 \sim N(\mu, 2)\). The AUC is \(\Pr(X_1 > X_0) = \Phi(\mu/\sqrt2)\). Inverting gives \(\mu = \sqrt2\,\Phi^{-1}(\text{AUC})\). AUC 0.85 corresponds to \(\mu \approx 1.47\), AUC 0.95 to \(\mu \approx 2.33\).

Random escalation is a straight line

With AUC 0.5, \(\mu = 0\): right and wrong answers have the same score distribution, so escalating a share \(e\) removes the same share of right answers as wrong ones. A random sample is no harder than average, so the large model scores \(p_2\) on it. The kept answers contribute \(p_1(1-e)\) and the escalated ones \(e\,p_2\): accuracy is \(p_1 + e\,(p_2 - p_1)\), linear in \(e\). Any useful confidence signal bends the curve above this line, because the answers it escalates are disproportionately wrong.

The best escalation rule

Escalating a request with score \(x\) changes expected accuracy by roughly \((p_2-h) - \Pr(\text{right}\mid x)\) and expected cost by \(c_2\). If each point of accuracy is worth \(\lambda\) in cost terms, escalate when \(\lambda\big((p_2-h) - \Pr(\text{right}\mid x)\big) > c_2\), that is, when \(\Pr(\text{right}\mid x) < p_2 - h - c_2/\lambda\). Since \(\Pr(\text{right}\mid x)\) rises with \(x\) under the binormal model, the rule is a threshold on the score, and sliding \(\lambda\) traces the frontier in the calculator.

References

  1. Chen, L., Zaharia, M. and Zou, J. (2023). FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performance. LLM cascades with learned scoring functions.
  2. Ong, I. et al. (2024). RouteLLM: Learning to Route LLMs with Preference Data. Routers that pick between a strong and a weak model per request.
  3. Viola, P. and Jones, M. (2001). Rapid object detection using a boosted cascade of simple features. CVPR. The classic cascade: cheap stages reject easy cases early.