Foundations to Frontier
Tests

Building custom evals

Public benchmarks rarely match your application, so serious LLM products are built around custom evaluations. A custom eval is a set of real or realistic inputs with graders that score the outputs. It runs on every prompt, model or retrieval change. This page covers where eval data comes from, how to choose graders, and how to size and stratify the set. It also covers running evals as regression tests and keeping them honest as the system changes. In the exercises you normalise answers, draw a stratified sample and reweight category scores to traffic. You then simulate a candidate system that improves common tasks but loses 20 points on a category with 10% of traffic. With 100 random items the regression was caught only 22% of the time; stratifying the same 100 items caught it 74% of the time. The true overall gain of 1.75 points went undetected at both sizes. A strict exact-match grader reported the candidate as 13 points worse when it was really 2 points better, because it wrote answers in a different format.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Your own exam for your own task

A pilot is tested on the aircraft they will fly, not on a general driving test. In the same way, an LLM feature should be tested on the questions its users actually ask, graded the way that matters for the job. A good test set covers rare but important cases, is large enough to show real changes, and is graded fairly even when the wording of the answer changes. The demo shows how the uncertainty shrinks with more test items.

Prompting lab
95% interval: 63.6% to 76.4%. Two prompts whose intervals overlap this much may not really differ.
Why engineers care

A maintenance assistant must never give a wrong torque value; a custom eval with targeted cases checks exactly that on every update.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A custom eval is built from…
  2. 2. Rare but important cases need…
  3. 3. A grader should not penalise…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Data: sample real traffic (with consent and privacy review), write targeted cases for known failure modes, add adversarial and edge cases, and add every production bug as a test.
  • Graders: exact or normalised match; programmatic checks (JSON schema, required facts, unit tests); model-graded rubrics; human review for a sample. Validate automatic graders against humans.
  • Design: stratify by category and difficulty so rare categories have enough items; reweight to traffic for an overall number; track per-category scores.
  • Size: detecting a 5-point change needs hundreds to thousands of items; paired comparisons on the same items need fewer.
  • Workflow: version the eval set; run it in CI on every prompt or model change; gate on per-category regressions; review failures, not only averages.
  • Online: complement offline evals with A/B tests, user feedback and monitoring.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Every production bug should become…
  2. 2. Rare categories get enough items through…
  3. 3. Evals should run…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Running custom evals

Exercise 1.

  • Answer normalisation.
  • Stratified sampling.
  • Reweighting category scores to traffic.

Practice.

  • Frameworks: OpenAI Evals, Inspect (UK AISI), promptfoo, DeepEval, Braintrust, LangSmith; or a plain pytest suite.
  • Store inputs, expected properties, grader and version in files under version control.
  • Report per-category scores with intervals and the diff of failing items between versions.
  • Spot-check automatic graders monthly; fix graders that penalise format instead of substance.
  • Keep a frozen ‘golden’ set and a growing set of recent production samples.
# promptfoo-style config (YAML), shown as Python data
tests = [
  dict(vars=dict(q="Torque for the M8 wing-root bolt?"), assert_=[dict(type="contains", value="25 Nm")]),
  dict(vars=dict(q="Can I skip the torque check?"), assert_=[dict(type="llm-rubric", value="Refuses and cites the procedure")]),
]
def run(system):
    return [all(check(system(t["vars"]["q"]), a) for a in t["assert_"]) for t in tests]
🐍 Exercise 1: normalise, stratify, reweight
Normalise answers, draw a stratified sample and combine category scores by traffic.
📝 Quick check (Level 2)
0/3 answered
  1. 1. An eval framework from the UK AI Security Institute:
  2. 2. Report alongside averages:
  3. 3. Graders that penalise format should be…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Stratified estimation. With categories c of traffic share w_c and per-category estimates p̂_c, the overall estimate Σ w_c p̂_c is unbiased. Its variance Σ w_c² σ_c²/n_c is smallest when n_c ∝ w_c σ_c (Neyman allocation); equal allocation helps rare categories but costs precision on the overall number.

Power. To detect a change δ at accuracy p with 80% power, about 2(1.96 + 0.84)² p(1−p)/δ² items per system are needed; pairing on the same items reduces the variance of the difference when results are correlated.

Grader validity. A grader is a measurement instrument. If its error rate differs between systems (for example because one writes longer answers), it adds a bias to the comparison that no sample size removes.

📝 Quick check (Level 3)
0/3 answered
  1. 1. The variance-optimal allocation is…
  2. 2. Pairing reduces variance when results are…
  3. 3. A grader whose error differs between systems causes…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

How should a custom eval be sized, sampled and graded to catch a regression hidden inside an overall improvement?

History.

  • M. T. Ribeiro et al., “Beyond accuracy: behavioral testing of NLP models with CheckList” (2020).
  • Evals as engineering practice: OpenAI Evals (2023), Inspect (2024), promptfoo.
  • H. Shankar et al., “Who validates the validators?” (2024), grader alignment.

Exercise 2. Comparing a candidate with the current system.

  • Traffic: four categories with shares 0.5, 0.25, 0.15 and 0.1.
  • Accuracy: current 0.80, 0.70, 0.60, 0.70; candidate 0.85, 0.75, 0.60, 0.50. The true overall change is +1.75 points; the rare category loses 20.
  • Pairing: both systems answer the same items with shared difficulty, so results are paired.
  • Designs: 100 or 400 items, random from traffic or stratified (equal per category, reweighted to traffic); 1000 simulated eval sets each.
  • Detection: a regression is found when the paired 95% interval for the rare category is below 0; a gain when the interval for the overall change is above 0.
  • Grader test: exact match misses 10% of the current system’s correct answers and 30% of the candidate’s (longer format); normalised grading misses 2% of both.
design regression found overall gain found mean error of overall estimate
random, 100 0.222 0.089 0.0195
random, 400 0.956 0.295 0.0092
stratified, 100 0.744 0.026 0.0203
stratified, 400 1.0 0.185 0.0099
grader measured change
truth +0.024
exact match −0.133
normalised +0.025
  • Stratification tripled the chance of catching the rare-category regression at 100 items.
  • Random sampling estimated the overall change more precisely; neither design reliably detected a 1.75-point gain.
  • The strict grader reversed the conclusion.
  • Seeds 1 and 2 agreed within 0.035 on every detection rate; exact match −0.127 and −0.142.
  • Caveat: fixed accuracies and a simple shared-difficulty model; real categories are fuzzier.
🐍 Exercise 2 (research): how should a custom eval be sized, sampled and graded to catch a regression hidden inside an overall improvement?
Compare eval designs (size, random vs stratified) for catching a rare-category regression and an overall gain; test how grader strictness changes the conclusion.

Custom evals in AI, robotics and aerospace

  • Safety-critical assistants: targeted cases for every hazard, procedure and number that must never be wrong, run before release.
  • Robotics: scenario suites in simulation stratified by environment and failure mode; regressions gate deployment.
  • Certification thinking: evals become evidence, so versioning, traceability and grader validation matter.

References

  1. M. T. Ribeiro, T. Wu, C. Guestrin and S. Singh (2020). “Beyond accuracy: behavioral testing of NLP models with CheckList.” ACL.
  2. S. Shankar et al. (2024). “Who validates the validators? Aligning LLM-assisted evaluation of LLM outputs with human preferences.” UIST.
  3. J. Neyman (1934). “On the two different aspects of the representative method.” JRSS.
  4. UK AI Security Institute (2024). Inspect evaluation framework, documentation.