Back to glossary

Term

Query Expansion

Query expansion enriches the original query in a RAG pipeline with synonyms, reformulations or hypothetical answer texts in order to lift retrieval recall.

Query Expansion — explained in more detail

User queries tend to be short, informal and ambiguous — while the documents being searched are long, jargon-heavy and structured. That vocabulary gap is the main reason plain vector retrieval misses relevant hits. Query expansion closes the gap by having an LLM generate additional search variants from the original question (synonyms, reformulations, alternative angles). Each variant is searched separately, the results are merged, deduplicated and trimmed back to the final top-k list with a reranker.

Example / Practical context

A question like “why is my build slow?” often yields only hits with identical wording when run through plain vector search. With multi-query expansion the LLM generates variants such as “optimise build performance”, “reduce compile times” and “speed up CI pipeline” — and so also finds documents that describe the same issue with different vocabulary. The cost: three to five times the latency and LLM spend per query, plus extra noise that must be filtered out downstream with a reranker.

HyDE (hypothetical document embeddings) is a specific variant: instead of multiple search variants the LLM generates a hypothetical answer document and searches with its embedding — effective for short, precise queries. Multi-query retrieval is the umbrella term for any approach that runs several reformulated queries in parallel. Reranking only kicks in after retrieval and re-orders the hits without issuing any new searches.

Entdecke mehr

Themenuebersicht