Problem solved in full
-
Where the four entropy figures on the panel come from 5 steps
Entropy 4.87 bits, perplexity 29.29, cross-entropy 6.08, KL divergence 1.21. Four numbers on the panel and only two of them are independent. Find the two exact relations that tie them together.
-
Entropy is the average surprise of the true distribution, measured in bits: the number of yes/no questions needed per token if you encode optimally for this text.
-
Perplexity just puts that on a friendlier scale — two to the power of the entropy. It answers 'how many equally likely options would feel this uncertain?', and 29.29 is easier to picture than 4.87 bits.
-
Cross-entropy is the cost of encoding the true distribution using a code built for a different one. It is never smaller than the entropy, because the optimal code for P is optimal.
-
The excess is the KL divergence, and it is a subtraction, not a separate computation: 6.08388 − 4.87254 = 1.21134, to the last printed digit.
-
Exponentiating that excess says what it costs in practical terms. 2^1.21 is 2.32, so using the wrong model is like facing 2.32 times as many choices per word — 29.29 becomes 67.8.
Answer
The tool prints H = 4.87254, PP = 29.2942, H(P,Q) = 6.08388 and DKL = 1.21134. The two identities — perplexity is 2^H, and KL is cross-entropy minus entropy — hold for any pair of distributions, so they are a check you can run on any model report you are handed. They also explain why language models are scored by cross-entropy rather than KL: KL needs the true distribution, which nobody has, while cross-entropy needs only the model's probability of the text that actually occurred. Minimising one minimises the other, because the difference is a constant the model cannot touch.
-
References (3)
- Entropy and cross-entropy, at the source: C. E. Shannon, "A Mathematical Theory of Communication." Bell System Technical Journal 27, 379–423, 1948.
- KL divergence, in the paper that defined it: S. Kullback & R. A. Leibler, "On Information and Sufficiency." The Annals of Mathematical Statistics 22, 79–86, 1951.
- Perplexity, introduced as a measure of task difficulty long before language models: F. Jelinek, R. L. Mercer, L. R. Bahl & J. K. Baker, "Perplexity — a measure of the difficulty of speech recognition tasks." Journal of the Acoustical Society of America 62, S63, 1977.