Testing prompt compression in enterprise systems—for a document Q&A use case
This article is based on a probe conducted by Genie, Emumba’s dedicated GenAI R&D group.
LLM prompts are getting longer.
A production prompt may contain system instructions, conversation history, retrieved documents, tool outputs, metadata, and examples. In document-heavy applications, the supporting context can account for most of the input.
Longer prompts increase input-token costs. They may also increase response time and make it harder for a model to identify the most relevant evidence.
Prompt compression offers an intuitive solution: remove tokens that appear unnecessary while preserving the information required to answer the question.
The expected result is a smaller prompt, a cheaper model call, and potentially better reasoning over a more focused context.
But does reducing prompt size actually improve the complete system?
We tested prompt compression in an enterprise-style technical document Q&A pipeline.
Why test prompt compression?
The argument for prompt compression is straightforward.
If a prompt contains repeated, irrelevant, or low-value information, reducing it could provide several benefits:
Lower input-token costs
Faster model inference
More room within the context window
Less distracting information
A clearer signal for the answer-generation model
However, token count is only one property of a prompt.
A long context may contain headings, separators, tables, ordering, and document metadata that help the model understand how individual facts relate to one another. A compressor may remove tokens successfully while also removing these relationships.
We therefore evaluated prompt compression as a system-level change, rather than treating token reduction as an improvement by itself.
We asked three questions:
Does compression preserve answer quality?
Does it improve end-to-end latency?
What additional costs or infrastructure does it introduce?
Our test setup
We used an enterprise-style RAG pipeline containing:
285 technical PDFs
138 technical Q&A queries
Long prompts combining each query with retrieved document context
Automated evaluation against ground-truth answers
The source documents contained product names, model numbers, configuration details, compliance requirements, tables, and version-specific information.
Before retrieval, the PDFs were converted into structured Markdown and divided by document section. Chunks retained information such as headings, section paths, document titles, and links to neighbouring chunks.
Retrieval combined dense vector search with BM25 lexical search. Split sections could also be reassembled so that the answer model received coherent context.
We used:
Meta Llama 4 Scout 17B 16E Instruct for answer generation
GPT-4o as the answer-evaluation judge
The answer model and evaluator remained the same across all compression levels. Only the context supplied to the answer model changed.
We measured:
Prompt tokens
Answer accuracy
Compression time
End-to-end latency
RAG was used because it naturally produced long, document-heavy prompts and provided an objective Q&A evaluation setup. The purpose of this probe was to study context engineering, not to optimize retrieval.
How we compressed the prompts
We explored multiple variants of the LLMLingua prompt-compression framework.
Base LLMLingua had difficulty with larger prompts because of compressor context limits. LongLLMLingua handled longer inputs, but answer accuracy remained around 50–55% in our tests. Compressing the context in separate small pieces also produced vague or incomplete answers because important information was lost within individual pieces.
LLMLingua-2 produced the strongest result, so we selected it for the final comparison.
LLMLingua-2 is a token filter
LLMLingua-2 does not rewrite the prompt as a conventional summary.
It uses a token-classification model to score each token according to how important it appears to be. Lower-scoring tokens are removed until the prompt reaches a specified token budget.
This often retains:
Product names
Technical terms
Numbers
Keywords
At the same time, it may remove:
Connective language
Formatting
Headers
Separators
Repeated context
We tested three target budgets:
Approximately 3,000 tokens
Approximately 2,500 tokens
Approximately 2,000 tokens
The uncompressed prompts averaged approximately 4,800 tokens.
Compression results
|
None | ~4,800 | 0% | 90% | 6.0 seconds |
Low | ~3,000 | ~40% | 80% | 12.8 seconds |
Medium | ~2,500 | ~50% | 78% | 12.7 seconds |
High | ~2,000 | ~60% | 72.5% | 11.1 seconds |
Prompt compression did exactly what it was designed to do at the token level.
Across all 138 queries, total input tokens fell from 669,147 without compression to:
411,639 at the 3,000-token budget
345,272 at the 2,500-token budget
278,271 at the 2,000-token budget
However, the wider system did not improve.
Accuracy declined as compression increased
The uncompressed pipeline achieved 90% answer accuracy.
Even the least aggressive compression reduced accuracy to 80%, a decline of 10 percentage points.
At the strongest compression level, accuracy fell to 72.5%—a decline of 17.5 points.
The relationship was consistent: fewer tokens produced lower answer quality.
End-to-end latency increased
The uncompressed pipeline took approximately six seconds per query.
With compression, total latency rose to between 11.1 and 12.8 seconds.
The compression stage itself added approximately seven to eight seconds of preprocessing. Sending a smaller prompt to the answer model recovered some of this time through faster downstream inference, but not enough to beat the baseline.
The high-compression setting was slightly faster than the low and medium settings because fewer tokens remained for answer generation. However, it was still substantially slower than using no compressor.
Usable compression required GPU resources
The compressor was a model in its own right.
Smaller compression models were faster but had context limits that made them unsuitable for the longer prompts. Larger models handled the context more effectively but were too slow on the available local hardware without GPU acceleration.
Compression therefore reduced the answer model’s input tokens while adding a separate compute requirement earlier in the pipeline.
Why did compression reduce accuracy?
We examined the compressed prompts to understand where information was being lost.
Three patterns appeared repeatedly.
Headers and section separators disappeared
Technical facts often depend on the section in which they appear.
For example, the same operating requirement may have different values for:
Different regions
Different product versions
Different hardware models
Different regulatory standards
A compressor might preserve the value and technical keywords while removing the heading that explains which case the value belongs to.
The remaining text looks relevant but becomes ambiguous.
Separate documents and sections blended together
The original RAG context preserved boundaries between retrieved passages.
After compression, content from different documents or sections was often presented as one continuous stream. This made it harder for the answer model to determine which statements belonged together and which source applied to the question.
In a corpus containing similar products and overlapping specifications, these boundaries are important.
Tables lost their anchor structure
Tables encode meaning through rows, columns, headers, and alignment.
Token filtering may retain individual values while removing the labels or formatting that define what those values represent.
A number without its row or column heading may no longer be useful evidence.
The link between chunking and compression
In an earlier probe, we found that layout-aware parsing and section-based chunking materially improved accuracy for the same technical-documentation use case.
That pipeline deliberately preserved:
Section hierarchy
Local context
Tables
Document boundaries
Product-specific qualifiers
Prompt compression often removed exactly these signals.
This reveals an important tension.
The retrieval pipeline invested effort in producing coherent, structurally meaningful context. The compression stage then treated that context primarily as a collection of independently removable tokens.
The result was a shorter prompt, but also a less interpretable one.
A prompt is not valuable only because it contains the correct keywords. The relationships between those keywords also carry information.
Did compression reduce cost?
It reduced one category of cost: the number of input tokens sent to the answer-generation API.
A reduction of 40–60% can materially lower API charges when input-token volume is high.
However, the complete cost picture also included:
Running the compression model
Provisioning GPU resources
Additional preprocessing latency
Operating another model and pipeline component
Accuracy lost through compression
In this setup, compression shifted costs rather than eliminating them.
The system exchanged answer-generation API tokens for local or cloud compute, additional latency, and lower answer quality.
Whether that trade-off is worthwhile depends on the application.
When might prompt compression still be useful?
The results do not mean prompt compression is never valuable.
It may be appropriate when:
The original input does not fit within the model’s context window
Input-token costs dominate the economics of the system
The workload is asynchronous and additional latency is acceptable
Some loss of accuracy is acceptable
The context contains substantial redundancy
The compression method can preserve document and data structure
Evaluation shows that critical information survives
Other forms of context reduction may also behave differently. A system could remove entire irrelevant documents, summarize conversation history, cache repeated instructions, or compress only selected sections rather than filtering every token uniformly.
The choice should be validated against the actual task and corpus.
Key takeaway
Prompt compression reliably reduced token usage in our experiment, but it did not produce better LLM performance.
In our technical-documentation Q&A system, it:
Reduced prompt tokens by up to 60%
Lowered answer accuracy by 10–17.5 percentage points
Increased end-to-end latency from 6 seconds to 11.1–12.8 seconds
Required GPU resources for practical execution
The central lesson is:
Reducing context size is not automatically an optimization.
The quality of a prompt depends not only on how many tokens it contains, but also on whether it preserves the structure, boundaries, and relationships the model needs to interpret the evidence.
Prompt compression should therefore be evaluated as a system-level design choice—not adopted by default because the resulting prompt is smaller.