Trimwise: query-aware context trimming

I’ve put together a Space for Trimwise, an open-source Python library for fitting source text into a context budget.

The problem is familiar: retrieved documents or tool outputs contain useful evidence, but also plenty of material unrelated to the current question. Simply cutting off the end can discard the part you needed.

Trimwise supports single-source trimming with atrim and multi-source trimming with atrim_context. The latter lets sources compete for one shared budget. It selects existing source spans rather than generating a summary, with provenance information for tracing retained text back to its inputs.

The lexical path uses no model weights or LLM inference. Optional embedding-based modes are available in the library for semantic and hybrid selection.

There are trade-offs: ranking can miss relevant evidence, and removing surrounding context can change how an excerpt is understood. Our published benchmarks cover specific scenarios, so I’m particularly interested in examples outside those tests.

If you try it, I’d love feedback on:

  • Qualifiers, negation or revised facts that get lost
  • Answers requiring evidence spread across sources
  • How the retained context compares with simple truncation at the same budget

Small reproducible examples would help a lot.