logoalt Hacker News

Can gzip be a language model?

366 pointsby networkedtoday at 6:08 AM142 commentsview on HN

Comments

jll29today at 9:00 AM

Yes: you can classify a test file by topic with gzip as follows:

  gzip -9 sports.txt   testfile.txt

  gzip -9 politics.txt testfile.txt

  gzip -9 business.txt testfile.txt
(ass. sports.txt politics.txt and business.txt are text docs pertaining from the sports, politics and business domains, respectively, and have equal size)

The test file belongs to the topic with the smallest size *.gz file.

Witten's group at Waikato uni were perhaps the first to work on this.

Also check out the Hutter prize if you are interested in this.

show 9 replies
Culonavirustoday at 7:37 AM

This tracks perfectly with Winrar being more profitable than OpenAI... coincidence? I think not!

show 1 reply
GodelNumberingtoday at 8:32 AM

3blue1brown did a series on this topic: https://www.youtube.com/watch?v=l6DKRf-fAAM https://www.youtube.com/watch?v=GlYgs6v2YfU (i think one more is yet to release)

show 1 reply
mgtoday at 7:40 AM

    give it a normal text prompt, and it
    continues that prompt by searching
    for the byte sequences that compress
    best.
One moment, how are we supposed to know how well that search was done? There is no way to search a meaningful part of the search space.

So the result only gives us some lower bound of how well gzip works as a "plausibility tester" of a continuation of a text. The space of possible sequences is many orders of magnitude larger than what was searched. So there might be sequences in there that compress much better.

The text mentions beamsearch, but I don't see a discussion about how well beamsearch performs in finding the global optima when it comes to gzip compressibility of a text?

show 2 replies
adamgordonbelltoday at 7:33 PM

Compressing something and next token prediction are very related. Once you understand the connection, things like ts_zip and hutter prize make a lot more sense.

https://bellard.org/ts_zip/ https://corecursive.com/the-hutter-prize/

montebicyclelotoday at 8:25 AM

This is fun, but historically people have gone a bit overboard with saying that models like this, or n-gram language models, are anywhere close to large neural network models. There is certainly a connection though.

show 1 reply
teh64today at 7:17 PM

There is an older paper that also looks at gzip for ML: https://arxiv.org/abs/2212.09410

Video from tsoding where he implements the algorithm: https://www.youtube.com/watch?v=9n39SbRPXKQ

northlondonertoday at 3:29 PM

Reminded me Google's earlier paper, "Language Modeling Is Compression" https://arxiv.org/abs/2309.10668

Learning being a compression is also recently proposed as Gibbs compression proposition.

See Gibbs randomness-compression proposition https://arxiv.org/abs/2505.23869v5

tromptoday at 8:07 AM

I'm more interested in the converse question: how well does an LLM perform as a compressor, compared to gzip (ignoring its insanely lower speed)?

show 5 replies
aghilmorttoday at 2:47 PM

zip2zip paper by Geng et al. also exploited LZ/LZW and made the rounds a while back; novel approach that uses zip content as output compression adapter

https://arxiv.org/abs/2506.01084

colinmarctoday at 10:21 AM

Would this work with video compression? Video codecs encode a lot of meaning; they use motion vectors to track the movement of objects on screen, for example.

berkestoday at 8:58 AM

I've been pondering on something related: can an LLM be a chat?

Some models are reproducible, in that the same prompt will generate the same output. Say that we could wire up such a model to generate some code.

In that case, we could create a prompt that generates, say, an entire codebase, or a large piece of text. The prompt (or really, the tokens) would then be the compressed version of the codebase or the text.

I am not talking about an "AI agent", but really a model that we call in a reproducible manner. Preferably one call, with one prompt. An agent could just run `git clone` to "decompress" a codebase, which conflates the idea of compression. If that were compression, then the "compressed version of the git kernel" would be a single line of text: `git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...`. I am really talking about having an LLM re-generate text based on a prompt.

Does that make sense? I can imagine that this is highly impractical and inefficient. But would this count as "compression" at all?

show 7 replies
Tornhooftoday at 8:04 AM

Previous discussions of that specific page https://news.ycombinator.com/item?id=48557691

adityaathalyetoday at 9:39 AM

I think language itself is compression, so the arxiv paper tracks for me.

