Home/
Part XIII — Expert Mode: Systems, Agents, and Automation/41. Advanced RAG (Beyond the Basics)/41.3 Query rewriting and expansion
41.3 Query rewriting and expansion
Overview and links for this section of the guide.
Lazy Users
Users type "pricing". They mean "What is the pricing for the Enterprise plan?".
Query Rewriting: Ask an LLM to rewrite the query before searching.
Input: "pricing" LLM: "Retrieve documents about the Enterprise, Pro, and Free tier pricing models." Search: (Uses the detailed query).
HyDE (Hypothetical Document Embeddings)
Ask the LLM to hallucinate the answer. "The Enterprise plan costs $50/month..." Embed that hallucination. Search for documents that look like the answer.
This often finds better matches than searching for the question.