SuperCompress
Benchmarks Agents Blog Changelog Docs Get API key Log in Playground GitHub

SuperCompress Architecture

Last updated July 3, 2026 · 10 min read

How query-aware compression keeps original answer-critical lines and drops junk before inference, a technical deep dive. Measure original_tokens / kept_tokens on your traffic.

Contents

  1. 1. System Overview
  2. 2. The Compression Pipeline
  3. 3. The Learned Policy
  4. 4. Compiler Mode
  5. 5. The Verifier
  6. 6. Deployment Architecture
  7. 7. Comparison with Alternatives

1. System Overview

SuperCompress is a query-aware context compression engine. It sits between your application and the LLM, scores lines of the prompt against the user's question and removes content that scores low on relevance.

Context + Query
↓
Segmenter → Scorer (neural ranking) → Compiler → Verifier
↓
Compressed Context → LLM

The key design choices:

The system is designed for serverless deployment, the local compiler path is a small CPU preprocess suitable for AWS Lambda, Cloudflare Workers, and Vercel Edge Functions. Do not treat a single latency figure as product-wide.

2. The Compression Pipeline

Step 1: Segmentation

The input context is split into semantic segments. Each segment is a coherent unit, a paragraph, a code block, a list item, or a section of a log file. The segmenter uses heuristics (blank lines, indentation, markdown headers, code fence boundaries) to identify natural breaks.

Step 2: Feature Extraction

Each segment is converted into a feature vector that captures:

Step 3: Scoring

The learned policy takes the feature vector and outputs a relevance score (0–1) for each segment. The threshold is adaptive, the policy adjusts its cutoff based on the distribution of scores and the target compression ratio.

Step 4: Assembly

Segments with relevance scores above the threshold are assembled back into compressed context, preserving their original order. The assembly step also handles edge cases: keeping context boundaries legible, re-inserting necessary transition text, and ensuring the output is valid for the downstream LLM.

Key property: extractive and query-aware

SuperCompress keeps original lines chosen against the question and never rewrites or summarizes. The scorer is conservative: when uncertain, it keeps the segment rather than dropping it.

3. The Learned Policy

The policy is a small feed-forward neural network with a learned query-aware neural policy. To put that in context:

Model Parameters Relative size
SuperCompress policy neural 1×
Headroom Content-type stack 33,000×
GPT-2 Small 124M 24,800×
BERT-Base 110M 22,000×
MiniLM-L6 22.7M 4,540×

The small size is intentional. It means:

The policy was trained on a dataset of ~100K (context, query, keep/drop) examples generated from real production prompts across customer support, code generation, data extraction, and Q&A tasks. Training used a contrastive loss that penalizes dropping segments that contain information needed to answer the query.

4. Compiler Mode

In addition to the basic scoring policy, SuperCompress offers a compiler mode that applies a second-pass optimization. The compiler:

  1. Deduplicates, removes repeated information across segments, keeping the most complete version
  2. Strips tool noise, removes boilerplate from tool outputs, stack traces, and logging statements that don't contribute to the answer
  3. Preserves dependencies, if a later segment references an earlier definition, both are kept even if one scores low individually
  4. Reports verification risk, the compiler flags segments where dropping them carries uncertainty, producing a risk score alongside the compressed output

Compiler mode adds a second pass (dedupe, tool-noise strip, dependency keep) and reports verification risk alongside the compressed output. Measure original_tokens / kept_tokens on your traffic. Published suites live on /benchmarks.

5. The Verifier

The verifier is a lightweight post-processing step that checks the compressed output for potential information loss. It answers two questions:

The verifier produces a risk score (low, medium, high) for each compression. Applications can use this score to decide whether to use the compressed output, fall back to the original, or keep the full context.

In practice, most compressions across the benchmark suite receive a low-risk score, and the high-risk cases are typically very short prompts where compression has little room to operate.

6. Deployment Architecture

SuperCompress ships in these forms:

Form Use case Setup
Hosted API Zero-infrastructure compression Get a key at /dashboard
CI / GitHub Actions CI/CD pipeline compression See github.com/Supercompress/Supercompress

The hosted API runs the Neural Keep model and adds automatic scaling, rate limiting, and usage analytics through the dashboard.

For framework-specific setup, see the integrations docs.

7. Comparison with Alternatives

SuperCompress's architecture differs fundamentally from other prompt compression approaches. Here's how:

Method Approach Query-aware Extra LLM call
SuperCompress Query-aware keep/drop scoring Yes No
Headroom Content-type / structure heuristics Type-oriented No
Sliding window Fixed-position truncation No No
Top-K retrieval Embedding similarity Partial No (embedding model)
HyDE Hypothetical doc + retrieval Yes Yes (plus embedding)

For a comprehensive comparison, see the alternatives hub and the full guide.

Try it in the playground → GitHub Get an API key