Modules/Gen AI/ Multi-Query Lab

Multi-Query Retriever

A single phrasing is one sample of what the reader meant. Ask the same question three more ways and retrieve for all of them — the union catches what any one wording would have missed.

Overview

The vocabulary mismatch problem

Embedding-based retrieval finds documents whose vectors are near the query’s vector. That works well when the question and the document use similar language, and fails when they do not.

Ask “how do I speed up my model?” of a corpus that discusses “reducing inference latency”, “quantisation” and “batch throughput” and the embedding may simply not land near any of them. The information is present and the phrasing is wrong, and a single query gets a single shot at matching it.

The failure is silent. The retriever returns its nearest neighbours regardless, so you get plausible-looking, unhelpful chunks with no signal that anything was missed.

Which queries run

Recall

Relevant found
—
Retrieved—

 

Each phrasing, and its own top 2

—

The union, against what was actually relevant

Where the variants come from

In a real multi-query retriever an LLM writes the rephrasings. The three below are written by hand as a labelled example of what it would produce — no model runs in this page. Everything after that point, the retrieval and the union, is really computed here.

Multi-Query Retriever: A Practical Guide

One question can be asked many ways, and vector search only finds what is phrased like the query it was given. A multi-query retriever generates several rewordings, searches with each, and merges the results.

Generating several queries and merging

A multi-query retriever asks a language model to produce N alternative phrasings of the question — typically 3 to 5 — each approaching it from a different angle. The original question above might become:

  • “What techniques reduce model inference latency?”
  • “How can I improve throughput at serving time?”
  • “What makes a neural network run faster in production?”

Each is embedded and searched independently, giving N result sets which are then combined and deduplicated. Because the rewordings cover different vocabulary, their nearest neighbours differ, and the union covers substantially more of the relevant material than any one query would.

Merging is usually done with reciprocal rank fusion rather than raw scores. RRF assigns each document a score of Σ 1/(60 + rank) across the lists it appears in, which rewards documents that several rewordings agree on and avoids the problem that similarity scores from different queries are not directly comparable.

One question, several searches

A single embedding of a question is one point in the space. If the question is phrased differently from the documents that answer it, that point sits in the wrong place, and no amount of index tuning will fix it.

Multi-query retrieval hedges by generating several rewrites of the question, searching with each, and combining the results.

Original: "How do I stop getting so many alerts?"
1. "How to reduce alert volume"
2. "Configuring notification thresholds"
3. "Suppressing duplicate alerts"

Each rewrite lands in a different region of the embedding space, and their union covers far more of the relevant material than any one of them. The third might be the only one that retrieves the deduplication documentation.

The mechanism is straightforward:

prompt = """Generate 3 alternative phrasings of this question that would
retrieve relevant documents. One per line, no numbering.

Question: {question}"""

queries = [question] + model.generate(prompt).strip().split("\n")
ranked_lists = [index.search(q, k=20) for q in queries]
results = rrf(ranked_lists)          # fuse by rank

Note that the original question is included. The rewrites are additions, not replacements — a poor rewrite then dilutes the results slightly rather than destroying them.

Why fusion rather than concatenation

The results from several searches must be combined, and how matters.

Concatenating and deduplicating loses the ranking information: a document ranked first by two rewrites is treated the same as one ranked twentieth by one.

Averaging scores requires the scores to be comparable across searches, and they are not reliably so.

Reciprocal rank fusion uses only ranks:

score(d) = Σqueries 1 / (60 + rank(d))

A document retrieved highly by several rewrites accumulates from each, so agreement across rewrites becomes evidence. That is exactly the property you want: a document that only one rewrite found is plausible; one that all four found is probably right.

RRF also needs no normalisation, which is what makes it practical when combining an arbitrary number of retrievers.

The costs

CostDetail
One model callTo generate the rewrites, 200–500ms
N searchesUsually parallelisable, so latency is the slowest one
More candidatesN×k documents before fusion
Reranking loadMore candidates to rerank, if reranking

The searches parallelise, so the added latency is roughly one model call plus one search — not N searches. That makes the technique considerably cheaper in practice than it looks.

Three or four rewrites is the usual range. Beyond that, the additional rewrites are paraphrases of paraphrases and the returns flatten while the reranking load grows.

Cache aggressively: at temperature 0 the rewrites are deterministic, and repeated or similar questions are common in real traffic.

What several searches recover that one does not

The sections above explain why the pattern generates variants and fuses them rather than concatenating. Here it is run -- three phrasings of one question against one corpus, the union measured against each variant alone, and the case where extra queries make the result worse.

example_01.pyNumPy
Output