Viz. if Language is compression (of thought / culture / the tacit je ne sait quois of being-to-being communication etc.), then definitionally, Language Modelling must also be Compression.

Except, language is an arbitrarily lossy compressor, who's "compression-prediction equivalence" is indeterminate and unstable, because Language co-evolves constantly; both as a function of or response to culture, as well as an influencer of culture.

So, the subjective-objective goodness of Language Models (of any kind of language) would be, at best, upper-bounded by the compression-prediction equivalence of the Languages corpus itself. And that is assuming the language corpus is perfect in every way---it captures all knowledge expressible by language and it is always in-sync with live evolution of all language expression and evolution (i.e. LLM training is not a batch job, but a real-time present continuous process).

For example, to my layperson eyes, the mathematical language of proofs actively weeds out ambiguity of subjective interpretation. Ideally, a proof ought to lead to the exact same conclusion on every single reading by any reader who can follow the steps. A proof also holds only if the rest of the formal, explicit, inviolable, internally-consistent set of axioms and results holds.

So it stands to reason that mathematical prose of proofs, being optimised as mechanical procedure of taking an open question to a deterministically closed solution, has better odds of approximating the tacit aspects of mathematical derivation.

Which makes an LLM able to construct a mathematical proof, which is mind-melting to say the least.

However, I wonder, can LLMs dream of mathematical sheep?

show 1 reply
kazinatortoday at 3:17 PM

My goodness, gzip is intelligent! Enjoy your job while you have it; put on some hip hop music and practice your pivoting.

js98today at 4:46 PM

“Solving” mnist with gzip: https://jakobs.dev/solving-mnist-with-gzip/

_deftoday at 2:33 PM

Fun topic but generated article text and then not even actually using gzip? Rubs me in a weird way.

modintoday at 9:37 AM

R. Hendricks, D. Chugtai, and J. Dunn, "Lossless compression via optimized middle-out bitstream processing," Pied Piper Inc., Palo Alto, CA, Tech. Rep. 42, Apr. 2014.

mentalgeartoday at 8:23 AM

Interesting approach, I wonder how this could be used as a classifier. :)

show 2 replies
networkedtoday at 9:51 AM

I was curious to see how this would work with bzip2 and zstd. The source is public at https://github.com/nathanrs/gzipt, and I asked MiMo-V2.6-Flash to fork and modify it in a straightforward way. The answer is that bzip2 produces sequences that don't resemble human language:

  gzipt \
      --corpus data/tinyshakespeare.txt \  
      --prompt $'MENENIUS:\n' \
      --length 200 \
      ;
  
  MENENIUS:
  MtLUMSeptuttyyyxyxyxyxyvyyyxyxyxyxyvyyyxyxyxyxywyvzyxyxyx
  yyxyyyxyxyxyxyxPlyxyxyxyxyxyxyxyxyxtoxzfTUS.zxzzzyzzzvzzz
  vzzzxvzyvyxyxyxyvyxyxyxyvy--,Vdvyxyxyxyxyxyxyxyxyxxy!zFlx
  zzyyxyxyxyvyxyxyxyvyySPffuyuy
