In my earlier post, A Few Hundred Dollars for a Frontier-Class Search Agent, I described how I trained a 4B model to search for evidence and rank documents. That model is the agentic ranker in my search stack.
The workflow begins with ColBERT-powered hybrid retrieval over a corpus of 1M documents. From the retrieved candidates, my 4B agentic search model ranks the top 10 documents. Highlight then prunes those documents in the same call, and the pruned documents go to a downstream LLM to generate the answer.
This is the next question after learning to rank: once I have the right documents, how much of each should I return? A relevant page can contain navigation, repeated descriptions, background, and perhaps one sentence with the fact the reader needs. Ranking puts the page in the right place. Highlight determines which regions to carry forward.
Given a query and a ranked document, Highlight extracts short regions of the original text and attaches them back to the result. The pruned document is then passed to the downstream LLM, with the source available when more context is needed. In the answer-quality evaluation later in this post, a separate reader generates the answers; those scores measure the usefulness of the returned context, rather than answer generation by the 4B ranker.
End-to-end latency covers that entire path: search over the 1M-document corpus → 4B model ranking the top 10 → Highlight pruning → downstream LLM answer generation.
The approach is to reuse the token interactions behind ColBERT retrieval. Instead of treating relevance as one number per document, I inspect which document tokens match which query tokens, then select a compact set of spans. The initial selector needs no additional training. I also test a small learned head that decides which span to add and when to stop.
The headline result: Highlight retains 99.61% of the encoded-document relevance score while selecting just 6.62% of the original document characters—a 93.38% reduction in source text. The core selector achieves this without training an additional model. It turns the fine-grained signal behind retrieval into a compact view of what the agent should read next. The span-selection results below report both measurements in the Highlight row.
The central idea is simple: the same token interactions that tell me which document is relevant can tell me which parts of that document to keep. This post walks through the architecture, the selection rule, and the performance numbers, including the tradeoff between compression and downstream answer quality.
The interface: carry evidence forward
Highlight operates after retrieval and agentic ranking. Its input is a query plus a result object containing source text. Its output keeps that object and adds extracted text and relevance scores.
query
→ hybrid search over 1M documents
→ 4B agentic model ranks the top 10
→ Highlight prunes the ranked documents
→ downstream LLM generates the answer
The selected text is copied from the source. Separate regions are rendered in source order with omission markers between them. This gives the consumer a short view that remains traceable to the original document. Extraction avoids generating new factual wording, although removing surrounding context can still change how a sentence is understood.
This interface also keeps the experiment focused. I am measuring what to retain from retrieved material. Retrieval quality, answer generation, and evidence selection affect one another, but each needs its own evaluation.
The signal: open up the relevance score
ColBERT represents the query and document as token embeddings. Each query token finds its strongest match among document tokens; summing those maxima gives the document score.
M[i,j] = similarity(query_token_i, document_token_j)
Score(Q,D) = Σ_i max_{j ∈ D} M[i,j]
For highlighting, I restrict the same matrix to a candidate span. No new encoder pass is needed to score each candidate once the matrix exists.
coverage_i(S) = max_{j ∈ S} M[i,j]
Score(Q,S) = Σ_i coverage_i(S)
The coverage vector matters more than the scalar score. Two spans may both match the same entity strongly. Selecting both could spend the budget repeating one aspect of the question. Another span may add a date, relationship, or technical detail the first span misses. Keeping coverage per query token lets the selector distinguish additional coverage from repetition.
The pipeline uses PyLate embeddings and FastPlaid to expose these interactions. Sentence pruning can also work directly from a query–document similarity matrix. In both cases, token-level matching becomes an input to context selection.
The selector: spend the budget on new coverage
The window-based baseline generates candidate regions at several token lengths. In the span-selection evaluation, these are 12-, 24-, and 48-token windows, with stride 8. Each candidate has source offsets and a coverage vector.
The greedy selector maintains the best coverage already supplied for each query token. It chooses a non-overlapping span according to how much new coverage it adds, divided by a length penalty.
current_i = best coverage for query token i so far
gain(S) = Σ_i [max(current_i, coverage_i(S)) − current_i]
value(S) = gain(S) / token_length(S)^α
A character budget constrains the selected spans. The exponent controls the preference for compact regions; the comparison uses α = 0.7. Selection ends when the remaining candidates cannot fit or cannot add enough coverage. Chosen regions are then ordered and rendered from the source.
This coverage objective gives the selector a concrete reason to prefer complementary spans. It rewards a region for adding something the selected text has not already covered, keeping the budget focused on new information.
Highlight also supports a threshold strategy: score each document token by its strongest query-token similarity, choose separated salient positions, expand context around them, and merge nearby spans. The performance numbers below use the greedy coverage selector.
Keeping every highlight anchored to its source
The interaction matrix uses the encoder's document-token sequence. Source text uses character offsets. Those sequences diverge when the model adds special tokens, masks punctuation, or truncates the document.
Highlight therefore maps the model's retained token positions back to character offsets using the corresponding tokenizer and model behavior. A matrix column must point to the text that produced that embedding. This alignment keeps the extracted regions tied to the source text.
The span evaluation uses a 512-token document limit and a 32-token query limit. Relevance preservation is measured against the encoded document representation; retained characters are measured against the original source text. These definitions keep the two performance measures precise when a source extends beyond the encoded region.
Sentence-level pruning: keep readable evidence
Short token windows can be awkward evidence for a reader. The sentence-pruning experiment keeps complete sentences instead. It splits the passage, maps tokens to sentence spans, and scores each sentence by restricted MaxSim. The saved answer-evaluation runs use square-root length normalization.
sentence_score(s) = [Σ_i max_{j ∈ s} M[i,j]] / √token_count(s)
The default relevance signal is leave-one-in: how well does this sentence match the query on its own? Leave-one-out measures something different: how much does the passage score fall when I remove the sentence?
The distinction matters with repeated evidence. If two sentences contain the same relevant fact, dropping either can leave the passage score almost unchanged because the other sentence supplies the maxima. Low leave-one-out importance does not imply that both sentences can be removed together. Scoring each independently keeps relevant sentences eligible even when their evidence appears elsewhere in the passage.
Selection uses an adaptive gap in the ranked sentence scores rather than a fixed threshold shared across queries. The implementation constrains eligible cut positions and has a fallback when the scores lack a clear gap. The balanced preset searches within approximately 30–65% retained sentence ranks; the conservative preset uses 70–95%. These control sentence selection, so actual retained character fractions differ.
Benchmark one: what survives in the highlights?
I evaluate span selection on SimpleQA-derived retrieved contexts, with a held-out split by source question. Verbatim answer matches are expanded to sentence-like boundaries to create silver evidence labels. The evaluation measures how well selected highlights recover those answer-bearing regions.
Precision, recall, and F1 below measure character overlap with those silver evidence spans, averaged per document. Reader-answer accuracy is evaluated separately below. “Retained chars” is selected source characters divided by original document characters; lower means stronger compression. The learned row averages three training seeds on the same held-out split. The matched baseline receives each learned selection's per-document character allowance and can use less if its available windows do not fit.
| Method | Evidence precision | Evidence recall | Evidence F1 | Retained chars | Encoded relevance retained |
|---|---|---|---|---|---|
| Learned decision head, three-seed mean | 0.138 | 0.307 | 0.168 | 4.88% | 97.52% |
| MaxSim, matched per-document allowance | 0.162 | 0.379 | 0.192 | 4.63% | 98.95% |
| Highlight (MaxSim, 320-character budget) | 0.133 | 0.433 | 0.178 | 6.62% | 99.61% |
| Oracle candidate selector | 0.727 | 0.955 | 0.797 | 3.49% | 92.26% |
“Encoded relevance retained” is the selected spans’ MaxSim score divided by the full encoded-document MaxSim score, averaged per document. For the Highlight row, 100% − 6.62% = 93.38% less source text, while 99.61% of encoded relevance is retained.
The training-free selector retains 99.61% of the encoded-document MaxSim score at 6.62% character retention, with 0.433 evidence recall and 0.178 evidence F1. At a matched output allowance, it reaches 0.192 evidence F1. That makes coverage-based selection a strong starting point for compact highlights without an additional trained model.
The label-informed oracle reaches 0.797 evidence F1 at 3.49% character retention, preserving 92.26% of the encoded relevance score. It is a diagnostic reference that shows useful answer-bearing regions are available in the candidate pool. The difference also motivates evaluating evidence recovery alongside relevance preservation: the two objectives emphasize different aspects of the text.
Extending the selector with a learned decision head
The learned experiment freezes ColBERT. A small neural head consumes 33 summary features describing a candidate's coverage, marginal gains, position, length, remaining budget, and selection history. A shared two-layer network with width 64 produces action and evidence readouts.
At each step it predicts whether to stop. If it continues, it selects a candidate span. Training combines a stop/choice log loss, a Brier loss for soft evidence membership, and expected decision regret under the oracle utility. The selector is allowed up to four spans under a 320-character budget.
The head learns when to add a span and when to stop. Its mean evidence F1 is 0.168, compared with 0.192 for MaxSim at a matched allowance. The comparison favors keeping the training-free coverage selector as the core approach: additional model complexity has not improved selection quality in this configuration.
The learned extension gives me a way to explore evidence-aware selection while keeping ColBERT frozen. A natural next step is to expose token identity or embeddings alongside coverage summaries, then test whether those features improve the choice of answer-bearing spans.
Benchmark two: can the reader still answer?
The sentence-pruning evaluation uses a separate answer-generating reader to measure how raw and pruned contexts support correct answers. The 4B agentic search model remains the document ranker. The table compares accuracy and retained context. The raw-context baseline shows the accuracy range across runs. Relative accuracy drop is calculated against each run’s own raw baseline: (raw accuracy − pruned accuracy) / raw accuracy. Accuracy for the conservative runs includes corrections to exact-match responses that the automated grader had rejected.
| Run / context | Answer accuracy | Relative accuracy drop | Retained chars |
|---|---|---|---|
| Raw context baseline | 70–80% | 0% | 100% |
| Balanced / pruned | 30% | 57.1% | 36.47% |
| Conservative / pruned | 60% | 25.0% | 81.70% |
| Additional conservative run / pruned | 60% | 25.0% | 81.43% |
Balanced pruning removes 63.53% of context characters. Answer accuracy moves from 70% to 30%, a 57.1% relative accuracy drop against its raw-context baseline, making this the more aggressive compression setting.
Conservative pruning keeps about 81% of context characters and achieves 60% answer accuracy, compared with 80% for raw context: 75% of baseline accuracy retained, or a 25% relative accuracy drop.
These results make the operating tradeoff explicit. More aggressive pruning delivers greater context reduction; conservative pruning retains more answer quality. Relevance preservation, evidence recovery, and reader accuracy measure different parts of that tradeoff.
Model context. These experiments used a relatively small late-interaction model, whose capacity may contribute to the observed answer-accuracy tradeoff. I expect Highlight to achieve a stronger overall accuracy–compression tradeoff when paired with a larger late-interaction model and integrated with my trained 4B agentic ranker. Better evidence ranking and selection should give the downstream reader more useful context. That expected improvement remains to be measured in a direct comparison.
Reuse the computation behind retrieval
If a retrieval system already exposes ColBERT interactions, Highlight can score candidate regions without another neural model pass. One representation supports document relevance and the finer decision about which text to carry forward.
The standalone pipeline obtains its own embeddings and builds a FastPlaid index. Integrating Highlight with cached retrieval representations lets the selection stage reuse that work. The benefit comes from making the token interactions useful twice: first to find relevant material, then to shape the context passed to the reader.
Where Highlight goes next
The training-free selector gives me a clear foundation: compact, source-grounded highlights with high relevance preservation. The next step is to bring evidence recovery and reader accuracy directly into the selection objective, while preserving the simplicity of reusing ColBERT interactions.
That means comparing selectors at matched output lengths, enriching the learned head with token-level information, and evaluating the complete retrieval-to-answer path. A reader that needs additional context should also be able to expand a highlight into the surrounding source text. Highlight's source offsets make that a natural extension of the interface.
The point of Highlight
Highlight turns a document-level relevance score into a practical decision about what an agent reads. The core selector retains 99.61% of encoded relevance while removing 93.38% of original source characters, without training an additional model.
The architecture is compact: expose the token interactions, score candidate regions, select complementary coverage under a budget, and return exact extracts in source order. The result is a controllable layer between retrieval and reasoning—one that makes context selection explicit, measurable, and reusable across search workflows.