Shannon's information theory reveals a striking connection: perfect compression and accurate prediction are mathematically identical. This insight transforms how we understand language models — pre-training isn't just about guessing the next word, it's about building the most efficient possible text compressor, where compression fundamentally requires intelligence.
The Robot Instruction Problem: When Probability Meets Data
A robot on a distant moon receives movement commands: up, down, left, right. The naive approach uses two bits per instruction (00, 01, 10, 11), but there's a catch — these instructions aren't equally likely. Up comes 50% of the time, down 25%, and left and right each 12.5%.
A clever encoding emerges: use a single bit (0) for up, two bits (10) for down, and three bits (110, 111) for left and right. The math is revealing. Half the time you send one bit, a quarter of the time two bits, the rest three bits. Multiply each by its frequency and you get 1.75 bits per instruction, beating the flat two-bit approach.
But here's the magic — when you visualize all possible binary strings as a tree diagram, with each layer representing strings of increasing length, the clever encoding consumes exactly the same fraction of space as the probability of each instruction. Up's single bit claims half the diagram, down's two bits claim a quarter, and the three-bit codes each claim an eighth. The probabilities and the space consumption align perfectly, suggesting something fundamental is happening beneath the surface.
The Random Noise Revelation: Why Perfect Compression Looks Chaotic
A theoretical insight unlocks everything: perfect compression should produce output indistinguishable from random noise. Here's why this matters.
Imagine you receive n compressed bits. That's one possibility out of 2^n equally likely messages. If the compression truly looks random, every one of those 2^n messages must have been equally probable in the original data. That means each message had probability 1/(2^n), or equivalently, 2^(-n).
Flip this around: a message with probability p must use -log₂(p) bits under perfect compression. This negative log expression becomes the foundational formula for all information theory. It's not an arbitrary definition — you're driven to it by asking what perfect compression must look like.
Try to compress random noise further and you hit a wall. That diagram of binary strings reveals why: moving one message to a shorter encoding (saving one bit) forces at least two other messages higher up (costing two bits). You're not compressing anything, just pushing bumps around in a rug. Random noise resists compression because every bit actually carries information — there's no redundancy to squeeze out.
Fractional Bits and the Meaning of Information
Real language doesn't have probabilities that are clean powers of two. When a language model predicts the next letter, you get messy decimals: maybe 'i' has 4.19 bits of information, or a predictable 'o' has just 0.3 bits. What does a fractional bit even mean?
The answer emerges when you zoom out from individual symbols to entire messages. Language probability works through multiplication — the chance of a full phrase is the product of each successive letter's probability (conditioned on what came before). Take the negative log, and multiplication becomes addition. The information of a message is just the sum of each letter's fractional information.
Here's the key: you can build compression algorithms that encode entire messages to within one or two bits of this summed value. Shannon information gives you a lower bound — the theoretical minimum compression possible. Even though you can't encode a single symbol with 4.19 bits, when you average over many symbols in real messages, this fractional accounting works out exactly.
The bar chart visualization drives this home: probability determines width, information (-log of probability) determines height. Multiply width by height for each symbol, add them all up, and you get total information content. Unlikely events shoot tall bars upward (high information), while predictable events barely register (low information).
Shannon's Wife and the Birth of Language Entropy
How do you measure the compressibility of English when you don't have clean probability tables? Shannon faced this problem in the 1940s, long before language models existed. His first experiments tracked short character sequences (n-grams) in books, recording what letters typically followed. But this approach collapsed for longer contexts — any string not in your books has no statistics.
So Shannon tried something unusual: he recruited his wife Betty as a language model. He pulled out a book and asked her to guess each next letter. When she guessed right, he wrote a dash. When she guessed wrong, he wrote the actual letter. His insight: this reduced transcript contained the same information as the original, because if you could perfectly replicate Betty's brain, you could reconstruct the full text using just these prompts.
Later, Shannon refined this into an actual measurement. He interviewed multiple people, recording how many guesses each person needed to identify the correct next letter. From the number of guesses, he inferred the implicit probability that person was assigning to each letter. With 100 characters of context, he estimated English has about one bit of entropy per character.
That number is staggering — it suggests you could compress English down to a single yes/no question per letter. What makes this estimate profound is that Shannon wasn't just analyzing data. He was probing intelligent models (human brains) because measuring language compressibility inevitably requires modeling language understanding. You can't separate compression from intelligence.
Entropy: The Visual Formula for Average Information
The weighted average we calculated for robot instructions — that's entropy. For any probability distribution, entropy measures average information per symbol: sum up p × (-log₂ p) across all possible symbols.
Visualize it as stacked horizontal bars, each width equal to its probability (summing to 1). Stack rectangles above each bar, height locked to information content (-log₂ p). The total area of all rectangles is entropy — literally the visual representation of average information.
Slosh probabilities around and watch what happens. Spread them evenly, entropy goes up (more uncertainty, more information needed on average). Concentrate everything in one dominant option, entropy plummets (high predictability, little information per symbol). Split probability across more symbols, each gets rarer, information per symbol rises, total entropy increases.
John von Neumann supposedly told Shannon to call this 'entropy' because it resembled formulas from statistical mechanics, and also because 'nobody knows what entropy really is, so in an argument, you'll always have the advantage.' The story is probably fake, but Shannon did adopt the name and notation (H).
Shannon's noiseless coding theorem proves two things: no encoding can compress below this entropy limit, and you can always get arbitrarily close to it. This is the fundamental limit of compression for any signal where symbols follow the same distribution — which is perfect for our robot, but not yet general enough for language.
From Bits to Brains: Why Compression Requires Intelligence
Shannon's entropy formula only applies when every symbol follows identical probability. Real language breaks this — each letter's probability depends heavily on context. You need a more general concept: entropy rate for stochastic processes. Same question (average information per symbol), but now averaged over all possible messages.
This calculation is almost never clean. What formula describes language probability? None that anyone can write down precisely. So if someone quotes 'the entropy of English,' understand: this goes far beyond exact calculation. Shannon turned to estimates through observation.
His methodology reveals something profound: satisfying estimates of compressibility required probing intelligent models. Pure data analysis on text corpora wasn't enough. He needed to interrogate brains — black boxes with sophisticated, indescribable language understanding. He was testing not what letters appeared in books, but what letters brains predicted would appear next.
In the 2020s, we've graduated from interrogating these black boxes to designing them. Modern machine learning leverages exactly the formulas that emerged from Shannon's work. When large language models train using 'cross-entropy loss' for 'next token prediction,' they're not just learning to guess words — they're being optimized as text compressors. The math that describes compression limits is the same math that trains artificial intelligence, because understanding language well enough to compress it efficiently is functionally indistinguishable from understanding language.
Keep these ideas with you.
- Prefix-Free Codes
A clever encoding trick: if no code word can be the prefix of another, a receiver knows exactly where to split the bitstream. Read bits until they form a complete code word, then start fresh. This is why '0' for up, '10' for down, '110' for left, and '111' for right works perfectly: the moment you see a '0', it can only be up; if you see '10', it can only be down. No ambiguity, no delimiters needed.
- Shannon Information Formula
Why is information equal to -log₂(p)? Because in perfect compression, a message with probability p uses that many bits. Think of it as asking: how many times do you halve your space of possibilities to reach this probability? A 50% event needs 1 bit (one halving), a 25% event needs 2 bits (two halvings), an event with probability 1/8 needs 3 bits. Unlikely messages require more bits, thus contain more information.
- Random Noise Is Incompressible
Imagine you compressed n bits of random noise down to fewer bits. You'd be claiming that some patterns exist in randomness. But true random noise means every sequence of n bits is equally likely (probability 1/2^n for each). Try to save one bit by making one message shorter, and you force at least two other messages to use an extra bit. You can't win: random noise already has maximum entropy, no redundancy to exploit.
- Entropy as Visual Area
Picture probabilities as horizontal bars (widths sum to 1). Stack rectangles above each bar, height = information (-log₂ p). Total rectangle area = entropy = average information per symbol. Spread probabilities evenly, area grows. Concentrate in one option, area shrinks. This visualization makes abstract entropy concrete: it literally shows you the compression limit as a measurable quantity.
- Shannon's Wife as Language Model
Before GPT, Shannon used his wife Betty to measure English entropy. He had her guess each next letter in a book. Correct guesses became dashes, wrong guesses stayed as letters. His insight: this reduced transcript contained full information because a perfect copy of Betty's brain could reconstruct the original from it. He was probing an intelligent model (human) because estimating compression requires understanding, not just counting letters in books.
Turn the ideas into action.
For Understanding AI Training
Reframe what 'next token prediction' really means: language models are being optimized as text compressors. When you see 'cross-entropy loss' in training logs, recognize it's measuring how efficiently the model could compress text. Better predictions = more efficient compression = lower entropy. This lens clarifies why compression and intelligence are two sides of the same coin.
For Evaluating Language Models
Ask how close a model gets to Shannon's estimate of ~1 bit per character for English. If a model achieves lower entropy than human guessers, it's compressing language more efficiently than humans predict it, suggesting it has captured patterns even native speakers miss. Entropy becomes a concrete benchmark for 'understanding.'
For Building Intuition About Data
Visualize probability distributions as those stacked bars with information-height rectangles. When you encounter any prediction task, mentally sketch this: concentrated probability = low entropy = high predictability. Spread-out probability = high entropy = true uncertainty. This visual grounds abstract concepts in something you can literally see and manipulate.
For Designing Compression Algorithms
Aim for output that looks like random noise, where each bit has 50/50 chance of being 0 or 1. If your compressed data shows patterns (like runs of repeated bits), you haven't compressed enough. Perfect compression squeezes out all predictability, leaving pure randomness. Test: run statistical tests on your output; it should pass randomness checks.
The complete summary: 6 chapters, 5 takeaways and 4 actionable insights.
Summarised with AI by Bite, an AI YouTube video summarizer and podcast summarizer. Timestamps keep the source close; check important details against the original.
Original video on YouTube




