RAG & Knowledge Retrieval5.0 · 0 ratings

Few-Shot Grounded QA Pattern

Uses worked examples to teach the model the exact grounded-answer and refusal behavior expected.

Few-ShotRAGStructured-Output

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

Few-Shot

Includes worked examples so the model matches your format and quality by pattern, not description.

Learn this technique
RAG

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

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