RAG with LangGraph
Agentic, corrective and adaptive retrieval-augmented generation.
RAG as a LangGraph graph, with a model deciding around the search instead of a fixed retrieve-then-answer chain. The first lesson compares three designs and the research behind them: agentic RAG, where a model with retriever tools decides whether and where to search; corrective RAG, which grades every retrieved chunk and turns to a web search when the chunks fail; and adaptive RAG, which routes each question to the right source and checks its own answer before returning it. The next three lessons build each design over real web pages, show what their runs did and where their loops never end, and the last one combines them in a single script with Gemini, with limits on every retry. Run the notebook cells in order, and try each practice task before you open its solution.
Lessons
- 1Agentic, corrective and adaptive RAGWhere a fixed RAG pipeline breaks, agentic RAG (retrievers as tools), corrective RAG (grade the chunks, rewrite, search the web), adaptive RAG (route the question, check the answer), the research behind each, the building blocks, what the extra calls cost, what goes wrong, which to use, interview questions and two practice tasks in plain Python.
- 2Agentic RAGTwo collections of documentation pages, retrievers as tools and what they return, the messages state, the agent, grade, generate and rewrite steps, the graph and its three runs, the answer stored as a human message, the rewrite loop run without a model, how LangGraph's documentation builds it today, interview questions and two practice tasks.
- 3Corrective RAGThe corrective flow, an index of three blog posts split by tokens, a document grader with structured output and why its field should be a Literal, the answer chain and what a list of Documents looks like inside a prompt, the question rewriter, web search with Tavily, the state, the nodes and the graph, the saved run, why one bad chunk sends the question to the web, interview questions and two practice tasks.
- 4Adaptive RAGQuery analysis and self-correction, the router with a Literal choice, the retrieval grader, the answer chain, the hallucination and answer graders, the rewriter, the state, nodes and edges with a conditional entry point, the graph, two saved runs replayed step by step, the three loops and why none of them ends, interview questions and two practice tasks.
- 5Adaptive RAG in one scriptAn adaptive RAG app in one script with Gemini and Tavily: what it changes from the notebook graphs, every step explained, the limits that end every loop, how to run it, which piece to swap, and a practice task that counts the worst case in plain Python.