ladderlore
Request a guide
  • Type a service name, like S3 or IAM.

Concept · Builds on AIF-C01

NLP and text-generation metrics

BLEU, ROUGE, BERTScore, semantic similarity and perplexity: what each compares and which need a reference text.

You know from AI Practitioner

  • ROUGE fits summaries, BLEU fits translation and BERTScore compares meaning.
  • Perplexity needs no reference text, and lower is better.
Read the AI Practitioner lesson
  • BLEU

    It counts
    Output n-grams found in reference
    Fits
    Translation
    Reference?
    Needed
  • ROUGE-N

    It counts
    Reference n-grams found in output
    Fits
    Summaries
    Reference?
    Needed
  • ROUGE-L

    It counts
    Longest shared word sequence
    Fits
    Summaries
    Reference?
    Needed
  • BERTScore

    It counts
    Token embedding similarity
    Fits
    Any text, paraphrase
    Reference?
    Needed
  • Semantic similarity

    It counts
    Whole-text embedding similarity
    Fits
    Any text, paraphrase
    Reference?
    Needed
  • Perplexity

    It counts
    How well the model predicts text
    Fits
    Comparing language models
    Reference?
    Not needed
Which metric fits, and whether it needs a reference.

1 / 3

  • BLEU

    It counts
    Output n-grams found in reference
    Fits
    Translation
    Reference?
    Needed
  • ROUGE-N

    It counts
    Reference n-grams found in output
    Fits
    Summaries
    Reference?
    Needed

2 / 3

  • ROUGE-L

    It counts
    Longest shared word sequence
    Fits
    Summaries
    Reference?
    Needed
  • BERTScore

    It counts
    Token embedding similarity
    Fits
    Any text, paraphrase
    Reference?
    Needed

3 / 3

  • Semantic similarity

    It counts
    Whole-text embedding similarity
    Fits
    Any text, paraphrase
    Reference?
    Needed
  • Perplexity

    It counts
    How well the model predicts text
    Fits
    Comparing language models
    Reference?
    Not needed
Which metric fits, and whether it needs a reference.
Model output
Embedding model
Cosine similarity
Reference text
  1. 1Embed the model output.
  2. 2Embed the reference text.
  3. 3Compare the two vectors. Close to 1 means similar meaning.
Semantic similarity embeds both texts and compares the vectors.

What it is

Most text metrics need a reference: a text a person wrote, which the output is compared with. Perplexity is the exception. None of these metrics judges facts, tone or helpfulness. Use a judge model or people for that.

What it is

BLEU is precision-oriented. It counts how many n-grams (groups of 1 to 4 words) of the output also appear in the reference, with a brevity penalty for short outputs. It was made for translation. ROUGE is recall-oriented: how much of the reference shows up in the output. ROUGE-N counts overlapping n-grams (ROUGE-1 single words, ROUGE-2 word pairs). ROUGE-L uses the longest common subsequence, so it rewards the same words in the same order. ROUGE was made for summaries.

What it is

Both reward matching words, so a good paraphrase scores low. BERTScore avoids that: it embeds each token with a BERT model, matches output and reference tokens by cosine similarity, and reports precision, recall and F1. Bedrock automatic evaluation uses BERTScore as the accuracy metric for summarization. Semantic similarity embeds the whole output and reference and takes the cosine similarity: near 1 means near in meaning. It is cheap and handles paraphrase, but can score high when one number or a “not” has changed.

What it is

Perplexity measures how surprised a language model is by a text: lower means it predicts the text better. It needs no reference and compares language models on the same text, but says nothing about whether an answer is right.

Remember

  • BLEU: n-gram precision plus brevity penalty. ROUGE-N: n-gram recall. ROUGE-L: longest common subsequence.
  • BERTScore and semantic similarity credit paraphrase.
  • Reference needed: all except perplexity.

On the exam

  • “Score a machine translation against human translations” points to BLEU.
  • “Compare a summary with a reference and respect word order” points to ROUGE-L.
  • “A paraphrase should still score well” points to BERTScore or semantic similarity.
  • “Evaluate a language model with no reference answers” points to perplexity.