Evals - What They Are, How to Design Them, How to Use the Score
Why a few examples are not evidence
New model, new prompts, new tools. You run 10 examples and they look better, but latency is higher. Ship it?
Not enough evidence. Sample is too small. Outputs are a distribution, so one run can look good by luck.
Averages can lie. System B can look 90% helpful overall, yet have more policy violations and twice the latency of A. Still not enough to decide.
- P95 latency - 95% of requests finish in that time or less. Example: P95 = 800 ms means the slowest 5% take longer.
- Other percentiles exist: P50, P99.
What an eval is
Eval - a repeatable procedure with defined cases. You observe the outcomes, judge them against explicit criteria, aggregate the scores and make a decision (upgrade or not).
What eval is not:
- Not a magic metric. One number going up does not mean the product improved.
- Not a prompt testing kit. Retrieval, tools, actions and decisions can all be wrong.
- Not a guardrail. It only tests, it prevents nothing.
Three layers of evals
| Layer | What it tests | Use |
|---|---|---|
| Model benchmark | The model alone (e.g. retrieval, reasoning, cybersecurity scores at release) | Choose which model to start with |
| Application eval | Model + prompts + tools + policy + pipeline | Show your new version is better; every team needs its own |
| Online evidence | Real traffic in production | Failures become new eval cases. Slowest, highest leverage |
Benchmarks decay. SWE-bench Verified was dropped as unreliable (more a memory test). OpenAI audited SWE-bench Pro and found about 30% of tasks broken. Evals decay because cases go stale, early judging errors exist, and models beat them.
Vocabulary and five questions
- Case - the situation or state being tested.
- Trial - one run on a case. Many trials per case; some pass, some fail.
- Trace - the record of what happened in a run.
- Holdout - set kept aside as evidence.
Before designing, answer five questions:
- What are you evaluating?
- Why?
- Where does the data come from?
- What is getting judged?
- Who is judging?
| Type | Tests | Tells you |
|---|---|---|
| End-to-end | Whole pipeline: request -> retrieval -> reasoning -> tools -> outcome | Does it work overall |
| Component | Retrieval, tools, reasoning, state separately | Where to improve or what might fail |
Regression set - every failure you fixed gets added here. Any new version must pass all of it (100%). Other sets hold harder and edge cases to improve quality.
Designing an eval: baseline, target, decompose good
Design loop: decision -> users and task -> cases -> grader -> metrics -> gate -> validate the eval.
Example
'Evaluate this chatbot' is vague. Ask for the baseline (current production system), the scope (refund agent, refunds under $5,000), and limits (latency below a bound, no wrong actions). Now the job is concrete: is the new agent better than the current one on these?
Decompose good. 'Good' as one pass/fail gives no clue why it failed.
- Split into correctness, helpfulness, conciseness, safety, professionalism, tool calls, retrieval.
- Each is its own criterion, so a failure points to a cause.
Building the case set
Open coding - read 50-100 traces yourself, write free notes, then cluster notes into groups (retrieval, tool, model). Do the first pass as a human.
A case is a reproducible, structured record, not a prompt string:
- User input (e.g. 'charger missing, refund just that')
- Initial state and policy version
- Expected outcome (refund only the charger)
- Forbidden outcome (never refund whole order, never claim success after a failure)
- Severity and category (partial request on multi-item order)
Buckets, so rare but important cases are not drowned out:
- Typical - common production traffic
- Edge cases
- Adversarial - injected to push the agent to its limits
- High-stakes - e.g. refunds
Example
95 simple questions, 5 refund actions. Five refund cases are too few. Bump to 30-40, but report the score re-weighted by the real 95/5 mix so you do not over- or under-estimate.
Sources: production logs, incidents, synthetic generation, benchmarks, red-teaming. Incidents mean a user already got hurt; logs are messy. Synthetic is most common.
- Do not ask an LLM for 1000 cases at once. It repeats itself and duplicates.
- List each case type you want, generate per type, then check they are correct, unique and grounded.
- Also slice by user, document, report or time period.
- Start with 30-100 hand-picked cases, then grow.
Graders, gates and testing the eval
Refund agent says 'refund processed' but the tool timed out and nothing is in the DB. A grader reading only the response passes it.
Grade the closest observable to the real outcome: the DB row. Also check the evidence behind the claim (tool call, DB check) and fail if the agent made it up.
- Verifiable facts -> check deterministically (run pytest, do not ask an LLM).
- Truly semantic things -> human or LLM judge.
- Exact-match graders punish correct answers: agent says 'valid until 10 August' but the expected text is '30 days'. Accept equivalent reasoning.
Judge pitfall - a naive judge given 'which is better, A or B?' invents its own criteria. Fix: judge on a stated rubric (e.g. correctness only) and let equal answers tie.
- Criterion - what must pass.
- Grader - judges one run.
- Metric - the overall number.
- pass@k - at least one of k tries passes.
- pass^k - all k tries pass.
Do not weight all failures equally. A wrong refund matters far more than a typo, even if typos are more frequent. Fix the highest-impact failure first.
Gate - pre-declared yes/no rules to ship. Example: zero privacy violations, under 1% wrong cases, better than baseline, latency under 2.5 s. Set them at the start, with the baseline.
Test the eval itself before using it:
- Cases known to be correct must pass.
- Cases meant to fail must fail.
- Compare the LLM judge with an external or human judge on the same data.
Turning a score into a fix
A score like 62% does not say what to fix. Look at traces and move one step back from where the failure shows up.
| Symptom | Look at |
|---|---|
| Tools fail (bad schema) | Model producing the tool calls: output schema |
| Wrong reasoning | Context given to the model |
| Wrong context | Harness and retrieval step |
Check each stage in order:
- Human test - can a competent human solve it from exactly the same inputs? If yes, the system is at fault.
- Does a known-good case pass the harness? Does the grader agree with experts?
- Bisect - test the middle of the pipeline first, then go to the failing half (like binary search).
Oracle probes - inject gold truth at one point:
- Paste the correct retrieval. If it now passes, retrieval was the problem. If not, the model's reasoning is.
- Inject a correct tool call. If it executes, the execution engine is fine and the model generated bad calls.
- Swap in a stronger model to test reasoning. Cost goes up.
Order of fixes, cheapest first: deterministic code fixes (retrieval, execution engine, grader) -> better or routed model -> fine-tuning. Fine-tune last: it needs labelled data, money and engineering hours. Do it only when the model has simply not seen enough examples.
Do not patch every failure into the prompt ('for this case do this'). That is overfitting the prompt. Cluster failures and write general guidance per cluster. After fixes, rerun everything including the regression set.
The eval flywheel
- Each new incident becomes a case, in the regression set or the performance set.
- No eval is permanent. It decays as cases go stale, errors surface and models beat it.
- Canary release - roll out to 1% of users first, then widen.
- Tracing tools like Langfuse give the real traces to read; they can also run evals.
Glossary
- Eval
- A repeatable procedure that runs defined cases, grades them against explicit criteria, aggregates scores and supports a ship decision.
- P95
- Latency under which 95% of requests finish.
- Case
- A structured, reproducible situation: input, initial state, expected and forbidden outcomes.
- Trial
- One run on a case.
- Regression set
- Past fixed failures that every new version must pass 100%.
- Gate
- Pre-declared yes/no thresholds a version must meet to ship.
- Open coding
- Reading traces by hand, writing free notes, then clustering them into failure types.
- Canary
- Rolling out to a small percentage of users first.