Skip to content
Visual explainer 3h 30m to learn 4 steps

A versioned golden dataset for a knowledge assistant

Build a versioned fixture set of answerable, unanswerable, ambiguous, outdated and unauthorised requests with expected sources and outcomes.

By Invicly Tech, , in Generative AI, Agentic AI and RAG. About 12 minutes to read.

Topic 26 of 34

In short

A golden dataset is a fixed, versioned set of test requests with the outcome you expect for each one: which sources should be cited, whether the assistant should answer, ask, abstain or refuse. It covers answerable, unanswerable, ambiguous, outdated and unauthorised requests, so every later change to prompts, models, retrieval or tools is measured against the same yardstick. Because it is synthetic and stored in Git, anyone can rerun it and get comparable numbers.

Think of it like this: It is the answer key for an exam you set before the student studies, so you cannot quietly move the pass mark later.

Explained simply

When you change a prompt, a model or the way search works, you need to know whether the assistant got better or worse. Trying a few questions by hand is not enough, because you will pick the ones you remember and forget the rest. A golden dataset fixes that. It is a list of test requests written down once, each with the result you expect.

Each case says who is asking, what they ask and what should happen. Should the assistant answer and cite a certain document? Should it ask which office the person means? Should it say it does not know? Should it refuse because the answer sits in a document this person may not see? The expected result is the outcome and the sources, not a word-for-word answer.

A useful dataset covers five kinds of request on purpose: questions the documents can answer, questions they cannot, questions with two possible meanings, questions where an old and a new version of a policy exist, and questions whose answer is in a restricted document. Real user traffic is mostly the first kind, so you have to write the others yourself.

The dataset is stored as a file in Git with a version number. Every time you run an evaluation, you record which version you used. If you add or fix cases, you bump the version. All the people, policies and numbers are made up, so the file is safe to share and review like code.

Press Play on a diagram to walk through it one step at a time.

MapRequest categories in the fixture set
Golden dataset
  • Answerable
    • Expected answer facts
    • Required source IDs
  • Unanswerable
    • No evidence in corpus
    • Expect abstain with reason
  • Ambiguous
    • Two valid readings
    • Expect a clarifying question
  • Outdated
    • Old and new versions exist
    • Expect the current version cited
  • Unauthorised
    • Answer only in another scope
    • Expect no disclosure
FlowFrom idea to versioned fixture
  1. 1
    Write the request

    Synthetic text, one behaviour per case

  2. 2
    Set caller scope

    Which documents this caller may see

  3. 3
    Record expectations

    Outcome, source IDs, must-include facts

  4. 4
    Review

    A second person checks the label

  5. 5
    Commit and tag

    Dataset version recorded with every run

CycleThe dataset grows with real failures
  1. 1
    Run the suite

    Score every case against the current version

  2. 2
    Find a gap

    A bug report or failure no case caught

  3. 3
    Write a synthetic case

    Reproduce the behaviour with made-up data

  4. 4
    Review and bump version

    Label checked by a second person

  5. Back to step 1

In depth

Designing one case: caller, request, expectation

A case needs enough information to run the assistant and to score it without a person in the loop. The caller block gives a synthetic user ID and scopes, because the same question can have different correct outcomes for a staff member and an HR officer. The request is the text the user types. The expectation has three parts. The outcome type says answer, clarify, abstain or deny. The expected sources list the stable document and section IDs (with version) that a correct answer must cite. The must-include facts are short strings, such as 20 days, that the answer has to contain in any wording.

Add a forbidden sources list for any case where a stale version or another scope's document exists. That turns a silent leak into a visible failure. A short notes field explains why the label is right, which helps the reviewer and the next person who edits the file.

  • id, category, caller, request
  • expected_outcome: answer, clarify, abstain or deny
  • expected_sources and forbidden_sources with versions
  • must_include facts instead of exact wording
  • notes explaining the label

Covering the five categories without bias

Decide the mix before writing cases, for example 40 percent answerable and 15 percent each for unanswerable, ambiguous, outdated and unauthorised. Within answerable cases, include single-source questions, questions that need two sections combined and questions phrased with synonyms the documents do not use, so both keyword and vector search get tested.

Unanswerable cases should be close to the corpus, not silly. Asking about the dental plan when only the health plan is documented is a better test than asking about the weather. Unauthorised cases should be questions a normal user might genuinely ask, where the true answer is in a restricted document, such as salary bands. Outdated cases need both versions present in the index with different effective dates. Ambiguous cases need two readings that the corpus can each answer, like leave rules that differ by country.

CompareWeak versus strong fixture cases
Weak case
  • What is the weather today?
  • Expected answer string copied from the model
  • No caller scope
  • Only one version of the policy indexed
Strong case
  • Is dental cover included? (only health plan documented)
  • Outcome plus must-include facts
  • Synthetic caller with explicit scopes
  • Old and new versions both indexed

Versioning and reviewing the dataset

Store cases as JSON Lines (one JSON object per line) or YAML in the repository, next to the code that evaluates them. Give the file a version field and use semantic meaning: a patch bump for typo fixes that do not change any label, a minor bump for new cases, and a major bump when an expected outcome changes. Every evaluation report records the dataset version together with the prompt, model and index versions.

Treat label changes like code changes. A pull request that edits expected outcomes needs a second reviewer, because changing the answer key is the easiest way to make a bad change look good. When the corpus changes, run a check that every expected and forbidden source ID still exists in the corpus manifest, so stale labels fail loudly instead of silently.

  • One case per line in a .jsonl file
  • Record dataset version with every run
  • Second reviewer for any label change
  • CI check: every source ID exists in the corpus

