Core lesson
Query Expansion
Improve retrieval by rewriting, expanding, or generating related query forms so the search system can find evidence users did not phrase exactly.
After this, you will understand
How Query Expansion helps you see how prompts, tools, retrieval, agents, and evals become real AI engineering workflows.
Article guideprerequisites, mental models, and concepts
Article overview
Three useful mental models
Treat the idea as a definition to memorize.
Real systems force the idea to handle Query Expansion, Query Rewriting, and HyDE.
Use the concept to decide what the system guarantees, what it risks, and what it costs to operate.
Think before reading
Where would Query Expansion appear in a real production system, and what failure or bottleneck would it help you reason about?
As you read, look for the pressure that creates the idea first. The mechanics matter more once the reason is clear.
Connected learning
These lessons add useful context to the current core lesson.Concepts Covered
- Query expansion
- Query rewriting
- Multi-query retrieval
- HyDE
- Recall improvement
- Retrieval drift
- Search intent
- RAG query preprocessing
Definition
Query expansion is the practice of transforming a user's query into one or more richer search queries before retrieval.
The plain-English version:
help the retrieval system search for what the user means, not only what they typed
Expansion can add synonyms, rewrite vague wording, generate multiple query variants, or create a hypothetical answer-shaped document for embedding.
Why This Concept Exists
Users rarely phrase questions the same way documents phrase answers.
A user may ask:
Can I get money back after renewal?
The policy may say:
Annual plan refunds are available within 30 days of renewal.
The retrieval system has to connect "money back" with "refund" and "after renewal" with "renewal policy."
Query expansion exists because short, vague, or user-shaped questions can be weak retrieval inputs.
The Beginner Mental Model
A beginner may think:
The best query is always the exact user query.
Sometimes it is. But in many RAG systems, the user query is not shaped like the corpus.
A better mental model:
user query -> retrieval-oriented query forms -> candidate search
The goal is not to change the user's question. The goal is to improve recall while preserving intent.
Common Expansion Strategies
Query expansion can happen in several ways.
Synonym expansion: add related terms such as "refund" for "money back."
Query rewriting: turn conversation context into a standalone search query.
Multi-query retrieval: generate several query variants and merge results.
HyDE: generate a hypothetical document or answer-shaped passage, embed that, and retrieve real documents near it.
Step-back style rewriting: search for a more general concept before narrowing down.
Each strategy tries to reduce mismatch between user wording and corpus wording.
A Concrete Example
In a chat session, the user asks:
What about contractors?
That query is useless without context.
The previous turn was about:
home office equipment reimbursement
A query rewrite could produce:
contractor home office equipment reimbursement policy
That expanded query is much better for retrieval.
The model did not answer yet. It only made the retrieval request more useful.
Retrieval Drift
Expansion can improve recall, but it can also drift.
If the expansion adds concepts the user did not ask about, retrieval may move toward the wrong evidence.
For example:
user query: "refund after renewal"
bad expansion: "chargeback dispute and cancellation fraud"
The expanded query may retrieve related but wrong policy areas.
This is why query expansion should be evaluated against real questions and failure cases.
Where Query Expansion Fits
Query expansion usually happens before candidate retrieval:
user question
-> rewrite or expand
-> retrieve candidates
-> merge and deduplicate
-> rerank
-> assemble context
For multi-query systems, each query variant may retrieve its own candidates before merging.
For HyDE-style systems, the generated hypothetical text becomes the embedding input for retrieval.
Common Confusions
Query expansion is not answering the question.
It prepares retrieval. The final answer still needs grounded context.
Expansion is not always better.
Bad expansion can retrieve confident nonsense.
HyDE does not require the hypothetical document to be factually correct.
Its purpose is to create a retrieval representation that points toward likely relevant real documents.
Conversation rewriting is not memory.
It uses available context to make the current query searchable.
What This Does Not Mean
Query expansion does not remove the need for filters, reranking, or answer grounding.
It improves the query side of retrieval. The system still needs to verify that retrieved documents actually support the answer.
Related Topics
Finished reading?
Your reading history is saved in this browser so you can continue later.
Recommended Next
Parent-Child RetrievalBuilding With AI3 min readThis turns the foundation vocabulary into a practical AI engineering decision.
Optional exploration
These links add context, but they do not replace the recommended next lesson.
More Links
Additional references connected to this page.
Arcflow Plus is coming — review drills, research breakdowns, more AI. Get one email at launch.