Sequential cascade (default)

Model Cascade diagramQuestion, Small model, Scorer, Large model, Answer. Step captions follow the diagram.QuestionSmall model$0.0002 / queryScorerLarge model$0.03 / queryAnswerModel Cascade diagramQuestion, Small model, Scorer, Large model, Answer. Step captions follow the diagram.QuestionSmall model$0.0002/ queryScorerLarge model$0.03 /queryAnswer

All steps

Easy question

Hard question

Parts of this pattern
Question Input / output
A support question. Most are easy ('How do I reset my router?'); a few are hard and need a stronger model.
Small model LLM call
The cheapest model, tried first on every question. It handles the easy majority on its own.
Scorer Evaluator
A cheap judge that rates the small model's answer from 0 to 1. Above the threshold the answer ships; below it, the question escalates.
Large model LLM call
The strongest, priciest model, called only for questions where the cheap answer scored too low.
Answer Input / output
The answer sent to the customer, from whichever rung of the cascade passed.
Question → Small model
Every question goes to the cheapest model first.Why does my VPN drop only on 5 GHz since the last firmware update?
Small model → Scorer
The small model's answer goes to the scorer, together with the question.Try restarting your router and reconnecting to the VPN.
Scorer → Answer≥ 0.8
If the score meets the threshold, the cheap answer is good enough and goes to the customer.score 0.93: 'Hold the reset button for 10 seconds until the light blinks amber, then set it up again in the app.'
Scorer → Large model< 0.8
If the score is too low, the same question goes up to the large model; the cheap answer is thrown away.score 0.41: generic advice that ignores the 5 GHz and firmware details. Escalating to the large model.
Large model → Answer
The top rung's answer is returned without another score; there is nowhere higher to go.Firmware 3.2 enables DFS channels on 5 GHz; when radar forces a channel switch, the VPN tunnel drops. Pin channel 36 or update to 3.2.1.

Predictive router

A trained router predicts how hard the query is before any model runs, so exactly one model answers and nothing is wasted on a failed cheap attempt.

Model Cascade: Predictive router diagramQuestion, Router, Small model, Large model, Answer. Step captions follow the diagram.QuestionRoutertrained classifierSmall modelLarge modelAnswerModel Cascade: Predictive router diagramQuestion, Router, Small model, Large model, Answer. Step captions follow the diagram.QuestionRoutertrainedclassifierSmall modelLarge modelAnswer

All steps
Parts of this pattern
Question Input / output
A support question, easy or hard; the router has to tell which before any answer exists.
Router Router
A small classifier trained on preference data. It predicts the chance the strong model is needed, in milliseconds.
Small model LLM call
The cheap model, which answers every query the router predicts it can handle.
Large model LLM call
The strong model, which answers only the queries the router predicts are hard.
Answer Input / output
The single answer generated for the query, from whichever model the router chose.
Question → Router
The question goes to the router before any model is called.Why does my VPN drop only on 5 GHz since the last firmware update?
Router → Small modeleasy
When the predicted need for the strong model is below the threshold, the cheap model answers.'How do I reset my router?' p(strong needed) = 0.07 < 0.5: small model.
Router → Large modelhard
When it is above the threshold, the query goes straight to the strong model, skipping the cheap attempt.'VPN drops only on 5 GHz since the firmware update' p(strong needed) = 0.86 > 0.5: large model.
Small model → Answer
The cheap model's answer is returned without any scoring step.Hold the reset button for 10 seconds until the light blinks amber, then set it up again in the app.
Large model → Answer
The strong model's answer is returned; it is the only model call this query made.Firmware 3.2 enables DFS channels on 5 GHz; pin channel 36 or update to 3.2.1.

Draft and verify

The small model always drafts; the large model accepts or rewrites it. Unlike speculative decoding, this saves money but costs time: two calls in sequence.

Model Cascade: Draft and verify diagramQuestion, Small model, Large model, Answer. Step captions follow the diagram.QuestionSmall modeldraftsLarge modelaccepts or rewritesAnswerModel Cascade: Draft and verify diagramQuestion, Small model, Large model, Answer. Step captions follow the diagram.QuestionSmall modeldraftsLarge modelaccepts orrewritesAnswer

