‹ BackHN Continuity

Thread

Can gzip be a language model?

414 points · 165 comments · networked

  1. berkes · · focus · HN ↗
    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 &quot;AI agent&quot;, 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 &quot;decompress&quot; a codebase, which conflates the idea of compression. If that were compression, then the &quot;compressed version of the git kernel&quot; would be a single line of text: `git clone <a href="https:&#x2F;&#x2F;git.kernel.org&#x2F;pub&#x2F;scm&#x2F;linux&#x2F;kernel&#x2F;git&#x2F;torvalds&#x2F;linux.git" rel="nofollow">https:&#x2F;&#x2F;git.kernel.org&#x2F;pub&#x2F;scm&#x2F;linux&#x2F;kernel&#x2F;git&#x2F;torvalds&#x2F;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 &quot;compression&quot; at all?

    1. evgpbfhnr · · focus · HN ↗
      You&#x27;re describing <a href="https:&#x2F;&#x2F;bellard.org&#x2F;ts_zip&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bellard.org&#x2F;ts_zip&#x2F; (&quot;Text Compression using Large Language Models&quot;) ?
      1. stackbutterflow · · focus · HN ↗
        Man,did that page load fast. It made me realize how slow the rest the (my) web is.
    2. [deleted] · · focus · HN ↗

      [deleted]

    3. eru · · focus · HN ↗
      You sound a bit confused.

      A large language model itself (the network) give you the probabilities for the next token given some prefix of tokens so far. You can use arithmetic coding to go from these probabilities to a deterministic compression &#x2F; decompression algorithm.

      When you use an LLM to generate text, you sample from that probability distribution. You can use a true random sample. Or you can make it trivially deterministic by using a seeded pseudo-random-number-generator or you just pick the highest probability each time. But that&#x27;s all a red herring; really, what you want is arithmetic coding.

      <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Arithmetic_coding" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Arithmetic_coding

    4. flyinglizard · · focus · HN ↗
      It makes a lot of sense. I thought about it in the context of pull requests or change sets: if the text-to-code process is reliable, why don&#x27;t you give me prompts instead of code? Code becomes just an intermediate representation.
    5. dist-epoch · · focus · HN ↗
      This was tried many times in the past for images, even before LLMs.

      <a href="https:&#x2F;&#x2F;imalogic.com&#x2F;blog&#x2F;2024&#x2F;06&#x2F;03&#x2F;image-compression-decompression-solution-based-on-text-prompt-generation-and-regeneration&#x2F;" rel="nofollow">https:&#x2F;&#x2F;imalogic.com&#x2F;blog&#x2F;2024&#x2F;06&#x2F;03&#x2F;image-compression-decom...

    6. vasco · · focus · HN ↗
      Sounds like an interesting way for future OS included apps to be distributed.

      Like when you click the Calculator button on your android, it wouldn&#x27;t actually exist yet, your click actually prompts it into existence. But naively that has problems because you don&#x27;t want a different UI every time. There&#x27;s something to your idea.

      1. StilesCrisis · · focus · HN ↗
        Someone did it!

        <a href="https:&#x2F;&#x2F;youtu.be&#x2F;7NfyZhV1dKM?is=YOUXCHuFUiPdlD0p" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;7NfyZhV1dKM?is=YOUXCHuFUiPdlD0p

    7. meindnoch · · focus · HN ↗
      &gt;I&#x27;ve been pondering on something related: can an LLM be a chat?

      A chat?

      &gt;I am not talking about an &quot;AI agent&quot;, but really a model that we call in a reproducible manner.

      An LLM is just as deterministic as any other computer program. For identical inputs (which includes the PRNG seed) it produces identical outputs.

      &gt;compressed version of the git kernel

      The git kernel, got it.

      &gt;But would this count as &quot;compression&quot; at all?

      Yes. The decompressor is several tens of gigabytes though.

      1. foldr · · focus · HN ↗
        &gt;An LLM is just as deterministic as any other computer program. For identical inputs (which includes the PRNG seed) it produces identical outputs.

        This is not really true in practice because of multi-threading and out-of-order execution. Mathematically equivalent orderings of operations are not equivalent when dealing with floating point values, so most practical LLM implementations end up being non-deterministic.

        1. MarkusQ · · focus · HN ↗
          &quot;An LLM is just as deterministic as any other computer program&quot; is not refuted by pointing out hardware limitations that would affect any other computer program implemented at similar scale (weather forecasts, or even just computing the average of a large stream of sensor readings).
          1. foldr · · focus · HN ↗
            I&#x27;m not really trying to &#x27;refute&#x27; the original statement. Certainly, an LLM is just doing some calculations that can be done deterministically in principle. However, I think it&#x27;s worth pointing out that there are practical barriers to doing those particular calculations both deterministically and efficiently. People who worry about LLM output not being reproducible aren&#x27;t necessarily misunderstanding what an LLM is doing; they are responding to a real feature of most practical LLM implementations.
            1. eru · · focus · HN ↗
              Agreed.

              If you wanted to and had enough engineering effort to spare, you could run an LLM deterministically at relatively small impacts to performance.

              One approach is to make sure you run things in the same order. Another is to change your operations so that more of them become associative or even commutative.

              See eg the paper &#x27;A Lattice-Based Approach to Deterministic Parallelism&#x27; for some interesting ideas on the latter.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.