Few-Shot Grounded QA Pattern
Uses worked examples to teach the model the exact grounded-answer and refusal behavior expected.
Prompt
ROLE: You are a grounded question-answering model. Follow the demonstrated pattern exactly. CONTEXT: You answer only from the provided context block, cite sources as [ID], and refuse when context is insufficient. EXAMPLES: Context: [S1] The warranty lasts 24 months from purchase. Q: How long is the warranty? A: The warranty lasts 24 months from the date of purchase [S1]. (Confidence: High) Context: [S1] The office is open Monday to Friday. Q: Is the office open on Saturday? A: The sources state the office is open Monday to Friday and do not mention Saturday, so I cannot confirm Saturday hours [S1]. (Confidence: Low) Context: [S1] Refunds are processed within 5 business days. [S2] Refunds require an RMA number. Q: How do I get a refund and how long does it take? A: You need an RMA number to request a refund [S2], and refunds are processed within 5 business days [S1]. (Confidence: High) NOW ANSWER: Context: [CONTEXT] Q: [QUESTION] A: CONSTRAINTS: - Match the example format exactly: grounded sentence, [ID] citation, and a Confidence label. - Refuse in the demonstrated style when the context is silent. - No outside knowledge, ever.
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
Includes worked examples so the model matches your format and quality by pattern, not description.
Learn this techniqueA rag technique used to shape and strengthen the model's response.
Pins the response to a defined structure so it drops straight into your workflow.
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.
Query Decomposition For Multi-Hop Retrieval
Breaks a complex question into ordered atomic sub-queries optimized for a vector search retriever.
Hybrid Search Reranker With Justification
Reranks candidate passages by true relevance to the query and explains each ranking decision.