Documentation
Start in one line. Go as deep as you need.
Short guides for compressing context, keeping provenance, and fitting chat, retrieval and tool output into a real token budget.
from llmslim import compress
result = compress(chat_history, target_ratio=0.25,
query="Where should the card be shipped?")
print(result.compressed_text) # what the model needs
print(result.tokens_saved) # what you no longer pay forGetting Started
Core Concepts
API Reference
Guides & Strategies
Framework integrations
- LangChainA BaseDocumentCompressor for ContextualCompressionRetriever. Use it where you would use LLMLinguaCompressor.llmslim[langchain]
- LlamaIndexA BaseNodePostprocessor for query engines. Use it where you would use LongLLMLinguaPostprocessor.llmslim[llamaindex]
- HaystackA Haystack 2.x and 3 component that compresses retrieved documents between the retriever and the prompt builder.llmslim[haystack]