Open Source: llmslim – Semantic Prompt Compression for LLM Applications

Published my first open-source Python package: llmslim.

It compresses prompts, chat histories, and RAG contexts using semantic chunking + extractive ranking before sending them to an LLM.

Example:

2847 tokens → 1138 tokens (60% reduction)

Looking for feedback from the HF community on:

  • Evaluation methodology
  • Embedding model choices
  • Retrieval + compression workflows
  • Long-context benchmarking

GitHub - Thanatos9404/llmslim: Shrink LLM prompts by 40-70% while preserving meaning, semantic chunking + extractive summarization · GitHub

Contributions and criticism welcome.

LLMSlim v0.4.0 is out.

This release treats tool definitions as execution contracts, not ordinary prompt text. It adds stable, contract-safe APIs for:

  • adapter views of MCP, OpenAI function, Anthropic, and generic tool shapes
  • deterministic canonical JSON
  • complete-contract SHA-256 fingerprints
  • conservative exact-equivalence verification and schema inspection

The boundary is deliberate: copied raw schemas remain authoritative; cross-provider output is an adapter view, not proof that another provider will accept or authorize it. Ranking never authorizes or executes tools.

We also published the uneventful benchmark result. Phase 4 measured 375 schemas across 18 catalogs; lossless serialization saved 0 tokens (0.00%) because the baseline was already compact canonical JSON. On the frozen retrieval corpus, policies retained high recall by failing open to the full catalog often, and median tokens avoided was zero. Those retrieval modules remain research-only and are never enabled automatically.

Install: pip install llmslim

Release notes: Release LLMSlim v0.4.0 · Thanatos9404/llmslim · GitHub
Tool API guide: llmslim/docs/tool-apis.md at v0.4.0 · Thanatos9404/llmslim · GitHub

I’d particularly value feedback from teams using MCP or multi-provider tool interfaces: where do you need stronger provenance or contract-change checks?