r/MachineLearning • • 1d ago

Project Neuralzip- per-file neural text compression with model weights included in the archive [P]

I’m sharing Neuralzip, an open-source experiment in lossless text compression with a small neural model.

The model learns from the text being compressed. Its byte probabilities are used by an arithmetic coder, and the archive stores the model weights together with the encoded stream. Decoding restores the exact original bytes without retraining.

The quantity I’m measuring is the complete archive size, including the cost of storing the model.

On one five-book collection:

  • Original: 3,120,899 bytes
  • gzip-9: 1,191,527 bytes
  • Neuralzip: 791,134 bytes

That is 33.6% smaller than gzip-9, including weights, stream, metadata, and checksum. Reconstruction was verified against the original bytes.

The result doesn’t extend uniformly across inputs: gzip beat the saved Alice model, and PPMd beat Neuralzip on the five-book collection. Training and inference costs are also substantial compared with conventional compression.

These results use completed research checkpoints. Fresh training runs can produce different archive sizes.

The implementation is available as a Python package:

python -m pip install neuralzip
neuralzip encode notes.txt
neuralzip decode notes.txt.nzip

Code · Browser demo

I’m interested in feedback on model overhead versus stream savings, evaluation methodology, and how to make deterministic decoding more efficient.

5 Upvotes

2 comments sorted by

3

u/Ae-Rabelais 1d ago

Ooh, this is timely. I'm working on speeding up the recent tufazip project that came out not too long ago, so I definitely have questions:
- For that example file, what was the total compression time? What compute did you use?
- Did you have momentum set to zero?
- Did prioritized replay help at all, if you were able to test that?

1

u/Agatsuma_Zenitsu_21 20h ago

For the five-book result, training totaled ~65 minutes across CUDA and Apple Silicon/MPS runs. i'm sure there could still be scope for improvement. I used AdamW with betas (0.9, 0.95) and zero weight decay, so momentum wasn’t zero. Haven’t tested prioritized replay yet, just uniformly shuffled chunks. i was more interested in similar techniques for other content types, like video or audio