Home/
Part XIII — Expert Mode: Systems, Agents, and Automation/41. Advanced RAG (Beyond the Basics)/41.5 "Answer with provenance" techniques
41.5 "Answer with provenance" techniques
Overview and links for this section of the guide.
On this page
Citations
Link every claim to its source. This enables verification and builds trust.
Implementation
const PROVENANCE_PROMPT = `
Answer the question using ONLY the provided sources.
For each claim, include a citation [1], [2], etc.
Sources:
${sources.map((s, i) => `[${i+1}] ${s.title}\n${s.content}`).join('\n\n')}
Output format:
{
"answer": "The answer with inline [1] citations [2]...",
"citations": [
{"id": 1, "source": "title", "quote": "exact text used"}
]
}
`;
// Verify citations exist in sources
function verifyCitations(response: any, sources: Source[]): boolean {
return response.citations.every(c =>
sources.some(s => s.content.includes(c.quote))
);
}