LLM Evaluation Metrics (BLEU, ROUGE, Perplexity)
Part of the AI Engineer Roadmap
In short
You changed the prompt. Is the output better or just different? Automatic metrics give you a quick number, as long as you know what each one can and can't see.
Automated metrics for scoring generated text against references — useful as a fast signal but each has real blind spots that make purely automated evaluation insufficient alone.

Think of it like this
The keyword-counting examiner
Some examiners check answers by ticking keywords from the model answer. Write 'mitochondria' and 'energy' and you get marks, even if your sentence is nonsense. BLEU and ROUGE grade like this examiner: they count matching words, not meaning.
Watch it happen
Counting word overlap with a reference
1/4Reference: 'The train to Pune leaves at 6 pm'. We check which words of the model's output also appear in it.
The big ideas
What you need to know
BLEU: precision of n-grams
How many of the output's word chunks appear in the reference. Built for machine translation.
ROUGE: recall of n-grams
How much of the reference shows up in the output. ROUGE-L uses the longest common word sequence. Built for summaries.
Perplexity: how surprised
How well a model predicts real text, from its own token probabilities. Lower is better. It says nothing about helpfulness.
Numbers aren't meaning
A correct answer in new words scores low. A wrong answer with the right words scores high. Use these as quick signals only.
See it in code
Walk through the code
1import sacrebleu2from rouge_score import rouge_scorer3 4ref = "The train to Pune leaves at 6 pm from platform 3."5hyp = "The Pune train departs at 6 pm from platform 3."6 7bleu = sacrebleu.sentence_bleu(hyp, [ref])8print("BLEU:", round(bleu.score, 1))9 10scorer = rouge_scorer.RougeScorer(["rouge1", "rougeL"], use_stemmer=True)11scores = scorer.score(ref, hyp)12print("ROUGE-1 F1:", round(scores["rouge1"].fmeasure, 3))13print("ROUGE-L F1:", round(scores["rougeL"].fmeasure, 3))1/4A reference answer and the model's answer. Same meaning, different words.
BLEU with sacrebleu and ROUGE with rouge-score. Both need a human-written reference answer to compare against.
Save yourself the pain
Common mistakes
Oops
Using BLEU to judge a chatbot's open-ended answers.
Do this instead
Many good answers exist for an open question. Use rubric scoring, LLM judges or human review instead.
Oops
Comparing perplexity across models with different tokenizers.
Do this instead
Perplexity depends on the tokenizer. Only compare models that split text the same way, on the same data.
Your mission
Break the metrics
Quick check
A summary is factually wrong but copies many phrases from the reference. What will ROUGE likely show?
Go deeper
- 1Compute BLEU/ROUGE scores for a small set of generated outputs against references.
- 2Learn what each metric actually measures (n-gram overlap) and what it misses (meaning, fluency).
- 3Understand why perplexity measures a model's confidence, not correctness.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.