Line breaks added. This looks roughly optimized for the most repetitive Burrows-Wheeler transform (https://en.wikipedia.org/wiki/Burrows%E2%80%93Wheeler_transf...). Why are they runs of alternating symbols and not one symbol?

Zstandard produces whitespace with the occasional letter thrown in. To quote MiMo: "As you can see, zstd does not speak Shakespeare. ... zstd encodes a run of one repeated byte as a near-free run-length sequence, and space and newline are the cheapest literals in the corpus: ten newlines cost about the same to append ten bytes of genuine corpus text and less than nonsense does."

show 2 replies
elendilmtoday at 9:57 AM

Good article.

Compression is a property of language.

A seemingly simple sentence like "I had lunch" has enormous amount of information compressed inside it.

The word lunch is a compressed form of "having food at noon" while "noon" in turn is a compressed form of "Sun's position against Earth's rotation" and so on and so forth.

Every sentence has layers of compressed sentences. How many layers one chooses to decompress is up to the person.

jcattletoday at 3:12 PM

Can JPEG be a vision model?

ronfriedhabertoday at 2:04 PM

See also the Hutter Prize [1]. Compression is a subset of Intelligence.

[1] https://en.wikipedia.org/wiki/Hutter_Prize

northlondonertoday at 3:26 PM

Yes.

neloxtoday at 9:00 AM

Only if it can run DOOM.

dominotwtoday at 2:09 PM

3blue did a series of videos on this

https://www.youtube.com/watch?v=l6DKRf-fAAM

DonHopkinstoday at 12:06 PM

Will Wright once described the same connection from the opposite direction: compression as procedural content generation.

In the 2023 discussion of "Demoscene accepted as UNESCO cultural heritage in The Netherlands" I posted a transcript from a video of Will Wright discussing the demo scene:

https://news.ycombinator.com/item?id=36599415

Will Wright Discusses the Demoscene:

https://www.youtube.com/watch?v=m7iuFVmTJus

>You can take any piece of content in the game, and imagine an algorithmic solution to it. Or also, you know, a way that the player could customize that object of thing.

>There's this group in Europe called the Demoscene that make these very elaborate demos for a computer that fit into very tiny little memory blocks, you know like 64K of memory, and you run the thing, and in fact it algorithmically generates about 100 megabytes worth of data, you know these rich 3D environment, generated music, generated wave files, generated animation.

>And they're developing techniques to generate, you know, huge amounts of interesting data, with very very simple, elegant, compression algorithms.

>And this is a skill that game developers used to have, back in the 8-bit days. That was the only ways to do a game like Karateka(?), was to find all these little tips and tricks to compress things and generate them algorithmically.

>But since the CD-ROM came out, and very cheap hard drives, storage is cheap, so basically we've lost that skill set, and now we attack all those problems with brute force. I think we've lost something by dropping that skill set.

[...]

https://news.ycombinator.com/item?id=36613058

[...] Here's a simple low-tech pre-LLM example that shows the equivalence of compression and procedural content generation:

Take a huge text file of HN postings, and compress it with gzip or compress or some other robust compression algorithm. The better the algorithm, the more the output will look like random noise. Then slice the compressed file in half, and replace the second half with random numbers. Then uncompress it. You'll find that at the point you sliced it, it keeps on writing out almost plausible text for a while, consisting of highly probably snippets of commonly encountered words and phrases, then goes downhill towards incoherence. It's not as coherent or confident as an LLM, but the point is to show how low the bar is for using compression for procedural content generation.

LLMs are essentially a form of compression of the world's knowledge or whatever they're trained on, not just word frequencies or pixel patterns, but also concepts and ideas. [...]

mohd_rafaytoday at 1:14 PM

[flagged]

corbinvachaltoday at 3:43 PM

[flagged]

kindkang2024today at 12:38 PM

[dead]

lotus_uktoday at 3:31 PM

[flagged]

greengemztoday at 1:25 PM

[dead]

fr2029today at 9:10 AM

[dead]

0x20cowboytoday at 8:24 AM

[flagged]

relevant_statstoday at 9:07 AM

Yay, another mostly AI authored piece with vibe-coded aesthetics.

Some will say that I should 'judge the idea, not the form'.

But if the author didn't find enough strength to write alone a short ~700 words summary about his work, it means he himself isn't that interested or enthusiastic about it. Why should others bother then? Particularly since low-effort like that signals possibility the whole work is superficial and derivative.

show 3 replies
bob1029today at 7:53 AM

Not without attention or something approximating it.

The fact that gzip is relatively fast should be your first clue that something important is missing.

Gzip is great at predicting the next token for one very specific narrative. LLMs can predict next tokens for entire universes of narratives. Searching for the correct next token across this space scales ~quadratically with the input size. Gzip scales linearly. I can gzip a one terabyte file. Imagine feeding that much into an LLM. These are wildly different animals that happen to overlap in a very small way. Equating compression to intelligence looks increasingly silly to me.

If we must compare language models to compression, they are much more like jpeg and mp3 than they are gzip and flac. I can go fuck with a jpeg file pretty severely at the bitstream level and still have something resembling performance on the other side. Gzip cannot remotely approach this.

show 3 replies
segmondytoday at 12:04 PM

I think not. it's true that a large language model compresses knowledge and allows us to decompress knowledge. but gzip compresses data and not knowledge. with a LM you can decompress various forms of knowledge from the same data. gzip is a 1 to 1 kind of decompression where as an LM is a 1 to infinity kind of decompression.