Long Context Costs You Twice, and Most of It Is Filler
You pay per token to send it, and you pay in latency for every token the model has to read before it can answer. The LLMLingua line of work (Jiang et al., 2023) showed you can compress a prompt 2 to 5x by dropping the tokens a language model finds highly predictable, the ones that add length without adding information, while keeping the ones that carry the actual content.
contextpack implements that with a transparent scoring proxy instead of a real perplexity model. Function words and repeated phrases score low and go first. Numbers and specific terms score high and stay. No model, no network, and every rule is a few lines you can read start to finish.
Compression Without a Recall Check Is a Vanity Metric
Hitting a target ratio is easy. You can get to 10% of the original length by keeping ten random words. Keeping the facts an answer actually depends on is the real job, so this ships a benchmark that checks exactly that: keyword recall against the specific numbers, names, and terms a set of questions needs answered correctly.
The Knee in the Curve Is the Real Number
Compress a realistic document at ratios from 100% down to 15% and watch recall hold steady, then drop. That knee, not "how small can I make this," is the number that actually matters, and it is right there in the output instead of hidden behind a single hand-picked setting.
The Number
On a 145-word document with 10 load-bearing keywords, you can compress to 50% of the original, saving 73 tokens, and keep every single one of them. Push past that knee and recall degrades gracefully, from 100% down to 80% and then 70% as compression gets aggressive, instead of falling off a cliff without warning.
10 tests pass in CI across Python 3.9, 3.11, and 3.13.