Module 3 · Reliability and cost patterns · Chapter 11 · Free
The eval loop: the pattern that makes every other pattern safer
- A demo proves your system works on cases you picked. An eval tests cases picked to be fair, hard and fixed in advance.
- The loop: keep a golden set of real questions with known-good answers, grade every change against it, block any release that drops the score.
- Close the loop: sample live traffic, mine failures, promote the best into the set.
The picture: a smoke alarm test button, pressed on a schedule, not when you smell smoke.
Pattern: The eval loop.
Problem: Every prompt, model or data edit changes behaviour, and nobody can feel a 5 point quality drop by reading a few outputs.
Forces: Coverage versus freshness, grading cost versus accuracy, shipping speed versus shipping safety.
Solution shape: A fixed golden set, automatic graders, a release gate with thresholds, plus production sampling feeding new cases back in.
Watch out: An eval that cannot block a release is decoration: run, admired and ignored.
Made-up Northwind Support ships a friendlier prompt for its help copilot on a Friday. The demo was lovely: ten questions, ten good answers.
- By Tuesday, refund chats are going wrong. Agents quietly rewrite about 1 in 6 copilot drafts before sending.
- At a made-up $4 per rewritten draft and 900 drafts a day, that is roughly $600 a day in hidden repair work.
- Nobody can name the cause: nothing was measured.
- Why demos lie, and the loop that replaces them.
- Build the golden set: common, hard, forbidden.
- Pick graders: rules, models, humans.
- The release gate, and the production half.
- A worked example, a lab, and when not to eval.
Next: why ten good demos tell you almost nothing.
Step 1: Demos lie, so run the loop instead
A demo uses hand-picked examples, shown once, judged by eye. Three things go wrong:
- Selection. You picked cases you suspected would work. The next ten thousand user questions were not consulted.
- Memory. You remember the charming answers and forget the flat ones.
- Drift. Next month the model, prompt or help pages change, and a demo feeling is all you can compare against.
Think of the loop as a fire drill: boring, scheduled, scored, which is why it works.
Where the picture breaks down:
- A drill tests one known route. Users invent new questions daily, so the set must keep growing.
- A drill is pass or fail. Eval scores are graded, and one slice can matter more than the average.
- A new prompt, model swap, edited help pages or retrieval tweak. Any can move quality either way.
- Same fixed cases, graded the same way, every time. That sameness makes two runs comparable.
- Scores face thresholds set in advance. Below the line, the release stops here, not in production.
- A pass is evidence the change did not break what already worked.
- Grade real conversations too. The set cannot contain questions nobody has asked yet.
- Read the worst live failures. Each shows a case your set was missing.
- The best failures, with checked answers, join the set. The next change faces a fairer test.
Next: what goes into the set that does all this work.
Step 2: The golden set is a fair test, written down
A golden set is a fixed list of cases: a real-style question, its context, and a known-good answer or a clear judging rule.
- The common. The questions users ask most, in real wording, messy and misspelled ones included.
- The hard. Multi-step cases, ambiguous cases, and every past production failure you have fixed.
- The forbidden. Requests the system must refuse or handle safely, such as another customer's data.
How big is big enough? A few hundred fresh, checked cases beat a few thousand stale ones. Grow by mining failures, not bulk generation. A wrong "known-good" answer teaches the gate to punish correct behaviour.
Keep the set versioned like code. When policy changes, update affected answers the same week, or the set grades against a world that no longer exists.
Next: who or what marks the answers.
Step 3: Graders, matched to the kind of truth
- Rules and exact checks where truth is mechanical: right order number cited, forbidden request refused, valid structure returned? Cheap, fast, never moody.
- Model graders where judgment is needed: is this reply helpful, complete, in the right tone? A model grader marks against a rubric. It can be wrong, so spot check its marks against human marks, regularly.
- Human review for calibration: a person grades a small sample each cycle, settles disagreements, and updates the rubric. Humans are the reference, not the workforce.
The analogy is school marking: a machine marks the maths quiz, a teacher marks the essay, and a second teacher samples both to keep standards honest.
Where the picture breaks down:
- A model grader can share the blind spots of the model it grades.
- Human marks drift too. Written rubrics and worked examples hold them steady.
Deeper grader design: see the AI engineering course chapter Evals.
Next: turning scores into a decision nobody has to argue about.
Step 4: The release gate turns a score into a decision
- Run the golden set on every change: prompt, model, retrieval settings, or the underlying data.
- Compare scores with thresholds written down before the run, overall and per slice (refunds, billing, forbidden).
- Block the release when a score drops past its threshold. Not "discuss it": block it, then investigate.
Per-slice thresholds matter: an average can hold steady while one slice, say refunds, quietly falls apart.
Predict first:
Block it. A safety slice is not tradable against general quality. Eight in a hundred forbidden requests going wrong is a breach pattern, not a rounding error.
Next: the half of the loop that runs after shipping.
Step 5: Production is the other half of the loop
- Sample live traffic. Pull a regular sample of real conversations, strip personal details, grade them with the same graders.
- Watch the slices. A live dip in one topic usually means the world changed: a policy reworded, a product renamed, a new question appeared.
- Mine failures. Read the worst cases yourself. Scores tell you where to look; reading tells you why.
- Promote the best failures. Write the known-good answer, get it checked, add the case to the set. That failure can never ship silently again.
That is why this is a loop, not a test: the set learns from production, and production is protected by the set. Chapter 15, the support copilot case study, runs it end to end.
Next: when not to eval at all.
Step 6: When NOT to eval
- A throwaway prototype. If it will be deleted next week and touches no real users, a demo and a careful read are enough.
- Metrics nobody acts on. If no threshold exists and no release has ever been blocked, the eval is decoration. Give it teeth or stop paying for it.
- Grading what you cannot define. If the team cannot agree what a good answer is, write the rubric first. That argument is the real work.
Next: the loop catching a real regression, with the numbers shown.
Worked example: a prettier prompt that made refunds worse
The made-up Northwind copilot now has a golden set: 400 cases, graded automatically. All figures are illustrative.
1. Baseline. The current prompt passes 88% of 400 cases: 0.88 × 400 = 352 passing.
2. The change. A friendlier prompt demos beautifully on ten questions. The gate runs the set anyway: 81%, which is 0.81 × 400 = 324 passing.
3. The drop. 352 − 324 = 28 more failures, a 7 point fall. The threshold is a 2 point drop, so the release is blocked.
4. Mine the failures. Of the 28 new failures, 21 sit in refund questions (illustrative). One cause: the refund policy page was reworded last week, and retrieval now surfaces a vaguer paragraph.
5. The fix. Restore the clear page wording, keep the friendly prompt, rerun: back to 88%, and the release ships.
Notice what the loop bought: the bug was in the data, not the prompt, and no demo would have shown it.
Next: build the judgment yourself, sorting cases and drafting a plan.
Hands-on lab: stock a golden set, then plan one
Why this exercise: most eval quality is decided at the case level. Choosing what belongs in the set is the skill; the tooling is routine.
Do this:
- Sort the candidate cases in the lab below. For each miss, read the explanation and ask what harm that case would do inside the set.
- Then do the design exercise on paper, using the brief below.
Lab: Most eval quality is decided at the case level, so choosing what belongs in the set is the skill and the tooling is routine. This lab runs in your browser and needs JavaScript enabled.
- Every rejected case fails on trust, not difficulty: duplicates, padding, leaked answers and stale rules corrupt the signal.
- Safety cases earn their place by the cost of getting them wrong.
Design exercise. Apply the pattern to this brief (illustrative):
Brief: a recipe assistant for home cooks.
Users ask: substitutions, scaling, timings.
Must never: suggest an allergen the user said to avoid.
The recipe database is edited weekly.
Write a one page eval plan sketch:
- List your first 5 cases: at least one common, one hard and one forbidden (allergen) case.
- Name the grader for each kind: exact checks for quantities and allergens, a model grader for helpfulness, human spot checks to calibrate.
- State the threshold that blocks a release, in numbers, overall and for the allergen slice.
- Say when you would NOT build this loop: for example, a one weekend prototype for friends, with no real users.
A strong answer sets the allergen slice at 100%, no exceptions, and treats weekly database edits as changes that must pass the gate, since the worked example showed data edits regressing quietly.
In production practice, evals tend to survive when wired into the release path, so skipping takes more effort than running. Golden sets also commonly grow from real failures, not cases written in advance. Treat both as practice patterns, not statistics.
Mix-ups to avoid
- A bigger set is a better set. No: fresh, checked cases beat thousands of stale or leaked ones.
- A model grader removes the need for humans. No: humans calibrate it on samples, or its drift goes unnoticed.
- The gate is a report. No: a gate blocks. If nothing can be blocked, you have a dashboard.
- Eval is a pre-launch step. No: sampling and mining in production keep the set honest.
- A falling score means the prompt is wrong. No: mine the failures first. The cause is often the data or retrieval.
Chapter quiz
Five questions. Score 70% or more to mark this chapter complete.
Review this chapter in 5 minutes
Watch the whole chapter recapped: the golden set, matched graders, the release gate, and mining live failures back into the test.
- Demos lie by selection: ten picked wins say nothing about the next ten thousand questions.
- Golden set: real cases with known-good answers, common, hard and forbidden. A few hundred fresh cases beat thousands of stale ones.
- Graders: rules for mechanical truth, model graders for judgment with spot checks, humans for calibration.
- Release gate: run the set on every change, compare with preset thresholds, block on a drop.
- Production half: sample live traffic, mine failures, promote the best into the set.
- Worked example: 400 cases, 88% (352) down to 81% (324); the cause was a reworded policy page, fixed in the data.
- Skip the loop for throwaway prototypes and metrics nobody acts on.
Decision rule: if a change can reach users, it runs the golden set first, and a score below threshold does not ship.
Review
Glossary
- Eval loop
- Testing every change against a fixed set, gating the release, then feeding production failures back into the set.
- Golden set
- A fixed list of cases with known-good answers. Example: 400 support questions, checked by hand.
- Case
- One test item: question, context, and the good answer or judging rule.
- Grader
- Whatever marks an answer: a rule, a model with a rubric, or a human.
- Release gate
- A threshold check that can block a release. Example: score may not drop more than 2 points.
- Slice
- One group of cases scored separately. Example: all refund questions.
- Failure mining
- Reading real production failures to find new cases and causes.
- Leaked answer
- An expected answer copied from the system's own output, so the test grades the system against itself.
- Calibration
- Checking a grader against human marks on a sample, fixing the rubric where they disagree.
Next: "Caching, batching and cost patterns".