The full chain, assembled: chunking, embeddings, retrieval, grounded generation, refusal handling, and citations — all built and run for real.
1Why Citations Close the Loop
Every piece before this lesson made the answer correct. Citations make it verifiable — a user (or a developer debugging a wrong answer) can check exactly which source backs a claim, rather than trusting the model's word for it. It's the difference between 'probably grounded' and 'demonstrably grounded', and it only cost one more line in the system prompt because Module 2 already labeled every source.
2The Full Pipeline You Built
Chunk real documents (Module 1) → embed chunks and queries with a real API (Module 1) → search and format the most relevant chunks (Module 2) → generate a strictly grounded, cited answer (Module 3). Every one of those four stages is a real function or a real API call you wrote and ran yourself — not a diagram you watched get explained.
3Step-by-Step Breakdown
The Last Piece: Citations. Back in Module 2 you labeled every retrieved chunk with a source number specifically so the model could cite it. This lesson finally uses that: one more instruction, and every grounded answer names exactly which source it came from — the mark of a genuinely production-ready RAG answer.
Your Complete RAG Chatbot. This is the full chain: strict grounding, real retrieved context with numbered sources, and now a citation requirement. Run it and confirm the answer both states the correct policy AND ends with the exact source that backs it — a fully traceable, grounded, cited answer.
What does this masterclass's complete pipeline actually consist of, end to end?
- →Chunk documents, embed the chunks and the query, retrieve and format the most relevant chunks, then generate a grounded, cited answer using a strict system prompt.
- →A single API call that automatically knows your private company data.
Masterclass Complete. You built a real RAG chatbot: chunking, embeddings, a vector store, retrieval, grounded generation, graceful refusal, and citations — every piece implemented and run for real, not just watched. The exact hallucination from Lesson 1 is fixed. This is the actual architecture behind production RAG systems.
Level Up 🚀
Advanced cheat sheets, SEO tricks, and interview prep for this topic.
Browser Support
Fully supported.
Fully supported.
Fully supported.
Fully supported.
Accessibility (A11y)
1Make Citations Navigable, Not Just Visible
A production RAG UI should let users click or focus a citation like [Source 1] to jump to or preview the actual source document, not just display it as static text.
<a href="#source-1" aria-label="View Source 1: PTO Policy">[Source 1]</a>SEO Implications
- 1
Target 'build a RAG chatbot from scratch' as the primary search for this masterclass
This is the exact high-intent phrase developers search for once they've decided to build rather than just read about RAG.
Best Practices
Ship Citations Alongside Every Grounded Answer
A cited answer costs almost nothing extra to generate once sources are labeled, and it converts an opaque 'trust the model' UX into a verifiable one — always include citations in production RAG systems.
Frequent Bugs
Adding a citation instruction but not testing that it survives alongside the refusal instruction for out-of-scope questions.
Test citation behavior across both the answerable and unanswerable cases — a citation requirement can sometimes cause a model to fabricate a source number even when refusing, which needs its own explicit instruction to prevent.
Real-World Examples
Production HR Chatbot, Complete
The Nexora HR chatbot now answers 'You can roll over up to 5 PTO days [Source 1]' — correct, grounded, and traceable back to the exact handbook section, the complete production pattern this masterclass built piece by piece.
"You can roll over up to 5 unused PTO days. [Source 1]"