Model Evaluation: Metrics, Judges and Benchmarks
Decide what "better" means before you measure anything
The most common evaluation failure is not a bad metric; it is running metrics before agreeing on what the product needs. A summariser that must preserve every number, a chatbot that must never invent a policy, and a creative writer that must sound distinctive are three different problems, and a single score will rank them incorrectly. Write down the failure that would actually hurt you â a hallucinated fee, a missed drug interaction, an off-brand tone â then choose measurements that would catch it.
Effective evaluation stacks three layers. Automatic metrics give cheap, repeatable signal on every commit. Model-based judges scale nuance to thousands of examples. Human review anchors both of them, because judges and metrics drift away from real user preference without periodic calibration. Teams that skip the anchor end up optimising a proxy that no longer resembles the thing they care about, and they usually discover it months later, when retention moves in a direction no dashboard predicted.
Reference-based metrics and their blind spots
BLEU and ROUGE were designed for machine translation and summarisation, where a reference text exists. BLEU counts n-gram overlaps between the candidate and one or more references and applies a brevity penalty; ROUGE counts recall-oriented n-gram and longest-common-subsequence overlap. Both are fast, deterministic, and deeply misleading for open-ended generation.
from nltk.translate.bleu_score import corpus_bleu, SmoothingFunction
from rouge_score import rouge_scorer
smoothie = SmoothingFunction().method1
def bleu(references, hypotheses):
"""references: list of lists of token lists (one list per hypothesis)."""
return corpus_bleu(references, hypotheses, smoothing_function=smoothie)
def rouge(reference: str, candidate: str):
scorer = rouge_scorer.RougeScorer(["rouge1", "rouge2", "rougeL"], use_stemmer=True)
return scorer.score(reference, candidate)
refs = [["the cat sat on the mat".split()]]
hyps = [["there is a cat on the mat".split()]]
print("BLEU:", round(bleu(refs, hyps), 4))
print("ROUGE-L:", round(rouge("the cat sat on the mat", "there is a cat on the mat").rougeL.fmeasure, 4))
A paraphrase that a human would rate as excellent can score under 0.4 BLEU because it used different words. Conversely, a response that parrots the reference with minor edits scores well while adding nothing. Use these metrics to detect regressions between two versions of the same system, never as an absolute quality claim.
Semantic similarity scores
BERTScore embeds tokens with a contextual encoder and matches candidate tokens to reference tokens by cosine similarity, which captures paraphrase that n-gram overlap cannot. It correlates much better with human judgement on paraphrastic tasks, at the cost of needing a forward pass through a second model for every example.
from bert_score import score
def bertscore_f1(references, candidates, lang="en"):
precision, recall, f1 = score(candidates, references, lang=lang, verbose=False)
return {
"precision": precision.mean().item(),
"recall": recall.mean().item(),
"f1": f1.mean().item(),
}
references = ["A barge carries containers down the river at dusk."]
candidates = ["Containers move along the river by barge in the evening."]
print(bertscore_f1(references, candidates))
Treat BERTScore as a middle layer: more permissive than n-grams, still blind to factual errors. A sentence claiming the wrong year receives a near-perfect score because almost every token matches contextually.
LLM-as-judge at scale
Pairwise judging is the workhorse of modern evaluation. You show a strong model two responses to the same prompt and ask which is better, which is easier for a model to answer reliably than assigning an absolute score.
import json, openai
JUDGE_PROMPT = """You are grading two assistant replies to one user question.
Score each on: correctness, completeness, and clarity.
Then pick the winner. Reply as JSON:
{{"A": <1-5>, "B": <1-5>, "winner": "A" | "B" | "tie", "reason": "<= 40 words>"}}
Question:
{question}
Reply A:
{answer_a}
Reply B:
{answer_b}"""
def judge(question: str, answer_a: str, answer_b: str, shuffle: bool = True) -> dict:
a, b = (answer_b, answer_a) if shuffle else (answer_a, answer_b)
raw = openai.chat.completions.create(
model="gpt-4o-mini",
response_format={"type": "json_object"},
messages=[{"role": "user",
"content": JUDGE_PROMPT.format(question=question, answer_a=a, answer_b=b)}],
).choices[0].message.content
result = json.loads(raw)
if shuffle: # undo randomised positions
result["winner"] = {"A": "B", "B": "A"}.get(result["winner"], result["winner"])
return result
Position bias is the trap: judges favour whichever answer appears first. Swap the order, run both, and only record a result when the winner is consistent. Verbosity bias is the second: longer answers often win regardless of quality, so instruct the judge to penalise padding.
Benchmarks that mean something
Public benchmarks are useful for comparing model families and almost useless as a proxy for your task.
| Benchmark | Measures | Metric | Watch out for |
|---|---|---|---|
| MMLU | Broad knowledge | accuracy | Contamination, saturation |
| GSM8K | Grade-school maths | exact match | Chain-of-thought sensitivity |
| HumanEval | Code synthesis | pass@k | Small sample, memorisation |
| TruthfulQA | Resistance to myths | % truthful | Style confounds |
| HellaSwag | Commonsense completion | accuracy | Nearly saturated |
| Your own set | Your product | your metric | Requires upkeep |
Check whether a model's training data plausibly includes the test set before citing a number. Contaminated benchmarks produce confident claims that evaporate the moment you evaluate on private data.
Building an evaluation set that predicts production
Start from real traffic. Sample a few hundred prompts covering your common intents, your expensive failures, and your edge cases, then have domain experts write the ideal response or a rubric for one. Keep a frozen holdout that nobody tunes against, and a second set that changes every quarter to reflect new usage.
Three properties matter more than size. Coverage: every intent and failure mode you fear should appear. Independence: prompts must be deduplicated so near-identical questions do not inflate your confidence. Ground truth quality: an ambiguous rubric produces noisy scores that hide real differences. Fifty well-labelled examples beat five thousand scraped ones.
Rubrics that two annotators can agree on
Automated scoring collapses the moment two humans disagree about the right answer, so the rubric deserves the same care as the code. A usable rubric states observable criteria rather than impressions: instead of "good explanation," it names the required elements â the claim, the supporting evidence, the stated limitation, and a structure a reader can scan. Each criterion becomes a question with a fixed scale, so an annotator is answering something concrete instead of rendering an overall verdict.
Attach one positive and one negative example from your own data to every criterion. Examples resolve the edge cases where policy wording is ambiguous, and they align new annotators faster than another paragraph of instructions. Keep the scale short as well: three levels â fails, acceptable, excellent â reliably produce higher agreement than five, and the extra granularity is usually noise that everyone then argues about.
| Criterion | Score 1 | Score 3 | Score 5 |
|---|---|---|---|
| Grounding | Unsupported claims present | Mostly supported | Every claim traceable to a source |
| Completeness | Key question unanswered | Answered at surface level | Answered with necessary nuance |
| Clarity | No structure, dense prose | Readable paragraphs | Scannable structure, precise wording |
Finally, measure agreement itself. Have two annotators independently label twenty examples and compute Cohen's kappa. If agreement sits near 0.4, the rubric is ambiguous and every score derived from it inherits that ambiguity â fix the wording before collecting a thousand labels nobody trusts.
Reading results without fooling yourself
Statistical care is the difference between knowing and guessing. With 100 examples, a two-point accuracy gap is noise; report confidence intervals from bootstrap resampling and refuse to call a winner when they overlap. Always compare against a baseline â the current production model, not zero â and pin the exact prompt, model version, and decoding parameters, because a temperature change can move a score more than a model upgrade does. Finally, watch for reward hacking: when a judge grades on "completeness," models learn to pad answers with caveats and restatements, and the score climbs while users get worse replies.
Common Mistakes
Reporting BLEU as proof that a summariser is good
Fix: Use n-gram metrics only for version-over-version regression, and validate quality with humans or a calibrated judge.
Letting the same model generate and judge without controls
Fix: Randomise answer order, average both positions, and spot-check judge decisions against human labels every few weeks.
Tuning repeatedly against a fixed holdout
Fix: Maintain a sealed test set that is scored once per release, plus a dev set for iteration.
Calling a 1.5 percent difference significant on 80 examples
Fix: Bootstrap confidence intervals; if they overlap, you have not measured a difference.
Best Practices
- Anchor every automatic metric to a human-labeled sample so you know what a point of score is worth in practice.
- Track eval cost per run; a suite that takes an hour will be skipped, and skipped suites catch nothing.
- Log judge rationales alongside scores â they are the fastest way to find rubric wording that models misread.
- Re-run your benchmark suite when you change model, prompt, or decoding settings, not just when you change code.
Interview Questions
Q1: Why can a response score high on BERTScore and still be wrong?
BERTScore measures contextual token overlap, so a sentence with the correct wording but an incorrect date or figure scores near the top; it needs a factual check layered on top.
Q2: What biases affect LLM-as-judge, and how do you control them?
Position bias, verbosity bias, and self-preference. Control them by swapping answer order, instructing the judge to discount padding, and using a model different from the one being evaluated.
Q3: How many examples do you need for a trustworthy evaluation?
Enough that the confidence interval around the difference you care about excludes zero â often 200 to 500 stratified examples for binary outcomes, fewer if the metric is low-variance.
Key Takeaways
- Define the failure you must catch first; the metric follows the product risk, not the other way around.
- BLEU and ROUGE detect regressions but reward parroting; BERTScore handles paraphrase but not factual errors.
- LLM judges scale nuance but need order randomisation, rubric tuning, and periodic human calibration.
- Public benchmarks compare model families; only a held-out set drawn from your traffic predicts production behaviour.
- Report confidence intervals, pin the full evaluation configuration, and keep a sealed set that tuning never touches.