Evals vs Efficiency
Observability showed you the cost side of every request. This page is about the side that does not show up on the latency graph: quality. The throughline of this book is making tokens cheaper — but almost every lever that makes a token cheaper can also make the answer worse. Evals are the instrument that measures the worse, so you can keep only the cheaper-without-worse wins.
Every efficiency lever is a quality bet
Section titled “Every efficiency lever is a quality bet”Walk back through the book and notice that each optimization quietly trades against accuracy:
| Efficiency lever | What it saves | What it can cost |
|---|---|---|
| Quantization (FP16 → INT4) | memory, dollars | precision on hard prompts, reasoning |
| Routing to a smaller model | dollars, latency | accuracy on the long tail |
| Fewer RAG chunks | prefill tokens, TTFT | grounding, recall of the right fact |
| Prompt compression | input tokens | dropped instructions, lost nuance |
| Aggressive prompt caching | prefill cost | stale context if invalidation is wrong |
| Speculative decoding | latency | nothing if implemented right (it is exact) |
That last row matters: a few optimizations are quality-neutral by construction (speculative decoding produces identical tokens; PagedAttention just packs memory). But most are not. The discipline is to know which kind each one is — and to measure the ones that are bets rather than assume they are free.
Build a representative eval set
Section titled “Build a representative eval set”You cannot measure quality against vibes. An eval set is a fixed collection of inputs with a way to score the outputs — your regression test for intelligence. What makes it trustworthy:
- Representative. Sample from real production traffic (your logs), including the hard tail, not just easy happy-path cases. An eval set of softballs greenlights changes that break in production.
- Stable and versioned. The set must not drift, or you cannot compare today’s score to last month’s. Version it like code.
- Scored by something. Exact-match or unit tests where possible (code, JSON schema, math answers); rubric-based judgment where not (helpfulness, tone, faithfulness).
- Sized for signal. Big enough that a 1-2 point move is not noise. A few hundred examples is a reasonable floor; a handful is theater.
Offline evals, then online
Section titled “Offline evals, then online”Two stages, because each catches what the other misses.
Offline — run the candidate (quantized model, new prompt, fewer chunks) against the frozen eval set before shipping. Cheap, fast, deterministic, reproducible. It is your CI gate: if the score drops below threshold, the change does not ship.
Online — offline sets never fully match live traffic, so confirm on real users at low risk:
- Canary: route a small slice (say 5%) of production traffic to the new config and watch quality and cost metrics. Roll back automatically if quality alarms fire.
- A/B test: run old and new side by side and compare real outcomes — thumbs-up rate, task completion, retry rate, escalation to a human. These business metrics are the ground truth that an eval score only approximates.
efficiency change ──► OFFLINE eval (frozen set) │ pass? ▼ CANARY 5% ──► metrics + quality OK? │ yes ▼ A/B 50/50 ──► real-outcome win? │ yes ▼ full rollout any stage fails → roll back, keep the old (more expensive) configLLM-as-judge, and its caveats
Section titled “LLM-as-judge, and its caveats”When there is no exact answer to match, a common trick is to have a strong model score the candidate’s output against a rubric — “rate faithfulness to the source 1-5.” It scales cheaply and correlates with human judgment well enough to be useful. But it is a measurement instrument with known biases, and treating its score as ground truth will burn you:
- Position/verbosity bias — judges favor the first option shown, and longer, more confident answers, regardless of correctness.
- Self-preference — a model tends to rate its own family’s outputs higher.
- It costs tokens too — judging is itself inference; a big eval run on a frontier judge has a real bill, so the measurement has a cost-versus-fidelity trade of its own (cheaper judge vs more reliable judge).
- Calibrate it. Spot-check the judge against human labels on a sample; if it disagrees with humans, fix the rubric before trusting the score.
Regression-test efficiency changes
Section titled “Regression-test efficiency changes”Fold the eval into the deployment pipeline so quality cannot regress unnoticed. Treat the eval score exactly like a test suite: every change to model, quantization, prompt, retrieval depth, or router gets run through the frozen set, and a score drop past a threshold blocks the merge the same way a failing unit test would. This is how you make the core rule automatic instead of aspirational — the cheaper config only ships if the quality held.
State the trade explicitly, every time: cost saved vs quality lost. Sometimes 2 points of accuracy for 40% off the bill is an obvious yes; sometimes 2 points is the difference between a usable product and a broken one. Evals do not make the decision for you — they make sure you are deciding with numbers on both axes instead of one.
With quality guarded, the last question is the biggest dollar lever of all: should you run the model yourself or rent it? That is cost modeling.
Check your understanding
Section titled “Check your understanding”- Why does almost every efficiency lever in this book need to be guarded by an eval? Give two examples of levers and the quality they risk.
- Which optimizations are quality-neutral by construction, and why does that distinction matter?
- What three properties make an eval set trustworthy?
- Why run both offline evals and online canaries/A-B tests rather than just one?
- Name two biases of LLM-as-judge and one way to keep it honest.
Show answers
- Each lever trades accuracy for cost/latency, and the quality loss is invisible on the cost dashboard — so you must measure it directly. Examples: quantization risks precision on hard reasoning; fewer RAG chunks risks grounding/recall; a smaller routed model risks long-tail accuracy; prompt compression risks dropped instructions.
- Speculative decoding (exact same tokens) and PagedAttention (just memory packing) do not change outputs. The distinction matters because you should spend eval effort on the genuine bets, not on neutral changes you can ship freely.
- Representative of real traffic including the hard tail; stable and versioned so scores are comparable over time; large enough that a small move is signal not noise (with a real scoring method).
- Offline is cheap, fast, and deterministic but never fully matches live traffic; online (canary/A-B) confirms on real users with real outcome metrics at low risk. Each catches failures the other misses.
- Biases: position/order bias, verbosity/length bias, self-preference (favoring its own family). Keep it honest by calibrating against human labels on a sample and fixing the rubric when the judge disagrees with humans.