← Jev From First Principles

The Decision Router

Can a router choose the cheapest competent provider for each request? A worked simulation of what routing saves, what bounds the saving, and when the router costs more than it earns.

This chapter is a simulation over assumed provider profiles. The provider accuracy-by-difficulty curves, costs and signal correlation are assumed and swept; every number is a consequence of them. No real router (RouteLLM, Hybrid LLM) is measured here. The assumptions sit next to the results.

The question

Chapter 28 ended with a comparison table that was mostly NOT_OBSERVED. That table asked which provider is best. This chapter asks a different question, because “best” was always a statement about an average over requests, and a program does not send an average. It sends one request at a time.

Some of those requests are easy. A rule can settle “is this a duplicate of the previous ticket?” at almost no cost, and a large judge model settles it no better. Others are hard, and only the expensive provider is competent. If you can tell which is which before paying, you can send each request to the cheapest provider that is competent for it. That mechanism is a router, and a router is itself a decision: it answers “which provider should answer this?” with an uncertain, typed result that costs time and money.

So the chapter asks: can a router choose the cheapest competent provider for each request, and what limits how much it saves?

You will leave with three things: a vocabulary for routers (oracle, rule, predictor, overhead), a small simulator in src/arbiter/router.py you can change, and a way to read routing claims in the literature as statements about a signal, not about models.

What the literature gives you

Three papers define the shape of the question. The reported figures below were checked in RouteLLM v4, Table 6, Hybrid LLM and RouterBench, §4.3 and §5.1. They describe those papers’ setups, not this chapter’s simulation.

Paper What the router is What it learns from Headline result (as the paper reports it) What it assumes
RouteLLM, Ong et al. (2024), §3-§5 Four learned routers (similarity-weighted ranking, matrix factorisation, a BERT classifier, a causal-LLM classifier) that estimate the probability the strong model wins, then send to the strong model above a threshold Chatbot Arena preference data, with MMLU gold labels or LLM-judged data added Up to 3.66x cost savings at 95% of GPT-4 quality on MT-Bench; 1.41x on MMLU and 1.49x on GSM8K at lower quality retention Two models; query distribution close to the training data
Hybrid LLM, Ding et al. (2024), §3-§4 A DeBERTa classifier that predicts whether the small model’s answer is as good as the large model’s Pairs of sampled responses scored by BART score, with labels softened (§3.2) or relaxed by a margin t (§3.3) Up to 40% fewer large-model calls with small quality drop on a small-gap model pair; a large-gap pair loses much more Cost approximated by the share of queries sent to the small model
RouterBench, Hu et al. (2024), §3-§5 Not a router: a benchmark of precomputed responses from many models, with an oracle router and a cost-quality curve (AIQ) About 405k recorded responses across 11 models and 8 datasets (§4.3) Predictive KNN and MLP routers match the best single model at similar or lower cost, but none clearly beats the zero-router baseline (§5.1) Recorded responses stand in for live calls

Three ideas from these papers organise the chapter.

First, the oracle is the ceiling. RouterBench defines it as the router that always picks the best-performing model, with ties going to the cheapest (§4.4). No real router can beat it, so how close a router gets to the oracle is the honest measure of how good its signal is.

Second, the evidence is thinner than the headlines. RouteLLM’s strongest numbers are on MT-Bench; its own results show routers trained only on Arena data performing near random on MMLU and GSM8K until the training data is augmented (§5.1). Hybrid LLM states that cost is approximated by the share of queries routed, not measured, and that results depend on how well the BART score tracks quality (§2.3, §4.6). RouterBench found that learned predictive routers did not significantly beat a simple baseline (§5.1). Taken together, these tell you to expect a saving that is real but conditional.

Third, one expectation of ours is weakened. We began thinking a learned router adds a new failure mode. RouteLLM reports that its routers kept working when the strong and weak models were swapped without retraining (§5.2). The failure mode is still possible, but that paper observed transfer, and this simulation cannot test transfer at all. Treat our expectation as unconfirmed.

