Evaluation Metrics: Perplexity & Similarity
AI Engineer path · lesson 87 of 124Compute cross-entropy and perplexity from a predicted probability, then run four adversarial reference/output pairs through exact match, lexical overlap and embedding similarity and watch the three metrics disagree with each other and with a human.
Key insight
Perplexity 1 means total certainty; perplexity equal to the vocabulary size means the model learned nothing. Everything useful happens in between — and none of it tells you whether the answer was true.
What is this metric measuring?
Sort each metric by what it compares.
Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.
Token overlap with a reference
Drop items hereMeaning, via embeddings
Drop items hereThe model’s own confidence
Drop items hereTest your knowledge
Perplexity is defined as:
The short version
Marking an essay by counting how many of the model answer's words appear in it. It works surprisingly often, fails completely on a good paraphrase, and fails silently — and dangerously — on an answer that says the exact opposite in the same vocabulary.
In more depth
Evaluation Metrics: Perplexity & Similarity
Two families of reference-based metric.
Language-modelling metrics
Useful for pretraining diagnostics, in-distribution detection and contamination hunting. Useless for application quality — a model can be beautifully unsurprised by text that is fluent, confident and wrong. Not comparable across different tokenizers.
Similarity metrics
Choosing
Pick from the shape of the task, not the shape of the output. Classification → exact match. Code → run the tests. Retrieval → Recall@k / nDCG. Open-ended → a calibrated judge. Anything factual → field-level checks, never similarity.
Report more than one, and treat divergence between metrics as the alarm.
Interview Questions
References & Further Reading
Love this visualization?
Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.
100% free • No credit card required