All steps

Draft accepted

Draft rewritten

Parts of this pattern
Question Input / output
A support question; every one gets a cheap draft first.
Small model LLM call
The cheap model writes a full draft answer to every question.
Large model LLM call
The strong model reads the draft and replies with a short accept, or with a corrected answer. Reading is cheaper than writing.
Answer Input / output
The draft if the large model accepted it, or the large model's rewrite if not.
Question → Small model
The question goes to the small model for a draft.How do I reset my router?
Small model → Large modeldraft
The draft goes to the large model with the question and documents, to accept or rewrite.Hold the reset button for 10 seconds until the light blinks amber, then set it up again in the app.
Large model → Answer
Either the accepted draft or the rewrite leaves; a short accept costs the large model only a few output tokens.{"verdict": "accept"} (returning the draft unchanged)

← → neighboursesc atlas

Efficiency & Cost

Model Cascade

Also known as LLM cascade · FrugalGPT · Escalation ladder · Cheap-first escalation

Try the cheapest model first; a scorer checks the answer and escalates to a stronger, pricier model only when confidence is low.

Sequential cascade: Introduced by Chen et al. (2023) · Stanford University

FrugalGPT introduced the LLM cascade for commercial model APIs. Cascades of cheap-then-expensive classifiers are much older.

Predictive router: Introduced by Ong et al. (2024) · UC Berkeley, Anyscale and others

RouteLLM (ICLR 2025) trains routers on human preference data to choose between a strong and a weak model per query.

Draft and verify: No single inventor · see source

Inspired by speculative decoding (Leviathan et al., 2022), which works inside the inference server, is lossless and saves time. No paper introduced this call-level version, which is lossy (the accept is a judgement), saves money and adds latency.

Measured over one run

Sequential cascade

Nodes
5. Boxes in the diagram: models, tools, stores, people and plain code.
LLM calls
2. Model invocations in the first scenario: each time a model or agent node starts thinking, plus each branch it decides.
Tool calls
0. Messages sent to a tool node in the first scenario.
Steps
2. Steps in the first scenario, with repeated steps counted every time they run.
Scenarios
2. Distinct example runs you can switch between on the diagram.
Loop
no. Whether the flow cycles back on itself until a condition is met.
Parallel
no. Whether two or more messages are in flight at the same time.
Branch
yes. Whether the flow takes one path out of several, chosen at run time.
Human in the loop
no. Whether a person appears as a node, to approve, correct or answer.
Autonomy
low. How much the model decides the control flow itself, from fixed code paths (low) to open-ended (high).
Cost
low. Relative token spend per request.
Latency
medium. Relative wall-clock time per request.

Predictive router

Nodes
5. Boxes in the diagram: models, tools, stores, people and plain code.
LLM calls
2. Model invocations in the first scenario: each time a model or agent node starts thinking, plus each branch it decides.
Tool calls
0. Messages sent to a tool node in the first scenario.
Steps
2. Steps in the first scenario, with repeated steps counted every time they run.
Scenarios
1. Distinct example runs you can switch between on the diagram.
Loop
no. Whether the flow cycles back on itself until a condition is met.
Parallel
no. Whether two or more messages are in flight at the same time.
Branch
yes. Whether the flow takes one path out of several, chosen at run time.
Human in the loop
no. Whether a person appears as a node, to approve, correct or answer.
Autonomy
low. How much the model decides the control flow itself, from fixed code paths (low) to open-ended (high).
Cost
low. Relative token spend per request.
Latency
medium. Relative wall-clock time per request.

Draft and verify