Fourth, a router sits in the same place as Chapter 8’s contract. Whatever answers a decision is a provider. A router is a provider whose “answer” is the name of another provider.

The hypothesis and prior work

Our starting hypothesis (HYPOTHESIS, preregistered in metadata/29-chapter.yaml) is that explicit rules capture most of the saving; learned routers add a small increment and a new failure mode.

The reasoning is simple. If routing quality depends on a difficulty signal, then a signal you can read directly (a length, a flag, a field) gets you most of the way, and a learned model only helps by finding a better signal. If so, the saving is bounded by signal quality, not by the router’s sophistication.

The build

Decision flow for Chapter 29

The diagram is the whole mechanism. The router never sees the true difficulty; it sees a signal. It routes by that signal, pays an overhead for looking, and the provider that answers is judged against the true difficulty.

src/arbiter/router.py is a deterministic simulation. Providers have assumed linear accuracy-by-difficulty curves. The routers are always_best, always_cheapest, random, oracle (cheapest provider that meets the target at true difficulty), explicit_rule (routes via a metadata signal correlated with difficulty) and difficulty_pred. The router’s own latency is a per-request overhead added to the routed cost.

from arbiter.router import Provider, p_correct
# 1. Provider accuracy as a function of difficulty (ASSUMED curves).
print("1. provider curves (ASSUMED)")
cheap = Provider("cheap", 0.95, 0.40, cost=1.0)
strong = Provider("strong", 0.99, 0.90, cost=20.0)
for d in (0.0, 0.5, 1.0):
    print(f"   d={d}: cheap {p_correct(cheap, d):.2f}  strong {p_correct(strong, d):.2f}")
# 2. The routing decision on one request.
print("2. one request, target 0.85")
d = 0.1
for p in (cheap, strong):
    print(f"   {p.name:<8} P(correct)={p_correct(p, d):.2f} cost={p.cost}")
print("   -> route cheap if it meets the target, else strong")
1. provider curves (ASSUMED)
   d=0.0: cheap 0.95  strong 0.99
   d=0.5: cheap 0.68  strong 0.95
   d=1.0: cheap 0.40  strong 0.90
2. one request, target 0.85
   cheap    P(correct)=0.90 cost=1.0
   strong   P(correct)=0.98 cost=20.0
   -> route cheap if it meets the target, else strong

Read the second block carefully, because it is the whole decision. At difficulty 0.1 the cheap provider is predicted to be 0.90 accurate, which clears the 0.85 target, so you pay 1.0 rather than 20.0. At difficulty 0.5 it would be 0.68, which does not, so you escalate. Everything else in the chapter is this comparison repeated over a stream of requests, with noise added to the difficulty the router can see.

These numbers are hand-set curves, not measurements. 0.95 and 0.40 are choices, not properties of any model. They are chosen so a cheap provider is good on easy requests and poor on hard ones, which is the situation that makes routing worth discussing in the first place.

The sweep

run_ch29.py sweeps the strong-provider cost ratio (5, 20), the signal correlation rho (0.0, 0.5, 0.95) and the router overhead, writing results/ch29.jsonl (mode: simulation, assumptions in every row). Each row is n = 4,000 simulated requests. At cost ratio 20, quality target 0.85:

router rho accuracy cost/request
oracle any 0.912 11.06
explicit_rule 0.95 0.911 11.01
explicit_rule 0.0 0.869 11.21
always_best any 0.945 20.00
always_cheapest any 0.679 1.00

Note what is missing: there is no row where a router matches always_best on accuracy at lower cost. The best routers sit at 0.91 against 0.945. The quality target 0.85 is a per-request target, and a router that meets it on every request reaches only a lower average accuracy. Be careful which target you compare against. Matching “the target” and matching “the strong provider’s average” are different claims, and conflating them is the most common way routing savings are overstated.

