Overview

13 Knowledge graph-powered retrieval augmented generation

2023 marked a turning point for applied NLP as powerful general-purpose LLMs made it easy to prototype conversational apps, but real value requires more than “question in, answer out.” The chapter frames this shift through AI agents—autonomous systems that plan, use tools, and collaborate—to tackle tasks demanding multi-step reasoning, current and private data access, and governance. It highlights production challenges with LLMs such as hallucinations, knowledge cutoffs, opacity, privacy and access control, cost, and bias, motivating Retrieval Augmented Generation (RAG) as a grounding approach that injects reliable external context into generation.

The chapter first walks through classic vector-based RAG: chunk documents, embed them, index in a vector store, retrieve semantically similar chunks for a query, and let the model answer with that context. While simple and broadly useful, this approach suffers from fragmented context and weak multi-hop reasoning, scalability trade-offs, embedding blind spots (missing exact entities or fine-grained domain nuances), and both noise and misses in retrieval that can distract models or omit crucial facts. A Rockefeller Archive Center use case illustrates how purely semantic similarity can retrieve plausible yet irrelevant passages and struggle with aggregate or cross-document questions.

To address these gaps, the chapter advances Graph RAG, where a Knowledge Graph acts as a governed, interpretable, and up-to-date source of truth that complements LLMs. Using a text-attributed and text-paired KG, the system adds three tool types: a KG Retriever (schema-aware Cypher queries for entities, properties, paths, and aggregates), a KG‑Enhanced Document Retriever (precisely fetch documents that mention specific entities/relations), and a semantic retriever as backup. Orchestrated by a ReAct-style agent (e.g., via LangChain), the agent decomposes queries, retrieves structured facts and the exact supporting documents, and then composes grounded answers. The result is higher accuracy, reduced hallucinations and distraction, better transparency, and stronger domain performance, with suggested production enhancements like Cypher self-correction, document re-ranking, and expanded toolsets.

An AI Agent design for KG-powered question answering. The agent has multiple tools at its disposal, which use external data sources such a vector database and a Knowledge Graph to provide necessary context for the user’s question.
Vector search-based Retrieval Augmented Generation. The documents are embedded into dense vector representation and indexed in a vector database. When a user asks a question, it is also embedded, and the most similar documents are retrieved from the database. The agent then generates the final answer.
The Rockefeller Archive Center KG as a combination of Text-Attributed and Text-Paired graphs. The documents are represented as nodes, each having properties representing metadata such as author, type of document, and date. The extracted entities and relationships are traceable back to the original documents, which enables us to design a KG-based document selection tool for AI Agents.
KG-powered Retrieval Augmented Generation agent with a grounding in external data sources: the Knowledge Graph and a vector database.
Example of Graph RAG agent internal steps. The agent starts with a thought that leads it to use the KG Retriever to obtain a list of people who talked about Dorothy M. Wrinch. Then for each of them, the KG-enhanced Document Retriever is used to identify the relevant documents. Finally, all of this is used as a context by the agent for generating the final answer.

