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:
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.
Related Resources
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.
For additional information on related topics, take a look at the following resources:
- Embeddings and Vector Databases With ChromaDB (Tutorial)
- LlamaIndex in Python: A RAG Guide With Examples (Tutorial)
- Vector Databases and Embeddings With ChromaDB (Course)
- Natural Language Processing With Python's NLTK Package (Tutorial)
- Prompt Engineering: A Practical Example (Tutorial)
- First Steps With LangChain (Course)
- Build an LLM RAG Chatbot With LangChain (Quiz)
- Embeddings and Vector Databases With ChromaDB (Quiz)
- Vector Databases and Embeddings With ChromaDB (Quiz)
- Using LlamaIndex for RAG in Python (Course)
- LlamaIndex in Python: A RAG Guide With Examples (Quiz)
- Natural Language Processing With Python's NLTK Package (Quiz)
- Practical Prompt Engineering (Quiz)
By Martin Breuss • Updated Aug. 18, 2026