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.

How to use this prompt

  1. 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. 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. 3

    Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.

Techniques in this prompt

Step-by-Step

Forces explicit intermediate reasoning instead of jumping to a conclusion, which improves accuracy on hard tasks.

Learn this technique
Structured Output

Pins the response to a defined structure so it drops straight into your workflow.

Learn this technique
Chain-of-Thought

Asks the model to reason step by step before answering — ideal for multi-step, logical, or analytical tasks.

Learn this technique

Recommended models

claudegpt-4ogemini

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