{"repo":"jia-gao/leanctx","free":true,"listed":false,"github":"https://github.com/jia-gao/leanctx","clone":"git clone https://github.com/jia-gao/leanctx.git","description":"Drop-in prompt compression for production LLM apps. Cut your token bill 40-60% without changing your code. Python SDK, LLMLingua-2, MIT.","language":"Python","stars":318,"topics":["anthropic","cost-optimization","gemini","langchain","langgraph","llm","llm-inference","llmlingua","openai","prompt-compression"],"license":"MIT","category":"ai-agents","readme_excerpt":"leanctx Drop-in prompt compression for production LLM applications. Cut your input-token bill by 10–40%，without sacrificing accuracy. On the full LongBench v2 set (N=503), layered on top of a compressor that is already running, leanctx removes an extra 18.7 % of tokens — rising to 36.7 % on prose-heavy traffic — at a cost of 1.8 pp of accuracy. Every figure regenerates from per-item records committed to this repo. Open-source models, runs locally, MIT-licensed. Your prompts and user data never leave your infrastructure by default. Quickstart · What makes it different · Benchmarks · Integrations · How it works --- What makes it different Loss-tolerance routing — classify every segment of a prompt by how much distortion it can survive, then compress each class differently. Class Content Treatment Effect --- --- --- --- Zero tolerance code, stack traces, tool use id , tool name and input, JSON verbatim 0 % altered High tolerance documentation, retrieved passages, logs, prior turns LLMLingua-2, on-device 50 % removed Conditional low-confidence prose, oversized context self-LLM, opt-in 41–49 % removed Compression applied uniformly to a prompt will eventually damage the one part that cannot survive being touched, and will do so unpredictably. The hard part is not shortening text — it is deciding, inside a live request, what may be shortened at all. --- Quickstart (60 seconds) First Lingua call loads 1.2 GB of model weights to /.cache/huggingface/ . Subsequent calls reuse the cache.","default_branch":null,"files":null,"tree":[],"storefront":"/r/jia-gao","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/jia-gao/leanctx/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}