Learn AI · Foundations
Evals Explained
Evals are the unit tests of AI systems. Without them you're flying blind. Here's how to build a useful eval set without going overboard.
Key takeaways
- 1Evals catch regressions that human review misses.
- 2Start with 20–30 cases. You can build that in an afternoon. Don't overengineer.
- 3Mix easy cases (sanity), hard cases (capability), and adversarial cases (safety).
- 4LLM-as-judge is fine for subjective quality, deterministic checks better for structure.
- 5Eval cost should be a fraction of model cost — if it's not, reduce the eval frequency, not the eval set.
The shift in mindset
In traditional software, you write tests because behavior is deterministic. In AI software, you write evals because behavior is probabilistic — and that makes them more important, not less.
An eval is not a unit test. It's a measurement of system behavior on a fixed set of inputs.
What goes in an eval set
Three categories, balanced:
- Sanity (easy) — basic cases the system must always handle. Tests for regression to known-broken states.
- Capability (hard) — real-world tricky cases. Tests for whether your system can handle the actual job.
- Adversarial (failure modes) — prompt injection, edge cases, things you've seen go wrong. Tests for safety + robustness.
Aim for 20–30 cases initially. You can always add more.
Evaluation methods, by task
| Task type | Best method |
|---|---|
| Structured output (JSON, tags) | Schema validation + exact-field check |
| Classification | Accuracy / F1 against gold labels |
| Extraction (entities, dates) | Token-level overlap or exact match |
| Summarization | LLM-as-judge with rubric |
| Reasoning correctness | LLM-as-judge OR human review |
| Voice / style | Human review (you can't shortcut taste) |
| Code generation | Run the code; check tests pass |
LLM-as-judge — the practical pattern
For subjective tasks, use a strong model to score outputs against a rubric.
You are an expert reviewer. Score the response below on:
- Correctness (1-5)
- Helpfulness (1-5)
- Avoids hallucination (1-5)
Output JSON: { correctness, helpfulness, no_hallucination, justification }
Question: {{question}}
Expected answer key points: {{key_points}}
Actual response: {{response}}
Validate the judge against human ratings on 20 samples before trusting at scale. Drift happens.
Run evals in CI
The biggest impact: run evals on every change to prompts, agent code, or model versions. Treat eval score drops above N% as deploy blockers.
# .github/workflows/evals.yml
- name: Run evals
run: python evals/run.py --threshold 0.85
Common pitfalls
- Evaluating on data the model was trained on — invalidates the eval. Always use fresh inputs.
- Eval set leaks into training — common with synthetic data. Keep eval set in a separate file, never in training pipelines.
- Optimizing the eval, not the system — when scores plateau, expand the eval set, don't just tweak it.
- Single-metric tunnel vision — track multiple dimensions (quality, latency, cost, safety) — improving one often regresses another.
Where to start tomorrow
- Write 20 cases as JSON:
{ id, input, expected }. - Write a 50-line Python script that loops them, calls your system, scores them.
- Run it. Fix the worst failures.
- Add to the set as you discover failure modes.
- Add it to CI when you have a baseline.
That's the whole game. Eval first, prompt-engineer second.
Common misconceptions
The wrong-but-common takes worth correcting.
Myth
Evals require a fancy framework.
Reality
A JSON file of inputs/expected outputs and a Python script that loops them is enough to ship. Frameworks help at scale; they're not a precondition.
Myth
100% pass rate means the system is good.
Reality
100% means your eval set is too easy. Push until you find failures the model can't fix without help.
Myth
Evals replace human review.
Reality
Evals catch regressions. Humans catch edge cases evals don't. Both are needed in production.
Real-world use cases
Prompt iteration
Compare two prompts on the same eval set in seconds — no guessing which one's better.
Model selection
Same eval, multiple models, side-by-side scores. The cheapest model that passes wins.
Agent loops
Evals are the difference between an agent that ships and one that hallucinates in production.
Open
Continuous regression testing
Run evals in CI before every deploy. Block merges on score drops above a threshold.
Frequently asked questions
Related on AIKnowHub
Concept
AI Agents Explained
Agents are LLMs that can take actions in a loop. Here's what that actually means, where they shine, and where they fall over.
Concept
Fine-Tuning Explained
When to fine-tune, when not to, and how to do it without burning weekend cycles. The honest version.
Concept
Prompt Engineering Basics
The actual techniques that move the needle — role priming, structured output, few-shot examples, and why specificity always wins.
Interview
How would you build an evaluation suite for an LLM-powered feature?
Evals are the difference between shipping and praying. Standard interview topic in 2026.
Tool Guide
Langfuse Guide
The definitive guide to Langfuse for LLM observability — traces, prompt versions, evals, cost tracking, self-host setup, and when to pick it over Braintrust or Phoenix.
Comparison
Langfuse vs Braintrust vs Phoenix
Three observability options for production LLM apps — open-source tracing, eval-first SaaS, and RAG-focused OSS from Arize.