LIVE · Thursday 3 December

Best Prompt Compression Tools 2026: LLMLingua-2, LongLLMLingua, RECOMP and Hosted APIs by Use Case

Which prompt compression tool fits which job, with verified licences and release dates, the failure case for each, and what compression saves on Claude Sonnet 4.6 once prompt caching is counted.

By Surya7 min read

For general prompts, the best prompt compression tool in 2026 is LLMLingua-2; for RAG, LongLLMLingua, both from Microsoft's MIT-licensed LLMLingua toolkit. Use RECOMP's extractive mode when wording must survive, a verbatim-routing wrapper such as leanctx when traffic mixes prose with code or tool calls, and The Token Company's invite-only API if you want nothing to run. 500xCompressor needs access to the model and suits research only. Independent studies show no tool winning everywhere, no benchmark has yet run all of these tools on the same prompts, models and hardware, and if your prompts repeat, prompt caching should come first.

Start with two questions

Two facts about your traffic decide most of this choice.

The first is length. A study by Kummer and colleagues, posted April 3, 2026 and accepted at ECIR 2026, ran 30,000 queries through LLMLingua and LLMLingua-2 on four models and three hardware classes. It found up to 18% end-to-end speed-ups with statistically unchanged quality, but the largest gains came beyond about 5,000-token prompts. On vLLM or commercial APIs, compression mostly added overhead, and short prompts gained nothing. Below a few thousand tokens, compression is mainly a cost play, not a speed play.

The second is how much of each prompt repeats. Anthropic's docs say cache hits "require 100 percent identical prompt segments," and OpenAI's say "cache reuse requires the entire rendered prefix to match." A compressed prompt that changes per query cannot hit the cache. Anthropic charges $0.30 per million tokens for a Claude Sonnet 4.6 cache read against $3 for fresh input. Whatever repeats should be cached, and only what changes should be compressed.

The tools at a glance

The table lists licences as the repository's licence file shows them on November 17, 2026, and the most recent release or commit.

Tool Type and what it needs Licence Latest release or activity
LLMLingua, LongLLMLingua, LLMLingua-2 Open-source library; small local scorer, works with any API model MIT (licence file) v0.2.2, Apr 9, 2024; commits to Nov 6, 2026
RECOMP Research code; extractive or abstractive compressor for retrieved text MIT (licence file) No releases; last commit Jan 6, 2026
Selective Context Open-source library; GPT-2 scorer README says MIT; no licence file v0.1.0rc1, Dec 26, 2023
500xCompressor KV-level research method; LoRA on LLaMA-3-8B-Instruct, needs model access README says CC BY 4.0; no licence file Last commit Mar 9, 2026
leanctx Open-source SDK wrapping Anthropic, OpenAI, Gemini clients; uses LLMLingua-2 MIT (licence file) v0.3.1, Apr 26, 2026
The Token Company Hosted API, invite-only; works with any model Proprietary service Current model bear-2

Runtime context pruning, which trims old tool output inside agent loops rather than compressing a prompt, is covered separately below.

General prompts: LLMLingua-2

LLMLingua-2 treats compression as token classification: a small encoder, XLM-RoBERTa-large or multilingual BERT, labels each token keep or drop. Its paper reports end-to-end latency down 1.6x to 2.9x at compression ratios of 2x to 5x. Independent work backs its standing. A 2025 study of six methods on 13 datasets, with GPT-3.5-turbo, GPT-4o-mini and Claude-3-Haiku, found "(Long)LLMLingua and LLMLingua-2 generally outperform other methods, especially at high compression ratios," with LLMLingua-2 producing the fewest hallucinations in reconstruction and summarisation. The 2026 latency study found it "reliably adheres to the specified target" ratio, which the original LLMLingua did not on long prompts.

Failure case: short prompts on a fast serving stack, where the compressor's own time cancels the saving, and any structured content left unprotected.

RAG and long documents: LongLLMLingua

LongLLMLingua is query-aware: it keeps the retrieved passages most relevant to the question. Its paper reports that on NaturalQuestions with GPT-3.5-Turbo it "boosts performance by up to 21.4% with around 4x fewer tokens," and the 2025 study found it the strongest method on long-context QA.

Failure case: because its output depends on the query, it breaks any cache on the text it compresses. Keep instructions in a cached prefix and run it only on the retrieved passages.

Exact wording and compliance text: RECOMP extractive

RECOMP compresses retrieved documents before they reach the prompt. Its extractive compressor keeps the top-scoring sentences verbatim; the abstractive one writes a summary. Its paper reports compression to "as low as 6%" of the retrieved text with minimal loss on language modelling and open-domain QA.

