LLM Evals: How to Test AI Features Before They Reach Users
Build evaluations for LLM features: golden datasets, code-based and model-graded checks, regression suites in CI, and production monitoring of quality.
Published December 1, 2026
Traditional tests check that a function returns an exact value. LLM features produce variable text, so many teams ship them on vibes and discover regressions from angry users. Evals are the testing discipline for AI: structured datasets and scoring that tell you whether a prompt change, model upgrade or new retrieval setting made things better or worse.
The concept
An eval has three parts: a dataset of inputs (ideally real, anonymised examples including hard and adversarial cases), the system under test (prompt + model + tools + retrieval), and graders. Graders range from code checks (valid JSON, contains the order ID, under 100 words, correct category) to model-graded rubrics for qualities like helpfulness or faithfulness, to periodic human review.
Run evals at three moments: during development to compare variants, in CI as a regression gate before deploys or model upgrades, and in production by sampling live traffic for grading and collecting user feedback. Production failures then become new dataset rows, so the suite grows where the product actually breaks.
Building evals
- Collect real inputs, including edge cases and past failures
- Define pass criteria per case (code checks first)
- Add model-graded rubrics for subjective qualities
- Run on every prompt/model change; compare to baseline
- Sample production traffic, add new failures to the set
Types of graders
| Grader | Good for | Cost / reliability |
|---|---|---|
| Exact / regex / schema checks | Format, required facts, categories | Free, deterministic |
| Programmatic checks | Code compiles, SQL runs, links valid | Cheap, reliable |
| Model-graded rubric | Tone, helpfulness, faithfulness | Some cost; calibrate vs humans |
| Pairwise comparison | Which of two outputs is better | Good for A/B of prompts |
| Human review | Ground truth, nuanced quality | Expensive; use on samples |
Why run evals on every change
Practical examples
A tiny eval runner
Code-based graders cover a lot.
cases = [json.loads(l) for l in open("evals/triage.jsonl")]
passed = 0
for c in cases:
out = triage(c["input"]) # system under test
ok = (out.category == c["expected_category"]
and (c.get("order_id") is None or c["order_id"] in out.summary))
passed += ok
if not ok: print("FAIL", c["id"], out)
print(f"{passed}/{len(cases)} passed")Model-graded rubric
Binary criteria are more reliable than 1-10 scores.
Grade the support reply. Answer each with YES or NO:
1. Does it answer the customer's actual question?
2. Does it avoid promising refunds or dates not in the policy?
3. Is it under 120 words?
Return JSON: {"q1": "...", "q2": "...", "q3": "...", "pass": true|false}Gate deploys in CI
Fail when pass rate drops below the baseline.
- run: python evals/run.py --suite triage --baseline evals/baseline.json --max-drop 0.02Common mistakes
- Evaluating with a handful of hand-picked examples.
- Only subjective model grading when simple code checks would work.
- Upgrading models without rerunning the eval suite.
- Never adding production failures back into the dataset.
Key takeaways
- Evals = dataset + system under test + graders.
- Prefer deterministic code checks; add model-graded rubrics where needed.
- Run evals in development, CI and production.
- Grow the dataset from real failures.
FAQ
How many eval cases do I need?
Start with 30-100 representative cases; precision improves as you add more, especially for rare failure types.
Can the same model grade itself?
It can, but using a different or stronger model as judge, and validating against human labels, is more trustworthy.
Are evals only for chatbots?
No. Any LLM feature (extraction, classification, code generation, agents) benefits from evals.