Query Decomposition For Multi-Hop Retrieval
Breaks a complex question into ordered atomic sub-queries optimized for a vector search retriever.
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.How to use this prompt
- 1
Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.
- 2
Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.
- 3
Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.
Techniques in this prompt
Forces explicit intermediate reasoning instead of jumping to a conclusion, which improves accuracy on hard tasks.
Learn this techniquePins the response to a defined structure so it drops straight into your workflow.
Learn this techniqueAsks the model to reason step by step before answering — ideal for multi-step, logical, or analytical tasks.
Learn this techniqueRecommended models
Build on this prompt
Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.
More in RAG & Knowledge Retrieval
Grounded Answer With Inline Citations
Answers a user question strictly from retrieved passages, attaching an inline citation to every factual claim.
Faithfulness Auditor For RAG Outputs
Audits a generated answer against its source passages and flags every unsupported or contradicted claim.
Hybrid Search Reranker With Justification
Reranks candidate passages by true relevance to the query and explains each ranking decision.
Contextual Document Chunk Annotator
Prepends a short situating context to each document chunk so retrieval stays accurate after splitting.