Skip to content

Checking your reading list…

Retry

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Reader activity
0 Useful 2 Views 6 min Read — No ratings
Artificial Intelligence
6 min read

Query-Aware Highlight Cuts Agent Search Costs 36-82% by Extracting Key Sentences

Baidu's Query-aware Highlight uses teacher-student distillation to extract only query-relevant sentences from web pages, reducing result length to 18-22% of full text and cutting Agent per-task costs by 36-82% while maintaining answer accuracy.

Introduction

As LLMs power agents that perform research, analysis, and coding, search APIs have become the primary external information gateway. Unlike humans who skim titles and skip irrelevant sections, agents ingest every token into the context window, pay for each token, and suffer from context overflow, high cost, latency, and redundant information.

Background: Agents as Primary Search Consumers

Traditional search serves humans who browse selectively. Agents, however, decompose a task into multiple sub-queries, call search APIs repeatedly, and feed all returned tokens into the model. A typical task may invoke search dozens of times, making the volume and relevance of returned content critical for both cost and quality.

Problem: Three Costs of Returning Full Pages

Context overflow and distraction: Average English pages contain ~13,611 characters, Chinese ~4,794. Ten results can exceed 100k tokens, exceeding context windows and forcing truncation that may drop the answer. Irrelevant content (nav, ads, unrelated paragraphs) increases hallucination risk; research shows middle-context information is often ignored.

High cost and latency: LLMs charge per input token. Navigation, templates, and irrelevant text multiply cost across multi-turn agent loops. Longer inputs increase first-token latency and total reasoning time, degrading user experience.

Redundant information wastes budget: Articles often repeat the same fact in intro, body, and conclusion. Duplicates consume context and cost without adding new information.

The goal is "just enough" content: retain all information needed to answer the query while discarding everything else.

Solution Overview: Offline Teacher Labeling, Online Small-Model Extraction

Four requirements guided the design: (1) return only query-relevant original sentences; (2) length adapts per page — more answers yield more sentences, zero answers yield empty; (3) deduplicate semantically identical sentences but keep those adding new numbers, times, or conditions; (4) extract verbatim — no rewriting — so every character traces back to the source.

Common approaches fall short: online large-model extraction re-incurs the cost we aim to save; chunking with vector similarity misaligns chunk boundaries with answer boundaries and uses fixed chunk counts; rule/keyword methods cannot judge if a sentence truly answers the query.

The adopted strategy: offline a large teacher model (e.g., DeepSeek) labels massive web pages sentence-by-sentence; online a small encoder (the Highlight model) scores sentences in a single forward pass. Teacher cost is paid once during labeling; online inference is cheap.

Offline Pipeline

Teacher labeling: Teacher reads query and all sentences, assigns 0–1 relevance scores, groups sentences expressing the same viewpoint, and designates a representative. A sentence is considered duplicate only if the representative contains all its relevant information.

Sample filtering: For each (query, page) pair, downstream answer quality is evaluated using both teacher-extracted and full-page results. Only samples where extraction score > 0 and ≥ full-page score are kept, yielding millions of training documents.

Model training & calibration: Train the Highlight model; on a validation set jointly search optimal relevance threshold θ and redundancy threshold τ. θ filters low-relevance sentences; τ skips sentences whose coverage probability by already-selected sentences exceeds τ.

Model Architecture

The Highlight model (Figure 4) addresses two questions: what to select and what to delete .

Understand query and document: Query and document are concatenated and fed to mmBERT-base (multilingual, 8192 length, alternating local/global attention). Word-level cross-attention captures alignments like "battery capacity" ↔ "5000mAh". Long documents are split into overlapping sentence windows.

Form sentence representations: For each sentence, concatenate mean, first-token, and last-token embeddings to capture both semantics and boundaries.

Incorporate context: A 4-layer sentence-level Transformer processes sentence vectors, with the query added as an extra position and positional encoding. This resolves context-dependent value (e.g., table headers, pronouns like "the device", lead-ins like "three ways:").

Decide what to select (relevance head): Outputs per-sentence relevance probability. Training uses two losses: (a) regression to teacher scores for cross-document score comparability, enabling a single global θ; (b) pairwise ranking loss because Highlight selects sentences top-down by score.

Decide what to delete (coverage head): Predicts directed coverage: "sentence i contains all relevant info of sentence j". Directionality matters: "Battery 5000mAh, 66W fast charge" covers "Built-in 5000mAh battery" but not vice versa. Symmetric similarity would risk keeping the shorter, less informative sentence.

Decoding Process

After scoring, the decoder runs:

Compute θ (relevance) and τ (redundancy) calibrated on validation set.

Iterate sentences in descending score order; stop when score < θ.

Skip any sentence covered by an already-selected sentence (coverage probability > τ).

Cap total output at 4000 characters for extremely long pages.

Concatenate selected sentences in original document order.

Example (Figure 5): Query: phone battery capacity and fast-charge power.

Sentence 4: "Battery 5000mAh, supports 66W wired fast charge" → highest score, selected.

Sentences 2 & 3: only mention 5000mAh → covered by sentence 4, skipped.

Sentence 6: describes charging speed → new info, kept.

Nav bar & event time: below θ, dropped.

Result: two sentences, complete answer, no duplication.

Single-Round Search Evaluation

Two test sets (English & Chinese) with automatic QU-granularity and Q-granularity evaluation via LLM judge.

Length reduced to 18–22% of full text (~1/5), meaning the same context window fits ~5× more results.

Chinese set quality on par with full text: qu1+ (per-result usefulness) differs by only 0.3 pp; Q-granularity usability identical. Chinese extraction already near-complete.

English set slightly lower: qu1+ down 1.8 pp, Q-granularity down 1.6 pp. Attributed to longer sentences, cross-sentence dependencies, complex coreference; optimization ongoing.

Agent End-to-End Evaluation

Two mainstream Agent paradigms tested using DeepSeek Harness framework:

1. web search + fetch

Agent iteratively generates sub-queries, retrieves summaries, and if insufficient, calls web_fetch to retrieve full pages (converted to Markdown with char limit) in either original or Highlight mode. New information feeds back into the loop.

2. only web search

No separate fetch; the model generates search terms, receives results with Highlight or full-text evidence, and decides when to submit final answer. This paradigm is more sensitive to returned content quality/length.

Results (Figure 9 & table): Across both paradigms, using DeepSeek v4.1 flash and GPT 6.1 sol as Agent models on a complex Agent benchmark:

Highlight reduces per-task cost by 36%–82% vs. full text.

Accuracy change ranges only −1.6 to +0.5 percentage points .

Cost savings are larger with more expensive Agent models: e.g., GPT 6.1 sol cost drops from ¥27.39 to ¥4.95 per task while accuracy improves +0.5 pp.

Conclusion & Future Work

Query-aware Highlight achieves fine-grained sentence selection and deduplication via teacher-student distillation, substantially lowering Agent search costs while preserving answer quality. Key results: 36–82% cost reduction, accuracy within ±1.6 pp; single-round length 18–22% of full text, Chinese quality matching full text.

Future directions:

Incorporate the Agent's overall task context so Highlight judges sentence value for the entire task, not just the immediate sub-question.

Fill missing contextual information to close the gap between Chinese/English extraction and full-text performance, improving completeness and readability.

For attribution, corrections or content rights, contactadmin@besthub.dev

Report an issue with this article

Discussion 0

Write a comment

Sign in to join the discussion

No public comments on this page. Sign in to comment