r/compression • u/Agatsuma_Zenitsu_21 • 4d ago
Neuralzip: lossless neural text compression, including model weights in the archive
Disclosure: I used AI assistance for development
I built Neuralzip, an open-source Python library for lossless text compression using a small neural model and arithmetic coding.
The model is trained on the input text. Its weights are stored alongside the encoded stream, metadata, and checksum in one archive. Decoding uses the saved model without retraining.
Results from two saved research models:
| Input | Original | gzip-9 | Neuralzip |
|---|---|---|---|
| 5 book collection | 3,120,899 B | 1,191,527 B | 791,134 B |
| Alice in Wonderland | 151,094 B | 53,249 B | 63,048 B |
The five-book archive is 33.6% smaller than gzip-9. Gzip wins on Alice, and PPMd produced a smaller five-book archive at 763,603 bytes.
Neuralzip sizes include the model weights and complete encoded stream. Shared decoder/runtime installation sizes are excluded. Both archives were decoded and compared with the original bytes.
Encoding requires training, decoding also evaluates the model, and both are much slower than conventional codecs. Small inputs can grow because of model overhead. These measurements use saved research checkpoints; fresh training runs can differ.
python -m pip install neuralzip
neuralzip encode notes.txt
neuralzip decode notes.txt.nzipI’d appreciate feedback on the archive accounting, implementation, and which datasets and baselines would make the next evaluation useful.
3
u/red38dit 4d ago
A text file with a lot of json:
Original - 109.6 KB Neuralzip - 53.5 KB (sloooooooow) XZ - 16.5 KB (fast)