Query decomposition

A RAG technique that breaks a complex user query into independent sub-queries that each get answered separately and synthesized.

What is Query Decomposition?

Query decomposition is a RAG technique that breaks a complex user query into smaller independent sub-queries, answers each one separately, then synthesizes the results into a final response. It is especially useful when the original question spans multiple facts, documents, or hops of reasoning. (docs.llamaindex.ai)

Understanding Query Decomposition

In practice, query decomposition sits between the user prompt and retrieval. Instead of sending one broad query to the retriever, the system first asks an LLM to produce focused sub-questions, such as one for each entity, constraint, or time period in the original request. Each sub-query can retrieve different evidence, which helps reduce missed context when the answer is distributed across multiple sources. (docs.llamaindex.ai)

The final step is synthesis. The system merges the retrieved passages or partial answers, removes redundancy, and generates a single response that reflects the combined evidence. This makes query decomposition a strong fit for multi-hop questions, comparison tasks, and long-form answers where coverage matters as much as precision. (docs.llamaindex.ai)

Key aspects of Query Decomposition include:

  1. Sub-question generation: The original query is rewritten into smaller questions that are easier to answer independently.
  2. Parallel retrieval: Each sub-query can search the knowledge base separately, improving evidence coverage.
  3. Answer fusion: Retrieved snippets or partial answers are combined into one coherent result.
  4. Multi-hop support: The approach works well when the answer depends on more than one fact or document.
  5. Noise control: Narrower searches can reduce irrelevant retrieval compared with one broad query.

Advantages of Query Decomposition

  1. Better recall: Smaller queries can surface evidence that a single broad retrieval pass might miss.
  2. Stronger multi-hop reasoning: It helps when one answer requires combining separate facts.
  3. Cleaner retrieval targets: Focused sub-queries often map more directly to relevant documents.
  4. More transparent pipelines: Teams can inspect each sub-question and its retrieved evidence.
  5. Flexible synthesis: The same pattern can support summaries, comparisons, and stepwise reasoning.

Challenges in Query Decomposition

  1. Decomposition quality: If the sub-questions are poorly formed, retrieval quality drops quickly.
  2. Extra latency: Multiple retrieval passes and synthesis add overhead.
  3. Answer overlap: Sub-queries can retrieve redundant evidence that must be deduplicated.
  4. Harder evaluation: It can be tricky to tell whether failures came from decomposition, retrieval, or synthesis.
  5. Prompt sensitivity: The technique depends on how well the model frames the follow-up questions.

Example of Query Decomposition in Action

Scenario: a user asks, "Compare the pricing, SOC 2 status, and data retention policies of three vendors."

A query decomposition pipeline would split that into separate sub-queries for pricing, compliance, and retention, then retrieve evidence for each vendor under each topic. After that, the system synthesizes the findings into a structured comparison table or summary.

For PromptLayer users, this pattern is especially helpful when building RAG workflows over product docs, policy pages, or internal knowledge bases where one answer rarely lives in a single chunk.

How PromptLayer Helps with Query Decomposition

PromptLayer helps teams track the prompts that generate sub-queries, compare decomposition strategies, and evaluate whether the final synthesized answer is grounded in the right evidence. That makes it easier to iterate on multi-step RAG systems with visibility into each stage of the workflow.

Ready to try it yourself? Sign up for PromptLayer and start managing your prompts in minutes.

Related Terms

Socials
PromptLayer
Company
All services online
Location IconPromptLayer is located in the heart of New York City
PromptLayer © 2026