Query Decomposition for Multi-Hop Retrieval
Single-shot dense retrieval embeds an entire question into one vector and competes that vector against the corpus. For questions that compose multiple independent evidence chains — which department offers procedure P? + which doctors work in that department? + when do those doctors consult on campus C? — a single embedding cannot represent the conjunction faithfully. Empirically, the model picks two of the three aspects, retrieves chunks that satisfy those two, and either hallucinates or silently omits the third aspect.
Query decomposition (see ADR-0032) breaks multi-hop queries into focused single-hop sub-questions, retrieves each in parallel, and merges the evidence before the LLM sees the context. This page documents the algorithm, the LLM prompt, the trade-off matrix that shaped the design, an experiment summary (self-reported), and the worked example.
The problem in one query
Consider:
"Welke arts op campus Sint-Jan doet knieoperaties en wanneer consulteert hij?"
Which doctor on campus Sint-Jan does knee operations, and when does he consult?
A faithful answer requires three independent lookups:
- Which department offers knee surgery? (treatment → department)
- Which doctors work in that department? (department → doctors)
- When do those doctors consult on campus Sint-Jan? (doctors + campus → schedule)
Without decomposition, vector search blends all three aspects into one embedding. The retrieved chunks typically cover Orthopedie and a handful of orthopedic surgeons, but consultation-schedule chunks are not in the top-K because the embedding's "schedule on Sint-Jan" component is diluted by the dominant "knee surgery" component. The LLM either hallucinates the schedule or quietly omits it. Decomposition fixes this at retrieval time, before the LLM is involved.
Trade-offs
| Decision | Chosen | Alternatives considered | Rejected because |
|---|---|---|---|
| When to decompose | LLM gate on every query that fails the cheap heuristic gate | Always decompose; never decompose; rule-based regex classifier | Always-decompose adds an avoidable model call to the large majority of queries, which are single-hop. Never-decompose loses the multi-hop case the feature exists to solve. A regex classifier was tried first and missed conjunctive forms across Dutch, English, French, and Italian patient input — patterns multiplied without ever achieving acceptable recall. The two-stage gate (heuristic + LLM) gives free pass-through for obviously simple queries and structured-output reliability where it matters. |
| Output validation | A shared schema-validated output helper with retries; plain JSON parsing retained as a fallback only after the helper's retries are exhausted | Raw client + plain JSON parsing; LangChain output parsers; an agent framework | Plain JSON parsing shipped malformed outputs to downstream code without retry, which is exactly the silent-failure pattern the project banned in May 2026. LangChain pulled in a heavier dependency surface than its runtime value justified. An agent framework was trialled but removed on 2026-05-12 after telemetry showed it added noticeable latency per call. The helper enforces the schema, retries on validation failure, and only triggers the fallback when all retries are exhausted. |
| Sub-question reranking | Per-sub-question reranking + round-robin interleave | Merge all sub-question results, rerank against the original blended query | The merge-then-rerank approach silently dropped minority topics: chunks about rolstoelen scored poorly against a 5-topic query dominated by afspraak and parking, even when the chunks existed in the corpus. Per-sub-question reranking scores each chunk against its own sub-question; round-robin interleaving guarantees every topic's best chunk reaches the top of the assembled context. |
| Sub-question concurrency | Parallel sub-retrieval; sequential reranking | Fully parallel (retrieval + rerank); fully sequential | Concurrent reranker calls trip API rate limits or — when the API fails — trigger parallel local-model fallback downloads that deadlock on the GPU lock. Sequential reranking costs one reranker call per sub-question (typically three or fewer), which is acceptable on the multi-hop branch where the user has already accepted higher latency in exchange for a complete answer. |
Architecture
Query decomposition sits at Stage 1b of the pipeline, between intent classification and retrieval:
Stage 1 — Heuristic gate (zero cost)
A query passes the heuristic gate as single-hop if both of:
- 6 words or fewer, AND
- The intent classifier extracted at most one entity type (campus, department, condition, treatment, examination, doctor)
For most pilot traffic the gate accepts immediately, saving one model call per query. The gate uses both the raw query and the entities extracted by the upstream classifier.
Stage 2 — LLM gate
Queries that do not pass the heuristic gate are sent to a Tier 2 model (a small, inexpensive model) with a required output schema: a yes/no multi-hop flag and a list of sub-questions. If the output fails validation the model is re-prompted; only after retries are exhausted does a legacy parsing fallback run, which exists purely as defence-in-depth (in pilot operation it has not fired).
The prompt instructs the model on multi-hop and single-hop indicators:
Multi-hop indicators (decompose)
- Doctor identification + department / campus / schedule
- Treatment-or-condition to department mapping + doctor listing
- Campus-specific filtering + service availability
- Temporal constraints (schedule, consultation hours) + entity lookup
- Cross-entity comparison ("arts die X doet EN op campus Y werkt")
Single-hop indicators (do NOT decompose)
- Simple entity lookup: "Wie is de kinderarts van de afdeling?"
- Single department: "Welke artsen werken bij Cardiologie?"
- Simple condition routing: "Waar kan ik terecht met diabetes?"
- Factual: "Wat zijn de bezoekuren?"
When the query is multi-hop the model returns at most six sub-questions (a configurable cap). Each sub-question must be:
- Written in Dutch (regardless of input language — already reformulated upstream).
- Self-contained — no pronouns or anaphoric references.
- Targeting a single entity type or relationship.
- Ordered by dependency (department before doctors, doctors before schedule).
Example output (the three sub-questions for the knee-surgery query above):
- "Welke afdeling van het ZOL biedt knieoperaties aan?"
- "Welke artsen werken bij de afdeling Orthopedie?"
- "Wanneer consulteren deze artsen op campus Sint-Jan?"
Stage 3 — Parallel retrieval
Each sub-question fans out to an independent retrieval call, using separate database sessions so the retrievals truly execute in parallel. Wall-clock latency for the retrieval phase scales with the slowest sub-query, not the sum.
Stage 4 — Per-sub-question reranking
Each sub-question's result list is reranked against its own sub-question by the cross-encoder (Jina Reranker v2, with a local BGE fallback — see Reranking & Evaluation). Graph results and keyword-rescue chunks are pinned — they pass through reranking unchanged because their relevance is already known structurally.
Reranking is sequential across sub-questions to avoid concurrent reranker API calls.
Per-sub-question top-K is the total top-K divided by the number of sub-questions (rounded up), with a floor of 3 chunks per sub-question.
Stage 5 — Round-robin interleave + dedup
The reranked lists are merged by taking the best chunk from each list, then the second-best from each, and so on, skipping duplicates.
Round-robin guarantees every sub-question's best chunk reaches the top of the merged pool. Without it, a sub-question with three near-tied top chunks could push a different sub-question's top chunk past the assembled-context budget. After dedup the merged pool is handed to context assembly.
Configuration
Three settings control the feature (all adjustable by an administrator without a code change): a master switch (off by default; when off the service is not instantiated and adds no overhead), the model used for the LLM gate (a small, inexpensive model), and an upper bound on sub-questions per query (default 6, range 2-8).
Fault tolerance
The service is designed to never break the pipeline:
| Failure mode | Behaviour |
|---|---|
| Output validation failure | Retry on malformed output; on exhaustion use the legacy parsing fallback. |
| Fallback parsing also fails | Fall back to single-hop with the original query. |
| LLM timeout / network error | Fall back to single-hop. |
| Multi-hop flag set with no sub-questions | Treat as single-hop. |
| Sub-question count exceeds the cap | Truncate to the cap. |
| Sub-retrieval fails for one sub-question | Continue with the remaining sub-questions; the failed one contributes no chunks. |
| Feature switch off | Service not instantiated; no overhead. |
Cost and latency
Single-hop queries accepted by the heuristic gate (the large majority of pilot traffic) incur no additional cost or latency. Single-hop queries confirmed by the LLM gate incur one small model call. Multi-hop queries incur that call plus the sub-retrievals, and their wall-clock latency is dominated by the slowest sub-retrieval and the sequential per-sub-question reranking. Token counts for the decomposition stage are written to the cost tracker per call. No dated latency or cost measurement is published here.
A/B experiment results (self-reported, historical)
Date: 17 February 2026. Question set: 121 questions from the project's golden evaluation set. Method: one run per condition, comparing a vector-only baseline with hybrid retrieval (vector search plus the knowledge-graph lookup, which at the time was a Neo4j graph, since replaced by PostgreSQL taxonomy tables). Metric: entity recall, a case-insensitive check that the expected entity names appear in the answer. This is the project's own measurement; it measures entity recall only, not answer correctness, and has not been independently reproduced. The experiment record describes a comparison of hybrid versus vector-only retrieval; whether query decomposition was active in the hybrid arm could not be verified, so these figures must not be read as the effect of decomposition alone.
| Metric | Vector-only (A) | Hybrid (B) |
|---|---|---|
| Entity recall | 0.881 | 0.915 |
By number of graph hops the question required:
| Hops | n | Vector-only | Hybrid |
|---|---|---|---|
| 0 (simple) | 17 | 0.971 | 0.971 |
| 1 | 23 | 0.826 | 0.891 |
| 2 | 16 | 0.771 | 0.865 |
| 3 | 7 | 0.810 | 0.857 |
The pattern is the one the design predicts: simple (0-hop) questions show no difference, and questions needing independent evidence chains (2 hops) benefit most. Subgroups are small (7 to 23 questions), so these differences should be read as indicative only. A re-run after the embedding-model migration (ADR-0048) has not been done; the figures above are retained as the historical record.
Worked example
Query: "Welke arts op campus Sint-Jan doet knieoperaties en wanneer consulteert hij?"
Step 1 — Heuristic gate. 11 words; two entity types (a campus and a treatment). Gate routes to the LLM.
Step 2 — LLM gate. The model flags the query as multi-hop with three sub-questions covering department, doctors, and schedule (see the example in Stage 2 above).
Step 3 — Parallel retrieval:
- Sub-Q1: taxonomy finds Orthopedie via an "offers" relationship; vector finds the knee-surgery brochure.
- Sub-Q2: taxonomy finds orthopedic surgeons via a "works in" relationship; vector finds doctor brochure pages.
- Sub-Q3: vector finds the Orthopedie consultation-schedule page for campus Sint-Jan.
Step 4 — Per-sub-question reranking + Step 5 — Round-robin interleave. The merged pool contains unique chunks covering department + doctors + schedule, with the consultation-schedule chunk in position 1 of its sub-question's reranked list — so it survives interleaving instead of being dominated by the higher-volume orthopedic-surgeon chunks.
Result. The LLM receives complete context for all three aspects and emits a single answer covering department, surgeon names, and consultation times, with citations to each.
References
- Khattab, O., et al. (2022). Demonstrate-Search-Predict. arXiv 2212.14024. — Composable retrieve-then-search-then-predict pattern; the conceptual lineage of decomposition-style retrieval.
- Trivedi, H., et al. (2023). Interleaving Retrieval with Chain-of-Thought Reasoning for Knowledge-Intensive Multi-Step Questions. ACL 2023. — Multi-hop QA via decomposition + interleaved retrieval.
- Min, S., et al. (2019). Multi-hop Reading Comprehension through Question Decomposition and Rescoring. ACL 2019. — Foundational work on question decomposition for multi-hop reasoning.
- Anthropic. (2024). Introducing Contextual Retrieval.