Failure case: it ships as research code with no tagged releases and models trained for NQ, TriviaQA and HotpotQA, so expect to train or adapt it for your domain. The abstractive mode rewrites text and should not be used where wording is binding.

Structured data, code and tool calls: protect, don't compress

A March 2026 study by Warren Johnson across 5,400 API calls found that aggressive compression made DeepSeek's output expand 56-fold on the MBPP coding benchmark, and traced such swings to whether task-critical parts of the prompt survived. The fix is routing. leanctx sends code, stack traces and tool calls through a verbatim path, "byte-identical," and compresses only prose with LLMLingua-2; in the project's own LongBench v2 run, layered on top of an existing compressor, it removed an extra 18.7% of tokens for 1.8 points of accuracy. LLMLingua's <llmlingua> tags can exempt a section, and its v0.2.2 release added compress_json.

Failure case: leanctx's first call downloads about 1.2 GB of model weights, and its README says Gemini function-call and multimodal requests bypass compression. How each tool degrades JSON, code or tables on the same models has not been measured.

Hosted, nothing to run: The Token Company

The Token Company, a San Francisco start-up its site says is "backed by Y Combinator," sells a compression API with an aggressiveness setting from 0.0 to 1.0 (default 0.2) and tags to protect "code snippets, structured data," a feature its docs mark experimental. The site claims compression of "typically 10–50%" and "p95 at 150ms"; these are vendor figures.

Failure case: its docs say it is "currently invite-only" and publish no per-token price, so cost cannot be planned in advance, and every prompt leaves your network for a third party (zero data retention is available on request).

Research methods and older libraries: 500xCompressor and Selective Context

500xCompressor packs up to 500 tokens into a single special token using key-value values, at ratios "from 6x to 480x." Its own README reports keeping 62.26% to 72.89% of the model's capability, and its weights are LoRA parameters for LLaMA-3-8B-Instruct. It cannot sit in front of a hosted model.

Selective Context, which scores information content with GPT-2 and cuts the low scorers, did best on reconstruction and conversational data in the 2025 study. It runs locally in front of any model and, unlike 500xCompressor, needs no access to the model's internals. Its repository has had no commits since February 2024 and no licence file, so check terms before commercial use.

Agents: runtime context pruning

In agent loops the bloat is usually accumulated tool output. Anthropic's context editing, in beta, clears the oldest tool results once input passes 100,000 tokens by default, and its docs warn this "invalidates cached prompt prefixes." Parsec's context layer for Claude Code, Codex and opencode trims unused tool output and thinking, and is free to start according to its site. In Parsec's own benchmark of 100 SWE-bench Verified tasks on Claude Sonnet 4.6, its arm cost $89.65 against $147.30 with no compression, and solved 62 tasks against 57. Parsec built and ran the benchmark; the harness is public and can be re-run, but no independent re-run has been published. It covers coding agents only.

Worked example: what compression saves once caching counts

Assume 1,000 RAG requests on Claude Sonnet 4.6 at Anthropic's list prices: $3 per million input tokens, $3.75 per million for a five-minute cache write, $0.30 for a cache read and $15 for output. Each request has a 3,000-token fixed system prompt, 8,000 tokens of retrieved text, a 200-token question and a 400-token answer. Steady traffic means the prefix is written 10 times and read 990 times. Compression is 4x, the ratio LongLLMLingua reports on NaturalQuestions. Compressor compute is excluded.

Setup Input cost Total with $6.00 output
No caching, no compression $33.60 $39.60
Cache the prefix only $25.60 $31.60
Compress whole prompt 4x, no cache $8.40 $14.40
Cache prefix, compress retrieved text 4x $7.60 $13.60

For RAG, compression does the heavy lifting and caching adds a little on top. For a chat assistant with a 20,000-token reference prefix, a 500-token question and a 400-token answer, the order reverses: $67.50 uncached, $14.19 with the prefix cached, and $21.38 compressed 4x without caching. Whether a 4x ratio keeps quality on your corpus has not been measured; test it before you bank the saving.

Bottom line

General prose prompts to any model: LLMLingua-2. RAG: cache the instructions and run LongLLMLingua on the retrieved passages. Legal or compliance text: RECOMP extractive, or no compression. Code, JSON and tool traces: leave them uncompressed, using leanctx or LLMLingua's structured tags. Nothing to host: The Token Company, once you have an invite and a price. Model access and research time: 500xCompressor. Repeated long prefixes: prompt caching alone, which in the chat example above beat compression outright.

Sources

More in Products

All Products →