LLM & Generation Evaluation
P5.evaluation.03 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Embedding Evaluation
Where next?
This module unlocks
Go up a level
P5.evaluation.03 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Embedding Evaluation
This module unlocks
Go up a level
Everything measured so far in this track had a ground truth to lean on — a correct label, a reference sentence. A large language model breaks that comfort: a good summary or answer can be phrased a thousand different ways, so counting matching words against one reference punishes correct output, and evaluation itself becomes a modelling problem. In this module you meet the modern answers in turn — scoring generated text by meaning rather than by surface overlap, the big public benchmark suites and the test-set contamination that quietly inflates their scores, using one model to judge another and the biases that come with it, and finally human annotation, whose own reliability must itself be measured. The classical metrics are assumed known from the first module of this track, which this module closes.
Why it matters to you. A reviser or a language-services manager who scores translations against a checklist (accuracy, fluency, terminology) is doing human evaluation. Using a language model as the judge means checking it against that same checklist first.
Worked example. Suppose a reviser and an LLM judge each mark the same 20 translated segments pass or fail for fluency. Each passes 19 of the 20, and they disagree on 2 segments, so they agree on 18 of 20. That sounds strong, but when nearly everything passes, two markers who never read the text would agree about as often: the agreement expected by chance is 0.95 × 0.95 + 0.05 × 0.05 = 0.905, above the 0.90 they reached. Corrected for chance, their agreement is (0.90 − 0.905) / (1 − 0.905) ≈ −0.05: no better than chance. Indeed, the one segment the reviser failed, the judge passed. That correction is Cohen's kappa, which this module's human-evaluation step computes. 20 segments is also very few: compare the judge with a reviser on a hundred or more before you let it sort work.
BLEU and ROUGE measure surface overlap — matching tokens between hypothesis and reference. For abstractive summarisation, paraphrase, and free-form generation, a correct output may share zero tokens with the reference and still score 0.
The paraphrase problem:
| Hypothesis | Reference | BLEU-1 | Semantic equivalence | BLEU correct? |
|---|---|---|---|---|
| The cat sat on the mat. | A feline rested upon the rug. | 0.000 | ✓ same meaning | ✗ No |
| A feline rested upon the rug. | A feline rested upon the rug. | 1.000 | ✓ same meaning | ✓ Yes |
| The cat sat on the mat. | The cat sat on the mat. | 1.000 | ✓ same meaning | ✓ Yes |
Row 1: the hypothesis is a perfect paraphrase of the reference but BLEU-1 = 0 because no tokens match. BLEU cannot distinguish a wrong answer from a correct paraphrase.
BERTScore (Zhang et al. 2020) replaces exact token matching with contextual embedding similarity — the contextual vectors come from a pretrained BERT-style encoder, the machinery built up in the P10 Transformers pillar:
Key property: 'cat' and 'feline' have high cosine similarity in BERT space, so a paraphrase scores near 1.0 even with no token overlap.
Worked BERTScore example. Hypothesis: 'a canine ran fast'; reference: 'a dog sprinted'. Suppose a BERT model produces the following pairwise cosine similarities (rows = hypothesis tokens, columns = reference tokens):
| a | dog | sprinted | |
|---|---|---|---|
| a | 1.00 | 0.40 | 0.30 |
| canine | 0.40 | 0.92 | 0.55 |
| ran | 0.30 | 0.45 | 0.88 |
| fast | 0.25 | 0.35 | 0.72 |
Precision (row max, then mean): a → 1.00, canine → 0.92, ran → 0.88, fast → 0.72, so P = 0.8800. Recall (column max, then mean): a → 1.00, dog → 0.92, sprinted → 0.88, so R = 0.9333.
P (BERT)
0.8800
R (BERT)
0.9333
F1 (BERT)
0.9059
BERTScore F1 = 2 × 0.8800 × 0.9333 / (0.8800 + 0.9333) = 0.9059. Compare to BLEU-1: only 'a' matches, so BLEU-1 ≈ 0.25 × BP, well below 0.25. BERTScore captures that 'canine'/'dog' and 'ran'/'sprinted' are semantically equivalent.
Other embedding-based metrics:
The papers and benchmarks this module draws on.
| Type | Resource |
|---|---|
| Paper | Zhang et al. 2020 — BERTScore: Evaluating Text Generation with BERT; see also MoverScore (Zhao et al. 2019), BLEURT (Sellam et al. 2020), COMET (Rei et al. 2020) |
| Paper | Hendrycks et al. 2020 — Measuring Massive Multitask Language Understanding (MMLU) |
| Paper | Liang et al. 2022 — Holistic Evaluation of Language Models (HELM); Srivastava et al. 2022 — BIG-Bench; Suzgun et al. 2022 — BIG-Bench Hard |
| In-app | P10 — the Transformers pillar, for the contextual embeddings BERTScore is built on (attention, encoder blocks, Sentence Embeddings) |
| In-app | P13 — Production ML & MLOps, for evaluation infrastructure: harnesses, regression suites, and eval-in-CI |
Practise this lesson's 8 self-checks
One per screen: you reveal each answer and mark it yourself. Nothing is recorded.
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
Off by default. The mentor always gets your file; this only decides whether your own copy stays here. Copies live in this browser only - they do not follow you to another device, and clearing site data removes them.
A scratch console for this page's ideas — ungraded, nothing you run here is recorded.
Scratch console
A scratch console with the scientific stack (pandas, numpy, scikit-learn). Runs on the server — no network, resource-limited and measured.
Output appears here.
Loading your notes...