Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 5 min read

2.18 bits/byte: perplexity is just compression

2.18 bits/byte: perplexity is just compression bzip2 squeezed 6.5 MB of English down to 2.18 bits per byte. My best hand-rolled predictor needed 2.47. OpenAI's GPT-3.5 needs the equivalent of about 2.7 guesses per toke

2.18 bits/byte: perplexity is just compression

bzip2 squeezed 6.5 MB of English down to 2.18 bits per byte. My best hand-rolled predictor needed 2.47. OpenAI's GPT-3.5 needs the equivalent of about 2.7 guesses per token. The gap between my 5-gram and their model is the whole story of the last three years β€” and it's measurable with nothing but the Python standard library.

The claim

OpenAI published "Perplexity and Intelligence" today, and it's on the Hacker News front page as I write this. The argument, in one paragraph: modern AI is mostly training a compressor on a huge corpus, and the one metric that has tracked progress the whole way is perplexity β€” how well the model predicts the next token. GPT-3.5 sat at a log-perplexity of ~0.99 on their held-out set. GPT-4 at ~0.91. Current models are below 0.8, and at ~0.76 a model started solving open problems in mathematics. OpenAI expects the next wave of emergent capabilities in the ~0.68–0.7 window, and proposes perplexity as a shared yardstick β€” even a basis for common limits on development.

It's a big claim with a testable core: perplexity is compression. A predictor that assigns high probability to the actual next character is, by Shannon's arithmetic, a compressor. So I tested the equivalence on my own machine, with no model weights at all.

The experiment

Corpus: norvig.com/big.txt β€” 6,488,666 bytes of English (Sherlock Holmes and other Gutenberg texts). Same file for everything. Compressors got the whole file; the n-gram models trained on the first 80% and were scored on the last 20%.

First, the compressors:

import gzip, bz2, lzma, zlib

data = open("big.txt", "rb").read()  # 6,488,666 bytes
for name, fn in [("gzip -9", lambda d: gzip.compress(d, compresslevel=9)),
                 ("bzip2 -9", lambda d: bz2.compress(d, compresslevel=9)),
                 ("lzma", lzma.compress),
                 ("zlib -9", lambda d: zlib.compress(d, 9))]:
    c = fn(data)
    print(f"{name}: {len(c):,} bytes -> {len(c)*8/len(data):.3f} bits/byte")
gzip -9:  2,373,530 bytes -> 2.926 bits/byte (36.6% of original), 1.07s
bzip2 -9: 1,766,283 bytes -> 2.178 bits/byte (27.2% of original), 0.78s
lzma:     1,807,532 bytes -> 2.229 bits/byte (27.9% of original), 6.74s
zlib -9:  2,373,518 bytes -> 2.926 bits/byte (36.6% of original), 1.07s

Then a plain character n-gram β€” count the last N characters, predict the next one, add-0.01 smoothing, scored on held-out text:

from collections import Counter, defaultdict
import math

train = text[:int(len(text)*0.8)]
test = text[int(len(text)*0.8):]
# ... build counts[context][char], then:
# cross-entropy = mean(-log2 P(actual char | context))
char 1-gram: cross-entropy 3.622 bits/char -> perplexity 12.3 per char
char 3-gram: cross-entropy 2.631 bits/char -> perplexity 6.2 per char
char 5-gram: cross-entropy 2.468 bits/char -> perplexity 5.5 per char
char 8-gram: cross-entropy 3.657 bits/char -> perplexity 12.6 per char
word unigram (no context at all): 11.653 bits/word -> perplexity 3,220 per word

What the numbers actually say

My 5-gram beats gzip. 2.468 bits per character against gzip's 2.926. A counting model I wrote in an afternoon predicts held-out English better than a general-purpose compressor. The compression-equals-prediction claim isn't philosophy; it's arithmetic you can reproduce before lunch.

But bzip2 beats my 5-gram. 2.178 against 2.468. Here's the honest reason: the compressors get to cheat. They see the whole file, including the test portion β€” bzip2's 900 KB blocks adapt to the text they're compressing. My n-gram only trained on the first 80% and never saw the test set. A compressor is a predictor that trains on the test data. If you let my 5-gram do that, the comparison flips. The equivalence holds; the experimental setup is what differs.

More context is not free. The 8-gram is worse than the 1-gram: 3.657 bits per character. On the test set, 29.5% of 8-character contexts never appeared in training, so the model falls back to near-uniform guessing. Every n-gram practitioner knows this as the sparsity wall; here it is as a number. More context helps exactly until the training data runs out β€” which is also, not coincidentally, the story of scaling.

The gap to frontier models is enormous, and now I can put a number on it. My 5-gram needs 2.468 bits per character. At roughly 4 characters per token, that's ~9.9 bits per token, or a per-token perplexity of about 940 (e^6.84). GPT-3.5's 0.99 log-perplexity is a perplexity of 2.7 per token. Same units, same idea, 350Γ— apart. That factor of 350 is what three years of scale and architecture bought. When OpenAI says the next capabilities arrive around 0.68–0.7 β€” perplexity ~2.0 β€” they're saying the difference between 2.7 and 2.0 guesses per token is where the next qualitative jump lives. After watching my own predictor collapse from 5-gram to 8-gram on sparsity alone, I believe them: small moves in this metric are not small.

The part OpenAI is honest about

The post lists the problems with perplexity as a shared standard, and they're real. Different labs use different evaluation datasets and different data mixtures, so a 0.76 at OpenAI isn't directly comparable to a 0.76 anywhere else. Perplexity doesn't capture chain-of-thought reasoning, which adds capability without reducing perplexity at all. And nobody knows the floor β€” the inherent entropy of the data β€” so as models approach it, the same absolute gain means more.

My afternoon adds one more caveat: the metric is only as honest as the train/test split. A compressor that peeks at the test set will always look smarter than a predictor that doesn't. Any shared perplexity standard needs a shared held-out set with real teeth, or the numbers will be gamed exactly the way benchmark numbers always are.

Still: the core claim survives contact with my machine. Perplexity is compression, compression is measurable, and the distance from my 5-gram to GPT-3.5 is the most concrete picture I have of what "intelligence" has meant so far β€” fewer guesses per token, bought with more data than I can fit on my disk.

Sources

  • OpenAI, "Perplexity and Intelligence", 2026-11-22: https://openai.com/index/perplexity-and-intelligence/ (HN front page, 434 points)
  • Corpus: Peter Norvig's big.txt, https://norvig.com/big.txt (6,488,666 bytes)
  • All numbers above are from my own runs on 2026-11-22, Python 3.12 standard library only. Log-perplexity figures for GPT-3.5/4 are OpenAI's, on their held-out set β€” different data from mine, so compare the shape, not the decimals.
πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.