Which coin flip tells you more?
Two coins are flipped. The first is fair (). The second is a trick coin that always lands heads ().
The fair coin lands heads. Mildly interesting; you expected this half the time. The trick coin lands heads. Completely unsurprising; you knew this with certainty before it happened.
Information content is the name for how much news an outcome carries. The trick coin coming up heads has zero news in it. The fair coin coming up heads has one bit of news. Module 9 is about putting numbers on that intuition, and then averaging them into the single number every loss curve in this course will be measuring.
Information content: I(x) = −log P(x)
The formal definition has exactly the properties you want:
Common outcomes (large ) carry little information ( of something near 1 is near 0). Rare outcomes carry a lot ( of something tiny is huge). And for independent events and , information adds: . Two independent surprises are twice as surprising as one. The formula respects every intuition you had in the last step.
(Convention: , because . We need this so impossible events don’t blow up the average. It’s a limit, not a definition added for convenience.)
A 1-in-8 outcome
An outcome has probability .
What is in bits?
Bits, nats, bans: same number, three units
You may have noticed I didn’t say what base the logarithm uses. That’s because the answer changes with the base, but it’s the same quantity. Three conventions:
- bits. Most natural for communication and storage.
- nats. Most natural for calculus, because .
- bans (or “hartleys”). Used by Turing’s group at Bletchley Park; almost extinct otherwise.
Modern ML defaults to nats, because torch.log and numpy.log are natural logs and the gradients of common losses are cleaner. The choice of base is a unit choice, like Celsius vs Fahrenheit. The widget below converts among them; play with it for a moment.
3 bits in nats
Convert 3 bits to nats. (Two decimals is fine.)
Entropy is expected surprise
Information content is a property of a single outcome. Entropy is a property of a whole distribution. The move is exactly the one from module 8: take an expectation.
In words: the average information content of a draw from . The widget below shows three panels for the same pmf. The left panel is . The middle panel is the per-outcome surprise . The right panel is the product , stacked into a single bar whose total height is exactly in bits.
Drag any bar on the left; everything else updates in the same frame. The middle bars get taller as you shrink an outcome (rare means more surprising). But the right-panel stack (the entropy) depends on the product, so rarer-but-more-surprising contributions don’t simply increase . The two factors fight each other.
Maximum certainty
Click the One-hot (H = 0) preset. The pmf is now concentrated entirely on one outcome.
What is in bits?
A slightly biased coin is still nearly maximum-entropy
Now switch the widget to two outcomes (you’ll need to imagine collapsing the panels in your head, or just note the binary entropy curve in the formula). The fair coin has bit. A coin with has
Tilt the coin a full 60/40 and you barely move the entropy. Entropy is a concave function of the pmf; small perturbations from uniformity have second-order effect on . This is why models can have qualitatively wrong predictions and still post a respectable cross-entropy.
Why ML defaults to nats (and why it doesn't matter)
You will see the same loss reported in three units by three different papers. PyTorch reports loss in nats by default (because log is natural). The compression community reports in bits per byte or bits per character. Information-theoretic textbooks switch freely. Two facts hold:
- The numerical value of the loss differs by a constant factor between units: .
- The perplexity (which we’ll meet in lesson 9.4) is base-invariant. . So when you compare models by perplexity, you don’t have to care.
In practice for the rest of this course: nats is the default; bits/character is reported for language-modeling benchmarks; the widget above will let you flip between them anytime.
Uniform on 32
A uniform distribution assigns probability to each of outcomes.
What is its entropy in bits?
Where this lands: entropy is the floor of the loss curve
The training loss your transformer minimizes is literally , the average surprise per token under your model . That’s the next lesson’s punchline: when the true distribution is and your model is , the average surprise you suffer is cross-entropy , which is bounded below by , the entropy of the data itself.
So entropy isn’t an abstraction. It’s the asymptote of every loss curve in this course. The Shannon estimate of English entropy (≈ 1.0–1.3 bits per character) is the floor a language model can never break. The m18 capstone’s training run is a race toward that floor.
Next lesson: when two distributions meet (the truth and the model ), what numbers describe their disagreement?
Lesson complete