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:
Parameters
str
required
The full context string to compress. All five policies receive this exact string as input.
str
required
The current user query. Used by all policies to drive relevance scoring, entity matching, and retention decisions.
float
default:"0.35"
Token retention fraction in
(0, 1]. Applied uniformly across all five policies so that the results are directly comparable.str
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
dict[str, CompressResult]
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.