uma_filter
Filters retrieved context to keep only sentences relevant to a query, using a cross-encoder to score relevance and trim excess tokens so an LLM gets the minimum context needed to answer correctly.
Instructions
Filter retrieved context down to sentences relevant to a query.
Runs sentence segmentation, then a local cross-encoder
(cross-encoder/ms-marco-MiniLM-L-6-v2 by default) to score every
sentence's relevance to the query, keeps sentences scoring at or above
threshold (0-1, default 0.5), optionally trims to max_tokens, and
returns the filtered context along with real measured metrics.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| context | Yes | ||
| threshold | No | ||
| max_tokens | No |