Guided experiments

  1. Compare a single query with the set. Look at what one phrasing retrieves against the union of all of them. The union is broader, and usually includes at least one document no single query found.
  2. Find the documents only one variant retrieves. These are exactly the recall the technique is buying — material the original phrasing would have missed entirely.
  3. Look for agreement. Documents retrieved by several variants are the strongest candidates, and that consensus is what rank fusion promotes to the top.
  4. Watch the precision cost. The merged list is longer and contains more marginal results. Multi-query improves recall and dilutes precision, which is why a reranker usually follows it.

What it costs, and what to use instead

Multi-query is not free. Generating the variants is an extra LLM call on the critical path, adding latency and cost to every request, and it runs N searches instead of one. For an interactive application that overhead is real.

Related approaches make different trades. HyDE generates a hypothetical answer and embeds that, on the argument that an answer is textually closer to the passage containing it than a question is. Query decomposition splits a multi-part question into separate sub-questions, which multi-query does not do — it rephrases rather than divides. And hybrid search, combining dense retrieval with BM25 keyword matching, addresses much of the same vocabulary problem for a fraction of the cost, because exact term matching catches precisely the rare words embeddings handle worst.

Common mistakes

  • Generating variants that all say the same thing. If the rewordings are near-identical, they retrieve the same documents and you have paid for nothing. The prompt must push for genuinely different angles and vocabulary.
  • Merging by raw similarity score. Scores from different query embeddings are not comparable. Use rank-based fusion.
  • Skipping deduplication. The same chunk retrieved by four variants will otherwise occupy four slots of context.
  • Not reranking afterwards. The merged list is broader and noisier; a cross-encoder reranker recovers the precision.
  • Using it where the problem is chunking. If the relevant text is split badly across chunks, no amount of query rewriting will retrieve it intact.

What to remember

A multi-query retriever compensates for the fact that a single embedding gets one attempt at matching the corpus vocabulary: it generates several rewordings, retrieves with each, and fuses the ranked lists. It buys recall at the cost of an extra LLM call, N searches, and some precision — so it pairs naturally with a reranker. Where the mismatch is about rare or exact terms, hybrid search with BM25 gets much of the same benefit far more cheaply.

Where it helps, and where it does not

It helps with vague or short queries. "It's broken" gives an embedding with almost no signal; several specific rewrites give several usable ones.

It helps when documents use different vocabulary from users — jargon, product names, formal register.

It helps with multi-faceted questions, where different aspects live in different documents. Decomposition is a related and sometimes better approach: split the question into its parts explicitly and retrieve for each.

It does not help much when the query already contains exact identifiers. Rewriting "error E4471" risks losing the code, which was the most retrievable part. Including the original query protects against this.

It does not help when recall is already high. If recall@20 is 0.97, there is almost nothing left to find and the extra latency buys nothing. Measure before adding it.

That last point generalises: multi-query addresses a recall problem. If your failures are ordering failures — the right document is retrieved at rank 15 — a reranker is the correct tool, not more queries.

TechniqueWhat it changes
Multi-querySeveral phrasings, fused
DecompositionSplits a compound question into sub-questions
HyDESearches with a generated hypothetical answer
Step-back promptingAsks a more general question first
Self-queryExtracts metadata filters from the question

Step-back prompting is worth knowing: for a specific question, first ask a broader one ("what are the general principles of X?"), retrieve for both, and fuse. It surfaces background material that a narrow query misses.

Decomposition is the better choice for genuinely compound questions. "How do refunds differ from exchanges, and what are the deadlines?" is three questions; rewriting it three ways is less effective than splitting it into its actual parts.

These compose, and each adds latency. The ordering to add them in is by measured benefit on your own question set — and in most systems hybrid search and reranking come first.

Questions people ask

How many rewrites? Three or four including the original. More flattens out.

Should I include the original query? Yes, always — it protects against a bad rewrite and preserves exact identifiers.

Which model for the rewrites? A small fast one. Paraphrasing a question is not a demanding task.

Does it increase hallucination? No — the rewrites are only search keys and are never shown to the user or to the answering model.

How do I combine the result lists? Reciprocal rank fusion, which needs only ranks.

Is it better than HyDE? They address the same gap differently and can be used together. HyDE matches the documents' register; multi-query covers several phrasings.

Recap in one screen

  • One embedding of a badly-phrased question searches from the wrong point; several rewrites cover more ground.
  • Generate 3–4 phrasings, search with each, and fuse with reciprocal rank fusion.
  • Always include the original query, so a poor rewrite cannot destroy the results.
  • Agreement across rewrites is evidence, and RRF rewards it automatically.
  • It fixes recall problems; ordering problems need a reranker instead.

Check yourself

0 of 3

Answer without scrolling back up.

  1. How are the results of the separate queries combined?

  2. Multi-query retrieval mainly improves:

  3. Why is multi-query usually followed by reranking or MMR?

Cheat sheet

Multi-Query Retriever

A single phrasing is one sample of what the reader meant. Ask the same question three more ways and retrieve for all of them — the union catches what any one wording would have missed.

GEN AI · vizlearn.in/gen_ai/multi_query_retriever.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.