liveBook · Manning

Chapter 5: Agentic RAG

What you will learn in chapter 5 of Essential GraphRAG

This introduction frames agentic RAG as a multi-retriever system in which a router selects suitable retrieval agents, typically through LLM tool use.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction frames agentic RAG as a multi-retriever system in which a router selects suitable retrieval agents, typically through LLM tool use.

Key terms: agentic RAG system, retrieval agents, retriever router, vector similarity search, unstructured data, structured data, graph data, tool use, function calling, GPT-3.5

5.1 What is agentic RAG?

This section defines a basic agentic RAG system and introduces the router, retriever agents, and answer critic that make it work.

Key terms: agentic systems, agentic RAG, retrieval agents, retriever router, retriever agents, answer critic, user question, original question

5.1.1 Retriever agents

This section defines retriever agents, contrasts generic retrieval approaches with specialized ones, and explains why production agentic RAG systems need both.

Key terms: retriever agents, vector similarity search, hardcoded database query, query template, text2cypher, unstructured data, structured data, graph database, specialized retrievers, generic retrievers

5.1.2 The retriever router

This section explains how a retriever router uses a user question, often with an LLM, to select the appropriate retriever and supply its needed argument.

Key terms: retriever router, retriever agents, LLM, capital_by_country, country_by_capital, extracted argument, hardcoded database queries

5.1.3 Answer critic

This section defines an answer critic that validates retrieved answers, blocks inadequate responses, and drives a bounded retry loop or unavailable-answer response.

Key terms: answer critic, retrievers, original question, blocking function, incomplete answer, incorrect answer, new question, exit criteria, data source

5.2 Why do we need agentic RAG?

This section explains why agentic RAG is valuable for selecting among multiple retrievers and checking answers, especially when data sources or queries are complex.

Key terms: agentic RAG, data sources, specialized retrievers, generic retrievers, vector similarity search, unstructured data, graph database, text2cypher, hard-coded database query, catchall retriever

5.3 How to implement agentic RAG

This section introduces the upcoming implementation of an agentic RAG system and points readers to its accompanying notebook and dataset.

Key terms: agentic RAG system, foundational parts, Jupyter notebook, kg-rag, ch05.ipynb, Movies dataset, appendix

5.3.1 Implementing retriever tools

This section defines the retriever tools an agentic RAG router can choose from and explains how to describe, invoke, and extend them.

Key terms: retrievers, Cypher templates, text2cypher, vector similarity search, retriever description, parameters, OpenAI's tools format, LLM, retriever, system that calls the LLM

5.3.2 Implementing the retriever router

This section implements a retriever router that uses LLM tool calling to select and invoke retrievers, process dependent questions sequentially, and update later queries with earlier answers.

Key terms: tool calls, tools, retriever, handle_tool_calls, LLM, continuous query updating, query updater, original question, updated question, retriever answers

5.3.3 Implementing the answer critic

This section implements an LLM-based answer critic that checks retriever results against the original question and requests follow-up retrieval when information is missing.

Key terms: answer critic, retrievers, original question, JSON format, answer critic function, new questions, LLM, retriever router, missing information, exit criteria

5.3.4 Tying it all together

This section combines the retriever tools, router, and answer critic into a main agentic RAG function with grounded answering and a one-time critique loop.

Key terms: instructions, prompt, consistent, trust, main function, user input, agentic RAG system, answer, critique function, new questions

5.4 Summary

This summary recaps agentic RAG as a tool-calling system that routes questions to suitable retriever agents and checks their answers.

Where this is used later

Concepts explained in this chapter

← Chapter 4: Generating Cypher queries from natural language questions Chapter 6: Constructing knowledge graphs with LLMs →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.