What the results show

  1. The oracle saves at most about 45% under these curves (20.00 → 11.06) and the explicit rule reaches it only when the signal is good: at rho 0.95 the rule is 11.01 vs the oracle’s 11.06, at rho 0.0 its accuracy falls to 0.869. The rule inherits the signal’s noise, and “close to the oracle” is exactly a statement about how good the difficulty signal is.

  2. The difficulty predictor and the explicit rule coincide here by construction: both route on the same signal. That is the finding, and it is a modest one: a difficulty predictor is an explicit rule over a learned signal, and the only new failure mode it can have is a signal that is worse than the metadata one. Our simulation could not distinguish them. A real learned predictor with its own noise could, and this simulation says nothing about that.

  3. Routing is a decision and its cost counts. With an overhead of 1.5 per request the explicit-rule total is about 12.5 vs 20 for always-best; routing still wins. The saving per request is 20.00 − 11.07 = about 8.9, so by arithmetic the router stops paying for itself when its overhead approaches 8.9. That break-even is derived from the table, not swept: the sweep covers overhead 0, 0.8 and 1.5. Where overhead is high, you would be better off to simply call the strong provider.

  4. always-cheapest is not competent (0.679 at target 0.85). Routing is not about always picking cheap; it is about picking the cheapest that is competent on this request, and the competence judgement is where the signal matters.

  5. The simulation reproduces the literature’s shape, which is not the same as confirming its numbers. RouteLLM and Hybrid LLM report that a router can move along a cost-quality curve between the weak and strong provider. So does this simulation. But the papers’ savings come from real model pairs on real query distributions, and ours comes from two straight lines. Do not read 45% here as comparable to 3.66x there.

Wrong / Correct. Wrong: “Routing saves cost because small models are cheap.” Correct: “Routing saves the cost of competence: the cheap model on the easy requests, escalated elsewhere, with the saving bounded by how well the router can tell easy from hard — a signal-quality statement, not a model statement.”

A scatter plot of simulated accuracy against simulated cost. The oracle and a good rule nearly coincide at about 0.91 accuracy and cost 11; always-cheapest is at 0.68 and cost 1; always-best is at 0.945 and cost 20.
Figure 29.1. The saving is bounded by the difficulty signal, not by the provider menu. A router that cannot tell easy from hard cannot buy accuracy with a cheaper model.

What this means for the decide construct

PROPOSED, not tested. If a router is a provider that returns a provider name, then decide(...) needs no new syntax to route: the specification names the question, and a router in the runtime picks which provider answers. Chapter 33 will test whether a compiler can make that choice ahead of time from measured profiles rather than per request. If the signal is metadata you already have, the router is a few lines of ordinary code, and Chapter 35 will record that as a library-form result rather than a language feature.

What to carry forward

Chapter 30 turns the router’s escalation into a cascade: instead of choosing one provider per request before it runs, it runs a cheap stage and escalates the uncertain ones, under a target end-to-end risk. The router chapter’s lesson carries over: the value is bounded by the quality of the difficulty or uncertainty signal, which this chapter swept and did not measure.

Limitations

  • SIMULATION over assumed profiles; results/ch29.jsonl is mode: simulation with the assumptions in every row. RouteLLM’s cost ratios were checked against Table 6; Hybrid LLM’s call reduction and RouterBench’s dataset counts and baseline comparison were checked in their primary texts. None of the three systems is measured here.
  • The explicit_rule and difficulty_pred routers coincide because both route on the same signal; a genuinely learned predictor with separate noise would differ.
  • The provider curves are linear, which is an assumption; a different curve shape changes the numbers (the direction of the finding — signal quality bounds the saving — does not).
  • The real router overhead and provider costs come from Chapter 28’s unmeasured cells; this chapter uses assumed costs instead and says so.
  • The overhead break-even (about 8.9) is arithmetic from two table values, not a swept result.

What this chapter establishes

When does routing cost more than it saves? When its own decision overhead approaches the per-request saving, and when its signal is too noisy to tell competence apart. Both were swept or derived here, neither measured on a real router.