Skip to content

query expansion

Query expansion is a technique that reformulates or enriches a search query with extra terms before retrieval, so a system finds relevant documents even when the original wording misses them. A long-standing idea in information retrieval, it is now central to retrieval-augmented generation (RAG), where the retrieved context sets a ceiling on how good the model’s answer can be.

Expansion sits at the front of the retrieval pipeline that produces that context:

A raw query is expanded by classic and LLM methods, retrieved from a vector database, then re-ranked into the model's context.
Broaden for Recall, Re-Rank for Precision

Classic approaches add synonyms, stem words to their root forms, correct spelling, or reweight terms to sharpen the match. Pseudo-relevance feedback goes further, expanding a query with terms drawn from the top results of a first search pass.

In modern pipelines, a large language model often does the expanding. Multi-query generation rewrites one question into several phrasings, while HyDE, or hypothetical document embeddings, drafts a hypothetical answer and embeds that instead of the raw query to search a vector database.

The core trade-off is recall versus precision. Broadening a query surfaces more candidate documents but can also pull in noise, so retrieval systems often pair expansion with re-ranking to keep the strongest matches on top.

Build an LLM RAG Chatbot With LangChain

Tutorial

Build an LLM RAG Chatbot With LangChain

Large language models (LLMs) have taken the world by storm, demonstrating unprecedented capabilities in natural language tasks. In this step-by-step tutorial, you'll leverage LLMs to build your own retrieval-augmented generation (RAG) chatbot using synthetic data with LangChain and Neo4j.

intermediate ai databases data-science

For additional information on related topics, take a look at the following resources:


By Martin Breuss • Updated Aug. 18, 2026