AIF-28Recommended
Run each case several times
Run each eval case at least three times and score the pass rate per case. One run of a model can pass or fail by chance.
How to do it
Use the same settings as production, including temperature. Mark a case as passed when it passes in every run, or in a share you set, such as two of three. Report cases that pass only sometimes as unstable, and fix the prompt or the schema for them. Mark the cases that test the spec's worst failure as critical. A critical case must pass every run. Three runs find unstable cases but cannot measure how often one fails. To compare two versions, run each case at least 10 times. Compare them only when the score gap is larger than the spread between repeated runs of one version. It is the same idea as finding flaky tests before they merge.
Examples
TypeScript example
const RUNS_PER_CASE = 3;
const results = await Promise.all(cases.map(async c => ({ id: c.id, passes: (await Promise.all(Array.from({ length: RUNS_PER_CASE }, () => runCase(c)))).filter(failures => failures.length === 0).length })));
const unstable = results.filter(r => r.passes > 0 && r.passes < RUNS_PER_CASE);
Python example
RUNS_PER_CASE = 3
results = [{"id": c["id"], "passes": sum(not run_case(c) for _ in range(RUNS_PER_CASE))} for c in cases]
unstable = [r for r in results if 0 < r["passes"] < RUNS_PER_CASE]
How to check
The eval report shows each case's pass count out of the number of runs. CI fails when the overall score is under target or a case marked critical fails any run. A report comparing two versions shows at least 10 runs per case and the spread between runs.
Related rules
- AIF-77 Put attack cases in every eval run in AI features
- TST-29 Find flaky tests before they merge in Testing
- AIF-32 Test that answers do not change with who asks in AI features
- AIF-62 Rebuild fine-tuned models from stored data and compare before switching in AI features
- AIF-83 Run the tool evals on more than one model in AI features
- AIF-56 Test agents by the end state in AI features
- MLO-17 Report each score with its uncertainty in Machine learning
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/ai-features/evals-and-quality/repeat-eval-runs">Agent Wranglers AI features playbook</a>. In code you write, add a comment next to it with the same link.