Perplexity Evaluation › The Information-Theoretic Foundation

Michael BrenndoerferFebruary 20, 20265 min read
Language AI HandbookAll chapters
Part 53 of 67Evaluation Fundamentals
Chapter 405Perplexity Evaluation › The Information-Theoretic Foundation
Reading section 2 of 12 · The Information-Theoretic Foundation · 5 minSection 2 of 12 · 5 min

Book contents

Section 2 of 12 · 5 min read

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 XX with probability distribution PP, entropy measures the average information content per sample:

H(X)=−∑xP(x)log⁡P(x)H(X) = -\sum_{x} P(x) \log P(x)

where:

  • H(X)H(X): the entropy of the distribution PP, measured in bits (base-2 log) or nats (natural log)
  • xx: a possible outcome of the random variable XX
  • P(x)P(x): the probability of outcome xx
  • −log⁡P(x)-\log P(x): the information content (surprise) of observing outcome xx

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 log⁡26≈2.58\log_2 6 \approx 2.58 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 PP. We have a model QQ (our language model) that approximates PP. Cross-entropy measures the cost of encoding samples from PP using a code optimized for QQ:

H(P,Q)=−∑xP(x)log⁡Q(x)H(P, Q) = -\sum_{x} P(x) \log Q(x)

where:

  • H(P,Q)H(P, Q): the cross-entropy between true distribution PP and model distribution QQ
  • P(x)P(x): the true probability of outcome xx under the actual data distribution
  • Q(x)Q(x): the probability assigned to xx by our model
  • −log⁡Q(x)-\log Q(x): the code length assigned to xx by our model

Cross-entropy is always at least as large as entropy: H(P,Q)≥H(P)H(P, Q) \geq H(P), with equality only when Q=PQ = P. 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 w1,w2,…,wNw_1, w_2, \ldots, w_N drawn from the true distribution PP. Our model QQ assigns probabilities to these tokens. The empirical cross-entropy of the sequence under our model is:

H(P,Q)=−1N∑i=1Nlog⁡Q(wi∣w1,…,wi−1)H(P, Q) = -\frac{1}{N} \sum_{i=1}^{N} \log Q(w_i | w_1, \ldots, w_{i-1})

where:

  • NN: the total number of tokens in the evaluation sequence
  • wiw_i: the ii-th token in the sequence
  • Q(wi∣w1,…,wi−1)Q(w_i | w_1, \ldots, w_{i-1}): the probability our model assigns to wiw_i given the preceding context

The 1N\frac{1}{N} 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.

The Entropy of English

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 21.02^{1.0} to 21.52^{1.5}, 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:

DKL(P∥Q)=H(P,Q)−H(P)D_{\text{KL}}(P \| Q) = H(P, Q) - H(P)

where:

  • DKL(P∥Q)D_{\text{KL}}(P \| Q): the KL divergence from model QQ to true distribution PP
  • H(P,Q)H(P, Q): the cross-entropy between PP and QQ
  • H(P)H(P): the entropy of the true distribution PP

Since H(P)H(P) 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 PPL=2H\text{PPL} = 2^{H} 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.