AI Evals: How to Test Systems That Don't Give the Same Answer Twice
Traditional tests check that add(2, 3) === 5. AI outputs vary, are often long text, and "correct" can be subjective. Evals — systematic evaluations — are how serious teams ship AI features with confidence.
Step 1: Build a Test Set
Collect 50–200 real examples:
- Real user questions or inputs
- Expected answers, or criteria for a good answer
- Hard cases: ambiguous, adversarial, out-of-scope
Grow it every time you find a failure in production.
Step 2: Choose Checks
Deterministic checks (cheap, reliable):
- Valid JSON? Required fields present?
- Contains a citation? Under 200 words?
- Correct category from a fixed list?
LLM-as-judge (scalable for subjective quality):
Rate this answer 1–5 for faithfulness to the provided context. Explain briefly. Answer only with JSON.
Calibrate judges against human ratings on a sample — judges have biases too.
Human review (gold standard): periodic expert review of a random sample.
Step 3: Metrics That Matter
- Accuracy / correctness
- Faithfulness — is the answer supported by sources (for RAG)?
- Refusal correctness — says "I don't know" when it should
- Safety — no harmful or policy-violating output
- Latency and cost per request
Step 4: Regression Testing
Run evals whenever you change a prompt, model, retrieval setting, or tool. A new prompt that improves one case often breaks three others. Put evals in CI like unit tests.
Step 5: Production Monitoring
- Track user feedback (thumbs up/down)
- Sample and review live conversations
- Monitor drift in cost, latency, and fallback rates
Tooling
Many open-source and commercial tools help (promptfoo, OpenAI Evals, LangSmith, Braintrust, and others) — but a spreadsheet plus a script is a fine start.
Evals are the difference between "it worked in the demo" and "it works for our users". Start small, but start before launch.