Nodes
4. Boxes in the diagram: models, tools, stores, people and plain code.
LLM calls
2. Model invocations in the first scenario: each time a model or agent node starts thinking, plus each branch it decides.
Tool calls
0. Messages sent to a tool node in the first scenario.
Steps
2. Steps in the first scenario, with repeated steps counted every time they run.
Scenarios
2. Distinct example runs you can switch between on the diagram.
Loop
no. Whether the flow cycles back on itself until a condition is met.
Parallel
no. Whether two or more messages are in flight at the same time.
Branch
no. Whether the flow takes one path out of several, chosen at run time.
Human in the loop
no. Whether a person appears as a node, to approve, correct or answer.
Autonomy
low. How much the model decides the control flow itself, from fixed code paths (low) to open-ended (high).
Cost
low. Relative token spend per request.
Latency
medium. Relative wall-clock time per request.

Counted from the first scenario's timeline when the site is built.

Problem

The strongest models cost tens to hundreds of times more per query than the smallest. A support bot that sends every question to its best model pays top price for “How do I reset my router?”, which a small model answers perfectly. Sending everything to the small model instead saves money but fails the hard tail: “Why does my VPN drop only on 5 GHz since the last firmware update?” needs real troubleshooting. Most traffic is easy, but you cannot tell from the outside which questions are which.

How it works

A cascade tries the cheap option first and pays for the expensive one only when it has to. Every question goes to the small model. Its answer goes to a scorer, a cheap judge that rates how likely the answer is to be correct, from 0 to 1. In FrugalGPT the scorer is a small trained model. A short prompt on a cheap LLM can stand in until you have labelled data, but a model’s self-reported score is poorly calibrated, so check it against labelled examples before trusting any threshold.

If the score clears the threshold, the cheap answer goes straight to the customer. The router-reset answer scores 0.93 and ships for a fraction of a cent. If the score is too low, the cascade throws the cheap answer away and sends the same question up to the large model. The VPN answer scores 0.41 because it ignores the firmware detail, so the large model takes over and finds the real cause.

The diagram shows two rungs; real cascades often have three or more, each with its own threshold. The thresholds are the main dial. Tune them on a labelled sample so the cascade matches the top model’s accuracy at the lowest total cost. FrugalGPT reports matching the best single model with up to 98% lower cost on its benchmarks.

Variants

  • Predictive router: a trained classifier guesses the difficulty before any model runs, so each query makes exactly one call. It saves the wasted cheap attempt but cannot look at an actual answer.
  • Draft and verify: the small model always drafts and the large model accepts or rewrites. Reading a draft and replying “accept” costs the large model far fewer output tokens than writing the answer itself. Unlike speculative decoding, which inspired it and is lossless and saves time, this saves money and costs time: two calls in sequence, and the accept is a judgement.

When to use

  • Traffic is mostly easy, with a long tail of hard cases.
  • You can score answer quality cheaply and reasonably well.
  • Cost matters more than the extra latency on the escalated queries.

When to avoid

  • Nearly every query is hard. You pay for the cheap attempt and the expensive one.
  • Latency is tight. An escalated query waits for two models and a scorer in sequence.
  • You have no way to score answers; a scorer that cannot tell good from bad makes the cascade a coin toss.

Trade-offs

The cascade’s savings depend on two numbers: the share of queries the cheap rung handles and how well the scorer separates good answers from bad. A lenient scorer saves money but ships weak answers; a strict one escalates too often and costs more than calling the large model directly. Escalated queries are always slower and slightly more expensive than they would have been without the cascade, which is the price paid for the cheap majority.

Failure modes

  • Overconfident scorer: confident-sounding wrong answers score high and ship. Calibrate the scorer on labelled examples, and spot-check what passes.
  • Everything escalates: a threshold set too high, or a model upgrade that shifts scores, sends most traffic to the top. Track the share answered at each rung.
  • Inconsistent answers: two similar questions get answers from different models in different styles. Use the same prompt at every rung and keep the output format fixed.
  • Scorer drift: a scorer tuned for one small model misjudges its replacement. Re-tune thresholds whenever a rung changes.

Build it with your AI

Sequential cascade

Paste this into Claude Code, Cursor, ChatGPT or any AI coding assistant.

Implement the Model Cascade pattern in this codebase, using the LLM client and language we already use.

## Goal

