37 Information Theory and Divergences
Most models in this book are trained by minimizing a cross-entropy loss: it turns the informal goal of assigning high probability to observed outcomes into a smooth objective for gradient descent. Yet what does that loss number actually measure? When a language model reports 1.2 nats per character, how low could it possibly go, and what are we comparing when we replace cross-entropy with the KL penalty of a variational autoencoder or the critic of a generative adversarial network?
Claude Shannon answered these questions in 1948 while asking how efficiently a message can cross a noisy line. His measure of unpredictability, entropy, sets the hard floor below which no model’s cross-entropy can fall (Section 3.1.2.3). Three consequences run throughout deep learning. First, cross-entropy exceeds data entropy by the KL divergence from data to model, vanishing only when the two match. Second, a model’s total loss in bits is literally a compressed file size up to two overhead bits, giving language-model perplexity (Section 8.3.2) a direct operational meaning. Third, learned critics provide only lower bounds on divergences and shared information: in contrastive learning, identifying one partner among \(N\) candidates certifies at most \(\log N\) nats, and weak adversarial critics (Section 16.2) can make distant distributions appear close.
The chapter unfolds in three parts. The first develops entropy and cross-entropy (Section 37.1) and connects log-loss directly to lossless compression and perplexity (Section 37.2). The second addresses a critical failure of density-ratio divergences (Section 37.3): whenever model samples fail to overlap the data, KL diverges and bounded \(f\)-divergences saturate with zero gradient. Comparing expectations of smooth test functions or optimal transport costs (Section 37.4) restores informative gradients, while matching log-density slopes (Section 37.5) compares unnormalized models without intractable partition functions. The third part studies pairs of random variables through mutual information, data processing, Fano’s inequality, and the information bottleneck (Section 37.6), culminating in sample-based estimation and InfoNCE (Section 37.7); these final two sections are self-contained after Section 37.1 if you wish to save transport and scores until Chapter 16 and Chapter 17.
We assume familiarity with Jensen’s inequality (Chapter 35), conditional distributions, and maximum likelihood (Chapter 36). Error-correcting codes, Kolmogorov complexity, and information geometry are surveyed in Section 37.8.