Prompt for Answering Only From Provided Context
This is a grounding prompt for retrieval-augmented generation setups: it forces ChatGPT, Claude, or Gemini to answer strictly from the text you provide and say so clearly when the answer isn't in it, instead of filling gaps with outside knowledge.
It's built for anyone wiring a model up to search results, internal documents, or a knowledge base, where an answer that sounds right but wasn't actually in the source is worse than no answer at all.
Prompt template
Want it sharper? Optimize this prompt with Prompt Optimizer, check it with the Prompt Debugger or shorten it with the Token Optimizer.
Example input
When to use it
- Building a RAG pipeline where answers must be traceable to source documents
- Question answering over internal docs, policies, or support articles
- Summarizing search results without letting the model add outside facts
- Any customer-facing bot where a hallucinated answer is a real risk
Best practices
- Pass only the retrieved passages that are actually relevant, not the whole document
- Ask the model to quote the specific passage it used to support its answer
- Explicitly instruct it to say the answer wasn't found when that's true
- Keep the context and the question in clearly separated sections
Common mistakes
- Not telling the model what to do when the answer isn't present, so it guesses
- Passing too much irrelevant context, which dilutes the retrieval signal
- Skipping citations, making it hard to verify the answer against the source
- Assuming grounding is automatic just because you supplied context
FAQs
Why would a model ignore instructions and use outside knowledge anyway?
Larger models sometimes blend in general knowledge when the context is thin. Making the not-found instruction explicit and repeating it reduces this, though it's not foolproof, so always spot-check outputs in a production system.
How much context should I include?
Only the passages your retrieval step actually ranked as relevant. Dumping in unrelated documents makes it harder for the model to stay grounded and wastes tokens.
Can I use this without a real retrieval system, just pasted text?
Yes. The prompt works the same whether the context came from a vector search or you pasted it in manually.
What's the difference between this and a normal summarization prompt?
A summarization prompt condenses what's there. This prompt also has to refuse to answer when the information isn't there, which most summarization prompts don't enforce.