Evaluation Methods
Which method fits which feature, how to choose a model, and how to build a pipeline you can trust.
Method chooser
| Method | Needs reference? | Use when | Trap |
|---|---|---|---|
| Functional correctness | No (needs tests) | Output can be executed or checked: code, SQL, game score, task completed | Hard to automate outside code-like tasks |
| Exact match | Yes | Short, unambiguous answers (math, trivia) | The “contains” variant accepts wrong answers; fails on long or varied outputs |
| Lexical similarity | Yes, many references | Wording matters (BLEU, ROUGE, edit distance) | Penalizes valid phrasings; BLEU barely separates correct from incorrect code |
| Semantic similarity | Yes, fewer references | Meaning matters, many phrasings are valid | Only as good as the embedding model; costs compute |
| AI as a judge | Optional | Subjective criteria; production without references | Inconsistency, non-standard criteria, cost and latency, biases |
| Comparative evaluation | No | Ranking models on subjective quality | Not for correctness questions; quadratic pairs; tells you which is better, not how good |
| Perplexity | No | Training signal, data contamination checks, abnormal-text detection | Rises after post-training, so a weak proxy for chat models |
Key numbers and definitions
- pass@k = fraction of problems where any of k samples passes all tests.
- Cosine similarity: 1 = identical direction, −1 = opposite.
- Embedding size: typically 100–10,000 numbers;
text-embedding-3-small= 1,536. - Perplexity: lower = more confident. It's lower for structured text and longer context, higher for bigger vocabularies.
AI-judge checklist
- The prompt states the task, the criteria, and the scoring system.
- Prefer classification labels over numbers, and a discrete 1–5 scale over a continuous one. Include an example per score.
- Pin the judge's model, prompt, and sampling settings, and version them. A judge change can look like an app change.
- Mitigate biases: swap positions (first-position bias), watch for length (verbosity bias), avoid self-judging (self-bias).
- Control cost with a weaker judge or spot-checking, and back the judge up with exact methods or human review.
- Specialized judges: reward model (prompt, response → score), reference-based judge, preference model (two responses → which one is preferred).
What to evaluate (Ch4)
- Evaluation-driven development: define criteria before building.
- Four buckets: domain-specific capability, generation capability (fluency, coherence, factual consistency, safety), instruction-following (format, length, structured output), cost and latency.
- Factual consistency is local (against given context; easier) or global (against open knowledge).
Choosing a model
- Filter by hard attributes (licence, privacy, size, and latency if someone else hosts the model).
- Narrow with public benchmarks and leaderboards. They are a filter, not a verdict, and likely contaminated.
- Experiment with your own eval pipeline.
- Monitor in production. The process is iterative.
API vs. self-host: weigh privacy · lineage · performance · functionality · cost · control · on-device. Contamination checks: n-gram overlap (accurate, needs training data) or perplexity (cheap, needs only the model).
Pipeline checklist
- Evaluate each component and the end-to-end output, both per turn and per task.
- Write a guideline that covers what the app should and shouldn't do, with a rubric that has examples. Map the metric to a business metric and set a usefulness threshold.
- Mix methods (cheap scorer on 100% of traffic, judge on 1%), and add human review as the North Star.
- Slice the data (tiers, sources, typos, out-of-scope). Watch for Simpson's paradox.
- Sample size: a score from N examples is only accurate to about ±1/√N (100 → ±10 pts, 1,000 → ±3, 10,000 → ±1), so 3× smaller gap → 10× more examples (30 pts ≈ 10, 10 ≈ 100, 3 ≈ 1,000, 1 ≈ 10,000). Bootstrap to check stability.
- Evaluate the evaluator: right signal? reproducible (judge temperature 0)? correlated metrics? added cost? Log everything.