Perplexity Evaluation › The Information-Theoretic Foundation
Language AI HandbookAll chapters Perplexity Evaluation › The Information-Theoretic FoundationOne section · Sections in this chapter2 / 12 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Before deriving the perplexity formula, it helps to understand why information theory provides the right language for thinking about language model quality. A language model assigns probabilities to sequences, and we want to know how well those probabilities match reality. This is precisely the question that information theory was designed to answer.
Entropy and the Limits of Compression
Claude Shannon's foundational insight, published in 1948, was that information can be quantified. The more surprising an event is, the more information it carries. If someone tells you that the sun rose this morning, they convey almost no information because you already knew that with near certainty. If they tell you it snowed in July in Phoenix, they convey a great deal of information because that event was unlikely.
Shannon formalized this intuition with the concept of entropy. For a discrete random variable with probability distribution , entropy measures the average information content per sample:
where:
- : the entropy of the distribution , measured in bits (base-2 log) or nats (natural log)
- : a possible outcome of the random variable
- : the probability of outcome
- : the information content (surprise) of observing outcome
Entropy is maximized when all outcomes are equally likely (maximum uncertainty) and minimized when one outcome is certain (no uncertainty). For a fair six-sided die, entropy is bits. For a biased coin that lands heads 99% of the time, entropy is close to zero.
Shannon also showed that entropy has a direct operational meaning: it is the minimum average number of binary questions needed to identify an outcome, or equivalently, the minimum number of bits needed to encode samples from the distribution. This compression interpretation is why perplexity has a natural meaning in terms of prediction difficulty.
Cross-Entropy: When Model and Reality Differ
In practice, we do not know the true distribution of language . We have a model (our language model) that approximates . Cross-entropy measures the cost of encoding samples from using a code optimized for :
where:
- : the cross-entropy between true distribution and model distribution
- : the true probability of outcome under the actual data distribution
- : the probability assigned to by our model
- : the code length assigned to by our model
Cross-entropy is always at least as large as entropy: , with equality only when . The gap between them is the Kullback-Leibler (KL) divergence, which measures how much additional information we waste by using the wrong distribution. Language model training minimizes cross-entropy precisely because minimizing cross-entropy is equivalent to maximizing the likelihood of the training data under the model.
In language modeling, we observe a sequence of tokens drawn from the true distribution . Our model assigns probabilities to these tokens. The empirical cross-entropy of the sequence under our model is:
where:
- : the total number of tokens in the evaluation sequence
- : the -th token in the sequence
- : the probability our model assigns to given the preceding context
The normalization converts total log-likelihood into a per-token average, making the metric independent of sequence length. Without this normalization, longer sequences would always have lower total likelihood simply because we multiply more probabilities together.
Shannon estimated the entropy of English text at approximately 1.0 to 1.5 bits per character, based on experiments where subjects predicted the next character of English text. This means a perfect language model for English would have a character-level perplexity of roughly to , corresponding to 2 to 3 equally likely character choices at each step.
Modern neural language models achieve bits per character (BPC) values of around 0.9 to 1.1 on standard English benchmarks, meaning they approach but do not quite reach the theoretical entropy of English. The gap represents inherent unpredictability in human language: word choice that depends on writer intent, style, and context outside the observed window.
This theoretical bound provides important context when interpreting perplexity scores. A character-level language model with perplexity 3 is not poor; it is close to the theoretical minimum. A word-level model with perplexity 100 might similarly be close to the theoretical floor for word-level prediction given typical vocabulary sizes.
The KL Divergence Perspective
Training language models by minimizing cross-entropy is equivalent to minimizing the KL divergence from the model distribution to the true data distribution. The KL divergence is:
where:
- : the KL divergence from model to true distribution
- : the cross-entropy between and
- : the entropy of the true distribution
Since is a constant determined by the true data distribution and not by our model, minimizing cross-entropy and minimizing KL divergence are equivalent from an optimization perspective. When we report perplexity, we are indirectly reporting how close our model distribution is to the true data distribution, as measured by KL divergence plus the irreducible entropy of natural language.
This perspective clarifies what perplexity improvement means in practice. Each bit of improvement in cross-entropy corresponds to halving the perplexity (since in bits). Moving from perplexity 100 to perplexity 50 means the model has reduced its average uncertainty by one bit per token, which in turn means it has approximately doubled its confidence in the most likely token at each step.