AI ENGINEERING · LLMS IN PRODUCTION · QUALITY · 30 OF 35

LLM Evaluation in Practice: Eval Sets, Graders, Gates

A practical eval workflow end to end: collecting real cases and defining good per case, graders in order of preference (code checks, rubric judges, human review), a five-criterion scorecard for a support bot, pass rates and sample size, pairwise A/B comparison, slicing to find regressions, CI release gates, held-out sets, online evals and eval drift.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
1 / 19

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Real cases
  • must and must-not
  • code before judges
  • error bars
  • pairwise
  • slices
  • CI gate
  • held-out
  • online

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.

What an eval is
  • 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.

Where cases come from
  • 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.

One case
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.

The grader ladder
  • 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.

Checks as code
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.

A judge prompt
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.

200 cases, support bot
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.

How sure is 80%?
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.

v1 vs v2, same 200 cases
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.

Resolution by category
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.

A release gate
  • 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.

Two piles
  • 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.

Evals on live traffic
  • 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.

Why evals go stale
  • 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.

Common mistakes
  • 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.

Ballparks
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.

In the interview
  • "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."

Interview questions

Q1How do you build an eval set for an LLM feature?

Sample real traffic, tickets, escalations and thumbs-down cases, add expert edge cases and a few attacks, and stratify to match the real category mix while oversampling rare, risky cases. For each case write what must and must not happen before looking at outputs, and add every production failure as a new case.

Q2What order should you prefer graders in?

Code checks first (exact match, schema, tool and arguments, length), because they are deterministic and free. Then a rubric-based model judge for qualities code cannot see. Human review for gold labels, judge calibration and ambiguous or high-stakes cases.

Q3How do you make an LLM judge reliable?

One narrow criterion per call, a binary pass or fail verdict, the policy and a reference answer in the prompt, brief reasoning before the verdict, and a pinned judge model version. Measure agreement against human labels, especially on failures, before trusting it.

Q4Why can a 20-case eval not detect a 2 point improvement?

With 20 cases one case is 5 points, and the 95 percent margin on an 80 percent pass rate is about plus or minus 18 points. The margin shrinks with the square root of n, so seeing about 2 points takes on the order of 1,500 or more cases, fewer with a paired comparison.

Q5How does pairwise comparison work and what bias must you handle?

Run both versions on the same cases and have a judge pick the better reply or a tie. Judges show position bias, so run both orders and treat disagreement as a tie. A quick check: the result is likely real if wins minus losses exceeds twice the square root of wins plus losses.

Q6Why slice eval results by category?

An overall gain can hide a large regression in one slice, such as returns dropping 15 points while the average rises 4. Slicing and reading the cases that flipped from pass to fail shows where and why a change broke things.

Q7How do you run evals as a release gate?

Run a small fast suite with code graders on every change to prompts, models, tools or retrieval, and the full suite with judges before release. Block if any must-pass case fails or any criterion or slice drops by more than its margin.

Q8What is a held-out eval set for?

It detects overfitting to the cases you tune against. You iterate on the dev set and run the held-out set only at release; a big dev gain with no held-out gain means the prompt fits the examples, not the problem. Never reuse held-out cases as few-shot examples.

Q9What are online evals and what is eval drift?

Online evals grade a sample of live traffic with reference-free judges and user signals, since there is no gold answer. Eval drift is when product, traffic or judge changes make old cases and scores misleading, fixed by versioning the set with policy, pinning the judge and refreshing cases.