Feedback on a Trimwise context-compression integration

Hi everyone, I’m exploring a standalone langchain-trimwise package and would like feedback on whether the approach would be useful in LangChain pipelines.

Trimwise is an MIT-licensed context trimmer. It selects query-relevant spans from the original text, returns source indices and character offsets, and can share a budget across multiple documents. The default lexical path runs without model weights or inference; embeddings are optional for semantic/hybrid ranking.

LLMLingua also does extractive compression, generally by pruning tokens. Trimwise focuses on selecting source spans with traceable provenance. I’d be interested in where that tradeoff is useful for retrieval workloads.

The repo’s benchmarks measured lower trimming latency against the tested LLMLingua GPT-2 setup and higher answer-match rates in downstream QA results on a limited 93-case diagnostic.

Before building the adapter:

  • Would this be useful as another compression option alongside the existing integrations?
  • Is a RunnableLambda-based interface the recommended starting point today, with optional BaseDocumentCompressor support for langchain-classic’s ContextualCompressionRetriever?
  • Under the current integration guidance, would an independent package like this fit the external retriever listings, or another category?