SuperCompress ships with a pretrained checkpoint atDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/arjunkshah/supercompress/llms.txt
Use this file to discover all available pages before exploring further.
checkpoints/default.pt so you can run compression immediately after install. When you want to experiment with the eviction policy itself — tweaking the training data, the network architecture, or the feature set — you can re-train the EvictionPolicyNetwork from scratch. The model is deliberately small (~5K parameters) so a fast training run completes in around 30 seconds on CPU.
CLI training commands
Thesupercompress CLI exposes a train subcommand. By default it runs the fast mode; pass --full for a longer training run:
What the train script does
scripts/train_checkpoint.py runs the full training loop without any external dataset:
Generate synthetic training data
generate_long_context() from supercompress.simulator produces varied context blocks (200–500 tokens each) paired with questions. build_token_records() labels each line as oracle-important or not.Build feature tensors
build_feature_tensor() from supercompress.features converts each labeled record into a fixed-length feature vector of dimension FEATURE_DIM. Sequences are zero-padded to the batch maximum.Train the network
EvictionPolicyNetwork (a small MLP with hidden_dim=64) is optimised with AdamW. Loss is BCEWithLogitsLoss applied only to non-padded positions via a mask, then averaged.Export model weights for the browser demo
The browser playground atweb/index.html runs inference entirely client-side using the serialised model weights. After training, export them to JSON:
checkpoints/default.pt, iterates the EvictionPolicyNetwork layers, and serialises each Linear and LayerNorm as plain JSON arrays. The output includes feature_dim, hidden_dim, layers, and policy_name.
export_model_json.py will exit with an error if checkpoints/default.pt does not exist. Run supercompress train first if you have deleted or never generated the checkpoint.Run the policy demo
Thedemo subcommand runs examples/demo_compare.py, which prints a side-by-side comparison of FIFO truncation and SuperCompress on a demonstration context:
Regenerate benchmarks and charts
The JSON data files and SVG charts consumed by the landing page can be regenerated with two scripts:web/assets/data/benchmarks.json. The chart script reads that file and writes chart-kv-savings.svg, chart-oracle-recall.svg, and chart-impact.svg.
Running tests
| Suite | What it tests |
|---|---|
test_supercompress.py | Core compress_context, compare_policies, CompressResult |
test_api_hard.py | Hard API validation edge cases |
test_api_keys.py | Key generation and hashing |
test_api_server.py | FastAPI routes |
test_local_server.py | Full local server integration (requires [serve]) |
test_local_server.py spins up the full FastAPI application using httpx.AsyncClient. It requires the serve extra (pip install -e ".[serve]"); it is skipped automatically if that extra is absent.