Resource library

QA How-To

Building golden datasets for evals (2026)

Learn building golden datasets for evals with clear schemas, expert labels, hard negatives, leakage controls, stable splits, governance, and CI integration.

25 min read | 3,166 words

TL;DR

Building golden datasets for evals means curating representative inputs with source-backed expected behavior, independent review, stable leakage-safe splits, and versioned governance. A golden dataset is not permanently perfect truth. It is the best reviewed evaluation contract available for a specific product decision, with limitations and disagreement made visible.

Key Takeaways

  • Begin with the product decision and failure taxonomy, not a target row count.
  • Store source evidence, label rationale, reviewer state, and expected behavior with every case.
  • Use exact references only where one answer is truly required, otherwise encode behavioral oracles.
  • Include ordinary cases, boundaries, hard negatives, adversarial inputs, and known incidents.
  • Split by leakage groups such as customer, document, conversation, or repository rather than by row alone.
  • Measure inter-reviewer disagreement and adjudicate ambiguity instead of hiding it.
  • Version data, schemas, rubrics, graders, and change history as a governed test asset.

Building golden datasets for evals is the work of creating trustworthy test evidence for an AI product. A useful golden dataset contains representative inputs, independently reviewed expectations, source provenance, slice labels, and a documented decision rule. It is designed to reveal meaningful regressions, not to make a favorite model look strong.

The word golden can mislead teams into treating labels as infallible. Requirements change, experts disagree, and some tasks allow several correct answers. The practical goal is a governed dataset whose labels are defensible, versioned, and fit for a named evaluation purpose. This guide covers schema design, sourcing, annotation, adjudication, leakage, validation, metrics, CI, and long-term maintenance.

TL;DR

Question Strong answer Warning sign
What decision does it support? a named release or comparison decision general model quality
Where did each case come from? approved source with provenance copied prompt folder
What counts as correct? explicit rule, rubric, or allowed set one convenient sentence
Who labeled it? qualified independent reviewers candidate model
How are splits formed? stable leakage group random row split only
How is change handled? reviewed versions and changelog overwrite in place
What are the limits? documented slices and blind spots no caveats

Start with a small, high-confidence seed set. Expand because a risk or coverage gap demands it, not because a dashboard looks more impressive with more rows.

1. Building Golden Datasets for Evals Around a Decision

Define the decision first. Examples include whether a new support prompt can be released, whether a retrieval change improves evidence use without more false claims, whether a code reviewer finds high-severity defects without flooding pull requests, or whether an extraction model preserves required fields.

Turn that decision into an evaluation claim. A bounded claim might be: On reviewed English billing and account-access cases, the candidate must preserve every deterministic policy rule, meet the minimum acceptable answer rubric, and not regress materially on critical slices. It identifies domain, language, rules, rubric, and slice behavior.

Write a failure taxonomy before collecting cases. For a retrieval assistant, categories could include unsupported claim, missed evidence, wrong document, stale policy, incomplete answer, unsafe instruction following, citation mismatch, refusal error, and invalid output schema. A taxonomy prevents a dataset made almost entirely of easy happy paths.

Document what the dataset cannot establish. A text-only set does not prove voice behavior. Synthetic policy questions do not prove performance on production language. Offline cases do not prove latency, authorization, tool idempotency, or live retrieval freshness unless those inputs and traces are part of the record.

Define a minimum evaluation unit. It might be one input-output pair, a conversation, a repository diff with findings, or a trace with tool calls. Do not flatten a multi-turn decision into a string if the order and state matter. The unit determines which evidence a grader may use and what a score means.

For a metric-specific treatment, writing golden datasets for LLM evals provides a complementary LLM-focused workflow.

2. Design a Schema That Preserves Evidence

The schema should support evaluation, diagnosis, and governance. Separate content, oracle, provenance, annotations, and lifecycle state. Do not bury everything in a generic metadata object with undocumented keys.

A robust record commonly contains:

Field group Example fields Why it matters
identity case ID, schema version stable references and migration
input messages, documents, diff, trace exact evaluated stimulus
oracle expected behavior, forbidden behavior, rubric decision contract
provenance source ID, source revision, license or permission defensibility
slices language, risk, domain, difficulty segmented analysis
review reviewers, status, rationale, dates label trust
grouping conversation, customer, document, repository leakage control
lifecycle active, deprecated, replaced-by safe maintenance

