Perplexity measures how much probability a model assigns to observed outcomes, expressed as the inverse geometric mean of those probabilities. For a sequence evaluated by a neural language model, let be the model's conditional probability of the actually observed token given its allowed context. Then
It is therefore exponentiated mean negative log-likelihood. If cross-entropy is expressed in bits rather than natural-log units, the equivalent expression is .[ref]
A uniform predictor over possible tokens assigns each observed token probability , giving perplexity . For an unequal two-token example with assigned probabilities and ,
The result need not be an integer or an actual vocabulary size. It is an effective branching measure defined by the likelihood calculation.
On a fixed evaluation representation and dataset, lower perplexity means higher geometric mean probability for the realized outcomes. Assigning zero probability to any realized outcome makes the unsmoothed sequence perplexity infinite. Correctness of the most probable token alone does not determine the metric: the probabilities assigned to all realized outcomes matter.
For an empirical example, the 2003 neural-language-model paper reports test perplexity for its MLP1 row, compared with for the five-gram back-off comparison row. These are measurements under the paper's Brown-corpus setup and token-counting conventions.[ref]
Changing tokenization, vocabulary, punctuation or sentence-boundary treatment changes the outcomes and the divisor . Per-word and per-subword scores therefore cannot be compared as if they measured the same event space. Perplexity is also distinct from BLEU, which compares generated text with references rather than directly averaging the probability of observed tokens.

Articles by others on the same topic (1)

Perplexity is a measurement used in various fields, particularly in information theory and natural language processing, to quantify uncertainty or complexity. In the context of language models, perplexity is often used as a metric to evaluate how well a probability model predicts a sample.