What is query transformation and why is it important for RAG?
Query transformation modifies or expands the user original query to improve retrieval results. Techniques include query rewriting where the LLM rephrases the query for better embedding match, hypothetical document embedding or HyDE where the LLM generates a hypothetical answer and uses its embedding for retrieval, query decomposition breaking complex queries into simpler sub-queries, query expansion adding synonyms and related terms, and step-back prompting generating broader abstracted queries for concept-level retrieval. These transformations address the vocabulary mismatch problem where users phrase questions differently from how information is stored in documents. For example, a user asking about cost savings might not match documents discussing ROI or expense reduction without query transformation. Implementing even basic query rewriting can improve retrieval recall by 15-30% in production RAG systems.