Input tokens generally contribute to your API bill, so sending more context than the model needs can increase cost without a corresponding improvement in the answer. Prompt compression is one form of context reduction: it shrinks the amount of input content sent to the model while trying to preserve the information needed for the task. This guide covers how prompt compression actually works, what a real tool like LLMLingua does under the hood, and where compression fits alongside the other input-reduction techniques you might already be using.
Key takeaways
Prompt compression reduces the token count of an LLM input while trying to retain the semantic content the model actually needs to produce a correct response. Here, "quality" means task performance relative to the uncompressed prompt, whether that's measured as accuracy, an exact-match score, or task success, rather than a single universal metric. Since the tokens being reduced are specifically the context tokens sent as input, this token compression generally lowers cost, because LLM pricing typically scales with token count: a prompt that's meaningfully shorter usually costs less to send. Understanding this connects directly to the packet.ai Context Window Cost guide, since compression is one concrete lever for keeping what actually gets sent smaller, rather than just being mindful of the window available, and can also help avoid context overflow on requests that would otherwise run close to a model's limit.
Compression approaches split into two broad categories. Lossy compression, which is what most production tools including LLMLingua use, actually removes tokens, accepting some risk of losing information in exchange for a real, often substantial reduction in size. Lossless approaches instead aim to represent the same content more compactly without removing anything, an active but less mature area of research by comparison. Related techniques worth distinguishing by name: context pruning generally refers to removing entire irrelevant sections rather than scoring individual tokens, while prompt distillation describes training a smaller model to reproduce a larger prompt's effect more compactly. All of these share the same underlying goal of finding a way to reduce prompt tokens without losing what the model actually needs from them.
LLMLingua, developed by Microsoft Research, is a prompt compression approach, and its mechanism is a useful concrete example of how lossy compression works in practice. It uses a small language model to calculate the perplexity of each token in a prompt, a measure of how predictable or informative that token is in context. Tokens with low perplexity contribute comparatively little new information and can generally be removed with less impact on the model's overall understanding than removing a high-perplexity token would have.
Three components work together in this process. A budget controller allocates how aggressively to compress different segments of a prompt, instructions, examples, and the actual question, preserving more tokens in the sections most sensitive to loss. Iterative token-level compression accounts for the fact that tokens can become more or less removable depending on what's already been removed around them, since a token that looks redundant in isolation may turn out to matter once its surrounding context has already been cut. Distribution alignment fine-tunes the small scoring model against the target LLM's own token patterns, which improves the quality of what gets kept versus removed for that specific model.
⚡ Reported compression ratios are benchmark-specific, not universal
Microsoft's own published research on LLMLingua reports up to 20x compression with minimal performance loss on specific benchmarks (GSM8K, BBH, ShareGPT, and Arxiv-March23, covering reasoning, in-context learning, conversation, and summarization). On one reasoning benchmark specifically, the reported loss at that 20x ratio was about 1.5 points on the evaluation metric used, not a general "under 2 percent" figure across all tasks. These are real, published results, not marketing claims, but they reflect particular tasks and content types tested in that research, not a guarantee that any given prompt will compress that aggressively with equally minimal loss. Prose-heavy, redundant content, such as retrieved documents in a RAG pipeline, tends to compress well precisely because it contains more genuinely low-information tokens to begin with.
The savings from prompt compression aren't free: compression itself requires computation, since a tool like LLMLingua runs a separate small language model to score and select which tokens to remove before the compressed prompt ever reaches the target model. The real economic comparison is the cost of running the compressor plus the cost of the now-shorter request, set against the cost of simply sending the original, uncompressed request. For a short prompt, that compressor overhead can outweigh the savings from a modest reduction in size. For a large, redundant prompt, particularly a long RAG context sent repeatedly, the tokens removed can far exceed the compressor's own overhead, making the economics genuinely favorable. The size and redundancy of what's being compressed, not just the existence of a compression step, determines whether it's actually worth doing.
Content type matters more than most other factors in how safely a prompt can be compressed. Prose-heavy, naturally redundant content, retrieved documents, verbose explanations, repeated boilerplate, tends to compress well, since a meaningful share of its tokens genuinely carry little unique information relative to the rest. This is part of why retrieval-augmented generation pipelines are often cited as a particularly good fit for compression: retrieved passages frequently contain far more context than a specific query actually needs.
Highly structured content compresses far less safely. Precise code, exact mathematical notation, and structured data formats often have little genuine redundancy, and a token that looks removable to a general-purpose compression model may be load-bearing for correctness in ways that aren't obvious without deep domain understanding. Compressing this kind of content aggressively risks silently breaking it rather than degrading gracefully, which is a meaningfully worse failure mode than simply losing some nuance in a paragraph of prose.
Compression and caching solve genuinely different problems, and it's worth being precise about the distinction rather than treating them as competing options for the same job. The packet.ai Prompt Caching guide covers caching's actual mechanism: discounting the cost of content that's identical across multiple requests, a stable system prompt or a shared document, by reusing previously computed results rather than reprocessing them from scratch.
Compression works regardless of whether content repeats across requests; it shrinks a given prompt's token count on its own terms, once, whether that prompt is sent a single time or thousands of times. The two techniques are complementary rather than substitutes: a stable, frequently repeated system prompt benefits most from caching, since the discount compounds every time it's reused, while a compressed prompt still pays the full uncached rate on whatever tokens remain after compression, just fewer of them. A pipeline that both compresses variable content and caches genuinely stable content addresses two different sources of token cost at once, and combining the two is a reasonable default rather than an either-or choice.
Since compression operates on the input side of a request regardless of which model ultimately processes it, the practical benefit applies whether you're calling a hosted API or running your own infrastructure, keeping in mind the compressor overhead discussed above. Understanding where input cost actually comes from is covered more broadly in the packet.ai LLM inference cost guide. packet.ai's Token Factory bills per token, so a genuinely compressed prompt directly reduces what a request costs, without needing separate infrastructure to realize that saving. It's currently in private preview, with the specific model catalog and pricing still being finalized.
Join the waitlist for early access once it opens.
Last reviewed: September 9, 2026. For the broader token-cost mechanics compression is designed to reduce, see the packet.ai LLM inference cost guide. For the complementary technique of discounting repeated content, see the Prompt Caching guide.
Same models. Same API. Fraction of the cost. Start free — no credit card required.
Start Building →