Module 5 · Evaluation & deployment
Public benchmarks and domain evaluations
8 min read
A fine-tuned model is evaluated along two axes: the task it was trained for, and everything else — what it could do before and must not have forgotten. Public benchmarks mainly serve the second axis; domain evaluations, the first. This lesson presents both, and an often neglected tool: statistical uncertainty, without which you mistake noise for progress.
Public benchmarks
| Benchmark | What it measures | Format |
|---|---|---|
| MMLU, MMLU-Pro | General knowledge, 57 domains (harder for the Pro version) | Multiple choice |
| GSM8K, MATH | Mathematical reasoning | Verifiable numerical answer |
| IFEval | Following verifiable instructions ("in under 100 words", "without commas") | Programmatic check |
| HumanEval, MBPP | Code generation | Unit tests |
| ARC, HellaSwag | Commonsense reasoning | Multiple choice |
| MT-Bench, Arena-Hard | Conversational quality | Judged by an LLM |
The reference tool to run them is lm-evaluation-harness (EleutherAI). It accepts a merged model or a base model with its adapter:
lm_eval --model hf --model_args pretrained=Qwen/Qwen2.5-0.5B-Instruct,peft=runs/sft-lora \
--tasks ifeval,mmlu --batch_size 8
Three limitations to keep in mind:
- Contamination: public benchmarks have circulated on the web for years, and recent models have often seen fragments of them. A high score does not prove a skill (lesson 2.4).
- Saturation: the best models reach the ceiling of the oldest benchmarks; they no longer distinguish anything.
- The mismatch with your task: a two-point gain on MMLU says nothing about triaging Nimbus's tickets.
For a fine-tuned model, public benchmarks mainly serve as a safeguard: checking that they do not drop after training.
A homemade smoke test
Before running full benchmarks (long), a quick test detects gross damage. Forge asks twenty general questions, without the task's system prompt, and checks the answers with keywords:
def general_score(model, tokenizer) -> tuple[float, float, list[str]]:
"""(part de bonnes réponses, part de réponses au format JSON, réponses)."""
messages = [[{"role": "user", "content": q}] for q, _ in QUESTIONS]
outputs, _ = infer.generate(model, tokenizer, messages, max_new_tokens=60)
correct = sum(bool(re.search(p, o, re.I)) for (_, p), o in zip(QUESTIONS, outputs))
as_json = sum(o.strip().startswith("{") for o in outputs)
return correct / len(QUESTIONS), as_json / len(QUESTIONS), outputs
Results on Forge:
| Model | Correct answers (out of 20) | Answers in JSON |
|---|---|---|
| Base Qwen2.5-0.5B-Instruct | 0.60 | 0.00 |
| Triage LoRA | 0.55 | 0.00 |
| Triage full fine-tuning (1 epoch) | 0.70 | 0.00 |
| Replies DPO | 0.60 | 0.00 |
No fine-tuned model started answering "What is the capital of Italy?" in JSON: without the triage system prompt, they answer normally ("La capitale de l'Italie est Rome."). The gaps in correct answers — one or two questions out of twenty — are not significant: on 20 questions, the uncertainty exceeds ± 20 points. This test detects a catastrophe, not a nuance; to measure a fine degradation you need hundreds of questions, that is, a benchmark.
The domain evaluation
It was built throughout the course: a frozen test set, split by template (lesson 2.4), a strict parser and per-field metrics (lesson 1.4), success criteria set in advance. Two additions make it reliable: uncertainty and paired comparison.
What is a three-point gap worth?
A score measured on 300 examples is an estimate. The Wilson confidence interval gives its precision:
def wilson_interval(successes: int, n: int, z: float = 1.96) -> tuple[float, float]:
"""Intervalle de confiance à 95 % d'une proportion (Wilson) : la précision d'une mesure."""
if n == 0:
return 0.0, 0.0
p = successes / n
center = (p + z * z / (2 * n)) / (1 + z * z / n)
half = z * math.sqrt(p * (1 - p) / n + z * z / (4 * n * n)) / (1 + z * z / n)
return center - half, center + half
For 195 exact out of 300 (65%), the interval runs from 59% to 70%: ± 5 points. Two models at 65% and 67% are indistinguishable on this set. To measure a two-point gap with confidence, you would need several thousand examples.
Paired comparison
When two models are evaluated on the same examples, you can do better than comparing two intervals: look only at the examples where they disagree. McNemar's test counts the examples right for A only and for B only; if the second number clearly exceeds the first, B is better.
def mcnemar(a: Report, b: Report) -> tuple[int, int, float]:
"""Comparaison APPARIÉE de deux modèles sur les mêmes exemples : seuls comptent les désaccords.
Renvoie (justes pour A seul, justes pour B seul, p-valeur exacte bilatérale)."""
only_a = sum(x and not y for x, y in zip(a.flags, b.flags))
only_b = sum(y and not x for x, y in zip(a.flags, b.flags))
n, k = only_a + only_b, min(only_a, only_b)
p = sum(math.comb(n, i) for i in range(k + 1)) / 2**n * 2 if n else 1.0
return only_a, only_b, min(1.0, p)
examples/12_compare_runs.py compares module 3's runs with the LoRA reference, on the same 300 messages:
| Run | Exact match | 95% CI | Right for the reference only / for this run only | p |
|---|---|---|---|---|
| LoRA (reference, seed 42) | 0.65 | [0.59; 0.70] | — | — |
| LoRA, seed 1 | 0.65 | [0.59; 0.70] | 25 / 25 | 1.000 |
| LoRA, seed 2 | 0.74 | [0.69; 0.79] | 6 / 34 | < 0.001 |
| QLoRA | 0.53 | [0.47; 0.59] | 49 / 13 | < 0.001 |
| DoRA | 0.61 | [0.55; 0.66] | 20 / 8 | 0.036 |
| Full fine-tuning, 1 epoch | 0.67 | [0.61; 0.72] | 26 / 32 | 0.512 |
| LoRA, rate 1e-3 | 0.42 | [0.37; 0.48] | 68 / 0 | < 0.001 |
The paired test settles cases the intervals left open: full fine-tuning (0.67) is not distinguishable from LoRA (p = 0.51); QLoRA, on the other hand, is clearly below (49 examples lost versus 13 gained).
But the "seed 2" row brings the most important lesson: two training runs identical except for the seed differ in a highly "significant" way (p < 0.001). McNemar's test answers the question "do these two models behave differently on this set?" — yes, they do. It does not answer "is this method better?", because it ignores the variance of training itself. To conclude about a method, you need several seeds on each side, and you compare the distributions of scores. On Forge, the DoRA/LoRA gap (0.61 versus 0.65) stays within the spread between LoRA seeds (0.65 to 0.74): no conclusion is possible.
A candidate model's dashboard
| Axis | Measure | Decision |
|---|---|---|
| Task | Exact match on the frozen test set, with confidence interval | Success criterion met? |
| Critical subpopulations | Exact match on serious cases (high urgency) | No regression on what is costly |
| Comparison | McNemar against the model in production | Is the new model significantly better? |
| General capabilities | Smoke test, then public benchmarks | No unacceptable forgetting |
| Safety | Red-teaming (lesson 5.2) | No regression |
| Cost | Latency, memory (lesson 5.4) | Compatible with the budget |
Key takeaways
- Public benchmarks (lm-evaluation-harness): mainly a safeguard against forgetting, with the limits of contamination and saturation.
- A twenty-question smoke test detects an over-specialized model in one minute.
- On 300 examples, a score is precise to ± 5 points: two models at 65% and 67% are indistinguishable.
- Compare two models on the same examples with a paired test (McNemar) — and remember it compares models, not methods: seeds matter.
- Decide with a dashboard: task, critical cases, comparison, general capabilities, safety, cost.
Practice
- Run
examples/11_general_regression.pyon your adapters: does any of them answer general questions in JSON? - Run
examples/12_compare_runs.pyon two runs that differ only by the seed: is the gap significant? - Compute how many test examples would be needed to tell 65% from 70% with a ± 2-point interval.