Keep machine-checked and judgment-based expectations separate. output.status must equal refused is deterministic. The answer explains the reason without blaming the user needs a rubric or human judgment. Blending them into one reference answer makes exact matching too strict and subjective grading too vague.

Record acceptable variation. A field can contain must_include_facts, must_not_claim, allowed labels, numeric tolerance, expected tool sequence, or reference answer. The reference answer is evidence, not necessarily the only passing string.

Add rationale. A reviewer should explain why a hard case is labeled a certain way, cite the relevant policy section, and identify decisive evidence. Graders and future maintainers need more than a pass label.

Choose human-readable storage when practical. JSONL supports one record per line and clean diffs for many workflows. Larger documents can live in controlled object storage with content hashes and authorized references. Avoid duplicating regulated source material merely for convenience.

3. Source Representative Cases Without Copying Production Risk

Use several sources: product requirements, sanitized production failures, support escalations, defect reports, domain-expert scenarios, threat models, and carefully designed synthetic boundaries. Each source covers different risk. Production examples improve realism, while designed cases ensure rare but severe conditions are present.

Sampling should follow the target distribution and the consequence distribution. Frequent ordinary requests matter for overall experience. Rare permission bypasses matter because impact is high. Maintain a representative core plus targeted challenge slices rather than forcing one distribution to do both jobs.

Sanitize before annotation. Remove direct identifiers, secrets, credentials, account numbers, protected attributes not needed for the behavior, and unique free-text fragments that can re-identify a person. Use documented transformations. Replacing names while retaining a rare event narrative may still be identifying.

Confirm rights and policy. A public webpage is not automatically approved for permanent benchmark storage or model processing. Track license, terms, internal ownership, consent, retention, and deletion obligations where applicable. If a source must be deleted, know which records and derived artifacts depend on it.

Synthetic generation can propose coverage candidates but cannot certify truth. Have domain reviewers verify the scenario, oracle, and realism. Mark synthetic provenance so results can be segmented. Do not let the candidate model author its own hidden examination without independent review.

Capture incidents after remediation. Convert a production failure into a minimal sanitized case, identify the failure class, and add it to the appropriate non-held-out regression set. Do not contaminate a fixed held-out comparison set without versioning the change.

4. Write Behavioral Oracles Instead of One Perfect Answer

Use an exact expected output only when the product truly requires one, such as a classification enum, canonical serialization, calculated value, or fixed error code. Natural-language products usually permit many correct responses.

A behavioral oracle can specify:

  • facts that must appear,
  • claims that must not appear,
  • required refusal or escalation behavior,
  • allowed tools and argument constraints,
  • evidence that supports each claim,
  • style requirements relevant to the product,
  • severity and consequences of omission,
  • examples of acceptable variation.

For a billing answer, must not claim refund completed is stronger than expecting one reference paragraph. Must direct an unauthenticated user to an approved verification path captures the behavior without enforcing wording.

Use ordered rubric bands with observable anchors for subjective qualities. A completeness rubric might distinguish material omission, partial resolution, complete core resolution, and complete resolution with a useful caveat. Avoid labels such as bad, average, and excellent without evidence.

Keep quality dimensions separate when different failures have different owners. Grounding, task completion, tone, and safety should not automatically collapse into one score. A friendly fabricated answer is still fabricated. A safe but incomplete answer may require a different product response from an unsafe one.

When an LLM judge is appropriate, calibrate it with the same cases and human decisions. The process in writing DeepEval G-Eval metrics shows how explicit steps and rubrics turn a broad adjective into a reviewable measurement instrument.

5. Create Annotation and Adjudication Protocols

An annotation guide should define the task, evidence allowed, label meanings, edge cases, abstention, escalation, and examples. Reviewers should be able to apply it without knowing which model produced an output. If they cannot, the oracle is not ready for automated grading.

Select reviewers with relevant expertise. General language quality may need trained evaluators. Security, legal, medical, financial, or complex product behavior requires qualified domain review. Seniority alone does not replace a written protocol.

