Query Decomposition for Complex Questions
What you'll learn: How to break down multi-part user questions into simpler sub-queries that your RAG system can answer independently and then combine.
The Problem with Complex Questions
When users ask compound questions like "Who won the 2020 Olympics gold medal in swimming and what country are they from?", a single retrieval pass often fails. The question contains two distinct information needs: (1) identifying the gold medalist, and (2) finding their nationality. Retrieving documents for the whole question may return irrelevant results that mention both "swimming" and "country" without actually answering either part.
What Is Query Decomposition?
Query decomposition is the process of splitting a complex question into atomic sub-queries—simpler questions that can each be answered independently. Think of it like factoring a math problem: instead of solving (a + b) × (c + d) all at once, you break it into steps.
For our swimming example:
- "Who won the 2020 Olympics gold medal in swimming?"
- "What country is [athlete name] from?"
Each sub-query targets a specific fact. You retrieve documents for each separately, then combine the answers into a final response.
How It Works in RAG
After query clarification and disambiguation (which you've already learned), decomposition identifies dependencies between sub-questions. Some sub-queries are independent; others depend on previous answers (like needing the athlete's name before finding their country). You execute retrievals sequentially or in parallel as dependencies allow, then aggregate results for the generation phase.
Key Takeaway: Query decomposition transforms complex, multi-part questions into atomic sub-queries that can be answered independently, dramatically improving retrieval accuracy for compound information needs in RAG systems.