SysDesignAtlas

Evaluation Systems

Golden sets, LLM-as-judge, statistical power, and CI gates — building the measurement infrastructure without which every AI change is a guess.

HLDHard11 min readaievaluationtestingllm-judge
Confidence

#Why this is infrastructure

Software has a clean feedback loop: write a test, it passes or fails, you know. AI systems have no such thing. Outputs are open-ended, correctness is often a judgment call, and the same input can produce different outputs.

The consequence is that without deliberate evaluation infrastructure, teams ship on vibes — someone tries ten prompts, feels the new version is better, deploys. Sometimes it is. Regressions ship regularly and are discovered weeks later, if at all.

   THE THINGS YOU CANNOT ANSWER WITHOUT EVALS

     · is the new prompt better than the old one?
     · did upgrading the model break anything?
     · is the cheaper model good enough for this step?
     · which of these three retrieval changes helped?
     · has quality drifted over the last three months?
     · is this failure a regression or has it always failed?

Every one of those is a routine question, and every one is unanswerable by inspection.

#The layers

Unit — assertions deterministic checks · seconds · every commit Golden set — offline fixed cases with expected outputs · minutes · every PR Judge — scaled scoring LLM grades open-ended output · minutes · every PR Human review the ground truth · days · periodic and for calibration Online A/B real users, real outcomes · weeks · the real answer
Fast and cheap at the top, slow and truthful at the bottom. You need all five.

Start at the top. Deterministic assertions are cheap and catch more than expected: is the output valid JSON, does it cite a source that exists, is it under the length limit, does it avoid banned phrases, did the tool call have valid arguments. These are ordinary tests, they run in CI, and they catch a large fraction of real regressions.

#Golden sets

A golden set is a fixed collection of inputs paired with known-good outputs — the AI equivalent of a test suite, and the backbone of offline evaluation, meaning evaluation you run before shipping rather than on live traffic.

Where the cases come from, in rough order of value:

  1. Production failures. Every bug becomes a permanent test case. This is the highest-value source by a wide margin, and it makes the suite grow in exactly the directions that matter.
  2. Real traffic samples, stratified so rare-but-important categories are represented rather than swamped by the common case.
  3. Edge cases by construction — empty input, adversarial input, extremely long input, wrong language, ambiguous requests.
  4. Synthetic generation for coverage, clearly labelled as such and always human-reviewed before entering the set.

#LLM-as-judge

For open-ended output there is no exact match to check, so a model grades it. This is what makes evaluation scale, and it needs to be treated as a measurement instrument that requires calibration.

   THREE FORMS

   POINTWISE     "Rate this answer 1-5 for helpfulness"
                 ✗ scores drift between runs and versions
                 ✗ clusters around 4; poor discrimination

   PAIRWISE      "Which answer is better, A or B?"
                 ✓ much more reliable — relative judgments
                   are easier than absolute ones
                 ✓ directly answers "did my change help?"
                 ✗ O(n²) comparisons if you want a full ranking

   REFERENCE     "Does this answer contain the key facts
                  from the reference?"
                 ✓ most reliable of the three
                 ✗ needs a reference answer per case

Pairwise is the default for comparing two systems, because that's the actual question and relative judgments are substantially more consistent than absolute ones.

The biases that will distort your results if unhandled:

BiasEffectMitigation
PositionPrefers whichever answer is shown firstRun both orders, average
VerbosityPrefers longer answers regardless of qualityLength-control the rubric; check length correlation
Self-preferencePrefers output from the same model familyJudge with a different model than the one being tested
Style over substancePrefers confident, well-formatted, wrong answersRubric must require factual grounding explicitly

#Statistical power

The question "is 78% better than 74%?" has a statistical answer, and ignoring it means shipping noise. The formula below uses four terms: δ is the smallest difference you want to detect; σ² is the variance of a single case's score (how much it swings between pass and fail); 80% power means that when a real difference of size δ exists, you detect it 80% of the time; and α = 0.05 means a 5% chance of declaring a difference that isn't really there.

Two practical consequences:

  • Pair your comparisons. Run both systems on the same cases and compare them case by case. A hard case is hard for both systems, so per-case comparison cancels difficulty out instead of letting it add noise — and that cuts the required sample size substantially.
  • State the minimum detectable effect alongside every result. "System B scored 3 points higher on 120 cases" should be reported as "3 points, which is within noise for this sample size."

#Evaluation in CI

