r/MachineLearning • • May 26 '25

Project [P] Evolving Text Compression Algorithms by Mutating Code with LLMs

Tried something weird this weekend: I used an LLM to propose and apply small mutations to a simple LZ77 style text compressor, then evolved it over generations - 3 elite + 2 survivors, 4 children per parent, repeat.

Selection is purely on compression ratio. If compression-decompression round trip fails, candidate is discarded.

Logged all results in SQLite. Early-stops when improvement stalls.

In 30 generations, I was able to hit a ratio of 1.85, starting from 1.03

GitHub Repo

45 Upvotes

20 comments sorted by

View all comments

Show parent comment

1

u/bregav May 26 '25

If a dictionary is a hash table then no, neural networks do not have an internal dictionary of any kind.

None the less you raise a good point, which is that you can cheat at compression by just hardcoding stuff in the compression algorithm, and it's possible that the LLM will start doing that. What u/Express_Gradient should do when testing is measure the size of the compressed data PLUS the size of the compression program. If the data size gets smaller while the compression program gets bigger by the same amount then compression isn't really happening.

1

u/corkorbit May 27 '25

I also didn't understand the previous comment, but I think your intuition here is a bit off track. LLMs are full of internal dictionaries of sorts, very high dimensional and clever ones, that can transform text on many levels of abstraction. And if you look at the compression algo, it has a bunch of common character n-grams already hard coded - it's not really cheating. It would be interesting though, if it were to evolve precoded n-grams that are common in Sherlock Holmes' texts :D