Every LLM app goes through the same two phases. Phase one: the demo works. The answers look good, the stakeholders nod, and someone says the dangerous words — “let’s ship it.” Phase two: you change something — a new model version, a rewritten system prompt, a different chunk size — and quality shifts in ways nobody can see. Not all at once, not in a stack trace. A refund answer that used to cite the 30-day policy now says 45. A summary that used to be tight now rambles for three paragraphs. Nobody notices for a week, because nobody was measuring.
This is the problem evals solve. An eval harness is a machine that answers one question on demand: is this version better than the last one? Not “does it feel better,” not “did the demo go well” — better, on a fixed dataset, against a written rubric, with numbers you can diff. If you built the RAG systems from my RAG from scratch and RAG in production posts, this is the missing third piece: in the production post I hand-verified every retrieval path and caught a hallucination with a small eval harness before it shipped. This post is that harness, generalized — and there’s a working one embedded below you can break on purpose.
The three moving parts
Every eval harness, from a weekend script to an enterprise platform, is the same loop:
- Golden dataset — a fixed set of inputs with known-good expectations. The questions your users actually ask, paired with what a correct answer looks like.
- Rubric — the criteria you grade against, with weights. Correctness matters more than tone; say so in numbers.
- Judge — whatever applies the rubric to a model’s output. A regex, a Python function, an LLM with the rubric in its prompt, or a human with a checklist.
Same dataset, same rubric, every run. Change the model, re-run, diff the scores. That’s the whole idea — everything else is implementation detail.
Golden datasets: harvest them from real failures
The most common way to build a golden dataset is also the least useful: sit down, imagine what users might ask, and write twenty tidy questions. The problem is that imagined questions measure what you already handle well. Your real failure modes — the refund question where the bot invents policy, the vague “it’s broken” ticket where it guesses the product — live in your production logs, not your imagination.
Hamel Husain’s essay “Your AI Product Needs Evals” makes this the central discipline: build the eval set from your own failure cases, scored against a rubric that matches what actually breaks for your product. His example is worth internalizing — a support agent’s rubric should check whether the response includes the correct refund policy and the customer’s actual order number, not whether it phrases things elegantly. Exact string matching rarely works, because two correct answers can be worded completely differently. Grade the facts that matter; ignore the ones that don’t.
In practice, the loop looks like this:
- Collect traces — production logs, pilot traffic, or realistic simulations. A hundred to start.
- Read the failures — not the aggregates, the actual transcripts. Note the first upstream failure in each one, not the downstream symptoms.
- Cluster into failure modes — “invented refund policy,” “ignored the order number,” “answered the wrong product.” Count them. Now you know what breaks and how often.
- Freeze cases as regression tests — every failure mode becomes permanent golden cases with a binary pass/fail verdict.
A great eval suite is harvested from traffic, not authored up front. And it never stops growing: every new production failure becomes a new golden case, which is what stops the whack-a-mole where fixing one prompt breaks a case you fixed last month.
Rubrics: write down what “good” means, in weights
A rubric turns “that answer felt off” into a score you can argue with. The lab below uses four criteria for a support bot — correctness, groundedness (no hallucinations), tone, and conciseness — but the criteria themselves are the least interesting part. The interesting part is the weights.
Weights force the product conversation. Is a correct-but-rude answer better than a polite-but-wrong one? Your rubric answers: correctness at 35%, tone at 15% — wrong facts fail loudly, bad tone dents. Is a 200-word correct answer acceptable? Conciseness at 20% says no, not quite.
Two rules that keep rubrics honest. First, keep every criterion binary — pass or fail, not a 1–5 vibe scale. Binary verdicts are auditable: you can point at the exact rule that failed and the exact text that failed it. Second, toggle a criterion and look at what happens to your scores — try it in the lab. Disabling tone makes the rude answer’s score jump from 85% to 100%. That’s not a bug in the harness; it’s the rubric telling you what you just decided tone is worth.
The judge, part 1: assert what can be asserted
Before any model grades anything, squeeze the deterministic juice. A surprising amount of “LLM quality” is checkable with plain code:
- Structure — valid JSON, required fields present, no leaked system prompt.
- Grounding — every cited fact appears in the retrieved context; order numbers match the ticket.
- Constraints — under the word cap, no banned phrases, links resolve.
These checks are fast, free, reproducible, and never have an off day. The practitioner’s rule of thumb is to let deterministic assertions carry the load they can — roughly the bulk of the suite — and reserve the expensive, fuzzy judgment for what code genuinely cannot see. The lab’s judge is this kind of scorer: substring checks for key facts, a hallucination list, a rude-phrase list, a word cap. You can read every rule it applies, which is exactly why it’s a good teaching judge. A production harness would swap in a model for the fuzzy parts — which brings us to the part everyone gets wrong.
The judge, part 2: LLM-as-judge, and why you can’t trust it raw
For everything code can’t assert — is this summary good, does this answer actually resolve the ticket — the standard tool is LLM-as-a-judge: a strong model, prompted with your rubric, grading outputs. It works in three flavors: single-answer grading (score this answer 1–5 against the rubric), pairwise comparison (which of these two answers is better?), and reference-guided grading (here’s a reference answer — how close is this one?).
The foundational paper is Zheng et al.’s “Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena” (NeurIPS 2023). Their headline result is encouraging: a strong judge like GPT-4 agrees with human preferences roughly 80% of the time — about the same rate at which two human annotators agree with each other. But the same paper documents systematic failure modes that will silently corrupt your scores if you don’t design around them:
- Position bias — in pairwise mode, the judge favors whichever answer is shown first (or second), regardless of content. Weaker judges flip their verdicts on order alone at alarming rates.
- Verbosity bias — longer answers score higher independent of quality. Length is not quality, but the judge keeps grading like it is.
- Self-enhancement bias — a judge favors outputs from its own model family. Letting a model grade its own homework inflates the numbers.
The fixes are refreshingly mechanical, which means they belong in code, not in hope:
- Swap the order and require consistency. Ask the judge twice — (A, B) and (B, A) — and only accept a verdict that survives the swap. A judge that says “A wins” both times was grading the answers; one that flips was grading the slots.
- Grade against a reference. Reference-guided grading anchors the judge to a known-good answer instead of its own taste.
- Judge with a different family than you generate with. If your product runs on model X, your judge should not be model X.
- Calibrate against humans. Have humans label a sample, check the judge agrees, and fix the rubric until it does. Then the judge can scale what humans validated — it can never replace the validation.
The lab’s bias simulator (section 6) lets you watch position and verbosity bias happen: a simulated naive judge flips its verdict when you reorder two identical-quality answers, while the debiased version — swap order, rubric-score both, keep only a consistent verdict — stays put.
Regression testing: the gate that earns its keep
Here’s where the harness pays for itself. The golden dataset is a snapshot of “what good looked like at launch.” Every change — new model version, new system prompt, new chunking strategy from the RAG production post — gets scored against the same dataset, and the new score is diffed against the baseline.
Wire it like CI: a quality-gate threshold blocks the deploy the way a failing unit test does. The lab’s gate is deliberately simple — candidate below baseline means blocked — but the shape is the real thing: this version does not ship until the failures are fixed or the rubric is deliberately changed. That last clause matters. Sometimes a regression is the rubric being wrong, and updating the rubric is a product decision you make consciously, in a diff, with your name on it — not something a model upgrade does to you silently at 2 AM.
One more practice worth stealing: when the gate blocks, the blocking cases become new golden cases if they aren’t already. The dataset grows exactly where the product hurts. Six months in, your eval suite is a fossil record of every quality incident you ever had — and proof none of them came back.
Try it: break the harness on purpose
Three experiments worth running:
- Toggle a criterion off. Disable tone and watch the rude answer’s score jump. Disable correctness and watch the whole harness go blind to wrong facts. Every toggle is a product decision — the lab just makes the cost visible.
- Swap to the V2 candidate. The “cost-optimized” model is cheaper and worse: invented warranty terms, a drone-delivery hallucination, a rude brush-off. The aggregate drops from 80% to 43%, the per-criterion chips show exactly where (−3 on correctness, −2 on groundedness), and the gate blocks the deploy. This is the Tuesday-morning scenario the harness exists for.
- Play with the bias simulator. Put the judge in position-biased mode and flip the presentation order — the verdict flips with it. Switch to verbosity-biased and the 89-word ramble wins forever. Switch to debiased and the verdict stabilizes, because it survived the swap. That’s Zheng et al.’s mitigation, running in your browser.
The unit tests of LLM apps
The through-line of all of this: evals are to LLM apps what unit tests are to regular software. Nobody ships a payments service without a test suite that runs on every commit; an LLM feature that touches customers deserves the same machinery, adapted for the medium — golden cases instead of assertions, rubrics instead of matchers, judges instead of test runners, and a gate that blocks the deploy all the same.
You don’t need the full apparatus on day one. Ten golden cases harvested from your last ten support failures, four binary criteria with honest weights, and a script that re-runs them whenever the prompt changes — that’s a harness. The lab above is that harness with the training wheels on. Build the real one before your users build it for you, one angry ticket at a time.