Query understanding & transformation
Rewrite, expand, decompose and route questions so retrieval gets a query it can answer.
Users do not write good search queries. Follow-up questions such as 'what about the second one?' only make sense with history, and short queries miss documents that use different words. Query transformation fixes the input before retrieval.
Common moves: rewrite a follow-up into a standalone question using the conversation, generate several paraphrases and merge their results, decompose a compound question into sub-questions, or use HyDE, where the model drafts a hypothetical answer and you embed that to find real passages. A router can decide which index, or whether to retrieve at all, a question should use.
Each step adds latency and a chance to drift from what the user meant, so apply them only where evals show a gain. Always keep the original query in the mix and log both versions.
Key points
- Resolve follow-ups into standalone questions using conversation history.
- Multi-query and decomposition raise recall at the cost of latency and spend.
- HyDE helps when questions and documents use very different language.
- Keep the original query and measure whether each transformation helps.
Answer these out loud
- 1Turn this chat into a standalone query: 'How do I set up SSO?' then 'and for the mobile app?'.
- 2When would you skip retrieval entirely for a question, and how does the router decide?
Use this from an agent
Any MCP client, including Grok, can read this lesson. See how to connect.
curl https://engineeros-delta.vercel.app/api/v1/topics/rag-query-transformation