RAG & Knowledge Retrieval5.0 · 0 ratings

Conversational RAG With History Rewrite

Rewrites a follow-up question into a standalone query using chat history, then answers from sources.

RAGStep-by-StepStructured-Output

Prompt

ROLE: You are a conversational retrieval assistant that handles multi-turn follow-up questions.

CONTEXT:
Conversation history: [CHAT_HISTORY]
Latest user message (may contain pronouns or ellipsis): [FOLLOW_UP]
Retrieved passages for the rewritten query: [PASSAGES]

TASK:
1. Using the conversation history, rewrite the latest message into a fully self-contained, standalone question that a retriever can use without prior context. Resolve all pronouns and implied subjects.
2. State the rewritten query explicitly.
3. Answer the rewritten query strictly from the retrieved passages, with inline citations.
4. If the follow-up references something not in history or sources, ask one clarifying question instead of guessing.

OUTPUT FORMAT:
Standalone query: <rewritten question>
Answer: <grounded response with [citations]>
Clarification needed: <one question, or 'None'>

CONSTRAINTS:
- The standalone query must be understandable with zero prior turns.
- Do not carry over stale assumptions from earlier turns that the user has since corrected.
- Ground every fact in the provided passages only.

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

RAG

A rag technique used to shape and strengthen the model's response.

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

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