Trimwise is an extractive Python library for the step between collecting text and assembling a prompt. Give it a document, a maximum size, and optionally the task you care about. It selects useful fragments from across the document, returns them in source order, and guarantees that the measured result stays within your token, word, or character limit.

This is especially useful when an agent has several sources but cannot place every source in the context window. Instead of taking the first N characters from each article, report, note, or search result, Trimwise gives each source a smarter evidence budget while leaving your system prompt, instructions, examples, and output schema untouched.

Features

  • Exact token, word, or character budgets
  • Query-aware lexical, semantic, and hybrid trimming
  • Verbatim excerpts in original source order
  • Source spans for exact provenance
  • Multi-source trimming under one shared budget
  • Markdown-aware structural selection
  • Lightweight lexical mode with no model or API key
  • Sync, async, and concurrent batch APIs
  • Custom sync and async embedding callbacks
  • Optional local FastEmbed CPU and GPU models
  • Custom token counters for target models
  • Typed Python package supporting Python 3.10–3.14
  • Public benchmark covering evidence survival, answer match, and warm latency
  • Automatic strategy selection for query and queryless use
  • Prompt-ready source labels, wrappers, and omission markers

Project Samples

Project Activity

See All Activity >

License

MIT License

Follow trimwise

trimwise Web Site

Other Useful Business Software
Build Data Resilience - Take the Assessment Today Icon
Build Data Resilience - Take the Assessment Today

Can you recover when it matters most? Take this quick assessment to identify gaps and build greater recovery confidence.

Is your recovery strategy as strong as you think? Take this quick self-assessment to check your recovery readiness and gain tailored insights. In only 2 minutes, you'll learn where you fall on the recovery readiness scale.
Take the Assessment
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of trimwise!

Additional Project Details

Operating Systems

Linux, Mac, Windows

Languages

English

Intended Audience

Developers

User Interface

Other toolkit

Programming Language

Python

Related Categories

Python Large Language Models (LLM), Python Natural Language Processing (NLP) Tool, Python Semantic Search Tool

Registered

4 hours ago