Prompts / RAG answer with citations
RAG answer with citations
A grounded-answer prompt template for a retrieval-augmented system, so answers cite their sources and admit gaps instead of blending in unsourced claims.
Copying runs entirely in your browser - nothing here is ever sent anywhere.
Fill in the variables
Answer the question using ONLY the retrieved passages below. Do not use
any outside knowledge, even if you're confident it's correct - if the
passages don't contain the answer, say so explicitly rather than filling
the gap from general knowledge.
For every claim in your answer, cite which passage it came from using
[1], [2], etc. matching the numbering below. If a sentence combines
information from two passages, cite both. A sentence with no citation
should be a connector ("Given that,") not a new factual claim.
If the passages partially answer the question but leave something out,
answer what you can and explicitly name what's missing, rather than
implying full coverage.
If the passages contradict each other, say so and present both instead of
silently picking one.
Question: {{question}}
Retrieved passages:
{{retrieved_chunks}}
When to use
As the answer-generation prompt in a RAG pipeline (the step after retrieval, before returning an answer to the user) - or for manually sanity-checking retrieved chunks by pasting them in along with a question, to see whether they actually support a good answer before wiring up the full pipeline.
Why it works
The most common RAG failure mode isn’t retrieval missing the right document - it’s the generation step blending retrieved facts with the model’s own background knowledge so seamlessly that a wrong or unsupported claim looks just as confident as a grounded one. Forcing a citation per claim makes ungrounded claims visually stand out (no citation), and explicitly asking the model to name gaps and contradictions turns “silently wrong” into “visibly incomplete,” which is a much safer failure mode for a system whose whole point is trustworthy grounding.
Variations
- Add “Format citations as clickable links to {{source_url_pattern}}” if your chunks carry source URLs you want surfaced in the UI.
- For a stricter system, add “If fewer than half the retrieved passages are relevant to the question, say the retrieval likely failed rather than forcing an answer from thin evidence.”
- Ask for a confidence label (high/medium/low) per claim, not just a citation, if downstream logic needs to react differently to weakly supported answers.