Query decomposition

On this page 7

Query decomposition is a retrieval technique that splits a complex user question into smaller, self-contained sub-queries, retrieves evidence for each one separately and then combines the partial answers into a final response. In retrieval & knowledge systems for artificial intelligence, it is most often used inside retrieval-augmented generation (RAG) pipelines, where a single search for a compound question tends to miss part of the required evidence.

The technique addresses a structural mismatch: embedding search works best for focused questions, while real users ask questions that compare entities, chain facts or span several time periods. Decomposition turns one hard retrieval problem into several easy ones.

How query decomposition works

A typical pipeline has four stages. A decomposer, usually a large language model with a dedicated prompt, analyzes the question and produces a list of sub-queries. A retriever runs each sub-query against the index. An optional intermediate reasoning step answers each sub-query from its own evidence. Finally, a synthesis step merges the sub-answers or the pooled passages into one grounded response.

The question “Did the company spend more on research in 2023 than its main competitor?” illustrates the mechanism. A single vector search may return documents about only one firm. Decomposition produces two lookup queries for each firm’s research spending and leaves the comparison to the generator, which then sees both figures side by side.

The stages and their typical implementations are summarized below.

StageTypical implementationOutput
DecompositionLLM prompt with few-shot examplesList or graph of sub-queries
RetrievalDense, sparse or hybrid search per sub-queryRanked passages per sub-query
Sub-answeringLLM call grounded in each passage setShort intermediate answers
SynthesisFinal LLM call over all evidenceOne answer with citations
Stages of a query decomposition pipeline

Parallel and sequential decomposition

Decomposition comes in two main forms. Parallel decomposition creates independent sub-queries that can run at the same time, which suits comparisons and multi-aspect questions. Sequential decomposition creates a chain in which a later sub-query depends on the answer to an earlier one, which is the core of multi-hop retrieval.

For example, “Where was the founder of the company that makes product X educated?” cannot be answered in parallel, because the founder’s name is unknown until the first hop returns. Sequential plans are more powerful but add latency with every hop and can propagate an early error through the whole chain.

FormDependency between sub-queriesBest forMain cost
ParallelNoneComparisons, multi-aspect questionsMore retrieval calls
SequentialEach step uses the previous answerMulti-hop questionsHigher latency, error propagation
Tree or graphMixed parallel and sequential branchesComplex analytical questionsPlanning overhead
Least-to-mostSimple steps build toward the hard oneReasoning-heavy questionsLonger prompts
Main forms of query decomposition

Query decomposition is one member of a family of query transformation methods, and the names are often confused. Query rewriting produces one better-phrased query, query expansion adds terms or synonyms, and HyDE generates a hypothetical answer to embed instead of the question. Only decomposition changes the number of information needs the system addresses.

TechniqueNumber of queries producedMain goal
Query decompositionSeveral distinct sub-queriesCover every part of a compound question
Query rewritingOne improved queryFix vague or conversational phrasing
Query expansionOne query with added termsRaise recall for lexical search
RAG-FusionSeveral paraphrases of the same needRobust ranking via rank fusion
HyDEOne hypothetical documentAlign query and document embeddings
Comparison with neighboring query transformations

The techniques combine well. A system may rewrite a conversational question, decompose it, and then merge the results of the sub-queries with reciprocal rank fusion before reranking.

When to apply query decomposition

Decomposition is worth its cost only when the question is genuinely compound. Applying it to every query wastes tokens and can even hurt simple lookups by fragmenting them. Many production systems therefore place a classifier or query router in front of the decomposer that decides whether a question needs splitting.

Question typeRecommended approachReason
Single fact lookupNo decompositionOne retrieval already finds the evidence
Comparison of entitiesParallel decompositionEach entity needs its own evidence
Bridging questionSequential decompositionLater steps need earlier answers
Open analytical requestAgentic planning with decompositionSteps are not known in advance
Decision guide for query decomposition

Good decomposer prompts specify a maximum number of sub-queries, often three to five, require each sub-query to be answerable on its own without pronouns that point back to the original question, and ask the model to return structured output such as a JSON list.

In agentic RAG designs, decomposition is not a single upfront step. The agent plans, retrieves, inspects the evidence and replans, adding new sub-queries only when a gap appears. This adaptive form handles questions whose structure is unclear at the start, but it needs stopping rules, such as a maximum number of retrieval rounds, to keep cost predictable.

Limitations and failure modes

The main trade-off is quality versus cost and latency. Each sub-query adds at least one retrieval call and often one model call, so a five-way decomposition can multiply response time and token spend several times over. Sequential chains suffer most, since steps cannot overlap.

  • Over-decomposition: trivial questions are split into redundant sub-queries that retrieve the same passages.
  • Lost constraints: a sub-query drops a date, region or unit from the original question and retrieves the wrong evidence.
  • Error propagation: a wrong first hop sends every later step in the wrong direction.
  • Weak synthesis: correct sub-answers are combined incorrectly, for example by comparing figures in different currencies.
  • Evaluation difficulty: end-to-end metrics hide which sub-query failed, so per-step tracing is needed.

Teams usually measure the benefit with multi-hop benchmarks and with RAG evaluation metrics such as context recall, comparing the decomposed pipeline against a single-query baseline on the same question set.

A non-technical view

Imagine asking a librarian a question with three parts. A good librarian does not search for the whole sentence at once. They split it into three small questions. They find a book for each part. Then they put the answers together for you.

Query decomposition does the same for an AI search system. Big, mixed questions are hard to look up in one go. Small, clear questions are easy. The system asks several simple questions instead of one hard one, then writes a single answer from everything it found.

A concrete example

An internal assistant at a manufacturing firm answers questions over 12,000 policy and product documents. Employees often ask questions such as “How does the warranty period for the industrial pump differ between the EU and the US, and who approves extensions?” A single vector search returned mostly EU documents, and answers missed the US terms in roughly a third of test cases.

The team added a decomposer that produces up to four sub-queries: the EU warranty period, the US warranty period, the extension policy and the approval role. Each sub-query retrieves its top five passages, and the final model compares them. On a set of 200 compound test questions, complete answers rose from 61 to 84 percent, while average response time grew from 2.1 to 3.4 seconds, a cost the team accepted for this use case.