Answer each query with the cheapest model whose answer passes a reliability score, escalating up an ordered list of models only when the score falls below that rung's threshold.

## How it works

1. Configure an ordered list of models from cheapest to most capable, each with a score threshold; the last rung has no threshold.
2. Call the cheapest model with the Answer prompt (same at every rung).
3. Score the answer from 0 to 1. FrugalGPT uses a small trained scorer; until you have labelled data, use the Scorer prompt on a cheap model, and calibrate its self-reported scores before trusting a threshold.
4. If the score meets the rung's threshold, return the answer. Otherwise call the next model up with the same prompt and score again.
5. Return the last rung's answer without scoring it, and record which rung answered and the total cost of the request.

## Prompts

### Answer prompt (same at every rung)

```markdown
You are a support assistant for {{product}}. Answer the customer's question
accurately and concisely, using the documentation below.

<docs>{{docs}}</docs>
<question>{{question}}</question>

If the documentation does not cover it, say what is missing rather than guessing.
```

### Scorer prompt

```markdown
Rate how likely the answer below is to be correct and complete for the question.
Judge only from the question, the documentation and the answer.

<docs>{{docs}}</docs>
<question>{{question}}</question>
<answer>{{answer}}</answer>

Reply with a single number between 0 and 1, and nothing else.
```

## Stop rule

Stop at the first answer that meets its threshold, or after the top model answers. If a scorer call fails, treat the score as 0 and escalate, so a broken scorer costs money rather than quality.

## Requirements

- Keep the models and thresholds in configuration, and tune the thresholds on a labelled sample so that the cascade matches the top model's accuracy at the lowest cost.
- Parse the scorer's reply as a number; if it is not one, treat it as 0.
- Log per request: each rung tried, its score, its token cost, and the rung that answered.
- Report the share of traffic answered at each rung; if most traffic reaches the top, the cascade is costing more than calling the top model directly.
- Add a test with stub models where the small model's answer scores 0.41 against a threshold of 0.8; assert exactly one large-model call and that the large model's answer is returned. A second case scoring 0.93 must make zero large-model calls.

Predictive router

Paste this into Claude Code, Cursor, ChatGPT or any AI coding assistant.

Implement the Model Cascade pattern (Predictive router variant) in this codebase, using the LLM client and language we already use.

## Goal

Before any answer is generated, predict whether the cheap model will answer a query well, and send it to exactly one model: the cheap one or the strong one.

## How it works

1. Collect labelled examples of queries where the cheap model's answer was as good as the strong model's, and where it was not (from preference data, evaluations or past cascade logs).
2. Train a small classifier on them that outputs the probability the strong model is needed. Until you have data, use a cheap model with the Difficulty router prompt as the router.
3. For each query, get the router's probability and compare it with a threshold set from your cost budget.
4. Send the query to the strong model if the probability exceeds the threshold, otherwise to the cheap model, using the Answer prompt for both.
5. Log the decision and sample routed traffic for offline grading, to retrain the router as the models change.

## Prompts

### Difficulty router prompt

```markdown
Decide whether a small, fast model can answer this support question well,
or whether it needs a stronger model.

<question>{{question}}</question>

Needs the strong model: multi-step troubleshooting, several interacting
conditions, ambiguous or unusual setups.
Small model is fine: single-fact lookups, standard how-to steps.

Reply with a single number between 0 and 1: the probability the strong model is needed.
```

### Answer prompt

```markdown
You are a support assistant for {{product}}. Answer the customer's question
accurately and concisely, using the documentation below.

<docs>{{docs}}</docs>
<question>{{question}}</question>

If the documentation does not cover it, say what is missing rather than guessing.
```

## Stop rule

Each query makes exactly one answer call. If the router fails or times out, send the query to the strong model.

## Requirements

- Make the threshold a parameter, and report the share of traffic it sends to the strong model.
- Keep the router far cheaper than the cheap model: a small classifier, or a short prompt on the smallest model.
- Re-evaluate the router whenever either model is upgraded; its training data describes the old pair.
- Add a test with a stub router returning 0.9 and 0.1 for two queries and a threshold of 0.5; assert the first reaches only the strong model and the second only the cheap one.

