Gradient
Lesson 5.8MathCode~45 min

Entropy & KL divergence

How uncertain is a distribution, and how far apart are two? The yardsticks behind RLHF and distillation.

Module 5 · 0/9 done

How unpredictable is it?

You met surprise in the cross-entropy lesson: an outcome with probability pp carries −log⁡p-\log p worth of surprise. Rare things are surprising; certain things aren’t surprising at all.

A distribution’s entropy is its average surprise: how unpredictable it is overall. In base-2 logs it’s measured in bits, the number of yes/no questions you’d need, on average, to find out the outcome.

H(p)=−∑ipilog⁡2piH(p) = -\sum_i p_i \log_2 p_i
Fig 5.13Drag the bars to load the die. A fair die is as unpredictable as possible (2.585 bits); a die that always lands the same way has 0.