r/learnmachinelearning • u/ramazanmelih1250 • 3d ago
I built a local Qwen3.5-9B lossless Arithmetic Coding visualizer (vs zlib -9) — watching pretraining memorization vs. real generalization live
Inspired by 3Blue1Brown's information-theory video and Giacomo Magnanini's pdoom-video visualizer, I built a local Python + llama-cpp-python pipeline on a single RTX 4060 (8 GB) that compresses song lyrics with exact 62-bit lossless arithmetic coding using Qwen3.5-9B-Base (Q4_K_S GGUF) softmax CDFs, verifies 100% lossless round-trip decompression via SHA-256, and renders the live probability intervals & bitstream side-by-side against traditional zlib -9 (ZIP).
What surprised me most is how clearly pretraining memorization vs. real generalization shows up in bits-per-byte:
• Rick Astley – Never Gonna Give You Up (video above): 1,777 B → 45 B LLM (0.20 bpb · 39.5×) vs 358 B ZIP (7.96× smaller — almost pure memorization; whole lines collapse to ~0 bits) • Queen – Bohemian Rhapsody: 1,864 B → 77 B LLM (0.33 bpb · 24.2×) vs 831 B ZIP (10.79× smaller) • Daft Punk – Around the World: 2,519 B → 29 B LLM (0.09 bpb · 86.9×) vs 53 B ZIP (1.83× smaller) • Eminem – Rap God (1,542 words): 7,755 B → 1,284 B LLM (1.32 bpb) vs 3,752 B ZIP (2.92× smaller) • A Capella Science – Evo-Devo (less-memorized biology parody): 2,962 B → 610 B LLM (1.65 bpb) vs 1,538 B ZIP (2.52× smaller) • I'm Upping My P(doom) (newer / out-of-distribution generalization benchmark): 1,326 B → 294 B LLM (1.77 bpb) vs 772 B ZIP (2.63× smaller)
How it works:
- Word-level alignment: faster-whisper large-v3 (CUDA int8_float16) + monotonic DP over ground-truth lyrics.
- Exact lossless arithmetic coding: single-pass Qwen3.5-9B-Base.Q4_K_S via llama-cpp-python (float64 softmax -> monotonic int64 CDF + 62-bit integer arithmetic coder + SHA-256 decode verification).
- Live rendering: 2-worker Playwright Chromium RGBA Canvas2D stream piped into ffmpeg at 1080p60 / 4K60.
Full-length videos & code: • Realistic generalization benchmark — P(doom) (4K60, 294 B): https://youtu.be/SdPMF5OY_U0 • Memorization extreme — Rick Roll full song (45 B): https://youtu.be/gH8xmJAJaKo • MIT-licensed fork: https://github.com/TryCatchIgnoreDev/pdoom-video