Learning path · Retrieval & Ranking · 47
Query Transformation
Rewriting user queries—expansion, decomposition, or step-back—for better retrieval against the index.
Why it matters
- Raw user messages are often vague or conversational.
- Multi-hop questions need sub-queries.
- Transforms add latency and must be eval-covered.
Key ideas
- Query expansion
- Sub-query decomposition
- Hypothetical documents
Query transformation uses an LLM to turn "why is my bill wrong?" into structured sub-queries against billing docs, or expands acronyms using a controlled glossary. Guard with templates and refusal when transformation invents constraints. Cache transformations for repeat users. Measure Recall@K with and without transforms to justify the extra model call. Log original and transformed queries with retrieval outcomes to detect transforms that systematically bias results toward stale content. Ship only after eval gates pass on representative production failures.
Updated 2026-08-09 · Full learning path