Skip to main content

Neurzip

Lossless text compression with a model trained on your file.

Neurzip trains a small transformer, stores its weights with an arithmetic-coded stream, and restores every original byte. One Python package, two commands, and a local browser playground built with Next.js. All encoding is model based.

Neurzip browser playground

Two commands

Requires Python 3.10 or newer:

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

Encoding creates notes.txt.nzip. Decoding restores notes.txt, or a .restored filename when the original already exists. Explicit output files are protected unless --force is supplied. The package includes PyTorch for training and embedded V8 for portable decoding. No separate Node.js installation or GPU is required for Python use.

For an isolated installation, create a virtual environment first: python -m venv .venv, then source .venv/bin/activate on macOS/Linux, or .\.venv\Scripts\Activate.ps1 on Windows PowerShell.

Python package · Try the playground · Website source

How it works

  1. A transformer learns byte probabilities from your file.
  2. An arithmetic coder encodes the exact bytes using those probabilities.
  3. The archive carries the learned weights, coded stream, settings and SHA-256.
  4. Decoding uses the saved model and verifies the reconstructed bytes before saving.

There is one compression path: model training plus lossless coding. There is no conventional fallback. Model overhead can make small or difficult files larger; Neurzip keeps the actual model archive and reports its size honestly. Empty files use an empty model record.

Encoding trains for 60 seconds by default. Set --seconds 120 to spend longer learning; coding and verification take additional time. Training defaults to one CPU thread, in an isolated process that exits before coding. Use --device mps or --device cuda to opt into GPU training. Coding and decoding default to one CPU worker; --workers enables more. Decoding runs on CPU and never retrains. Compression results depend on the data, training budget and hardware.

BOMs, Unicode, CRLF, tabs, trailing spaces and arbitrary byte values are preserved. Progress shows stages, completed bytes/chunks, elapsed time and ETA where measurable. Ctrl+C cancels without publishing a partial file. Progress callbacks run on the calling thread.

neurzip encode book.txt --seconds 120
# Optional acceleration
neurzip encode book.txt --device mps --workers 2
neurzip decode book.txt.nzip -o restored.txt
neurzip info book.txt.nzip
neurzip encode book.txt --seconds 10 --json
python -m neurzip --help

compress / decompress are aliases. --quiet suppresses status; --json emits one machine-readable result. Files are processed locally and the archive needs neither the original file nor a remote model.

Python API

from neurzip import encode, decode, encode_file, decode_file

original = b"Every byte comes back."
archive = encode(original, filename="notes.txt", seconds=10)
assert decode(archive) == original

archive_path = encode_file("book.txt", seconds=60,
    on_progress=lambda event: print(event["stage"], event.get("progress")))
restored_path = decode_file(archive_path)

Browser playground

The Next.js app lives in the separate neurzip-web repository. Clone it and run npm ci, npm run build, then npm run preview with Node.js 22 or newer. It exports static files to out/ and deploys directly to Vercel.

Files stay on your device; no account, API key or file-processing server is needed. Training loads TensorFlow.js only when needed in a worker. A ready-made Alice model demonstrates restoration without training. The browser trains a smaller two-layer preset; Python trains a four-layer preset. Both share the same fixed numerical decoder and .nzip format.

Current limit Value
Python input / restored output 16 MiB
Browser training input 500,000 bytes
Browser training budget 15, 30 or 60 seconds
Python training budget 1–3,600 seconds
Archive input 160 MiB

Neural coding and decoding can take minutes for books. These are resource bounds, not performance guarantees. See hosting instructions.

Tested default and research results

The installed wheel passed nine representative-file round trips, including a complete Alice in Wonderland using the normal 60-second CPU preset: 151,094 → 80,193 bytes (1.88×). Encoding plus verification took 87.86 seconds; restoration took 8.75 seconds on this Apple Silicon machine, with one CPU thread/worker. Short-budget tests on small files grew because of model overhead; every restored SHA-256 matched. These are measured operating points, not timing guarantees.

Completed research models

These use completed research models, rather than the short default training preset. Sizes include model weights, streams, metadata and checksum, with no outer conventional compression. Both archives have been decoded and verified against source SHA-256.

Input Original bytes Complete .nzip bytes Ratio
Alice in Wonderland 151,094 63,048 2.40×
Five-book collection 3,120,899 791,134 3.94×

These results do not promise 3–4× on every file or lower total storage cost. Encoding compute, decode latency and your existing compression baseline matter. PPMd was smaller in the earlier research comparison. Shared library/runtime sizes are excluded from archive ratios.

Current measurements · Format · Research

The historical limits report measures an older experimental container with an outer wrapper. Its byte counts are not the current .nzip archive sizes.

Development

python -m pip install -e '.[dev]'
python -m pytest -q
python -m build

Tests cover actual training, byte preservation, Python/browser interoperability, malformed archives, safe output, progress, cancellation, mobile layout and accessibility. GitHub workflows provide a Python platform matrix. Browser tests and hosting configuration live with the separate website.

Neural prediction plus arithmetic coding is established: DeepZip, DZip, NNCP and Language Modeling Is Compression. Neurzip focuses on approachable commands, small per-file models and portable recovery; it does not claim to invent neural lossless compression.

MIT license · Contributing · Security

Metadata

Release files for neurzip 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neurzip 0.3.0
File Size Uploaded Provenance Actions
neurzip-0.3.0.tar.gz 146.0 kB Without provenance Details for neurzip-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for neurzip 0.3.0
File Interpreter ABI Platform Actions
neurzip-0.3.0-py3-none-any.whl Python 3 none any Details for neurzip-0.3.0-py3-none-any.whl

Total release size: 179.3 kB

Release files / neurzip-0.3.0.tar.gz

Download URL neurzip-0.3.0.tar.gz
Size 146.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b1bc15b73c37f3557e610d1d5ae3ce5cffd470baecf1d41295870d56fb4e359d
BLAKE2b-256 checksum
How to use checksums
dc61a02afbba21568bc6925e6b39b27d6abf15829bc32b1666858045f0c41679
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / neurzip-0.3.0-py3-none-any.whl

Download URL neurzip-0.3.0-py3-none-any.whl
Size 33.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
117ad57418a72a6f729c8b7ad6151698a90556fca339365d0e8b1d81ff0b3a39
BLAKE2b-256 checksum
How to use checksums
c10cd106c833a14e4fe143646648c36ccf12591ab8062869896b3291115c2db9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Security for neurzip 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page