What is query transformation in RAG?
LLM & AILevel: IntermediateRetrieval Techniques
What is query transformation in RAG?
Hints
- Break the query into candidate retrieval, context selection and generation.
- How would you locate the stage that lost a fact without using only one end-to-end metric?
Answer
User queries are often vague, ambiguous, or syntactically different from indexed content. Query transformation improves recall:
HyDE (Hypothetical Document Embeddings): generate a hypothetical answer to the query, embed that answer, retrieve documents similar to the hypothetical answer. Works because the hypothetical answer is in the "document space" rather than the "question space."
Query decomposition: split a complex query into sub-questions, retrieve for each, merge results.
"Compare GPT-4 and Claude on reasoning and coding" →
["GPT-4 reasoning benchmarks", "Claude reasoning benchmarks", "GPT-4 coding", "Claude coding"]
Step-back prompting: generate a more abstract version of the query to retrieve foundational context.
"Why did LeCun say transformers can't scale?" → "LeCun's views on transformer limitations"
Source and licence: JustInCache & contributors — Awesome AI Interviews · Apache-2.0