BLEU calculator

How do you score a translation automatically? BLEU counts how many of its words, pairs of words, triples and quadruples also appear in a human reference translation, and lowers the score if the translation is too short. The paper reports its results in BLEU.

Candidate translation (German)
Reference translation (German)

The English: Anna has a small flower . She draws it .

BLEU = 100.00

nThe candidate's n-grams (matches marked)MatchesPrecision
1 Anna (in the reference)hat (in the reference)eine (in the reference)kleine (in the reference)Blume (in the reference). (in the reference)Sie (in the reference)zeichnet (in the reference)sie (in the reference). (in the reference) 10 / 10 100.0 %
2 Anna hat (in the reference)hat eine (in the reference)eine kleine (in the reference)kleine Blume (in the reference)Blume . (in the reference). Sie (in the reference)Sie zeichnet (in the reference)zeichnet sie (in the reference)sie . (in the reference) 9 / 9 100.0 %
3 Anna hat eine (in the reference)hat eine kleine (in the reference)eine kleine Blume (in the reference)kleine Blume . (in the reference)Blume . Sie (in the reference). Sie zeichnet (in the reference)Sie zeichnet sie (in the reference)zeichnet sie . (in the reference) 8 / 8 100.0 %
4 Anna hat eine kleine (in the reference)hat eine kleine Blume (in the reference)eine kleine Blume . (in the reference)kleine Blume . Sie (in the reference)Blume . Sie zeichnet (in the reference). Sie zeichnet sie (in the reference)Sie zeichnet sie . (in the reference) 7 / 7 100.0 %

Candidate 10 tokens, reference 10: brevity penalty 1.000.

How the score is made

For n = 1 to 4, take every run of n words in the candidate (its n-grams) and count how many also appear in the reference. Each reference n-gram can be matched only as often as it occurs there, so repeating a right word does not help. The share that match is the n-gram precision; matching longer n-grams means the word order is right too.

BLEU multiplies the four precisions and takes the fourth root (their geometric mean), then multiplies by the brevity penalty: 1 if the candidate is longer than the reference, otherwise e^(1 − r/c), with r the reference's length and c the candidate's. Without it, a candidate of one sure word would score perfectly. The result is shown from 0 to 100.

BLEU only counts matching words. A correct translation that uses other words than the reference scores lower, so it is a rough measure, good for comparing systems on thousands of sentences, poor for judging one.

In the paper (6.1)

The paper reports BLEU on the WMT 2014 English–German and English–French test sets (its Table 2). Our model scores 99.95 on its 805 held-out sentences, because our synthetic task is far easier than real news text.

An unhandled error has occurred. Reload ๐Ÿ—™

Reconnecting…

Your connection to the Transformers and Attention Lab dropped, probably a Wi-Fi blip. Hold on while it reconnects.

The connection could not be restored. The page will reload in a few seconds.