KL Divergence
Chapter 14: Information Theory — KL Divergence (also appears in Ch. 18, Ch. 21)
From the book
Chapter 14: Information Theory. In the chapter mind map this icon labels **KL Divergence: $D_{\mathrm{KL}}(P \parallel Q)$. The discussion below is excerpted and lightly edited from § KL Divergence** in Mathematics for AI and Machine Learning. Related material also appears in Chapter 18 (Language Models: Temperature, Top-$p$, Gumbel-Max), Chapter 21 (KL Decay & Log-Sobolev Inequality).
1. Non-negativity: $D_{\mathrm{KL}}(p || q) \ge 0$ for all $p, q$, with equality if and only if $p = q$ almost everywhere.
2. Asymmetry: $D_{\mathrm{KL}}(p || q) \neq D_{\mathrm{KL}}(q || p)$ in general (KL divergence is not a metric).
3. Chain rule: For joint distributions, $D_{\mathrm{KL}}(p(x, y) || q(x, y)) = D_{\mathrm{KL}}(p(x) || q(x)) + \mathbb{E}_{p(x)}[D_{\mathrm{KL}}(p(y|x) || q(y|x))]$.
4. Convexity: $D_{\mathrm{KL}}(p || q)$ is convex in both $p$ and $q$.
What this drawing shows
What you see. Blue $P$ and green $Q$ fixed; peach gap between the curves grows, visualizing $D_{\mathrm{KL}}(P \parallel Q)$.
In the mind map. Chapter 14 — KL Divergence. See From the book above for definitions, figures, and worked examples.
Also appears in Ch. 18 (Language Models: Temperature, Top-, Gumbel-Max); Ch. 21 (KL Decay & Log-Sobolev Inequality).
Where to read next
Read the full definitions, figures, and worked examples in Chapter 14: Information Theory — see the mind-map node KL Divergence.
This concept is also referenced in Chapter 18 (Language Models: Temperature, Top-, Gumbel-Max); Chapter 21 (KL Decay & Log-Sobolev Inequality).