Pre-retrieval Techniques

By Ludovico Bessi, Senior ML Engineer at Google ยท Updated

Pre-retrieval techniques transform the user's query before searching: routing it to the right source, rewriting conversational follow-ups into standalone queries, expanding vocabulary, decomposing complex questions, and generating multiple query variants fused with Reciprocal Rank Fusion (RAG Fusion).

Why Transform the Query

Users do not write queries the way documents are written. Queries are short, ambiguous, conversational ("and for contractors?"), multi-part, or phrased in different vocabulary than the corpus. Pre-retrieval techniques turn the raw user input into one or more queries that retrieval can answer well. Each technique usually costs a small LLM call (100โ€“500 ms), so apply them where evaluation shows they help.

Query Routing

Routing decides where and whether to search:

  • Source routing: product docs vs. HR policies vs. code vs. tickets โ€” each may have its own index, chunking and embedding.
  • Strategy routing: a keyword-heavy query (error codes, SKUs) may favor BM25; a conceptual one favors dense retrieval; an aggregate question may need SQL or a GraphRAG global search.
  • No-retrieval routing: greetings, chit-chat or general-knowledge questions can skip retrieval entirely, saving latency and avoiding irrelevant context.
  • Tool routing: some questions are better answered by an API ("what's my order status?") than by documents.

Implementations range from rules and embedding-similarity classifiers (cheap, fast) to an LLM with function calling (flexible, slower). A small fine-tuned classifier is often the production sweet spot.

Query Rewriting

Conversational rewriting

In multi-turn chat, the latest message often depends on history: "What about the EU?" must become "What is the parental leave policy for employees in the EU?". A small LLM rewrites the latest turn into a standalone query using the conversation. This is the single most important pre-retrieval step for chat-based RAG.

Clarifying and normalizing

Fix spelling, expand acronyms with a domain glossary, normalize product names and dates ("last quarter" โ†’ "Q3 2026").

Rewrite-Retrieve-Read

Ma et al. (2023) proposed training a small rewriter (with reinforcement learning from the downstream answer quality) to produce queries optimized for the retriever, rather than relying on the user's phrasing. In practice, prompting a capable LLM to "rewrite this question as a search query" captures much of the benefit.

Step-back prompting

For specific questions, also generate a more general "step-back" question ("What were the causes of the 2008 crisis?" for "Why did bank X fail in 2008?") and retrieve for both, giving the model background principles alongside specifics (Zheng et al., 2023).

Query Expansion

Add terms or content to improve recall:

  • Synonyms and related terms โ€” classic in keyword search, from a thesaurus or an LLM.
  • Pseudo-relevance feedback โ€” retrieve, take terms from the top results, and search again.
  • LLM-generated expansions โ€” Query2doc (Wang et al., 2023) generates a pseudo-document with an LLM and appends it to the query, improving both BM25 and dense retrieval.
  • HyDE โ€” embed a hypothetical answer instead of the question.

Expansion helps vocabulary mismatch but can cause topic drift if the generated content is wrong; fusing results with the original query mitigates this.

Query Decomposition

Complex questions need multiple retrievals:

  • Parallel decomposition: "Compare the pricing of plans A and B" โ†’ two independent sub-queries, retrieved in parallel.
  • Sequential (multi-hop) decomposition: "Who manages the team that owns service X?" โ†’ first find the team, then its manager. Each step depends on the previous answer โ€” this blends into iterative retrieval and agentic RAG.

Multi-Query RAG and RAG Fusion

Multi-query retrieval generates several paraphrases of the user's question with an LLM, retrieves for each, and merges the results. Different phrasings hit different relevant chunks, raising recall.

RAG Fusion (Rackauckas, 2024) merges the result lists with Reciprocal Rank Fusion (RRF):

RRF_score(d) = ฮฃ over queries q  1 / (k + rank_q(d))      with k โ‰ˆ 60

Documents that rank well across many query variants rise to the top; RRF needs no score calibration across lists, which makes it robust. RAG Fusion improves answer comprehensiveness, at the cost of an LLM call to generate queries and N retrievals (cheap if run in parallel). Its risk is the same as expansion: generated queries can drift from the user's intent, so keep the original query in the set.

Putting It Together

A typical production pre-retrieval stage:

user message + history
  โ†’ (small LLM) standalone rewrite
  โ†’ router: no-retrieval | docs | tickets | SQL tool
  โ†’ for docs: 1 original + 2โ€“3 paraphrases (optional), filters extracted from the query
  โ†’ parallel hybrid retrieval per query โ†’ RRF โ†’ rerank

Measure each addition's effect on retrieval recall and end-to-end answer quality, and its latency. Often the rewrite and router pay for themselves; multi-query and expansion help most on short, ambiguous queries.

Key Takeaways

  1. Users' queries are short, ambiguous and conversational; transform them before retrieval.
  2. Routing chooses the source, strategy, or no retrieval at all.
  3. Conversational rewriting into standalone queries is essential for chat RAG.
  4. Expansion (synonyms, Query2doc, HyDE) fights vocabulary mismatch; decomposition handles multi-part and multi-hop questions.
  5. Multi-query retrieval with Reciprocal Rank Fusion (RAG Fusion) raises recall; keep the original query to limit drift.