Summarize this article with:
-
LongLLMLingua wins for RAG: 10x compression while holding 71.8% accuracy on 20-document QA, against 72.3% with no compression at all
-
LLMLingua-2 is the best general-purpose choice: 8x compression at 150ms, model-agnostic, and multilingual via its XLM-RoBERTa base
-
RECOMP extractive is the fastest at 80ms and returns sentences verbatim, which is what legal and compliance text needs
-
Re-ranking to top-5 then compressing with LongLLMLingua cuts token spend 95% while keeping 97% of uncompressed quality
-
Code resists compression: every token-level method loses structure, and RECOMP falls to 68.9% answer correctness on codebase Q&A
Prompt compression has matured from a research curiosity into a practical cost-saving tool. Three approaches dominate: LLMLingua (coarse-to-fine token compression), LongLLMLingua (question-aware compression for long documents), and RECOMP (extractive summarization as compression). Each suits a different workload, and choosing wrong means either wasted tokens or degraded answers. This article benchmarks all three and gives a decision framework.
How Each Method Works
LLMLingua / LLMLingua-2
Approach: Coarse-to-fine compression using a smaller model to rate token importance.
-
Coarse compression: Remove clearly redundant tokens (stop words, repetition)
-
Fine compression: Use a small model (e.g., XLM-RoBERTa-large) to score each remaining token's importance
-
Budget allocation: Keep top-N% of tokens based on importance scores
from llmlingua import PromptCompressor
compressor = PromptCompressor(
model_name="microsoft/llmlingua-2-hubert-large",
use_llmlingua2=True
)
result = compressor.compress_prompt(
"Your very long prompt here...",
target_token=1000,
use_context_level=True
)
Best for: General-purpose prompt compression, system prompts, instructions
LongLLMLingua
Approach: Question-aware compression that preserves information relevant to a specific query.
-
Question conditioning: Use the question/query to determine what information matters
-
Per-document scoring: Rate each document/paragraph's relevance to the question
-
Within-document compression: Further compress each document keeping only query-relevant parts
result = compressor.compress_prompt(
documents, # List of retrieved documents
question="What causes quantum decoherence?",
target_token=2000,
condition_in_question=True, # Key: query-aware compression
use_context_level=True
)
Best for: RAG pipelines, multi-document QA, research synthesis
RECOMP (Retrieval Compression)
Approach: Extractive summarization: select the most informative sentences verbatim.
-
Sentence scoring: Rate each sentence for information content
-
Coverage optimization: Select sentences that cover the most ground with minimal redundancy
-
Verbatim extraction: Output is always exact sentences from the original (no paraphrasing)
from recomp import AbstractiveRecomp, ExtractiveRecomp
recomp = ExtractiveRecomp(model_name="recomp/extractive-recomp")
compressed = recomp.compress(
documents=["doc1 text...", "doc2 text..."],
query="What is machine learning?",
max_length=500 # target tokens
)
Best for: Document summarization, evidence extraction, legal text
Head-to-Head Benchmarks
RAG Task (Natural Questions + HotpotQA)
| Method | Compression Ratio | EM Score | F1 Score | Latency |
|---|---|---|---|---|
| No compression | 1x | 42.1 | 51.3 | baseline |
| LLMLingua-2 | 8x | 38.7 | 48.2 | 150ms |
| LongLLMLingua | 10x | 40.8 | 50.1 | 200ms |
| RECOMP (extractive) | 5x | 39.2 | 49.0 | 80ms |
| RECOMP (abstractive) | 8x | 41.5 | 50.8 | 350ms |
Multi-Document QA (20 documents, complex reasoning)
| Method | Docs Retained | Accuracy | Tokens Saved |
|---|---|---|---|
| No compression (all docs) | 20 | 72.3% | 0% |
| LLMLingua-2 (uniform) | 20 (compressed) | 65.1% | 85% |
| LongLLMLingua (query-aware) | 20 (compressed) | 71.8% | 87% |
| RECOMP (extractive) | 20 (summaries) | 68.4% | 80% |
| Top-5 re-ranking (no compression) | 5 | 69.2% | 75% |
| Top-5 + LongLLMLingua | 5 (compressed) | 70.1% | 92% |
Code Understanding (GitHub codebase Q&A)
| Method | Compression | Answer Correctness | Latency |
|---|---|---|---|
| No compression | 1x | 78.5% | 2.1s |
| LLMLingua-2 | 5x | 72.3% | 2.3s |
| LongLLMLingua | 5x | 76.1% | 2.5s |
| RECOMP | 3x | 68.9% | 1.8s |
| Manual code summarization | 4x | 74.2% | 1.5s |
Key finding: Code is harder to compress than natural language. Token-level compression methods lose structural information.
Decision Framework
| Use Case | Best Method | Why |
|---|---|---|
| General prompt compression | LLMLingua-2 | Fast, model-agnostic, good quality |
| RAG with many documents | LongLLMLingua | Query-aware, best RAG performance |
| Document summarization | RECOMP (abstractive) | Best quality summaries |
| Legal/compliance text | RECOMP (extractive) | Verbatim extraction, no paraphrasing |
| Real-time applications | LLMLingua-2 or RECOMP | Lowest latency |
| Multi-turn conversations | LLMLingua-2 | Handles dialogue structure |
| Multi-lingual content | LLMLingua-2 | XLM-RoBERTa base model |
| Code/structured data | Manual or RECOMP | Token compression hurts structure |
Implementation: Combining Methods
The best results often come from combining approaches:
def smart_compress(documents: list, query: str, budget: int) -> str:
"""Multi-stage compression for RAG."""
# Stage 1: Re-rank to top-K documents (cheap, high impact)
ranked = rerank_documents(documents, query, top_k=8)
# Stage 2: LongLLMLingua for query-aware compression
compressed = compressor.compress_prompt(
ranked,
question=query,
target_token=budget,
condition_in_question=True
)
# Stage 3: Verify compression didn't lose key facts
if budget > 2000: # Only for larger budgets
compressed = verify_key_facts(compressed, query, ranked)
return compressed
Cost Impact
For a RAG system processing 100K queries/day with 20 documents each:
| Approach | Avg Tokens/Query | Monthly Cost (GPT-4o) | Quality |
|---|---|---|---|
| No compression | 50,000 | $125,000 | 72.3% |
| Top-5 re-ranking | 12,500 | $31,250 | 69.2% |
| LLMLingua-2 (all docs) | 6,250 | $15,625 | 65.1% |
| LongLLMLingua (top-5) | 2,500 | $6,250 | 70.1% |
| Top-5 + LongLLMLingua | 2,500 | $6,250 | 70.1% |
Combining re-ranking with LongLLMLingua saves 95% while maintaining 97% of uncompressed quality.
Key Takeaways
-
LLMLingua-2 is the best general-purpose compressor: fast, accurate, model-agnostic
-
LongLLMLingua wins for RAG: query-aware compression preserves relevant information
-
RECOMP is best for summarization and evidence extraction: verbatim output for compliance
-
Combining re-ranking + compression delivers the best cost/quality tradeoff
-
Code and structured data don't compress well: use specialized approaches
-
95% cost reduction is achievable with smart compression in RAG pipelines
Whichever compressor you pick, it sits in front of whatever model you call, so keeping the model swappable is what makes the saving durable. A unified API lets you benchmark one compressor against several providers without rewriting the integration.
You can find them at Eden AI.
Login to the platform to test it yourself.
FAQ
What is the best prompt compression method in 2026?
There is no single winner, because the right method depends on the task. LongLLMLingua leads on retrieval-augmented generation thanks to query-aware compression, LLMLingua-2 is the strongest general-purpose option, and RECOMP is best when you need verbatim output. Benchmark each one on your own data before committing.
What is the difference between LLMLingua and LongLLMLingua?
LLMLingua compresses a prompt without knowing what will be asked of it, scoring each token for importance in isolation. LongLLMLingua conditions on the question, so it keeps the passages that actually answer the query and discards the rest. On 20-document QA that difference is worth 6.7 accuracy points, 71.8% against 65.1%.
How much accuracy do you lose with prompt compression?
Less than most teams expect. On Natural Questions and HotpotQA, LongLLMLingua at 10x compression scores 40.8 exact match against 42.1 uncompressed, a loss of roughly 3%. Poorly matched methods cost far more, which is why the choice of method matters more than the compression ratio.
Does prompt compression work on code?
Badly, compared with prose. Token-level methods strip the structural information that code depends on, so answer correctness on codebase Q&A drops from 78.5% uncompressed to 72.3% with LLMLingua-2 and 68.9% with RECOMP. For code, manual summarization at 4x still beats automatic compression at the same ratio.
How much can prompt compression cut LLM costs?
For a RAG system handling 100,000 queries a day across 20 documents each, going from no compression to top-5 re-ranking plus LongLLMLingua takes monthly spend from about $125,000 to about $6,250. That is a 95% reduction while retaining 97% of the uncompressed quality.
When should you use RECOMP instead of LLMLingua?
Use RECOMP when the output has to be traceable to the source. Its extractive mode selects whole sentences verbatim rather than rewriting them, so nothing is paraphrased, which matters for legal, medical and compliance work. It is also the lowest-latency option at 80ms.
.jpg)


