Documentation 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.
compare_policies is a benchmarking helper that runs all five built-in compression policies against the exact same text and question, then collects the results in a single dictionary. Because every policy operates on identical input at the same budget_ratio, the returned results are directly comparable: you can inspect token retention, KV-cache savings, and compressed output side-by-side without writing any loop yourself. Use this function when you are evaluating which policy best preserves answer quality for a given domain, or when you want to produce a comparison table for a demo or research experiment.
Function signature
Policies compared
compare_policies runs exactly five policies on every call:
| Key | Policy | Description |
|---|---|---|
"FIFO" | FIFO | Drops the oldest tokens first; keeps the most recent budget tokens. |
"Truncation" | TruncationPolicy | Head-and-tail truncation: keeps attention sinks plus the most recent tokens. |
"Summarization" | SummarizationPolicy | Extractive: keeps lines with the highest entity overlap with the question. |
"H2O" | H2OPolicy | Heavy Hitter Oracle: retains attention sinks, a recent window, and top cumulative-attention tokens. |
"SuperCompress" or "H2O-fallback" | LearnedPolicy or H2OPolicy | The trained learned policy from checkpoint. Falls back to H2O if no checkpoint is found. |
Parameters
The full context string to compress. All five policies receive this exact string as input.
The current user query. Used by all policies to drive relevance scoring, entity matching, and retention decisions.
Token retention fraction in
(0, 1]. Applied uniformly across all five policies so that the results are directly comparable.Path to a trained weights file for the
LearnedPolicy. Defaults to the bundled checkpoints/default.pt. If the file is not found, the SuperCompress slot falls back to H2OPolicy and its key becomes "H2O-fallback".Returns
A dictionary mapping each policy name (string) to its
CompressResult. The keys are exactly the policy names listed in the table above. Each value contains the full token statistics, compressed text, and savings percentage for that policy’s run.