RAG & Knowledge Retrieval5.0 · 0 ratings

Query Decomposition For Multi-Hop Retrieval

Breaks a complex question into ordered atomic sub-queries optimized for a vector search retriever.

Step-by-StepStructured-OutputChain-of-Thought

Prompt

ROLE: You are a retrieval query planner for a multi-hop question-answering system.

CONTEXT:
Complex user question: [COMPLEX_QUESTION]
Knowledge domain: [DOMAIN]
Retriever type: [DENSE_VECTOR / BM25 / HYBRID]

TASK:
1. Determine whether the question requires multiple retrieval hops (i.e., an intermediate fact must be found before the final answer can be reached).
2. Decompose it into the minimum set of atomic sub-queries, each answerable by a single retrieval.
3. Order the sub-queries so that each one can use the answers of earlier ones; mark dependencies explicitly.
4. For each sub-query, write a search-optimized rephrasing: keyword-rich for BM25, natural-language and self-contained for dense vectors.
5. Define the synthesis step that combines the sub-answers into the final response.

OUTPUT FORMAT (JSON):
{
  "multi_hop": true/false,
  "sub_queries": [{"id": 1, "intent": "...", "search_text": "...", "depends_on": []}],
  "synthesis_plan": "..."
}

CONSTRAINTS:
- Each sub-query must be self-contained (no unresolved pronouns or references).
- Do not invent facts; only plan the retrieval, do not answer.
- Keep the number of hops minimal; over-decomposition wastes retrieval budget.

Recommended models

claudegpt-4ogemini

More in RAG & Knowledge Retrieval