Prediction, Compression, and Intelligence
Connect probability to ideal code length, separate source entropy from model mismatch, include model complexity, and state the limits of compression as a view of intelligence.
Probabilistic prediction and lossless compression measure the same uncertainty in two forms. A model that assigns high probability to outcomes that occur can describe them with fewer bits on average. This connection explains why prediction can reveal structure, but it does not make compression a complete definition of intelligence.
Probability Determines Ideal Code Length
An outcome assigned probability has ideal information content
“The ideal code length for outcome x is the negative base-two logarithm of its probability.” Doubling the probability reduces ideal length by one bit; halving it adds one bit.
| Probability | Ideal length |
|---|---|
| bit | |
| bits | |
| bits |
These can be literal lengths for a suitable binary code. Other probabilities, such as , give fractional ideal lengths. Prefix codes use integer-length codewords, while arithmetic coding over long sequences can approach the fractional average predicted by logarithms.
Exercise: Convert probability to ideal length
What ideal code length corresponds to probability ?
Compute it first, then check your number.
HintWrite the probability as a power of two
.
SolutionThe ideal length is four bits
Because , bits. Four binary distinctions identify one outcome among sixteen equally likely possibilities.
Better Prediction Gives a Shorter Average Description
Suppose a binary source produces with probability and with probability . A code matched to the source has ideal average length
A model that predicts both symbols with probability spends
bit per symbol. Its mismatch costs about extra bit per symbol, exactly .
The model can remove mismatch cost by learning the source distribution. It cannot remove the source entropy while remaining lossless: genuinely uncertain outcomes still require information to distinguish them.
Exercise: Calculate excess description length
A source has entropy bits per symbol. A mismatched predictor gives cross-entropy bits per symbol. How many extra bits does it use over symbols on average?
Compute it first, then check your number.
HintFind the excess per symbol first
Multiply bits by symbols.
SolutionThe mismatch costs 500 extra bits
The excess is bit per symbol, so extra bits on average.
Context Makes Repeated Structure Predictable
For a sequence , an autoregressive predictor gives the ideal description length
“The ideal length of the whole sequence is the sum, over positions t, of the negative log probability assigned to token x sub t given all earlier tokens.” A context that makes the next token easier to predict shortens its contribution.
Suppose a four-symbol sequence receives conditional probabilities . Its ideal length is
A uniform binary predictor would spend four bits. The contextual predictor saves about bits on this sequence because it captures the repeated pattern after the first symbol.
Exercise: Add contextual code lengths
Three observed tokens have ideal lengths , , and bits. What is the sequence's ideal length?
Compute it first, then check your number.
HintConditional code lengths add across positions
Add the three token-level lengths.
SolutionThe sequence requires 3.5 ideal bits
Conditional ideal code lengths add across sequence positions, so the total is bits.
Learning a Pattern Can Improve Prediction
Text contains recurring structure at several scales: spelling, syntax, references between sentences, common facts, genre, and longer patterns of argument. A predictor can reduce average log loss only by exploiting structure that helps anticipate later tokens. This is why next-token prediction supplies a broad learning signal.
The relationship must be stated carefully. Predicting a sentence well means that it fits patterns in the training distribution and context. It does not prove that the sentence is true. Frequently repeated errors, fictional claims, and stylistic habits can also be predictable.
Exercise: Separate predictability from truth
Does assigning high probability to a claim prove that the claim is factually correct?
Select one choice, then check.
HintAsk what the probability model was trained to match
It predicts patterns in data and context.
SolutionPredictability does not establish truth
A claim can be common or contextually expected while still being false. Factual reliability requires evidence and evaluation beyond token loss.
A Compressor Also Has a Description Cost
A complicated model can memorize a finite dataset and assign it very short data codes. A fair comparison should also consider the cost of specifying the model. This motivates a two-part description:
“Total description length is the length of the model plus the length of the data when encoded with that model.” A larger model is worthwhile only when the data savings compensate for its added description cost.
Suppose Model A takes bits to describe and encodes the data in bits, for a total of . Model B takes bits but encodes the data in bits, for a total of . Under this two-part accounting, Model B gives the shorter complete description despite being more complex.
Exercise: Compare complete description lengths
Model A costs bits and encodes data in bits. Model B costs bits and encodes the same data in bits. Which has the shorter total description?
Select one choice, then check.
HintInclude both parts
Compare with .
SolutionModel B is shorter overall
Model A totals bits; Model B totals bits. Model B saves bits after model complexity is included.
Visualize the Cost of a Mismatched Predictor
Plot expected code length for a binary source
Change the source probability and see where the predictor minimizes expected code length.
Ready to run.
Exercise: Locate the best binary predictor
If a source produces with probability , which predicted probability for minimizes expected logarithmic code length?
Compute it first, then check your number.
HintMatch the source distribution
Cross-entropy is minimized when the predictor equals the source.
SolutionThe optimum prediction is 0.75
Predicting matches the source and removes KL mismatch cost.
Compression Is Evidence of Learned Structure, Not a Complete Verdict
Compression provides a precise way to test whether a model captures predictive regularities. It does not by itself measure factuality, causal understanding, planning, safety, fairness, computational cost, or usefulness to a person. Claims that “intelligence is compression” are therefore best read as a productive research viewpoint, not a settled mathematical equivalence.
The chapter's review now brings together surprise, entropy, distribution mismatch, shared information, log loss, perplexity, and the coding view.