Golden datasets & test sets

In one sentence

A curated, versioned set of inputs with expected outputs or grading criteria, covering the slices that matter. It's the fixed ruler every change is measured against; without it, scores aren't comparable.

Analogy: A standardized exam bank: experts write the questions, tag them by topic and difficulty, keep them away from students, and retire them when the syllabus changes.

Cases come from four sources, pass an expert gate, carry slice tags and a version, and never leak into prompts or training data.

How it works

  • Draw cases from production logs, expert-written answers, human-filtered synthetic inputs and adversarial cases like injections.
  • Tag every case by slice (user type, language, difficulty) and report per slice; an average hides what broke.
  • Include no-answer cases, ~10–20% of the set, where the right behavior is to abstain or refuse.
  • Treat it like code: version it, log which version produced each score, and grow it from production failures.
  • Keep it disjoint from few-shot examples and fine-tuning data, or you grade against the answer key.

Check yourself

Answer to mark it learned; your answers aren't scored.

A new model scores +3 overall on your 150-case golden set. Slice tags show only 6 Spanish cases, though 22% of traffic is Spanish. What do you do before deciding?

Go deeper

Full explanation

A golden dataset is a curated set of eval cases. Each has an input (question, conversation or document, plus any context) and either an expected output (answer, label, SQL result, relevant doc ids) or grading criteria ("must cite the refund policy", "must refuse"). It is the fixed ruler that makes two runs comparable.

Where cases come from:

  • Production logs: the most realistic, especially failures found in Error analysis: look at your data.
  • Subject-matter experts: write and verify reference answers.
  • Synthetic generation: an LLM drafts inputs along chosen dimensions (persona × intent × difficulty) and a human filters them; see Synthetic data.
  • Adversarial cases: injections, ambiguity, out-of-scope requests.

Cover slices, not just volume. Tag each case by user type, language, difficulty and channel, and include no-answer cases where the right behavior is to abstain or refuse. Report pass rates per slice; an average hides the slice that broke.

Treat it like code. Version it, log which version produced each score, and review changes. Start with ~50–200 cases, grow from production failures, and retire stale ones when the product changes. Keep it disjoint from Zero-shot vs few-shot prompting examples and fine-tuning data, or you are grading against the answer key.

Code A typed eval case plus leak and coverage checks
pythonA typed eval case plus leak and coverage checks
import json
from collections import Counter
from pydantic import BaseModel

class EvalCase(BaseModel):
    id: str
    input: str
    expected: str | None = None   # exact answer, label or SQL result...
    criteria: list[str] = []      # ...or rubric lines when there is no single answer
    slices: dict[str, str]        # {"lang": "es", "intent": "refund", "difficulty": "hard"}
    source: str                   # "prod" | "sme" | "synthetic" | "adversarial"
    should_abstain: bool = False  # no-answer case: the right behavior is to refuse

VERSION = "v3"  # bump on every edit and log it next to every score
cases = [EvalCase.model_validate_json(l) for l in open(f"golden/{VERSION}.jsonl")]

# Every case must be gradable one way or another
assert all(c.expected or c.criteria or c.should_abstain for c in cases)

# Never grade against the answer key
shots = {ex["input"] for ex in json.load(open("prompts/few_shot.json"))}
assert not shots & {c.input for c in cases}, "golden case leaked into few-shot"

# Coverage: a pass rate over 4 cases is noise, so flag thin slices
for dim in ("lang", "intent", "difficulty"):
    counts = Counter(c.slices.get(dim, "?") for c in cases)
    thin = {k: n for k, n in counts.items() if n < 20}
    print(dim, dict(counts))
    if thin:
        print("  thin slices (<20 cases):", thin)
print("no-answer share:", sum(c.should_abstain for c in cases) / len(cases))
Real example

A bank's support assistant starts with 150 golden cases: 90 sampled from chat logs, 30 written by compliance staff, 30 adversarial. Slice tags reveal only 6 Spanish cases, though 22% of traffic is Spanish, and zero no-answer cases. The team adds 40 Spanish and 25 "we can't advise on that" cases as v4. The next model upgrade scores +3 overall, but the Spanish slice drops from 88% to 71% and the abstain slice from 92% to 60%: the new model gives investment advice. The v3 average would have shipped it.

Trade-offs +3 · −3

+ You gain

  • Makes runs comparable over time: same ruler, explicit version.
  • Slice tags show whom a change hurts, not just the average.
  • A durable asset that survives model, prompt and vendor changes.

− You pay

  • Expert-written reference answers are slow and expensive to produce.
  • Goes stale as the product, policies and traffic mix change.
  • Small sets give wide error bars; per-slice numbers on 10 cases are noise.

Use it when

From the first prototype of any LLM feature, and as the backbone of CI regression tests, model migrations and vendor comparisons. Grow it every time production shows a new failure.

Avoid it when

As your only signal: offline sets miss what real traffic does, so pair them with online metrics. And don't chase size first: 100 reviewed, sliced cases beat 5,000 unreviewed synthetic ones.

Numbers to know 4
  • Rule of thumb: start with ~50–200 cases; grow toward several hundred to ~1,000 as slices multiply.
  • At an 80% pass rate the 95% CI is ~±8 points with 100 cases and ~±4 with 400.
  • A 25-case slice at 80% carries a ~±16-point 95% CI: per-slice reads need more cases or bigger effects.
  • Rule of thumb: ~10–20% no-answer or out-of-scope cases, so abstention is actually tested.
Common pitfalls 4
  • Reusing golden cases as few-shot examples or training data: scores inflate and stop predicting production.
  • Only happy-path cases: no ambiguity, no adversarial inputs, no no-answer questions.
  • Unversioned edits: someone fixes a "wrong" label and last month's scores silently become incomparable.
  • Synthetic cases nobody reviewed: they inherit the generator's blind spots and are often too easy.
Interview questions 2

Answer out loud first, then reveal.

How do you build a golden dataset for a product with no users yet?Show answer

I start with about 50 cases from three places. Domain experts write realistic requests and reference answers. I generate synthetic inputs along explicit dimensions, persona, intent and difficulty, and filter them by hand. And I add adversarial and no-answer cases on purpose. Every case gets slice tags and either an expected output or grading criteria. The day we have beta users, production traces become the main source: each failure from error analysis becomes a case, and the synthetic share shrinks over time.

Your eval set says the new version is better, but production complaints rose. What went wrong?Show answer

Most likely the set no longer represents traffic. I check three things. Distribution: compare slice proportions in the set with last month's logs, since new intents or languages appear all the time. Contamination: are golden cases also in few-shot examples or fine-tuning data, inflating scores? Staleness: policies or product facts changed, so some expected answers are now wrong. The fix is a new version seeded with fresh production failures, results reported per slice, and a frozen holdout that nobody tunes against.