1. Clipped n-gram counts
Consider the example from the original BLEU paper (Papineni et al., 2002).
If you count a candidate word as correct whenever it occurs anywhere in a reference, all seven candidate words match. The resulting precision is , despite the translation conveying almost no information.
The problem is that the same reference evidence is reused from the references. The first reference contains two occurrences of
the, and the second contains one. BLEU therefore credits at most two occurrences, not seven and not three. Counts from alternative references are not added together.
Let be the number of occurrences of an n-gram in the candidate, and its count in reference . The clipped count is
The modified precision at order is
where is the set of distinct candidate n-grams. In the repeated-word example, . The denominator counts all candidate occurrences; the numerator counts only those supported by reference evidence.
This resembles precision in classification, because it measures how many proposed occurrences are supported. There is no conventional true-negative count, however, and BLEU does not explicitly compute recall.
Code
Code
2. From words to sequences of words
Unigram precision cannot distinguish sentences containing the same words in different orders. Consider a single reference and two candidates.
Both candidates have perfect unigram precision. Candidate B, however, reverses the roles of the animals.
For candidate B, the bigrams are
the cat, cat chased, chased the, and the dog. Three of these four occur in the reference. Its modified bigram precision is therefore . Neither of its two four-grams occurs in the reference.
Higher-order n-grams provide evidence about local word order and phrasing. They do not, by themselves, establish grammatical correctness or semantic equivalence.
Code
Code
3. The brevity penalty
Suppose the reference isthe dog chased the cat across the garden and the candidate is only the dog chased the. Every candidate n-gram of orders one through four is supported by the reference. All four modified precisions equal one, even though half the translation is missing.
BLEU addresses this failure with a brevity penalty. Let be the candidate length and the effective reference length. Then
For the example, , , and the penalty is . When multiple references exist, BLEU chooses the reference length closest to the candidate length, breaking ties in favor of the shorter reference. At corpus level, these selected lengths are summed.
The brevity penalty is not recall: it penalizes insufficient length but does not check which information was omitted. Overly long candidates receive no separate length penalty; unsupported extra n-grams typically lower modified precision.
Code
Code

4. Combining the components: BLEU-4
You now have two complementary mechanisms: modified precision at several n-gram orders and a penalty for short translations. BLEU combines them as where the weights are nonnegative and sum to one. Terms with zero weight are omitted. Standard BLEU-4 uses and . The geometric mean rewards translations that perform well across all selected orders. For example, if the four precisions are , their arithmetic mean is , whereas their geometric mean is approximately . Poor higher-order agreement has a stronger effect on the geometric mean. If any positively weighted precision is zero, unsmoothed BLEU is zero. This is a design choice, not a mathematical necessity. It is useful for corpus evaluation but can be excessively harsh for individual sentences.5. From sentence-level examples to corpus-level BLEU
The original BLEU metric aggregates clipped counts across sentences before calculating precision. For candidate sentence with its own references, let and be its clipped and total n-gram counts. Then The brevity penalty uses the total candidate length and the sum of effective reference lengths. Consequently, corpus BLEU is not the arithmetic mean of sentence BLEU scores. Longer sentences generally contribute more n-gram occurrences. The following implementation exposes the calculation. It uses fixed-order, unsmoothed BLEU, defining it as zero if a required order has no matching occurrences (including when the corpus has no n-grams of that order).Code
Code
6. Investigating translation errors
The next experiment uses one reference and several candidate translations. Inspect the individual precisions before looking at the combined score. The truncation has excellent precision but incurs a length penalty. The paraphrase may preserve meaning yet have little lexical overlap. The negation changes the meaning while retaining many reference n-grams.Code
Code

7. Sentence-level BLEU and smoothing
Short sentences may have no matching four-grams, even when much of the translation is correct. Smoothing modifies the precision calculation to avoid a zero geometric mean. Different smoothing methods produce different scores; they should not be treated as interchangeable with original unsmoothed corpus BLEU. NLTK exposes several smoothing methods described by Chen and Cherry (Chen & Cherry, 2014). The code below uses method 1, which adds a small constant to the numerator for orders with zero matches (NLTK also guards against zero denominators).Code
Code
8. What BLEU measures in practice
BLEU is useful when comparing machine translation systems on the same test corpus under the same evaluation protocol. Its limitations become particularly visible when evaluating individual outputs. A faithful paraphrase can score poorly, while a translation with a critical factual error can score relatively well. Tokenization, case handling, reference selection, smoothing and effective-order conventions can affect reported results. BLEU is often reported on a scale from 0 to 100, which is the 0 to 1 score multiplied by 100. For reproducible machine translation benchmarks, SacreBLEU provides standardized evaluation and a configuration signature (Post, 2018). Semantic metrics such as COMET (Rei et al., 2020) add complementary evidence, but they do not guarantee correctness.References
- Chen, B., Cherry, C. (2014). A systematic comparison of smoothing techniques for sentence-level BLEU. Proceedings of the Ninth Workshop on Statistical Machine Translation. DOI
- Papineni, K., Roukos, S., Ward, T., Zhu, W. (2002). BLEU: a method for automatic evaluation of machine translation. Proceedings of the 40th Annual Meeting on Association for Computational Linguistics - ACL ‘02. DOI
- Post, M. (2018). A Call for Clarity in Reporting BLEU Scores. Proceedings of the Third Conference on Machine Translation: Research Papers. DOI
- Rei, R., Stewart, C., Farinha, A., Lavie, A. (2020). COMET: A neural framework for MT evaluation. Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP). DOI
Found an error on this page? Report an issue.

