Education › Evals & Harness › Stage 1: Evaluation foundations

Building eval datasets

Sourcing real cases, golden sets, synthetic data, slices, splits and contamination.

Intermediate ~35 min read Module 2 of 20

An eval is only as good as its dataset. A set of easy, repetitive examples will report 95% while users struggle; a set nobody can explain will start arguments instead of ending them. This lesson covers where good eval cases come from, how to write expected answers and grading guidance that two people would apply the same way, when synthetic data helps and when it lies, slicing a dataset so averages do not hide failures, keeping a held-out set so you do not overfit your prompts, and versioning it all like code.

After this module you can
  • Source eval cases from production, experts and known failures
  • Write targets and grading guidance that are unambiguous and checkable
  • Use synthetic data to fill gaps without letting it dominate
  • Slice datasets by intent, difficulty and risk, and report per slice
  • Keep development and held-out splits and version the dataset

Where good cases come from

  • Production traffic: real user inputs (sampled, with personal data removed) are the single best source, because they show how people actually phrase things.
  • Support tickets and complaints: failures users cared enough to report.
  • Domain experts: the cases they know are tricky, ambiguous or high-stakes.
  • Your own failure analysis: every bad output found in testing becomes a case.
  • Adversarial cases: prompt injection attempts, out-of-scope requests, requests that must be refused.
  • Synthetic generation: to fill gaps you cannot get real data for yet, covered below.

Start small and real: 30 to 100 carefully chosen cases beat 5,000 generated ones you have never read. Grow the set continuously, especially from production failures.

Targets and grading guidance

For each case, record what a good output looks like in a form a scorer can use. That might be an exact answer, a set of facts the answer must contain, a forbidden behaviour, the tool that should be called, or a rubric for a judge. If two careful people would grade the same output differently using your guidance, the guidance is not finished.

One case (stored as a single line in a JSONL file), with metadata for slicing
json
{
  "id": "ref-017",
  "input": "My blender arrived cracked, can I return it after 40 days?",
  "target": "Explains the 30-day window and offers escalation for damaged items",
  "must_include": [
    "30 days",
    "damaged"
  ],
  "must_not": [
    "guarantee"
  ],
  "slice": {
    "intent": "refund",
    "difficulty": "hard",
    "source": "ticket"
  }
}
  • Write labelling guidelines with examples of pass and fail for borderline cases.
  • For judgement-heavy cases, have two people label a sample independently and measure how often they agree; low agreement means the task or the guidance is unclear.
  • Record the reason for tricky labels, so future you remembers why.

Synthetic data: useful, with care

Models can generate eval inputs quickly: paraphrases of real questions, edge cases for a rare intent, translations, long documents. Synthetic data is useful for coverage, especially before launch, but it has predictable flaws: it is often cleaner and more uniform than real input, it inherits the generator's blind spots, and if the same model family generates and answers, results can be flattering.

  • Seed generation with real examples and explicit variation instructions (tone, length, typos, missing information).
  • Read and filter generated cases; discard the unrealistic ones.
  • Label synthetic cases as such in metadata and report their scores separately.
  • Replace synthetic cases with real ones as production data arrives.

Slices: averages hide failures

A 90% average can hide a 40% score on the slice that matters most, such as refund requests, non-English users or long documents. Tag every case with slice metadata (intent, difficulty, language, length, source, risk) and always report scores per slice as well as overall. Make sure high-risk slices have enough cases to be measured at all.

Per-slice scores from a results file
python
import json
from collections import defaultdict

by_slice = defaultdict(list)
for line in open("results.jsonl"):
    r = json.loads(line)
    by_slice[r["slice"]["intent"]].append(r["passed"])

for intent, outcomes in sorted(by_slice.items()):
    print(f"{intent:12} {sum(outcomes) / len(outcomes):6.1%}  (n={len(outcomes)})")

Splits, contamination and versioning

If you tune prompts against the same cases you report, you will overfit: the prompt learns the dataset, not the task. Keep a development set you iterate on freely and a held-out test set you run rarely, for decisions such as releases and model swaps. When scores on the two diverge, you are overfitting.

70%30%ProductionPII removedTickets, expertsknown hard casesSynthetictagged, readLabel + guidancetargets, rubricSlice tagsintent, riskDev setiterate freelyHeld-out setdecisions only
Eval cases come from real sources first, get targets, grading guidance and slice tags, then split into a development set you iterate on and a held-out set you use for decisions.
  • Contamination: public examples may be in a model's training data; prefer private, recent cases for decisions.
  • Leakage: do not put eval answers into few-shot examples or retrieval indexes the system can see.
  • Versioning: keep datasets in Git (or a data versioning tool) with a changelog; record the dataset version with every result.
  • Privacy: strip or pseudonymise personal data before cases enter the dataset.
Hands-on practice

Build a real dataset with slices and a held-out split

  1. Collect 60 inputs for one AI task from logs, tickets or your own realistic writing; include 10 adversarial or out-of-scope cases.
  2. Write a target and grading guidance for each in JSONL with slice metadata (intent, difficulty, source).
  3. Have a second person label 15 cases independently and compute how often you agree; fix the guidance where you disagree.
  4. Generate 20 synthetic cases for an under-covered intent, read them, keep the realistic ones and tag them synthetic.
  5. Split into dev (70%) and held-out (30%), stratified by intent.
  6. Run any baseline system and print scores overall, per slice, and dev versus held-out.
Cheat sheet

Building eval datasets — at a glance

Main things to focus on

  • Real, read, and small beats large and generated.
  • Guidance two people would apply identically.
  • Report per slice; protect high-risk slices with enough cases.
  • Synthetic data fills gaps; label it and score it separately.
  • Dev set for iterating, held-out set for decisions.
  • Version the dataset; record its version with every result.

Case fields

id, inputStable ID and the input
target / must_include / must_notWhat good looks like
rubricGuidance for judge or human
slice: intent, difficulty, source, riskFor per-slice reporting
synthetic: trueFlag generated cases

Sources

production samples (PII removed)Best realism
tickets and complaintsFailures users noticed
expert-written hard casesDomain edge cases
adversarial and out-of-scopeSafety and refusals
your own failure analysisEvery bad output becomes a case

Hygiene

dev 70% / held-out 30%Avoid overfitting
inter-annotator agreementIs the guidance clear?
no eval answers in few-shot or indexAvoid leakage
dataset version in resultsComparable over time
label + reason for tricky casesRemember why

Common pitfalls

  • Thousands of generated cases nobody has read.
  • Reporting only the overall average.
  • Tuning prompts on the same cases used for release decisions.
  • Eval answers leaking into retrieval or few-shot examples.
  • Personal data copied into eval datasets.
Quiz

Check your understanding

5 questions · 4 to pass · answers are explained as you go. Your best score is saved on this device only.

Progress and quiz scores are saved in this browser only. Back up or restore on the hub.

Was this lesson useful? Tell me what to improve →