Notes
The idea
The idea. An eval is a fixed set of real cases, a written definition of good for each case, and graders that score every output the same way each time. Run version one and version two of your bot over the same cases and you get numbers instead of impressions. The goal is not a single grade. It is to answer one question: is the new version better, where exactly, and by how much.
- a fixed set of real cases
- + a definition of good for each one + graders that score them the same way every time
- it answers one question: is v2 better than v1, where, and by how much?
Collect real cases
Start with real traffic, not imagined questions. Sample production logs, support tickets, escalations, thumbs down and handoffs to a person. Ask the support team for the tricky cases they remember. Add a few synthetic attacks. Then stratify: keep roughly the same mix of categories as real traffic, but oversample the rare and risky ones. Fifty cases is a fine start. Every failure you see in production becomes a new case.
- best first:
- sampled production logs
- tickets and escalations
- thumbs-down and handoffs
- edge cases from experts
- a few synthetic attacks
- stratify: match the real mix, oversample rare and risky
- start ~50, add every failure
Define good per case
Each case needs a definition of good, written down before you look at any output. Here is one. The customer bought something forty days ago and asks for a refund. The case stores the input, the account state, and the rules: must say the window is thirty days, must offer store credit, must not call the refund tool. A reference answer helps judges, but the must and must not lines are what make grading objective.
id: ret-017 slice: returns
input: "Bought it 40 days ago.
Can I get a refund?"
state: order 5521, delivered
must: say the window is 30 days
must: offer store credit
must not: call issue_refund
reference: "That order is past
the 30-day window, but..." Graders, in order
Graders come in a ladder, and you prefer the lowest rung. First, code checks: exact matches, valid schema, the right tool with the right arguments, length limits. Second, a model acting as a judge with a rubric, for qualities code cannot see, like tone or correctness of an explanation. Third, human review, which is slow and costly but is the ground truth that creates gold labels and keeps the judge honest.
- 1 code checks: exact match, schema, tool and args, length
- 2 rubric judge: a model grades one narrow criterion
- 3 human review: gold labels, judge calibration, the ambiguous and high-stakes
- prefer the lowest rung that can answer the question
Code checks
Code checks are the workhorse. Is the output valid JSON? Is it under a hundred and twenty words? Did the bot avoid the refund tool? Did it look up the right order? Did it leak an internal ticket id? Each check is a few lines, gives the same answer every run, and costs nothing. Try to turn every must and must not line into code. Much of quality is checkable this way.
valid_json(reply)
word_count(reply) <= 120
not called("issue_refund")
args("find_order").id == "5521"
not regex(r"INT-\d{6}", reply)
links_to(reply, "/returns")
deterministic, free, instant:
run on every case, every time Rubric judges
For what code cannot judge, use a model with a rubric. Keep it narrow: one criterion per call, a pass or fail verdict, the reference answer and policy included, and a sentence of reasoning before the verdict. Pin the judge model version, so scores do not move when the provider updates it. Then have people label about a hundred cases and check that the judge agrees with them, especially on the failures.
Given POLICY, CASE and REPLY, judge ONE thing: does the reply state the correct refund outcome? REFERENCE: past 30 days → credit Reason in 1-2 sentences, then answer PASS or FAIL. one criterion per call, binary, reference in, pin judge version, check vs ~100 human labels
A worked scorecard
Here is a scorecard for a support bot over two hundred cases and five criteria. Resolution, meaning the right outcome. Grounded, meaning no invented policy. Right action, meaning the right tools and arguments. Format, under a hundred and twenty words. And tone. Version two improves four criteria, but format drops nine points, because the new prompt makes answers longer than the chat widget allows. A blended average would call that a win.
criterion grader v1 v2 resolution judge 82% 86% grounded judge 94% 95% right action code 90% 91% format/length code 97% 88% ✗ tone judge 88% 90% all five pass 68% 66%
Pass rate and confidence
Now the statistics everyone skips. With twenty cases, one case is five points. Sixteen passing is eighty percent, but the honest range is roughly plus or minus eighteen points. A two point change is less than half of one case, so twenty cases cannot detect it at all. The margin shrinks with the square root of n: a hundred cases gives about eight points, four hundred about four, and around fifteen hundred gets you to two.
20 cases, 16 pass → 80% one case = 5 points 95% margin ≈ ±1.96·√(p(1−p)/n) n = 20 ±18 points n = 100 ±8 points n = 400 ±4 points n = 1,500 ±2 points quick rule: about ±1/√n
Pairwise comparison
A sharper tool is pairwise comparison. Run both prompts on the same cases and ask the judge which reply is better, or a tie. Judges favour the first answer they see, so run each pair in both orders and count disagreements as ties. Say version two wins thirty, version one wins fifteen, and a hundred and fifty five tie. The gap is real if wins minus losses beats twice the square root of their sum. Fifteen beats thirteen point four, just.
judge sees both replies, picks the better one or a tie run both orders: A,B and B,A disagree → count as a tie v2 wins 30, v1 wins 15, tie 155 rule: real if W − L > 2·√(W+L) 15 > 2·√45 ≈ 13.4 → real pairing cancels case difficulty
Slice the results
Now slice the resolution score by category. Overall it rose from eighty two to eighty six percent. But returns fell from eighty five to seventy. Seven returns cases flipped from pass to fail and only one the other way, which passes the same wins and losses rule. Reading those seven shows why: the new prompt says always offer store credit first, so it stopped granting refunds that policy allows. Always read the flipped cases, not just the totals.
slice n v1 v2 billing 60 83% 93% shipping 50 80% 92% returns 40 85% 70% ✗ account 30 80% 87% other 20 80% 80% all 200 82% 86% returns: 7 flipped to fail, 1 to pass → read all 8
Evals in CI
Put this in CI like any test suite. Every change to the prompt, the model, a tool or retrieval settings runs a fast smoke set of about fifty cases with code graders, in a few minutes. Before release, run the full suite with judges, several times if outputs vary. Block the release if any must pass case fails, such as never refunding above the cap, or if any criterion or slice drops by more than its margin.
- on every change to prompt, model, tools or retrieval: smoke set ~50 cases, code graders, a few minutes
- before release: full suite, judges, 3 runs
- block if:
- any must-pass case fails
- a criterion drops > margin
- a slice drops > margin
Keep a held-out set
When you tune a prompt against the same cases for weeks, you start fitting those cases, not the problem. So split the set. Iterate freely on a dev set, about seventy percent. Keep a held out set that you run only at release and never tune against. If the dev score rises eight points and held out rises one, you overfit. Never copy held out cases into few shot examples, and refresh the set as traffic changes.
- dev set (~70%): read failures, tune prompts against it
- held-out (~30%): run at release only, never tune
- dev +8 pts, held-out +1 pt → you overfit the dev set
- never use held-out cases as few-shot examples; refresh it
Online evals
Offline evals cannot cover what real users will do, so grade live traffic too. Sample one to five percent of conversations, scrub personal data, and run judges that need no gold answer: is the reply grounded in what was retrieved, does it follow policy, is the tone right. Add signals like thumbs, edits and handoffs. Track each score per slice, daily. Flagged conversations go to a person, and the real failures become new eval cases.
- sample ~1–5% of conversations
- scrub personal data first
- no gold answer, so use
- reference-free graders: grounded? policy? tone?
- add signals: thumbs, edits, rephrases, handoffs
- trend per slice, daily
- flagged → human → eval set
Eval drift
Evals drift. If the refund window moves from thirty to forty five days, every returns case with the old answer is now wrong, and a correct bot will fail them. A new feature brings questions your set has never seen. A new judge model shifts every score. So version the eval set alongside the policy it encodes, pin and recalibrate the judge, and compare the category mix of live traffic to your set each month.
- the product changes: refund window 30 → 45 days → gold answers now wrong
- the traffic changes: new feature, new user mix
- the judge changes: new judge model, new scores
- fixes: version the set with the policy, pin the judge, compare mix every month
Common mistakes
The common mistakes. Judging a change by five hand picked tries. One blended score out of ten instead of separate pass or fail criteria. Claiming a two point gain on twenty cases. Trusting a judge nobody has checked against people. Reporting only averages, with no slices and no reading of flipped cases. Tuning on the held out set. And freezing the eval set while the product keeps changing underneath it.
- vibes: five hand-picked tries
- one blended score out of 10
- 20 cases, 2-point claims
- a judge never checked against people
- only averages, no slices
- tuning on the held-out set
- the set frozen while the product moves on
Numbers worth knowing
Numbers worth knowing. A pass rate's margin is roughly plus or minus one over the square root of n. Seeing a five point change takes about four hundred cases, and two points takes fifteen hundred or more, though paired comparisons need fewer. A CI smoke set is thirty to a hundred cases, a full suite three hundred to two thousand. Aim for judges that agree with people eighty five to ninety percent of the time or better.
95% margin, pass rate ≈ ±1/√n see a ~5 pt change ~400 cases see a ~2 pt change ~1,500-2,500 paired A/B needs fewer CI smoke set ~30-100 cases full suite ~300-2,000 judge vs human agree ~85-90%+ online sample ~1-5% traffic agent or random tasks 3-5 runs each
Say it like this
How to say it. We keep three hundred cases from real tickets, sliced by category, each with must and must not checks. Code graders come first, then binary judges calibrated against a hundred human labels. Every prompt change gets a paired comparison and a CI gate per criterion and per slice. A held out set confirms releases, and we grade two percent of live traffic. Error bars make it sound real.
- "300 cases from real tickets, sliced by category, each with must and must-not checks. Code graders first, binary judges calibrated on 100 human labels. Paired A/B on every prompt change, gated in CI per criterion and slice, plus held-out and 2% online."