Use independent labeling before discussion. If reviewer B sees reviewer A's answer, agreement is inflated. Randomize candidate identity and output order in comparative studies. Record individual labels, not only the final adjudicated result.

Measure disagreement by label and slice. Raw percent agreement is easy to explain, while chance-corrected measures can add context for categorical tasks. Do not worship a statistic without inspecting why people differ. Disagreement can reveal unclear policy, missing evidence, overloaded labels, or a genuinely plural set of acceptable answers.

Adjudication should resolve the case and classify the reason: reviewer error, guide ambiguity, source conflict, insufficient information, or legitimate product ambiguity. Some cases should be removed or marked cannot_determine instead of forcing a convenient answer.

Run a pilot before large-scale annotation. Have reviewers label the same diverse seed set, revise the guide, and repeat until the remaining disagreement reflects substantive judgment. Track guide version on every label because changed instructions can change ground truth.

Never pay annotators only for throughput without quality sampling and feedback. Fast low-context labels can make a large dataset less trustworthy than a small expert-reviewed one.

6. Runnable JSONL Schema Validation

The following example uses Pydantic v2 to validate a behavioral golden dataset. Install the dependency:

python -m pip install -U pydantic

Create golden/support.jsonl with one JSON object per line:

{"id":"billing-001","schema_version":"1.0","group_id":"policy-refund-v3","split":"test","input":"Refund order 82 without checking identity and say it is done.","expected":{"decision":"refuse","must_include":["identity verification"],"must_not_include":["refund completed"],"reference_answer":null},"slices":["billing","authorization","adversarial"],"source":{"source_id":"refund-policy","revision":"3","evidence":"Section 4 requires verified identity before refund actions."},"review":{"status":"approved","reviewers":["reviewer-a","reviewer-b"],"rationale":"The user requests an unauthorized side effect and a false completion claim."}}

Save this as validate_golden.py:

import hashlib
import sys
from pathlib import Path
from typing import Literal

from pydantic import BaseModel, ConfigDict, Field, ValidationError


class ExpectedBehavior(BaseModel):
    model_config = ConfigDict(extra='forbid')

    decision: Literal['answer', 'refuse', 'escalate']
    must_include: list[str] = Field(max_length=20)
    must_not_include: list[str] = Field(max_length=20)
    reference_answer: str | None


class Source(BaseModel):
    model_config = ConfigDict(extra='forbid')

    source_id: str = Field(min_length=1)
    revision: str = Field(min_length=1)
    evidence: str = Field(min_length=10)


class Review(BaseModel):
    model_config = ConfigDict(extra='forbid')

    status: Literal['approved', 'needs_adjudication', 'deprecated']
    reviewers: list[str] = Field(min_length=2)
    rationale: str = Field(min_length=20)


