2-step RAG with citations
Notebook· 06.06· 150–180 min· Lesson 51 of 129
The notebook opens in your lab, in a new tab. If your server is stopped, it starts first (a few seconds).
By the end you can
- Build a 2-step RAG chain: retrieve → prompt with numbered sources →
with_structured_output(CitedAnswer). - Verify every citation in code: the quote must be a substring of a retrieved chunk from the cited source.
- Implement a "not found in the sources" policy and test it on out-of-corpus questions.
- Show retrieval in a LangSmith trace (
run_type="retriever"). - Recognise prompt injection hidden in documents, and what does (and doesn't) protect you.
Before you start
Lessons 06.01–06.05; Lesson 01.05 (structured output).