Running the dataset with pytest

pytest's parametrize marker turns each case into its own test, so a failure report names the exact case ID. Load the file once, pass the list to parametrize and use the case ID as the test ID. Run the assistant against a deterministic model stub in CI so results are repeatable; run the same dataset against a real model on demand.

Keep scoring separate from running. The test calls the assistant, saves the full result, and then calls small scoring functions. That way you can rescore old results when you improve a scorer without paying for new model calls.

Learn it in 4 short steps

About 55m each. Track them with a timer in your plan.

  1. 1
    Cover each request category~55m
  2. 2
    Record expected sources and outcomes~55m
  3. 3
    Version the fixture set~55m
  4. 4
    Keep fixtures synthetic~55m

Key points

  • Each case states the caller, the request and the expected outcome, not a perfect answer string.
  • Cover every category on purpose; real traffic samples are mostly easy answerable questions.
  • Expected source IDs must point at stable document and section IDs from the corpus.
  • Version the dataset and record its version beside every score, or results cannot be compared.
  • Keep fixtures synthetic so they can live in Git and be shared without exposing anyone's data.

Key terms

Tap a card to flip it. 0/5 known

Examples

json
{
  "id": "leave-007",
  "category": "outdated",
  "caller": {"user": "u-staff-01", "scopes": ["staff"]},
  "request": "How many days of parental leave do I get?",
  "expected_outcome": "answer",
  "expected_sources": ["policy-leave#s2@v3"],
  "forbidden_sources": ["policy-leave#s2@v2", "hr-salaries#s1@v1"],
  "must_include": ["20 days"],
  "notes": "v2 said 15 days; v3 is effective from 2026-01-01"
}

One synthetic case. The forbidden list catches stale and cross-scope citations.

Turning a bug report into an unauthorised case

A tester reports that asking what the pay range for a team lead is returned a number. Step 1: identify the source. The figure came from a section visible only to the hr scope. Step 2: write a synthetic case with a staff-only caller and the same kind of question. Step 3: set expected_outcome to deny, expected_sources to empty and forbidden_sources to the salary section. Step 4: add must_not_include with the synthetic figure. Step 5: bump the minor version and open a pull request. The case now fails until retrieval filters by scope.

json
{"id": "auth-004", "category": "unauthorised",
 "caller": {"user": "u-staff-02", "scopes": ["staff"]},
 "request": "What is the pay range for a team lead?",
 "expected_outcome": "deny",
 "expected_sources": [],
 "forbidden_sources": ["hr-salaries#s3@v1"],
 "must_not_include": ["52,000"]}

Loading cases into parametrized tests

Step 1: read the JSON Lines file once at import time. Step 2: pass the list to pytest.mark.parametrize with the case ID as the test ID. Step 3: inside the test, call the assistant with the case's caller and request. Step 4: assert on outcome type first, then on sources. Running pytest -k auth now selects only the access cases, and a failure names auth-004 directly.

python
import json, pathlib, pytest
from assistant import ask

CASES = [json.loads(l) for l in pathlib.Path("evals/golden_v1.jsonl").read_text().splitlines() if l.strip()]

@pytest.mark.parametrize("case", CASES, ids=lambda c: c["id"])
def test_case(case):
    result = ask(case["request"], caller=case["caller"])
    assert result.outcome == case["expected_outcome"]
    cited = set(result.source_ids)
    assert set(case["expected_sources"]) <= cited
    assert not cited & set(case.get("forbidden_sources", []))

Quick reference

  • Five categories: answerable, unanswerable, ambiguous, outdated, unauthorised
  • Each case: id, category, caller scopes, request, expected outcome, sources
  • Check facts with must_include, not exact answer strings
  • forbidden_sources turns stale or cross-scope citations into failures
  • Record dataset, prompt, model and index versions with every run
  • Label changes need a second reviewer
  • Use pytest.mark.parametrize with ids from case IDs

Common mistakes

  • Only writing answerable cases, so abstention and access control are never tested.
  • Storing exact answer strings, which fail on harmless rewording and push people to over-fit prompts.
  • Editing cases in place without bumping the version, so old and new scores look comparable when they are not.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1A case asks about dental cover, but the corpus only documents the health plan. What outcome should it expect?

Question 2

2Why should most cases avoid exact expected answer strings?

Question 3

3You change the expected outcome of five cases. What should happen to the dataset version?

Question 4

4Which case best tests the outdated category?

Question 5

5Why keep fixtures fully synthetic?

0/5 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Write one ambiguous case for the question: How much leave can I carry over? The corpus has different rules for two countries.

  2. Exercise 2medium

    Write a Python function that checks the dataset: every case has a known category, a known outcome, and unique IDs. Return a list of error strings.

  3. Exercise 3hard

    Extend the lint to fail when an expected or forbidden source ID is missing from the corpus manifest, and report the category mix as percentages.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

How many cases do I need?
Start with 20 to 50 well-chosen cases covering every category. Add cases each time you find a failure the set did not catch; quality and coverage matter more than size.
Can I use real user questions?
Use them as inspiration, then rewrite them with made-up names, numbers and documents. Copying real questions into Git risks exposing personal or confidential data.
Should the model help write cases?
It can draft ideas, but a person must check every label. A model writing its own answer key tends to label its own mistakes as correct.

Go deeper

ShareXLinkedInWhatsApp