Sub topic 12
Measuring Quality with ROUGE, BLEU and chrF
This chapter assumes that you know basic Python, tokenisation, and how an encoder-decoder model generates text. It also assumes that you have a prediction and one or more reference texts for each example.
A generated text cannot be judged only by whether it looks fluent. A summary should preserve important information. A translation should express the source meaning in the target language. Evaluation metrics provide repeatable measurements for comparing models, decoding settings, or fine-tuning runs.
The three metrics
ROUGE, BLEU, and chrF compare generated text with human-written reference text. They measure overlap, not complete meaning.
| Metric | Main unit | Common use | Strength |
|---|---|---|---|
| ROUGE | Words and word sequences | Summarisation | Measures recall of reference content |
| BLEU | Word or subword sequences | Translation | Measures matching translated phrases |
| chrF | Character n-grams | Translation | Handles word forms and rare words better |
A reference is the expected output written by a human. A prediction is the text produced by your model. If several references are available, they can represent valid alternative wordings.
ROUGE for summarisation
ROUGE means Recall-Oriented Understudy for Gisting Evaluation. ROUGE-1 compares individual words, and ROUGE-2 compares pairs of consecutive words. ROUGE-L uses the longest common subsequence, which captures a shared word order without requiring an exact continuous phrase.
ROUGE commonly reports precision, recall, and F-measure. Recall asks how much of the reference appears in the prediction. Precision asks how much of the prediction also appears in the reference. The F-measure combines them.
A summary can receive a high ROUGE score by copying many reference words while still being unclear. Conversely, a good paraphrase can receive a low score because it uses different words.
BLEU for translation
BLEU, or Bilingual Evaluation Understudy, counts matching n-grams between a prediction and its references. It uses a brevity penalty so that a very short prediction does not score well merely by matching a few words.
BLEU is usually reported as a score from 0 to 100 by the SacreBLEU implementation. Compare scores only when the tokenisation, dataset, and evaluation settings are consistent. A BLEU score from one language pair is not directly comparable with a score from another.
BLEU rewards exact phrases. It may penalise a grammatically correct translation that uses a valid synonym or a different word order.
chrF for translation
chrF compares character n-grams instead of complete words. It combines character-level precision and recall. Because it works inside words, chrF often handles inflections, spelling variations, and unknown or rare terms more gracefully than word-based BLEU.
chrF still measures surface similarity. A fluent translation with different wording can receive a lower score, and a sentence with copied character patterns can receive a misleadingly high score.
Computing the metrics
The evaluate library provides standard implementations. SacreBLEU expects references as a list of lists: the inner list contains all valid references for one prediction.
import evaluate
predictions = [
"The council approved 40 km of new bike lanes."
]
references = [
"The city council approved 40 kilometres of new bike lanes."
]
rouge = evaluate.load("rouge")
rouge_scores = rouge.compute(
predictions=predictions,
references=references,
use_stemmer=True,
)
print("ROUGE:", rouge_scores)
translation_predictions = [
"Das Haus ist wunderbar."
]
translation_references = [
["Das Haus ist wunderbar."]
]
bleu = evaluate.load("sacrebleu")
bleu_score = bleu.compute(
predictions=translation_predictions,
references=translation_references,
)
print("BLEU:", bleu_score["score"])
chrf = evaluate.load("chrf")
chrf_score = chrf.compute(
predictions=translation_predictions,
references=translation_references,
)
print("chrF:", chrf_score["score"])The use_stemmer option lets ROUGE treat related English word forms, such as “connect” and “connected”, as closer matches. Apply preprocessing consistently to predictions and references. Do not remove punctuation from only one side.
Interpreting scores and limits
Use metrics mainly to compare systems on the same test set. Keep a fixed test set that was not used for fine-tuning. Report the metric name, library, preprocessing, language pair, and number of references.
A single score hides important errors. A summary may have strong word overlap but invent a number. A translation may score well overall while mistranslating a person’s name or a technical term. Inspect examples, especially low-scoring and high-scoring outputs. For summarisation, also check factual consistency. For translation, ask a fluent speaker to assess meaning and grammar when the result matters.
Exercise
A translation has a lower BLEU score but a higher chrF score than another translation. What might this indicate?
Show answer
It may use different word forms or partial matches that BLEU misses. Inspect both translations because neither score alone proves that the translation is better.