Summary

  • An AI agent is a combination of an LLM model functioning as the agent’s brain, and a set of tools that allow the agent to interact with the outside world.
  • Retrieval Augmented Generation (RAG) is a framework for building intelligent systems, such as AI agents, by combining generative models and information retrieval. As such, it addresses inherent LLM issues such as hallucinations, freshness, transparency or data privacy.
  • Vector-based RAG systems suffer from multiple shortcomings such as limited reasoning capabilities, scalability issues, or inaccuracies in retrieval, including noise and missed relevant information.
  • Graph RAG integrates KGs with LLMs to reinforce the reasoning capabilities and precision of information retrieval by leveraging the structured relational multi-hop patterns within the KGs. KGs also bring in more control and transparency into the overall question-answering process.
  • The KG integration methods into RAG systems are determined by the graph design. The most useful KGs are a combination of text-attributed and text-paired graphs, which enable to leverage both the well-curated structured knowledge and documents along with their metadata.
  1. Lanham, Michael. AI Agents in Action. Manning Publications, 2025. ISBN 9781633436343.
  2. Gao, Yunfan et al. Retrieval Augmented Generation for Large Language Models: A Survey, arXiv:2312.10997 [cs.CL]
  3. Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F., and Liang, P. Lost in the middle: How language models use long contexts. arXiv:2307.03172 [cs.CL].
  4. Shirui Pan, Linhao Luo, Yufei Wang, Chen Chen, Jiapu Wang, Xindong Wu. Unifying Large Language Models and Knowledge Graphs: A Roadmap. arXiv:2306.08302 [cs.CL]
  5. Bowen Jin, Gang Liu, Chi Han, Meng Jiang, Heng Ji, Jiawei Han. Large Language Models on Graphs: A Comprehensive Survey. arXiv:2312.02783 [cs.CL]
  6. Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, Yuan Cao. ReAct: Synergizing Reasoning and Acting in Language Models. arXiv:2210.03629 [cs.CL]
  7. Bratanič, T., Hane, O. Knowledge Graph-Enhanced RAG. Manning Publications, 2025. ISBN 9781633436268.

FAQ

What is an AI agent and how is it different from a simple “question in, answer out” chatbot?An AI agent is an autonomous system that plans, uses tools, and adapts to achieve a goal. Unlike a basic chatbot, it maintains memory, performs multi-step reasoning, accesses external data sources, and can operate as part of a multi-agent setup with specialized roles (e.g., Researcher, Writer, Reviewer).
What problems in production do LLM-based apps commonly face?Key challenges include hallucinations, knowledge cut-off (freshness), lack of transparency, data privacy and access control, operational costs, and ethical biases. Addressing these requires tooling, retrieval, governance, and human-in-the-loop processes.
What is Retrieval Augmented Generation (RAG) and why use it?RAG augments an LLM with external, question-relevant context retrieved from data sources (documents, APIs, databases). It reduces hallucinations, improves freshness, increases transparency (cite sources), and enables private data use without retraining the model.
How does vector search-based RAG work?Documents are chunked and embedded into vectors stored in a vector database. A user question is embedded, similar chunks are retrieved, and the LLM generates an answer grounded in those chunks.
What are the limitations of vector-based RAG?- Fragmented context limits multi-hop reasoning - Scalability and approximate search trade-offs - Embedding gaps (domain nuances, underrepresented terms) - Noise in retrieval (distraction) and misses of key documents - Aggregate or cross-document questions are hard to answer purely from chunks
What is Graph RAG and how do Knowledge Graphs help?Graph RAG uses a Knowledge Graph (KG) to retrieve structured, connected, and explainable context. KGs unify entities, relations, metadata, and document links, enabling multi-hop reasoning, better document selection, higher transparency, and easier updates and governance.
Which KG-powered tools are useful in a Graph RAG agent?- KG Retriever: generates Cypher to fetch entities, properties, aggregates, or paths - KG-Enhanced Document Retriever: selects documents that mention specific entities/relations - Semantic (vector) retriever: backup when graph-based tools lack coverage - Combined retrieval: chain KG results to drive document selection
How does the KG-Enhanced Document Retriever work?The agent extracts two entities and a relationship from the question, fills a pre-canned Cypher query, and returns only documents that explicitly discuss that relation. This reduces irrelevant hits and improves grounding versus pure vector similarity.
How does a ReAct agent orchestrate Graph RAG tools?ReAct iteratively reasons about the next best tool, acts (executes it), observes results, and repeats until enough context is gathered. Well-written tool names/descriptions and structured inputs guide reliable tool selection and fewer errors.
What kinds of questions does Graph RAG answer especially well?- Relationship details between specific people (e.g., “What did X say about Y?”) - Cross-entity aggregations (e.g., shared research topics between institutions) - Multi-hop insights that require connecting dots across documents and metadata

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Knowledge Graphs and LLMs in Action ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Knowledge Graphs and LLMs in Action ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Knowledge Graphs and LLMs in Action ebook for free