What is the role of query transformation in improving RAG results?
Query transformation rewrites user queries before retrieval to improve result quality. Techniques: HyDE (Hypothetical Document Embeddings) generates a hypothetical answer using the LLM, then embeds that answer for retrieval since it's closer to document space than the question. Query decomposition breaks complex questions into sub-queries, retrieves for each, and synthesizes results. Query expansion adds synonyms, acronyms, and related terms to broaden recall. Step-back prompting generalizes specific queries to retrieve broader context first. Multi-query generation creates 3-5 variant phrasings of the original query and retrieves for all, then deduplicates results. Implementation: use an LLM to generate transformations with careful prompting, cache common transformations, and evaluate the impact of each technique on your specific dataset. Measured improvements: HyDE typically adds 5-15% retrieval improvement for knowledge-intensive queries but can hurt performance for simple factual lookups. Best practice is to classify query types and apply appropriate transformations selectively.