Introduction to Query transformation and rewriting
Query transformation modifies a user's original question into a form that is more suitable for information retrieval.
It can improve retrieval when user questions are ambiguous, conversational, overly broad, or contain terminology that differs from the source documents.
Core concepts and architecture
Understand query rewriting, query expansion, decomposition, normalization, conversational query resolution, and intent detection.
Study how an LLM can transform a question using conversation history or domain context before passing it to a retriever.
Learn how transformed queries should preserve the user's original intent and avoid introducing unsupported assumptions.
Practical implementation
Build a query-rewriting step that converts conversational questions into standalone search queries.
Compare retrieval results for original and rewritten questions using a fixed document collection.
Log both the original and transformed queries so developers can inspect unexpected retrieval behaviour.
Challenges and trade-offs
Query rewriting may change the meaning of a question or remove important constraints.
Additional model calls increase latency and cost.
A rewritten query should be evaluated against the original user intent and should not silently introduce assumptions.
Interview preparation
Explain query transformation and why it is useful in RAG.
Compare query rewriting, expansion, decomposition, and conversational query resolution.
Discuss the risks of changing user intent and how transformed queries should be evaluated.
Key takeaways
- Understand the purpose and main concepts of Query transformation and rewriting.
- Understand how Query transformation and rewriting works and how its components interact.
- Be prepared to explain practical implementation and real-world use cases.
- Understand common challenges, limitations, and design trade-offs.
- Practise explaining Query transformation and rewriting clearly in a technical interview.