llmlingua
To speed up LLMs' inference and enhance LLM's perceive of key information, compress the prompt and KV-Cache, which achieves up to 20x compression with minimal performance loss.
Decision gist · record as of 2026-08-14
Yes. The package solves a real problem—token costs and context limits—with active maintenance, low install friction, and permissive licensing. It integrates cleanly into existing LLM workflows and has been adopted by major frameworks. Install if you work with LLM APIs or long-context tasks and want to reduce costs or fit within token constraints.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python >=3.8.0 and a compatible version of torch and transformers; model weights are downloaded on first use.
- Low friction install with a pure Python wheel.
- The package depends on transformers, torch, accelerate, and other standard ML libraries—all widely maintained.
License · maintenance · safety
MIT License (permissive) — MIT License permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations.
last release 2024-04-09 (857 days) · last repo commit 2026-04-08 · 6,559 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 95,983 downloads/mo, #13,238 on PyPI
Alternatives
Verify before relying
pip install llmlingua
from llmlingua import PromptCompressor
llm_lingua = PromptCompressor()
compressed = llm_lingua.compress_prompt(
prompt="your prompt here",
instruction="",
question="",
target_token=200
)- Whether the package works offline after initial model download or requires network access for inference.
- Memory footprint and GPU requirements for different compression methods (LLMLingua vs. LongLLMLingua vs. LLMLingua-2).
- Compatibility with specific LLM APIs (OpenAI, Anthropic, etc.) beyond the examples shown.
What it is and what it does
LLMLingua is a prompt compression toolkit that uses a small, efficient language model to identify and remove non-essential tokens from prompts before sending them to larger LLMs. It implements three variants—LLMLingua, LongLLMLingua (for long-context scenarios), and LLMLingua-2 (faster, distilled from GPT-4)—each designed to reduce token consumption while preserving task performance. The core use case is lowering costs and latency when working with token-metered LLM APIs or handling long contexts that would otherwise exceed model limits.
The package integrates with popular RAG frameworks like LangChain and LlamaIndex, making it straightforward to drop into existing pipelines. It depends on transformers, torch, accelerate, tiktoken, nltk, and numpy—standard ML infrastructure. The project is actively maintained by Microsoft researchers, with recent releases and integration into production systems.
Use it for
- Reduce API costs when calling GPT-4 or GPT-3.5 by compressing prompts before submission.
- Handle long documents in RAG systems by compressing retrieved context to fit within token budgets.
- Mitigate the 'lost in the middle' problem in long-context LLM tasks by prioritizing key information.
- Accelerate inference latency by reducing KV-cache size and prompt processing overhead.
- Preserve in-context learning and chain-of-thought reasoning while shrinking prompt size.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package solves a real problem—token costs and context limits—with active maintenance, low install friction, and permissive licensing. It integrates cleanly into existing LLM workflows and has been adopted by major frameworks. Install if you work with LLM APIs or long-context tasks and want to reduce costs or fit within token constraints.
Install
llmlingua on PyPI
Before you install
Low friction install with a pure Python wheel. The package depends on transformers, torch, accelerate, and other standard ML libraries—all widely maintained. Maintenance is active with recent commits and a healthy star count.
Requires Python >=3.8.0 and a compatible version of torch and transformers; model weights are downloaded on first use.
License in practice
MIT License permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations.
Quickstart
pip install llmlingua
from llmlingua import PromptCompressor
llm_lingua = PromptCompressor()
compressed = llm_lingua.compress_prompt(
prompt="your prompt here",
instruction="",
question="",
target_token=200
)
Verify before relying
- Whether the package works offline after initial model download or requires network access for inference.
- Memory footprint and GPU requirements for different compression methods (LLMLingua vs. LongLLMLingua vs. LLMLingua-2).
- Compatibility with specific LLM APIs (OpenAI, Anthropic, etc.) beyond the examples shown.
Package facts
| License | MIT License permissive |
| Python support | Supports the current Python release >=3.8.0 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 6 packagestransformersacceleratetorchtiktokennltknumpy |
| Maintenance | Actively maintained 857 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 95,983 / month, #13,238 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 3 - AlphaIntended Audience :: Science/ResearchProgramming Language :: Python :: 3Topic :: Scientific/Engineering :: Artificial Intelligence |
Evidence: llmlingua-0.2.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “prompt compression for llms”
- llmlinguaLLMLingua compresses prompts by identifying and removing…
- garakGarak is a command-line tool that probes large language models for…
- cohere-melodyParses and renders templated text for Cohere language models,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to call 100+ LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Azure, and others) using OpenAI-compatible API format, available as both a Python SDK and a self-hosted AI Gateway proxy server.
Install it if you need to work with multiple LLM providers or want to centralize LLM routing in your organization.
Client library and CLI tool for downloading, uploading, and managing models, datasets, and repositories on the Hugging Face Hub platform.
Install it if you work with Hugging Face Hub models or datasets.
LangChain provides a framework for building agents and LLM-powered applications by composing language models, tools, and memory through a unified API that abstracts over multiple model providers.
hf-xet provides chunk-based deduplication and efficient file transfer for the Hugging Face Hub, enabling faster uploads and downloads of large files with local disk caching.
Tokenizers converts raw text into token sequences for NLP models, with support for training custom vocabularies and using pre-built tokenizers (BPE, WordPiece) optimized for speed via Rust.
Transformers provides a unified framework for loading, fine-tuning, and running state-of-the-art pretrained models across text, vision, audio, video, and multimodal tasks using PyTorch, JAX, or TensorFlow.
Install it if you need to run or train any transformer-based model for NLP, vision, audio, or multimodal tasks.
See also headroom-ai · fhlmi · pymupdf4llm · llama-index · llama-index-vector-stores-faiss · llm · gepa · tokencost · fla-core · lmcache