Sub topic 12
Maintaining datasets and updating baselines
This chapter assumes you have a JSONL golden dataset, a pytest suite that runs it, and a stored baseline pass rate checked in CI, as built in earlier chapters. It covers how to keep those assets accurate as the product changes.
Why datasets and baselines decay
A golden dataset describes what "correct" meant on the day you wrote it. Three things make it stale:
- The product changes. Cases test behavior you removed or never needed.
- Real traffic shifts. Users ask things your cases do not cover.
- The baseline stops matching reality. After a deliberate improvement, the old baseline lets later regressions hide below the new level.
Maintenance is routine work. Treat it with the same review as code.
Adding cases from failures
Every production bug that your suite missed should become a case. The steps are:
- Reproduce the bad output with the exact input.
- Add a case with a unique
id, the input, and the checks that would have caught it. - Confirm the new case fails on the old prompt and passes on the fix.
- Commit the case in the same pull request as the fix.
Scrub personal data from any real input before it enters the repository.
{"id": "refund-007", "input": "I want my money back for order 4412", "required_keys": ["intent", "order_id"], "must_contain": ["refund"], "added": "2026-11-20", "source": "incident-318"}The added and source fields are extra metadata. The test in the earlier chapter ignores keys it does not read, so they are safe, and they tell a future maintainer why the case exists.
Retiring and fixing cases
Review the dataset on a schedule, for example once a quarter. For each case that fails every run or never fails, ask whether it is still valid.
- Remove cases for features that no longer exist.
- Fix cases whose expected values were wrong. A case that fails on every model is often a bad case.
- Deduplicate near-identical cases. They inflate the pass rate and give false confidence.
- Check the balance of categories. If adversarial cases fell below a reasonable share, add some.
Never delete a failing case just to make the build green. Record the reason in the commit message.
Versioning the dataset
Because the baseline is a pass rate over a specific set of cases, changing the set changes what the number means. Store the dataset version next to the baseline.
{"dataset_version": "2026-11-20", "case_count": 142, "baseline": 0.94, "model": "pinned-model-id", "prompt_commit": "a1b2c3d"}When the version in this file differs from the version of the dataset being run, the comparison is not valid, and the gate should say so instead of reporting a regression.
import json
from pathlib import Path
def load_baseline(path="evals/baseline.json"):
return json.loads(Path(path).read_text(encoding="utf-8"))
def check_version(baseline, dataset_version):
if baseline["dataset_version"] != dataset_version:
raise SystemExit(
"Dataset changed since the baseline was recorded "
f"({baseline['dataset_version']} vs {dataset_version}). "
"Re-record the baseline in this pull request."
)Updating the baseline deliberately
A baseline should move for a reason you can state. Acceptable reasons are:
- You added or removed cases, so the number needs re-recording.
- You changed the prompt or model on purpose and the new pass rate is better.
- You accepted a known trade-off, such as lower pass rate on one category for a gain elsewhere.
Unacceptable reasons: the build was red and someone wanted it green.
Keep the baseline file in Git and require a reviewer on changes to it. The diff shows who raised or lowered the bar, and why.
Also move the baseline upward. If a prompt improvement lifts the pass rate from 0.94 to 0.97, record 0.97. Otherwise the 0.02 tolerance leaves room for the score to fall back to 0.93 without a failure.
Common mistakes
| Mistake | Effect | Fix |
|---|---|---|
| Lowering the baseline to pass CI | Hides a real regression | Triage first, then document any lowering |
| Changing cases without re-recording | Gate compares unlike numbers | Version check in the gate |
| Never adding production failures | Suite misses real problems | Add a case per incident |
| Keeping duplicate cases | Inflated pass rate | Periodic deduplication |
Exercise
Your pass rate fell from 0.94 to 0.90, below the 0.02 tolerance. Triage shows 6 of the failing cases expect an answer format that the product dropped last month. What should you do, and what should happen to the baseline?
Show answer
Remove or fix those 6 outdated cases in the dataset, because the failures come from bad cases and not from worse output. Bump the dataset version, re-run the suite, and record a new baseline in the same pull request. Give the reason in the commit message and have a reviewer approve the baseline diff. If failures remain after the cleanup, triage them as real regressions.
Exercise
Why store the dataset version and prompt commit alongside the baseline pass rate?
Show answer
The pass rate only means something for a specific set of cases and a specific prompt and model. The stored version lets the gate detect that the dataset changed and refuse to compare unlike numbers. The prompt commit helps reviewers trace which change produced the recorded score.