惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
G
Google Developers Blog
D
Docker
阮一峰的网络日志
阮一峰的网络日志
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
T
The Blog of Author Tim Ferriss
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
I
InfoQ
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
Google DeepMind News
Google DeepMind News

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
gni-compression is on npm — What a month of building a do...
Buffer Overf · 2026-05-03 · via DEV Community

Seven articles ago I shipped a serialization layer that recovered 1M+ messages losslessly. Today the package is on npm and the compression numbers are real.

Here's where I landed.
What shipped
gni-compression is a domain-adaptive lossless compression package for LLM conversation data. It's a Rust native binary (via napi-rs) with a thin JS wrapper.

Two functions:

const { compress, decompress } = require('gni-compression')

const compressed = await compress(Buffer.from(longContext))
const restored = await decompress(compressed)
// lossless, verified

No warmup. No session state. The domain knowledge is baked into a pre-trained dictionary (gcdict.bin) bundled with the package — trained on real LLM conversation corpora.

The numbers
Benchmarked against brotli-6 across five public corpora (50 messages each, lossless round-trip verified):

Corpus GN Ratio Savings brotli-6
WildChat 4.94x 79.8% ~2.1x
ShareGPT 8.65x 88.4% ~2.0x
LMSYS 10.38x 90.4% ~2.1x
Ubuntu IRC 8.40x 88.1% ~1.2x
Claude convos 12.40x 91.9% ~1.9x

Ubuntu IRC is the surprising one. Messages average 67 bytes — too short for brotli to do much (1.2x). GN gets 8.4x because IRC vocabulary is extremely consistent. Short repetitive messages are where a domain dictionary wins hardest.

Why the numbers are what they are
The architecture splits input into separate token-ID and literal streams before compression. Token IDs are compact integers referencing the pre-trained vocabulary. Literals are the residual bytes that didn't match anything in the dictionary.
Each stream compresses independently with different characteristics. The tok stream is tiny (integers, high redundancy). The lit stream is whatever didn't compress semantically — it gets deflate with the GCdict applied.

When I swept minimum phrase length I found the vocabulary isn't a smooth distribution — it's two clusters with a gap:

· minLen 4→5: token count drops 68% (short filler tokens)
· minLen 5–9: flat, essentially nothing lives here
· minLen 10+: another 84% drop (long phrase tokens)

This means compression cuts filler preferentially. That's probably why we see a small consistent downstream quality improvement when feeding compressed context back to models — the signal-to-noise ratio improves.

What it took to get here
Phase 1 (article 1) was a serialization layer. Caught a CRC32 bug in our own validation before it hit anyone.
Getting from that to a published package with real compression ratios took: figuring out why the pure JS engine lost to brotli on every corpus (it does — the Rust GCdict pipeline is what actually wins), solving the round-trip problem (the raw split format has no inverse without the original buffer — I had to rebuild around the interleaved format), and training a dictionary that generalizes across corpora without overfitting any single one.
The version history on npm reflects that — 3.x was the interleaved pipeline, 4.x settled the API.

Why I built it

I'm building NN Dash, a persistent AI agent scaffold that routes across Claude, GPT, and local Ollama. The goal is to make a long-running AI relationship essentially free. GN is what makes multi-thousand-message context sessions viable without the token bill killing it.
The compression work got an NLNet grant application. The algorithm is solid enough to write up formally.

Use it

npm install gni-compression

const { compress, decompress } = require('gni-compression')
const compressed = await compress(Buffer.from(longContext))
const restored = await decompress(compressed)

Source: github.com/atomsrkull/glasik-core (MIT)
Feedback on the numbers, methodology, or use cases welcome.