1. Peel
  2. The Pith
  3. Can a model beat ZIP?
Essay · Information theory

Can a Language Model Beat ZIP?

A fair comparison must include the cost of intelligence.

By · · Updated · The Pith, no. 13 · 4 min read

An elaborate brass machine under a glass dome, spilling punched paper tape, beside a small orange zipped pouch

A language model is trained to predict what comes next. That makes it a candidate for lossless compression. If the model assigns a high probability to the next token in a file, an entropy coder can represent it with fewer bits on average.

Suppose the resulting stream is smaller than a ZIP archive of the same text. To know whether it wins, we still need to know how the recipient decodes it, which dependencies they already have, and what exact output their decoder can reconstruct.

Turning prediction into a codec

ZIP is a container. For this comparison, use ZIP with DEFLATE as the conventional baseline. DEFLATE represents repeated byte sequences using references to earlier data and uses Huffman codes for symbols in the compressed representation. A neural codec can instead predict a distribution over the next symbol given the symbols already seen and use arithmetic coding to encode the actual symbol. The model supplies the distribution. The coder makes the sequence recoverable. [1] [2] [3]

At each step the decoder runs the same prediction on the prefix it has recovered. A practical arithmetic coder partitions its range using integer cumulative frequencies. Both ends must agree on those frequencies, symbol order, how context is initialized, and when the stream ends. Even with the same weights, a different numerical implementation can move a probability across a rounding boundary. Compatibility depends on reproducing the integer tables the coder actually consumes (Figure 1).

Fig. 01 / Interactive

What if the probability table changes?

The encoder divides a scale of 100 points at 70: points 0–69 mean A and points 70–99 mean B.

Point 60 represents A at a split of 70. A decoder whose split is 50 reads the same point as B.

Figure 1. A simplified illustration of one interval choice. A real arithmetic coder narrows and rescales intervals across a whole sequence.

Recovering the exact bytes

Tokenization has its own round-trip requirement. Two sequences of Unicode characters can look the same while their UTF-8 bytes differ. A tokenizer that normalizes the input can erase the distinction before the model sees it. Use a reversible representation of the source bytes, or carry the extra information needed to undo transformations such as normalization. For arbitrary files, text decoding with replacement characters can also lose information (Figure 2). [4]

Fig. 02 / Interactive

Same glyph, different bytes.

Compare a precomposed é with an e followed by a combining acute accent.

The precomposed form is C3 A9 and the combining form is 65 CC 81. NFC maps both to C3 A9.

Figure 2. Your browser calculates the UTF-8 bytes for these two examples. The normalization option keeps no record of the original form.

Who already has the model?

Suppose a neural codec produces 1 MB of coded text and requires a 100 MB model. For a recipient without the model, a one-off self-contained transfer takes at least 101 MB before framing or additional runtime components. If the recipient already has the exact compatible model and decoder, the marginal transfer can be close to 1 MB. If you send the model once and reuse it, the upfront cost spreads over the files you actually transfer (Figure 3).

Fig. 03 / Interactive

How many files pay for the model?

Assume a hypothetical 3 MB ZIP archive or a 1 MB neural stream per file. The ZIP decoder is already available.

Sending the model once costs 101 MB for one file. At 50 files both methods total 150 MB; at 51 files the neural transfer is 151 MB and ZIP is 153 MB.

Figure 3. Illustrative decimal megabytes, before framing and runtime delivery. The result measures transferred bytes and assumes one model can serve every file.

Transfer size is one measure. Reproducing the probability tables also costs time and memory, and the first decode may have to load substantial weights before it reads the first symbol. In Language Modeling Is Compression, Delétang and colleagues report raw compression rates separately from rates that charge for model parameters. The Hutter Prize uses its own explicit rules for what executables and archives count toward the score. State which accounting boundary your comparison uses. [3] [5]

How to investigate it

Compare a pinned ZIP/DEFLATE implementation against a small deterministic predictor paired with an entropy coder. Prepare the same public held-out text for both. For a model trained specifically for the test, separate its training corpus from the evaluation corpus. For pretrained weights, report what you can establish about overlap and what remains unknown.

  1. Freeze the inputs and decoder contract. Record input hashes, software versions, model and tokenizer hashes, context rules, symbol order, and the integer probability table construction.
  2. Check exact reconstruction. Decode from a fresh process and compare the output bytes with the input. Repeat on every platform or runtime you claim is compatible. Keep cases with accented characters, unusual line endings, and inputs near block boundaries.
  3. Separate marginal and delivered sizes. Record the actual coded bytes including framing. Record model, tokenizer, and required runtime components separately and charge them according to what each endpoint already has.
  4. Measure both directions. Report encode and decode throughput, startup time, and peak memory. Use the same documented machine and distinguish a cold model load from a warm run.

This is a proposed experiment. The figures demonstrate a decoding choice, actual byte representations for two sample strings, and hypothetical transfer sizes.

What this means

A language model can yield a smaller coded stream on a particular corpus. Whether that is a better way to move or store the file depends on who has the decoder, how often the model will be reused, and what the receiver can afford to run.

A compression result needs to say what the decoder already knows.

References and further reading

  1. PKWARE. ZIP File Format Specification (APPNOTE).
  2. L. Peter Deutsch. RFC 1951, DEFLATE Compressed Data Format Specification.
  3. Grégoire Delétang et al. Language Modeling Is Compression, especially sections 2 and 3.
  4. Unicode Consortium. Unicode Normalization Forms (UAX #15).
  5. Marcus Hutter. Human Knowledge Compression Contest rules.
Read next · No. 12 · Information theoryIs Intelligence Just Compression?Behind that comparison sits a bigger claim: is predicting well the same thing as understanding?
Peel's icon: an orange on a cream tile

Get Peel. Free forever.

No account, no ads, no trial. Everything Peel does today stays free, and it keeps itself up to date.

Download Peel 1.4.0 brew install --cask snackstudio/tap/peel
Requirements
macOS 13 Ventura or later, on Apple silicon or Intel.
Install
Open the installer and follow it. Or open the disk image and drag Peel to Applications, or run brew install --cask snackstudio/tap/peel in Terminal.
Updates
Peel updates itself, and every update is signed. To check now, choose Peel ▸ Check for Updates…
Uninstall
Drag Peel to the Trash, or run brew uninstall --cask peel.
Price
Free. No account, no ads, no trial.
Privacy
Your files never leave your Mac, and the app has no analytics. This site counts visits to learn what helps; the privacy policy says how.