induwara.lk
induwara.lkAI · Text Metrics

GLEU Score Calculator (Google-BLEU)

Paste a reference and a model hypothesis to get the GLEU score — the minimum of n-gram recall and precision from the GNMT paper (Wu et al. 2016). See the precision, the recall, and every counted n-gram, so the number is auditable. Matches NLTK, no signup, runs in your browser.

By Induwara AshinsanaUpdated Jul 10, 2026
GLEU Score
The correct sentence. Stays on your device.0 words
The output being scored. Stays on your device.0 words
Max n-gram (N)
Examples
GLEU (N=4)
Rating
Precision
Recall

Runs entirely in your browser — your text is never uploaded, logged, or stored. Method: multiset n-gram intersection with clipping, then GLEU = min(recall, precision), per Wu et al. (2016). Up to 50,000 characters per box.

How it works

GLEU — Google-BLEU — is a sentence-level metric for machine translation and grammatical error correction. It was defined by Wu et al. (2016) for Google's Neural Machine Translation system, where corpus-level BLEU was a poor per-sentence reward. GLEU compares a model's output (the hypothesis) with a correct reference and rewards shared n-grams from both directions at once. The definition is:

GLEU = min( recall, precision )

where recall and precision are built from the same matching-n-gram count. The steps are:

  1. Tokenise.The reference and hypothesis are optionally lowercased and split on whitespace. By default, leading and trailing punctuation is split into its own token so that “end.” becomes two tokens.
  2. Record n-grams. For every order n from 1 to N (N = 4 in the GNMT paper), list the multiset of n-grams in the reference and in the hypothesis.
  3. Count matches with clipping. The matching count M is the size of the multiset intersection — M = Σ min(count_hyp(g), count_ref(g)) over every n-gram g and every order. Clipping stops a repeated correct word from being credited more times than it truly appears.
  4. Divide and take the minimum. With total_R reference n-grams and total_H hypothesis n-grams, recall = M / total_R and precision = M / total_H. GLEU is the smaller of the two.

Unlike BLEU, GLEU applies no brevity penalty. It does not need one: a hypothesis that is too short misses reference n-grams and loses recall, while one that over-generates inflates total_H and loses precision. The final min()is bound by whichever failure is worse, which is exactly why GLEU is stable on single sentences where BLEU's geometric mean can collapse to zero. Orders longer than a sentence simply contribute zero n-grams on that side, so short inputs stay division-safe. This tool re-counts the intersection from both the hypothesis and the reference side and confirms the two agree, and it reconciles with NLTK's sentence_gleu for a single reference under matching tokenisation.

Worked examples

Recall-bound → 61.11

Reference
the cat is on the mat
Hypothesis
the cat is on mat
  1. Reference n-grams total: 6 + 5 + 4 + 3 = 18
  2. Hypothesis n-grams total: 5 + 4 + 3 + 2 = 14
  3. Matches: 1-grams 5, 2-grams 3, 3-grams 2, 4-grams 1 → M = 11
  4. precision = 11/14 = 0.7857
  5. recall = 11/18 = 0.6111
  6. GLEU = min(0.6111, 0.7857) = 0.6111 → 61.11 / 100 (recall-bound)

Precision-bound → 28.57

Reference
she reads books
Hypothesis
she reads many good books
  1. Reference n-grams total: 3 + 2 + 1 + 0 = 6
  2. Hypothesis n-grams total: 5 + 4 + 3 + 2 = 14
  3. Matches: 1-grams 3 (she, reads, books), 2-grams 1 (she reads) → M = 4
  4. precision = 4/14 = 0.2857
  5. recall = 4/6 = 0.6667
  6. GLEU = min(0.6667, 0.2857) = 0.2857 → 28.57 / 100 (precision-bound)

Clipping / over-repetition → 16.67

Reference
the cat
Hypothesis
the the the
  1. Reference n-grams total: 2 + 1 = 3
  2. Hypothesis n-grams total: 3 + 2 + 1 = 6
  3. 'the' is clipped from 3 to min(3, 1) = 1; 'cat' and 'the the' unmatched
  4. M = 1
  5. recall = 1/3 = 0.3333, precision = 1/6 = 0.1667
  6. GLEU = min = 0.1667 → 16.67 / 100 — clipping stops the repeat gaming the score

Frequently asked questions

Sources & references

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.