Skip to content

What is Perplexity and Why It Matters

Cover: perplexity

You have probably noticed the mysterious 'perplexity' in model specifications. Let's understand what it is, how to calculate it, and why low perplexity does not necessarily mean 'smart model'.

Perplexity in Simple Terms

Perplexity is a measure of the model's 'surprise' at the text. If the model predicts each next word perfectly, it is hardly surprised — perplexity is low. If the text is like a random word sequence to it — perplexity is high.

An ideal model has a perplexity of 1: it always knows which word comes next.

How It Relates to Language

A language model is simple: it predicts the next token. Perplexity shows how confidently it does this on real text. The better the predictions — the better the model 'understands' the language.

flowchart LR
    A[Text] --> B[Model predicts<br>next token]
    B --> C{Confidence}
    C -->|High| D[Low perplexity]
    C -->|Low| E[High perplexity]

Why It Is Needed

  • Compare models before and after fine-tuning.
  • Monitor training: perplexity should decrease.
  • Evaluate generation quality without data labeling.

Why Perplexity Is Not Everything

Perplexity does not measure 'usefulness'. A model with low perplexity can confidently spout nonsense — the nonsense will just sound smooth. Therefore, it is supplemented with other metrics and live tests.

Where to See

Perplexity is calculated based on cross-entropy — the loss function of language models. The lower the losses, the lower the perplexity.

See Also