Debuly

LLMLingua

Microsoft research toolkit for compressing long LLM prompts, cutting token counts, API cost and latency with little loss of meaning.

Open source

What is LLMLingua?

LLMLingua is a series of prompt compression methods from Microsoft researchers. Long prompts built from chain-of-thought examples, retrieved documents or meeting transcripts can run to tens of thousands of tokens, which raises latency and API bills and can push content out of the context window. LLMLingua uses a small language model to measure which tokens carry little information and drops them, so the larger model reads a shorter prompt. The authors report up to 20x compression with little performance loss. The series also includes LongLLMLingua, which compresses with the question in mind for long contexts and reported a 17.1% improvement at 4x compression, and LLMLingua-2, a BERT-sized classifier trained by distilling GPT-4 that runs 3x to 6x faster. The project is published as code, papers, demos and case studies for RAG, meetings, reasoning and code, and it has been integrated into LangChain and LlamaIndex. No pricing is listed, and you pay only for your own compute and model API.

Use cases

  • Compress retrieved passages in RAG pipelines
  • Shorten meeting transcripts before summarizing
  • Reduce token spend on LLM API calls
  • Fit long documents into a context window
  • Trim chain-of-thought example prompts
  • Speed up long-context inference
  • Compare prompt compression methods

Who it's for

  • ML engineers
  • LLM researchers
  • RAG builders
  • Python developers

Why use LLMLingua

  • Shorter prompts mean fewer billed tokens on each call to a paid LLM API.
  • Smaller inputs lower response latency and help long prompts fit inside a context window.
  • Question-aware compression keeps the passages that matter for the query, which helps with the lost-in-the-middle problem.
  • LLMLingua-2 is a small model, so compressing a prompt adds little delay of its own.
  • Open papers and examples let you inspect and reproduce how the compression works.

LLMLingua features

  • LLMLingua: coarse-to-fine token pruning guided by a small model's perplexity
  • Budget controller that sets different compression rates for different prompt segments
  • LongLLMLingua: question-aware compression and reordering for long contexts
  • LLMLingua-2: task-agnostic compression framed as token classification
  • Compressor models built on XLM-RoBERTa-large and mBERT encoders
  • Integrations with LangChain and LlamaIndex
  • Online demos for LLMLingua-2 and example scripts for RAG, meetings, chain-of-thought and code
  • Evaluated on GSM8K, BBH, ShareGPT, Arxiv-March23, MeetingBank, LongBench and ZeroScrolls

LLMLingua integrations

  • LangChain
  • LlamaIndex

How to get started with LLMLingua

  1. Choose the variant for your task: LLMLingua, LongLLMLingua for long contexts or LLMLingua-2 for general use.
  2. Try the online demo to see which parts of a sample prompt are removed.
  3. Install the library from the linked code repository into your Python environment.
  4. Load a compressor model, pass in your prompt or retrieved passages and set a target compression rate.
  5. Send the compressed prompt to your chosen LLM and compare answer quality with the original.

LLMLingua limitations

  • It is a code library for your own pipeline, not a hosted app
  • Higher compression ratios trade away some completeness, so check output quality on your own data
  • Documentation is mostly research papers and project pages

LLMLingua pricing

LLMLingua is open source, so you can use and self-host it for free.

Prices can change and may vary by country or exclude tax. Check the official pricing page.

LLMLingua alternatives

The main LLMLingua alternatives listed on Debuly are Headroom, LangChain, LlamaIndex, Repomix, HandyAI and OpenLIT. The table compares pricing and platforms; order is A–Z.

LLMLingua compared with its alternatives
ToolPricingStarting pricePlatforms
LLMLinguaOpen source——
HandyAIFree—Web
HeadroomOpen source—Python, TypeScript, CLI, Docker
LangChainFreemium$39/moWeb, API, Self-hosted
LlamaIndexFreemium$50/moWeb, API, Self-hosted
OpenLITOpen source—Web, CLI, API, Self-hosted
RepomixOpen source—CLI, Web, Chrome extension, Docker
  1. HandyAI

    Free in-browser utilities for LLM builders, led by a side-by-side token counter and an API cost calculator.

  2. Headroom

    Open-source context compression for LLM apps and coding agents that trims tool output, logs, files and RAG results before the model reads them.

  3. LangChain

    Open-source framework for building LLM agents, paired with LangSmith for tracing, evals and agent deployment.

  4. LlamaIndex

    Open-source framework plus the LlamaParse platform for parsing, extracting and indexing documents so LLM apps can use them.

  5. OpenLIT

    Open-source, OpenTelemetry-native platform for tracing, evaluating and guarding AI agents, with cost and GPU monitoring

  6. Repomix

    Open-source tool that packs a whole code repository into one AI-friendly file with token counts and secret checks.

LLMLingua FAQ

Is LLMLingua free?

The project page publishes code, papers and demos and lists no plans or prices. You pay only for the compute you run it on and for any LLM API that receives the compressed prompts.

How much can LLMLingua compress a prompt?

The authors report up to 20x compression with minimal performance loss for LLMLingua. They report a 17.1% performance gain at 4x compression for LongLLMLingua on long-context tasks.

What is the difference between LLMLingua, LongLLMLingua and LLMLingua-2?

LLMLingua prunes tokens using a small model's perplexity. LongLLMLingua adds question-aware compression for long contexts. LLMLingua-2 learns what to keep through data distillation, and is described as 3x to 6x faster than LLMLingua.

Does LLMLingua work with LangChain or LlamaIndex?

Yes. The project states that LangChain and LlamaIndex, both widely used RAG frameworks, have integrated it, and the examples include RAG with LlamaIndex.

Who is LLMLingua for?

It suits engineers and researchers who run their own LLM applications and want lower token cost or latency, particularly RAG, long-document and meeting-summary workloads.

What are alternatives to LLMLingua?

Alternatives include context-trimming tools such as Headroom, summarizing or reranking steps in LangChain and LlamaIndex, and repository packers such as Repomix, which shorten what a model has to read in different ways.

Sources & verification

Facts on this page come from the official sources below, each with the date we read it. Written by Debuly; the vendor did not review this page.

SourceTypeAccessed
llmlingua.com/official
llmlingua.com/llmlingua.htmlofficial
llmlingua.com/llmlingua2.htmlofficial

Image credits

  • Logo: none collected yet, so a monogram is shown.
  • Cover: none collected yet, so a generated tile is shown.

Spot an error? Report an issue with this listing. We also remove a logo or image on the owner's request.