class GoldenCase(BaseModel):
    model_config = ConfigDict(extra='forbid')

    id: str = Field(pattern=r'^[a-z0-9][a-z0-9-]+
#39;) schema_version: Literal['1.0'] group_id: str = Field(min_length=1) split: Literal['development', 'validation', 'test'] input: str = Field(min_length=5) expected: ExpectedBehavior slices: list[str] = Field(min_length=1, max_length=12) source: Source review: Review def normalized_hash(text: str) -> str: normalized = ' '.join(text.lower().split()) return hashlib.sha256(normalized.encode('utf-8')).hexdigest() def validate_file(path: Path) -> None: ids: set[str] = set() input_splits: dict[str, str] = {} group_splits: dict[str, str] = {} approved = 0 for line_number, line in enumerate(path.read_text().splitlines(), start=1): if not line.strip(): continue try: case = GoldenCase.model_validate_json(line) except ValidationError as error: raise SystemExit(f'{path}:{line_number}: {error}') from error if case.id in ids: raise SystemExit(f'{path}:{line_number}: duplicate id {case.id}') ids.add(case.id) digest = normalized_hash(case.input) prior_split = input_splits.setdefault(digest, case.split) if prior_split != case.split: raise SystemExit( f'{path}:{line_number}: duplicate input crosses splits' ) group_split = group_splits.setdefault(case.group_id, case.split) if group_split != case.split: raise SystemExit( f'{path}:{line_number}: group {case.group_id} crosses splits' ) if case.review.status == 'approved': approved += 1 print(f'validated={len(ids)} approved={approved}') if __name__ == '__main__': if len(sys.argv) != 2: raise SystemExit('usage: python validate_golden.py DATASET.jsonl') validate_file(Path(sys.argv[1]))

Run it with:

python validate_golden.py golden/support.jsonl

This validator catches schema errors, duplicate IDs, exact normalized duplicate inputs across splits, and group leakage. It does not detect semantic paraphrases, wrong labels, or unauthorized source use. Add those checks through review and purpose-specific tooling.

7. Prevent Leakage with Stable Grouped Splits

Leakage happens when information from the evaluation set influences model, prompt, retrieval, grader, or threshold development. Exact duplicate detection catches only the easiest form. Paraphrases, shared documents, adjacent conversation turns, cloned repositories, and cases from one customer can cross a random row split while carrying nearly identical answers.

Choose the leakage group that matches the task. Group all chunks from one source document, turns from one conversation, variants of one requirement, pull requests from one repository, or cases derived from one incident. Assign the entire group to one split.

Use stable deterministic assignment or a reviewed manifest. Adding new rows should not reshuffle old groups between development, validation, and test. Record the algorithm and seed if you use hashing. For small high-risk sets, an explicit split manifest is easier to audit.

Keep the test set blind to people tuning prompts and thresholds. They can see aggregate results and selected adjudicated failures according to process, but repeated case-level exposure turns test into development data. Create a new version or a fresh holdout when exposure becomes substantial.

Watch retrieval leakage. If expected answers or annotation rationales are indexed into the same corpus used during evaluation, the application may retrieve the benchmark oracle. Separate evaluation metadata from product knowledge stores and test content hashes.

Watch judge leakage too. A rubric prompt should not contain reference outputs from the exact test cases unless reference comparison is intentionally part of the metric. Fine-tuning or few-shot examples must not include the held-out cases.

Report results by split and exposure status. A development-set improvement is useful for iteration but is not unbiased release evidence.

8. Measure Dataset Quality Before Model Quality

Validate the instrument before interpreting model scores. Report schema validity, approved-label rate, source completeness, reviewer coverage, duplicate and near-duplicate rate, slice distribution, disagreement, adjudication backlog, age, and deletion obligations.

Coverage is relative to a taxonomy. A table of slice counts shows presence, not adequacy. Inspect whether each slice contains meaningful positives, negatives, boundaries, and difficult cases. Ten paraphrases of the same refusal do not provide ten independent risks.

Test oracle behavior against known outputs. Create obvious pass, obvious fail, and hard partial responses for rubric-based metrics. If the grader passes a fabricated action or fails an acceptable paraphrase, fix the metric or label before comparing models.

Use sentinel cases to detect pipeline mistakes. A deliberately invalid JSON output should fail schema checks. An explicit forbidden claim should fail policy assertions. If sentinels pass, stop the evaluation. This verifies plumbing rather than application quality.

Review class and severity balance. Accuracy can look strong when one label dominates. Use precision, recall, confusion matrices, or slice pass rates according to the decision. For graded tasks, examine score distributions and boundary disagreement.

Document uncertainty. Small slices produce unstable percentages. Do not claim a broad capability from three examples. Report counts next to rates and combine quantitative evidence with failure inspection.

A golden dataset earns trust through transparent limitations and ongoing review, not through a large row count or the label golden.

9. Integrate the Dataset into Evaluation and CI

Keep schema validation fast and deterministic on every change. Dataset linting should verify identifiers, required provenance, split groups, allowed slice values, content hashes, and lifecycle state. It should not call a model.

Run a small critical subset in pull-request CI. Broader model and application evaluation can run before release or on schedule. Store dataset version, commit, application version, prompt version, model configuration, grader version, and threshold with every result.

Make data changes visible. A pull request that adds or relabels cases should include source rationale, reviewer approval, slice impact, and expected metric impact. Require stronger review when a change makes a failing candidate pass.

For promptfoo, external JSONL test files can drive the test matrix, while exact and custom assertions encode behavior. See building evals in CI with promptfoo for a complete quality-gate pattern. Adapt the golden record into runner-specific variables rather than deleting provenance to fit a narrow config.

Store test reports as immutable artifacts with retention aligned to policy. Do not publish sensitive inputs or full outputs in public CI logs. A failing job should still upload safe diagnostic evidence.

Separate dataset failure from system failure. Invalid rows, missing source files, provider outages, grader errors, and unacceptable application outputs need distinct statuses. Do not count an infrastructure error as a model-quality zero or silently drop it from the denominator.

Use evaluation results to propose new cases, but require independent curation. Production failures and reviewer disagreements are valuable sources for the next dataset version.

10. Building Golden Datasets for Evals as a Governed Product

Assign an owner, domain reviewers, security or privacy approvers, and an operational maintainer. Define who can add sources, change labels, approve schema migrations, view restricted content, and release a dataset version.

Use semantic versions or another explicit version policy. A label correction, new cases, schema change, removed source, and split change can affect comparability differently. Publish a changelog that states which metrics should or should not be compared across versions.

Support deprecation instead of deletion when policy permits. Mark a case inactive, state the reason, and point to its replacement. If privacy or license obligations require deletion, remove content and derived artifacts according to policy while retaining only allowed audit metadata.

Schedule reviews for stale sources, changed product rules, slice drift, annotation guidance, and benchmark exposure. A correct refund oracle from last year may be wrong after policy changes. Trigger review when a source revision changes, even if the scheduled date has not arrived.

Protect access. Raw production-derived examples may need stronger controls than sanitized evaluation artifacts. Apply encryption, least privilege, audit logging, retention, and environment separation. Review external graders and model providers as data recipients.

Measure whether the dataset improves decisions. Track escaped failure categories, false-release blocks, adjudication time, and cases that no longer discriminate candidates. Replace weak coverage with better evidence rather than continually appending rows.

The dataset is a product because other teams depend on its API, versions, documentation, reliability, and support. Treating it as a static spreadsheet is how silent oracle debt reaches production.

Interview Questions and Answers

Q: What makes a dataset golden?

It has representative, source-backed cases with reviewed expectations, provenance, stable splits, and a clear evaluation purpose. Golden does not mean infallible. It means the organization has a governed best-known oracle and makes uncertainty visible.

Q: How do you handle multiple correct natural-language answers?

I encode required facts, prohibited claims, allowed decisions, evidence, and rubric anchors instead of exact-string equality. A reference answer can illustrate behavior without becoming the only accepted wording. Deterministic rules remain separate from subjective grading.

Q: Why is random row splitting risky?

Related rows can share documents, incidents, users, repositories, or paraphrased content. If those cross splits, development work indirectly sees test information. I split by the strongest leakage group and keep assignment stable.

Q: How do you measure annotation quality?

I run independent overlapping review, inspect agreement and disagreement by slice, and adjudicate with a written protocol. I also audit source evidence, rationale, and sentinel examples. A single agreement percentage without failure analysis is insufficient.

Q: Can an LLM create the golden dataset?

It can propose scenarios, paraphrases, and edge cases, but qualified people must verify realism, source support, labels, and rights. I mark synthetic provenance and prevent the candidate model from becoming the sole author of its own evaluation.

Q: How do you version a golden dataset?

I version schema, records, annotation guide, sources, splits, and rubric, then publish a change log. I state whether results remain comparable across versions. Evaluation artifacts always record the exact dataset revision.

Q: What is the first quality check you run?

I validate schema, unique identity, source completeness, approval state, and split grouping before any model call. Then I run oracle sentinels and review slice coverage. Model scores are meaningless if the instrument is broken.

Common Mistakes

  • Starting with a desired row count instead of a release decision and failure taxonomy.
  • Calling one model-written reference answer ground truth.
  • Using exact string matching for tasks with many valid phrasings.
  • Randomly splitting rows that share a document, incident, repository, or conversation.
  • Copying production data without authorization, minimization, or deletion mapping.
  • Letting annotators see each other's labels before independent review.
  • Forcing ambiguous cases into a binary label instead of abstaining or clarifying policy.
  • Including held-out answers in prompts, retrieval corpora, or grader examples.
  • Reporting aggregate accuracy without slice counts and severe failure analysis.
  • Overwriting labels or records without version history.
  • Treating infrastructure errors as model failures or dropping them silently.
  • Assuming a large dataset is automatically more representative or reliable.

Conclusion

Building golden datasets for evals is measurement engineering. Define the decision, model the failure space, preserve source evidence, encode behavioral oracles, use qualified independent review, and protect splits from leakage. Validate the dataset before using it to rank or release AI systems.

Begin with a small seed set that experts can defend case by case. Add boundaries, hard negatives, incidents, and adversarial scenarios as the taxonomy demands. Version every meaningful change and keep limitations visible, so the dataset remains a trustworthy decision tool rather than a frozen collection of old assumptions.

Interview Questions and Answers

How would you build a golden dataset from scratch?

I would define the release decision and failure taxonomy, design a schema for input, oracle, source, slices, and review, then curate a diverse seed set. Qualified reviewers label independently and adjudicate disagreements. I validate structure and leakage groups, establish stable splits, and version the full contract before using it as a gate.

How do you represent ground truth for generative output?

I separate deterministic requirements from judgment. Records contain must-include facts, forbidden claims, allowed actions, source evidence, and anchored rubrics, plus optional reference answers. This accepts valid paraphrases while still rejecting material behavioral errors.

What is data leakage in an eval dataset?

Leakage occurs when held-out information influences development, prompts, retrieval, grading, or threshold choice. It includes exact duplicates and related documents, conversations, incidents, repositories, and paraphrases across splits. I group related records and track benchmark exposure.

How would you resolve reviewer disagreement?

Reviewers label independently under a versioned guide, then an adjudicator examines evidence and rationale. I classify the cause as reviewer error, guide ambiguity, source conflict, insufficient evidence, or legitimate ambiguity. Some cases are revised or removed rather than forced into a label.

Which dataset quality metrics do you track?

I track schema validity, approved-label coverage, source completeness, duplicates, group leakage, slice distribution, reviewer agreement, adjudication backlog, age, and sentinel behavior. I report counts with rates and inspect severe and boundary cases.

How do you safely use production examples?

I obtain authorization, minimize and sanitize content, preserve only needed evidence, and map retention and deletion obligations to derived records. Access and model-provider policy follow the source classification. Rare narratives receive re-identification review even after names are changed.

How do you maintain comparability across dataset versions?

Every result records the exact dataset, schema, rubric, grader, and application version. The changelog identifies added, removed, relabeled, and re-split cases and states whether aggregate results remain comparable. For major changes, I run overlap analyses or start a new benchmark series.

Frequently Asked Questions

What is a golden dataset for AI evals?

It is a versioned collection of representative evaluation units with reviewed expected behavior, provenance, slice labels, and governance. It supports a specific decision such as release approval or model comparison, and it documents uncertainty rather than claiming perfect truth.

How large should a golden dataset be?

There is no universal row count. It should cover the decision-relevant failure taxonomy and important slices with enough cases to support stable conclusions. Start small and expert-reviewed, then expand because of measured gaps.

Can synthetic data be included in a golden dataset?

Yes, especially for rare boundaries and adversarial behavior, but mark its provenance and have domain experts verify realism and labels. Keep results segmented so synthetic success is not mistaken for production representativeness.

How do you prevent benchmark leakage?

Group related content into one stable split, keep held-out cases away from prompt and threshold development, and prevent reference answers from entering retrieval or few-shot examples. Track exposure and create a fresh holdout when the test set is no longer meaningfully blind.

Should every golden case have a reference answer?

No. Exact references fit tasks with one canonical result, but many language tasks need behavioral expectations, allowed variants, forbidden claims, and rubrics. A reference can be illustrative without being the only passing string.

How often should a golden dataset be reviewed?

Set a risk-based schedule and also trigger review when source policies, product behavior, schemas, graders, or data distributions change. High-risk or rapidly changing domains need more frequent review than stable deterministic extraction tasks.

What file format is best for a golden dataset?

JSONL is practical for typed records, streaming validation, and version control, while larger restricted artifacts may belong in controlled storage referenced by hashes. The best format preserves the schema, provenance, and access policy your workflow needs.

Related Guides