Offline evals belong in the pipeline, gating changes the way tests do.

   ON EVERY PULL REQUEST touching prompts, models, or retrieval:

     1. deterministic assertions          ~30 s   must pass
     2. golden set, small (100 cases)     ~3 min  no category
                                                  regression > 5%
     3. judge comparison vs main          ~5 min  win rate ≥ 45%
                                                  (not 50 — an equally
                                                  good change can score
                                                  below 50 by chance)
     4. cost and latency check            ~1 min  within 20% of main

   NIGHTLY:
     · full golden set (2,000 cases)
     · full judge evaluation
     · per-category breakdown, tracked over time

   Anything that fails posts the specific failing cases as
   a diff in the PR — not a score, the actual outputs.

Two design points that determine whether this gets used or disabled:

  • Cache aggressively. Re-running 2,000 model calls per commit is slow and expensive. Key results on (input, model version, prompt version) — most PRs change one component and most results are reusable.
  • Show diffs, not scores. "Score dropped from 0.81 to 0.78" is unactionable. "These 12 cases regressed, here are the before/after outputs" is a review.

#Online evaluation

Offline evals measure a proxy — a golden set and a judge are stand-ins for what users actually want. Only production, with real users doing real tasks, measures the thing itself.

  • A/B test by user, not by request, so each person sees one consistent version and outcomes like "did they come back next week" can be attributed to it. Run long enough for slow metrics like that one.
  • Instrument implicit feedback — did they copy the code, accept the suggestion, resolve the ticket, avoid escalating? Available on every interaction and usually more informative than thumbs.
  • Sample production traffic into the judge continuously, so quality is a live time series rather than a per-release snapshot.
  • Route production failures back into the golden set automatically. This closes the loop and is the mechanism by which the suite gets better at the things you actually get wrong.

#Evaluating retrieval and agents separately

From retrieval architecture: measure recall@k independently, or you cannot tell a retrieval failure from a generation failure.

For agents, evaluate the trajectory as well as the outcome: task success on verifiable criteria, step count versus optimal, tool selection accuracy, and recovery rate after a tool failure. An agent that reaches the right answer in 40 steps is worse than one that takes 6, and outcome-only evaluation cannot see the difference.

#Check yourself

Why is evaluation infrastructure, not an afterthought?Show answer
AI outputs are open-ended and nondeterministic, so without evals teams ship on vibes — and routine questions (better prompt? safe model upgrade? cheaper model enough?) are unanswerable by inspection.
Name the evaluation layers.Show answer
Deterministic assertions (cheap, every commit), a golden set (every PR), an LLM judge (scaled scoring), human review (ground truth and calibration) and online A/B tests (the real answer).
Where should golden cases come from?Show answer
Production failures first (every bug becomes a test), then stratified real traffic, constructed edge cases, and reviewed synthetic cases. Keep cases that discriminate; check per-category scores.
Pointwise, pairwise or reference judging?Show answer
Pointwise 1–5 scores drift and cluster around 4. Pairwise "A or B?" is far more consistent and answers "did my change help?". Reference-based checking for key facts is most reliable when references exist.
What judge biases must you control?Show answer
Position (run both orders), verbosity (control length, check correlation), self-preference (use a different model family) and style over substance (require grounding in the rubric).
When can a judge be trusted?Show answer
After measuring agreement with ~100–200 human labels: above ~80% (kappa > 0.6) for comparisons; 60–80% as a noisy signal only; below 60% it measures something else. Recalibrate on changes.
How many cases do you need?Show answer
Roughly n ≈ 16σ²/δ²: around p = 0.75, ~1,200 cases to detect 5 points, ~300 for 10, ~7,500 for 2. Pair comparisons and report the minimum detectable effect.
What makes an eval CI gate usable?Show answer
Fast tiers (assertions, a small golden set, a judge comparison with win rate ≥ 45%), cost and latency checks, caching by (input, model, prompt version), and showing regressed cases as diffs.

#What to carry forward

  • Without evals you ship on vibes, and regressions go unnoticed for weeks.
  • Five layers: assertions, golden set, judge, human, online. Start with assertions — they're cheap and catch a lot.
  • Production failures are the best source of golden cases. Route them back automatically.
  • Pairwise judging beats pointwise. Validate the judge against humans before trusting it.
  • Compute your minimum detectable effect. A 3-point gain on 100 cases is noise.
  • Gate CI on category regressions and show diffs, not aggregate scores.
  • Evaluate retrieval and agent trajectories separately from final answers.
00:00
/ 11m