How SuperCompress works under the hood — the learned policy, feature extraction, training approach, and compiler-mode pipeline that runs in ~60ms on CPU.
Long context + user question
↓
Tokenizer + feature extraction (CPU)
↓
Semantic block segmentation
↓
Block scoring (learned policy)
↓
Duplicate/noise removal
↓
Dependency-preserving packer
↓
Verifier (estimates important context kept)
↓
Compressed evidence prompt → LLM
The entire pipeline from input to compressed output runs in ~60ms on a single CPU core. No GPU, no model download, no extra LLM calls. The policy is small enough to fit in L1 cache.
The core of SuperCompress is a tiny MLP (multi-layer perceptron) called EvictionPolicyNetwork:
| Property | Value |
|---|---|
| Parameters | ~5,200 |
| Architecture | MLP with 1 hidden layer (64 units) |
| Input features | 12-dimensional per-token feature vector |
| Activation | ReLU (hidden), Sigmoid (output) |
| Output | Eviction score per token — lower score = more likely to be kept |
| Inference | Pure NumPy / ONNX / browser JS — no PyTorch required at inference |
| Checkpoint size | ~25 KB (included in pip package) |
This is 25,000x smaller than alternative approaches like Headroom's ModernBERT (165M params). The small size means zero model download time, zero warmup, and instant cold starts.
Each token is represented by a 12-dimensional feature vector:
Features are computed on the fly in Python/NumPy. No tokenizer or model download needed — feature extraction uses lightweight string operations and precomputed tables.
The policy was trained on thousands of question-answering examples spanning code, documentation, logs, prose, and structured data. For each example:
The training objective is a pairwise ranking loss: the policy should assign lower eviction scores (higher importance) to lines that affect the answer. Training takes ~60 seconds on a laptop CPU.
supercompress-train --fast
# Outputs checkpoints/default.pt (~25 KB)
Compiler mode is the production path (and the default on the hosted API). Unlike the fixed-ratio mode, it does not ask users for a budget. Instead it:
The verifier makes compiler mode safe for production. If the verifier detects high risk (too much important context may have been removed), it signals the user to adjust their approach.
The legacy fixed-ratio mode uses a budget (e.g., keep 35% of tokens) and evicts the lowest-scored tokens up to the budget limit. This mode exists for research comparisons and backward compatibility. In production, use compiler mode.
| Compiler mode | Fixed-ratio mode | |
|---|---|---|
| Budget required? | No — maximizes removal safely | Yes — pass budget_ratio |
| Savings | 82.5% avg on bundled presets | Fixed at budget_ratio (e.g., 65%) |
| Risk reporting | Yes — risk level + important-kept % | No — just keeps X% of tokens |
| Block breakdown | Yes — kept/dropped blocks with reasons | No |
| Best for | Production API calls | Research benchmarks |
The same policy runs in the browser via compress-engine.js. After exporting the model weights to JSON:
python scripts/export_model_json.py
# → Creates web/assets/data/model.json
The browser engine uses the identical NumPy-derived numerical computation as the Python version. The feature extraction, scoring, and block segmentation are reimplemented in JavaScript with the same logic, producing the same results.
The browser demo at supercompress.dev/playground runs this engine. No API key needed — compression happens entirely in your browser.
| Module | Role |
|---|---|
supercompress/local.py | Build TokenRecord list from text + query entities |
supercompress/features.py | 12-dim per-token feature extraction |
supercompress/model.py | ~5K-param MLP (EvictionPolicyNetwork) |
supercompress/policies.py | FIFO, Truncation, Summarization, H2O, Learned |
supercompress/compress.py | Public API (compress_context, etc.) |
supercompress/benchmarks/ | Quality metrics + sustainability estimates |
web/assets/js/compress-engine.js | Browser port (identical logic) |