Draft and verify

Paste this into Claude Code, Cursor, ChatGPT or any AI coding assistant.

Implement the Model Cascade pattern (Draft and verify variant) in this codebase, using the LLM client and language we already use.

## Goal

Have a cheap model draft every answer and a strong model verify it in one call, accepting the draft unchanged when it is right and rewriting it only when it is not.

## How it works

1. Call the small model with the Draft prompt to draft an answer.
2. Call the large model with the Verify prompt, passing the question, the documents and the draft.
3. Parse its JSON reply. If verdict is accept, return the draft; if it is rewrite, return the large model's answer instead.
4. Record the verdict, so you can track how often drafts are accepted.

## Prompts

### Draft prompt

```markdown
You are a support assistant for {{product}}. Answer the customer's question
accurately and concisely, using the documentation below.

<docs>{{docs}}</docs>
<question>{{question}}</question>
```

### Verify prompt

```markdown
A junior assistant drafted an answer. Check it against the documentation.

<docs>{{docs}}</docs>
<question>{{question}}</question>
<draft>{{draft}}</draft>

If the draft is correct and complete, reply exactly: {"verdict": "accept"}
Otherwise reply: {"verdict": "rewrite", "answer": "<your corrected answer>"}
```

## Stop rule

Every query makes two calls (three if the verifier's reply is retried). If the verifier's reply cannot be parsed, retry once, then return the draft flagged as unverified.

## Requirements

- Keep the verifier's output short when it accepts: accepting must cost far fewer output tokens than rewriting, or the pattern saves nothing.
- Track the acceptance rate; below about half, call the large model directly instead.
- Log both calls' token counts per query.
- Add a test with a stub verifier that accepts the first draft and rewrites the second; assert the first returned answer equals the draft and the second equals the verifier's rewrite.

Prompt templates

Sequential cascade

Answer prompt (same at every rung)
You are a support assistant for {{product}}. Answer the customer's question
accurately and concisely, using the documentation below.
<docs>{{docs}}</docs>
<question>{{question}}</question>
If the documentation does not cover it, say what is missing rather than guessing.
Scorer prompt
Rate how likely the answer below is to be correct and complete for the question.
Judge only from the question, the documentation and the answer.
<docs>{{docs}}</docs>
<question>{{question}}</question>
<answer>{{answer}}</answer>
Reply with a single number between 0 and 1, and nothing else.

Predictive router

Difficulty router prompt
Decide whether a small, fast model can answer this support question well,
or whether it needs a stronger model.
<question>{{question}}</question>
Needs the strong model: multi-step troubleshooting, several interacting
conditions, ambiguous or unusual setups.
Small model is fine: single-fact lookups, standard how-to steps.
Reply with a single number between 0 and 1: the probability the strong model is needed.
Answer prompt
You are a support assistant for {{product}}. Answer the customer's question
accurately and concisely, using the documentation below.
<docs>{{docs}}</docs>
<question>{{question}}</question>
If the documentation does not cover it, say what is missing rather than guessing.

Draft and verify

Draft prompt
You are a support assistant for {{product}}. Answer the customer's question
accurately and concisely, using the documentation below.
<docs>{{docs}}</docs>
<question>{{question}}</question>
Verify prompt
A junior assistant drafted an answer. Check it against the documentation.
<docs>{{docs}}</docs>
<question>{{question}}</question>
<draft>{{draft}}</draft>
If the draft is correct and complete, reply exactly: {"verdict": "accept"}
Otherwise reply: {"verdict": "rewrite", "answer": "<your corrected answer>"}

Related patterns

Composes well with:

Sources

  1. FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performance (Chen, Zaharia, Zou, 2023)
  2. RouteLLM: Learning to Route LLMs with Preference Data (Ong et al., 2024)
  3. Fast Inference from Transformers via Speculative Decoding (Leviathan et al., 2022)

From the Agentic Atlas by Joran Kikke · Edit on GitHub · Suggest a correction