Query rewriting: improve the search question without inventing its answer
Distinguish intent-preserving rewrites, independent expansions, and dependent subquestions while bounding fanout, latency, and evidence drift.
On this page
The question for today
What you’ll understand
- Separate rewriting from decomposition and answer generation.
- Calculate raw-hit and critical-path budgets for a stated fanout.
- Detect semantic drift and preserve evidence lineage across subqueries.
A user's wording may not resemble the language used by relevant documents. Rewriting can bridge that gap, while decomposition can turn a compound request into smaller evidence searches. Both introduce another model-mediated stage that can misunderstand entities, dates, negation, or scope. Preserve the original question and make each derived query traceable, then measure the gain against its extra calls, latency, and failure modes.
A derived query is a hypothesis about useful evidence
An intent-preserving rewrite can expand an abbreviation, resolve a reference from authorized conversation context, or translate a question into a corpus's vocabulary. It should not quietly replace an uncertain premise with an invented fact. Keep the original query as a baseline or parallel candidate where appropriate. Log the original, rewrite, rewriter configuration, and retrieval outcome under the application's data policy. A successful fluent rewrite is not evidence that the resolved entity or time range was correct.
Decomposition creates subquestions whose answers may need to be combined. Some are independent and can run concurrently; others depend on a first result, such as identifying a project before searching its owner. The original self-ask work studies such compositional reasoning, while Rewrite-Retrieve-Read studies query adaptation. These are specific methods rather than proof that every question benefits from more queries. Retain the relationship between a subquestion, its supporting sources, and the final claim so a wrong intermediate assumption can be diagnosed.
Fanout consumes more than a context window
Bound the number of rewrites, subquestions, retrieval calls, retries, and candidate rows. At a stable request rate, backend call demand grows with the mean executed calls per request even when calls overlap in wall-clock time. Parallel searches reduce only the independent portion of latency and still consume concurrency and bandwidth. Dependent hops require additional serial stages. Timeouts and partial results need an explicit policy: synthesize from sufficient remaining evidence, retry within a budget, ask for clarification, or abstain.
A union can contain many duplicate passages, different versions of one document, and query-specific score scales. Do not compare raw similarity scores from unrelated query formulations as though they were calibrated probabilities. Deduplicate by the intended evidence identity, rerank under a declared policy, and preserve which queries produced each candidate. Every derived search must retain the same principal, permission scope, corpus snapshot, and freshness requirements unless the application explicitly authorizes another scope. A fallback search is not an excuse to drop these constraints.
Evaluate the original intent and the final evidence set
Create tests with ambiguous names, negation, temporal constraints, compound comparisons, and questions that need only one precise search. Compare original-only, rewrite-only, and bounded multi-query variants with a fixed corpus and generator. Measure authorized evidence recall after deduplication and packing, task accuracy, unsupported claims, and cost. A rewrite can raise retrieval recall while lowering answer quality by introducing a mistaken premise or excessive distractors. Inspect failures by stage rather than crediting every final improvement to the rewriter.
The queue lab isolates fanout pressure as abstract work demand. Reset, set λ=2 and μ=4, predict q(2)=0, then use four Steps. Separately Reset, set λ=4 and μ=3, predict q(2)=6, then use four Steps. Both start with four work units. It has no queries, parallel search graph, or document scores, and its separate M/M/1 residence time has additional stochastic assumptions. Use it to see why more offered work can outgrow service, then measure the actual per-request fanout and concurrency limits.
Work it through
Budget a bounded multi-query path
One original query and three derived queries each return at most four hits. Their union contains nine distinct evidence identities. Assume rewriting takes 20 ms, the four independent searches take [30,60,40,50] ms with unlimited needed concurrency, and synthesis takes 80 ms.
There are four search calls and at most sixteen raw hit rows. Deduplication leaves nine distinct candidates; neither number proves that the required facts were found.
Under the stated ideal schedule, all searches start after rewriting and finish after sixty milliseconds. The path is 20+60+80=160 ms before omitted overhead.
The pipeline still pays four backend calls and must authorize, rerank, and pack the nine candidates. A dependent subquestion or a lower concurrency limit invalidates the simple maximum-time calculation.
Fanout has separate raw-candidate, backend-call, and dependency-path budgets. Parallel latency does not make its resource cost disappear.
The living notebook
Explore the model
Interactive lab · queue
More search work can exceed a service budget
Reset, set λ=2 and μ=4, predict q(2)=0, then use four Steps. Separately Reset, set λ=4 and μ=3, predict q(2)=6, then use four Steps. The initial-four fluid stream has no retrieval queries, parallelism, or relevance model.
- Fluid backlog
- 4
- Net rate · λ − μ
- −1 /s
- M/M/1 mean residence
- 1 s
Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forBound executed calls and candidate work even when independent searches run concurrently.
Pause & reason
Check your understanding
Your turn
Try it yourself
Five executed queries each return at most six hits. Deduplication leaves eighteen candidates, and a fictional serial reranker takes two milliseconds per candidate. Find the raw-hit upper bound and this reranking duration.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Separate the fanout bound from the distinct candidate count used downstream.
Compare with the solution
The raw-hit upper bound is 5×6=30. Reranking eighteen distinct candidates at two milliseconds each takes 36 ms under the stated serial constant-cost model. A real batched reranker can have another cost curve, and the final evidence budget may retain fewer than eighteen candidates.
Keep the idea
Take it with you
- Rewrites and subquestions need traceable intent and evidence lineage.
- Fanout has call, candidate, concurrency, and dependency-path costs.
- Evaluate retrieval gains after permission checks, deduplication, and packing.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.