Spaces:
Sleeping
Download README.md from markjouh/text-compressor: direct link, hf CLI and curl.
- Browser
- Download file 3.54 kB
-
https://huggingface.co/spaces/markjouh/text-compressor/resolve/main/README.md
- Command line
-
hf download hf://spaces/markjouh/text-compressor/README.md
-
curl -L -o README.md https://huggingface.co/spaces/markjouh/text-compressor/resolve/main/README.md
A newer version of the Gradio SDK is available: 6.31.0
title: Text compressor
short_description: Lossless text compression with a language model
emoji: 🗜️
colorFrom: gray
colorTo: green
sdk: gradio
sdk_version: 6.28.0
python_version: '3.12'
app_file: app.py
models:
- Qwen/Qwen3.5-35B-A3B-Base
- mradermacher/Qwen3.5-35B-A3B-Base-i1-GGUF
tags:
- compression
- zerogpu
pinned: false
startup_duration_timeout: 1h
license: mit
Text compressor
Lossless text compression using Qwen3.5-35B-A3B-Base, arithmetic coding, and printable basE91 ASCII. Uses the published imatrix i1-Q4_K_M GGUF from mradermacher, unchanged. On our samples it compresses as well as the Q8_0 file (0.889 bits per byte for both) and loads in about 3.5 s instead of 6 s. This is a community conversion of Qwen's pretrained base checkpoint, not a Qwen-certified quantization. No weights are quantized or modified by this app.
The exact GGUF revision, source tokenizer revision, inference settings, and probability conversion are recorded in profile.json. The CUDA llama.cpp Python wheel is pinned by version and SHA256. Only the text GGUF is downloaded (21.2 GB); no vision projector is needed.
The Space uses 48GB ZeroGPU. Downloads happen at app startup. Unlike the previous PyTorch Gemma demo, llama.cpp initializes its GPU model inside the first GPU request. That initialization consumes GPU quota and can recur when the worker is replaced. Loading displays an indeterminate status, followed by measured token progress. GPU loading and encoding timings are available through the API.
Both directions evaluate one token at a time, starting with the end-of-document token, with fresh attention and recurrent caches. No chat template, sampling, or top-k filtering is applied. The full vocabulary is converted to positive integer frequencies with the same rule used in the Gemma demo. Compression performs one encoding pass. Use Restore to decode and verify the checksum when desired; automatic round-trip verification is disabled for faster interaction.
The packet contains a format version, model/runtime/GPU profile, token and byte counts, original-text checksum, and packet checksum. Decoding requires this model and a compatible runtime. Codes from the Gemma and SmolLM2 demos are separate formats. This is an experiment, not a permanent archival format; keep the original text.
Limits: 8,192 model tokens and 64 KiB of UTF-8 input. Tokenization must preserve the exact text. Both encoding and decoding consume GPU quota. GPU time reservations are 25 s plus 12 ms per token (ZeroGPU scales them by 1.5 on this GPU), up to 6 minutes. The backend has a 16,384-token context allocation.
Run
Upload these files to a Gradio ZeroGPU Space (zero-a10g). For a local CUDA installation, install the requirements and gradio==6.28.0, then run python app.py.
CPU codec tests: python -m unittest discover -s tests. Deployment additionally requires exact model round trips, independent decode requests, and decoding after a Space restart.
Token costs
The UI highlights tokens using −log₂(p) from the actual integer coding distribution. Hover, tap, or use the arrow keys to inspect each token’s cost and probability. UTF-8 byte pieces are grouped until they form valid text, with the individual costs retained. The scale is fixed at 0–12+ bits per token; packet and ASCII overhead are not included in these ideal costs. The UI uses custom CSS with Gradio components, and keeps technical details in About.