Perplexity
Cover the next word of a sentence and ask a model to guess it. If it narrows the field to two or three plausible words, it has a real grip on the text. If it is hesitating between a thousand, it does not. Perplexity puts a number on that hesitation.
Average surprise, made legible
Perplexity is the exponentiated average negative log-probability a model assigns to each token of a held-out text. The exponentiation is what makes it readable: a perplexity of 30 means the model is as uncertain as someone choosing uniformly among 30 options at every step — an effective branching factor. Lower is better, and the floor is set by how genuinely unpredictable the text is.
The comparison trap
The number is only meaningful under identical conditions, and this is where it is most often misread:
- Change the tokeniser and it changes, because a per-token average is being taken over different units. A word-level and a subword model's scores are not on the same scale.
- Change the test set and it changes. Published figures belong to a specific corpus — WikiText-103, the Penn Treebank — and are never absolute.
- Handling of unknown words shifts it too: a model that dumps rare words into a single unknown token can score well precisely by refusing to model them.
What it does and does not tell you
As an intrinsic measure it is cheap and sensitive — the fastest way to see whether a smoothing scheme helped, or whether a model fits the kind of text you actually have. What it does not measure is usefulness: a model can post a low perplexity and still produce bland, repetitive output, which is why it is reported alongside task scores rather than in place of them.
Perplexity measures how well a language model predicts held-out text: the exponentiated average negative log-probability per token, read as the effective number of equally likely choices the model faces at each step. Lower is better. It is the standard intrinsic evaluation for language models, but comparable only across identical tokenisation and test data, and a low score guarantees nothing about the quality of generated output.
Imagine a friend who finishes your sentences. Sometimes they get the next word instantly; sometimes they have no idea and could blurt out any of a hundred things. Perplexity is a score for that second feeling — how surprised a piece of software is by the words it actually meets.
A low score means the program was rarely caught out, so it has picked up how the language works. A high score means it was guessing wildly. Developers lean on it as a quick health check while building anything that handles text, because it is cheap to calculate and reacts straight away to an improvement. One catch worth knowing: it only tells you the text was predictable to the program, not that anything the program writes is interesting or true.