{
  "slug": "graphrag-for-agents",
  "title": "Knowledge Graphs and GraphRAG for Agents",
  "description": "Graph-structured retrieval: when and how to use knowledge graphs over vector RAG for multi-hop, relational, and global corpus queries.",
  "category": "Guide",
  "tags": [
    "rag",
    "knowledge-graph",
    "graphrag",
    "retrieval",
    "neo4j",
    "agents"
  ],
  "updated": "2026-07-21",
  "premium": false,
  "canonical": "https://changegamer.ai/resources/graphrag-for-agents",
  "markdown": "https://changegamer.ai/resources/graphrag-for-agents.md",
  "outline": [
    {
      "depth": 2,
      "text": "The problem vector RAG does not solve",
      "anchor": "the-problem-vector-rag-does-not-solve"
    },
    {
      "depth": 2,
      "text": "Core concepts",
      "anchor": "core-concepts"
    },
    {
      "depth": 2,
      "text": "Approaches and variants",
      "anchor": "approaches-and-variants"
    },
    {
      "depth": 2,
      "text": "Storage",
      "anchor": "storage"
    },
    {
      "depth": 2,
      "text": "Tradeoffs",
      "anchor": "tradeoffs"
    },
    {
      "depth": 2,
      "text": "Agentic angle",
      "anchor": "agentic-angle"
    },
    {
      "depth": 2,
      "text": "Verified sources",
      "anchor": "verified-sources"
    }
  ],
  "related": [
    {
      "slug": "choosing-a-vector-database",
      "title": "Choosing a Vector Database",
      "description": "Criteria-based decision guide: dedicated vs. add-on vector stores, scale thresholds, hybrid search support, self-host vs. managed, and a start-here recommendation.",
      "url": "https://changegamer.ai/resources/choosing-a-vector-database"
    },
    {
      "slug": "chunking-strategies-for-rag",
      "title": "Chunking Strategies for RAG",
      "description": "Practitioner reference for chunking documents before embedding: fixed-size, recursive, semantic, late chunking, and contextual retrieval — with a strategy comparison table, chunk-size and overlap tradeoffs, code/table/Markdown handling, embedding model context limits, and evaluation methods.",
      "url": "https://changegamer.ai/resources/chunking-strategies-for-rag"
    },
    {
      "slug": "hybrid-search-for-rag",
      "title": "Hybrid Search for RAG: BM25 + Dense Retrieval and Fusion",
      "description": "How to combine lexical (BM25/SPLADE) and dense vector retrieval with Reciprocal Rank Fusion for higher first-stage recall in RAG pipelines — with the RRF formula, a sparse-method comparison table, and verified DB support.",
      "url": "https://changegamer.ai/resources/hybrid-search-for-rag"
    },
    {
      "slug": "rag-retrieval-for-agents",
      "title": "RAG and Retrieval for Agents",
      "description": "End-to-end practitioner reference for Retrieval-Augmented Generation: pipeline stages, chunking strategies, dense/sparse/hybrid retrieval, reranking, agentic retrieval patterns, quality failure modes, and evaluation — with verified sources for every named technique.",
      "url": "https://changegamer.ai/resources/rag-retrieval-for-agents"
    }
  ],
  "furtherReading": [
    {
      "slug": "acp-vs-ap2-vs-x402",
      "title": "ACP vs. AP2 vs. x402: Which Agent Payment Rail Should You Implement?",
      "description": "A decision framework for choosing between ACP, AP2, and x402 (plus the self-hosted 402 gate) — sorted by who your buyer actually is, what you are selling, and what is live versus waitlisted today.",
      "url": "https://changegamer.ai/articles/acp-vs-ap2-vs-x402"
    },
    {
      "slug": "agent-checkout-vs-human-checkout",
      "title": "Agent Checkout vs. Human Checkout: Why Your Payment Flow Fails Machine Buyers",
      "description": "Why checkout built for a person watching a screen is unusable by an AI agent, and what a checkout flow that actually completes for a machine buyer looks like — 402 + API key versus native x402.",
      "url": "https://changegamer.ai/articles/agent-checkout-vs-human-checkout"
    }
  ],
  "body": "## The problem vector RAG does not solve\n\nStandard vector RAG retrieves chunks by embedding similarity. That works well for\nsingle-hop, fact-lookup questions (\"What does X say about Y?\") but fails on three\ndistinct problem classes:\n\n- **Multi-hop / relational** — \"How is entity A connected to entity C through B?\"\n  requires traversing a path that pure cosine similarity cannot reconstruct.\n- **Global summarization** — \"What are the main themes across this whole corpus?\"\n  requires aggregating over the entire document set, not retrieving a few chunks.\n- **Cross-document entity linking** — the same person, organization, or concept\n  appears under different surface forms across documents; a graph merges these into\n  one node.\n\nKnowledge graphs model a corpus as **entities** (nodes) and **relationships**\n(typed edges), enabling structured traversal at query time.\n\nCross-link: /resources/rag-retrieval-for-agents for the vector-RAG baseline.\n\n## Core concepts\n\n**Graph construction** — an LLM reads each document chunk and extracts named\nentities plus the relationships between them (e.g., `Person –WORKS_AT→ Company`).\nThis is expensive: each chunk costs one or more LLM calls. The output is a property\ngraph stored in a graph database.\n\n**Community detection** — clustering algorithms (e.g., Leiden) group densely\nconnected entities into communities. The Microsoft GraphRAG system\n(arxiv:2404.16130) then pre-generates a **hierarchical summary** for each\ncommunity using an LLM. These summaries are the backbone of global search.\n\n**Local search** — uses entities as the query entry point. The query is embedded\nto find nearest-neighbor entities, then graph traversal expands outward through\nrelationships and community context to build the prompt. Best for targeted,\nentity-specific questions.\n\n**Global search** — instead of traversing, it broadcasts the query across all\npre-computed community summaries, collects partial answers (MAP step), and\naggregates them into a final response (REDUCE step). Best for whole-corpus\nsensemaking and thematic questions.\n\n## Approaches and variants\n\n**Microsoft GraphRAG** (`microsoft/graphrag`) — the reference implementation of\nthe arxiv:2404.16130 paper (\"From Local to Global: A Graph RAG Approach to\nQuery-Focused Summarization\"). Produces a full Leiden-community hierarchy with\npre-generated summaries. Also supports a DRIFT search mode (Dynamic Reasoning\nand Inference with Flexible Traversal, per Microsoft's docs) that combines\nglobal and local search, a Basic Search mode (baseline top-k vector RAG for\nquick comparisons), and a Question Generation capability that proposes\ncandidate follow-up questions from prior user queries. Documented at\nhttps://microsoft.github.io/graphrag/ and https://github.com/microsoft/graphrag.\nNote: not an officially supported Microsoft product; graph construction is\nintentionally expensive.\n\n**LightRAG** (`HKUDS/LightRAG`, arXiv:2410.05779, EMNLP 2025) — a lighter\nalternative that builds a dual-layer knowledge graph (entities + higher-level\nconcepts) alongside vector embeddings. Supports five query modes: local, global,\nhybrid, naive (pure vector), and mix (default). Incremental graph updates avoid\nfull re-indexing. GitHub: https://github.com/HKUDS/LightRAG\n\n**HippoRAG** (`OSU-NLP-Group/HippoRAG`, arXiv:2405.14831, NeurIPS 2024) —\ninspired by hippocampal indexing theory. Combines knowledge graphs with\nPersonalized PageRank to model associative memory. Demonstrated up to 20%\nimprovement on multi-hop QA vs. standard RAG with lower latency than iterative\nretrieval approaches. HippoRAG 2 (arXiv:2502.14802, ICML 2025) extends to\ncontinual learning. GitHub: https://github.com/OSU-NLP-Group/HippoRAG\n\n**Hybrid vector + graph** — combine a vector store for chunk retrieval with a\ngraph store for relational traversal. LlamaIndex `PropertyGraphIndex` and\nNeo4j's `neo4j-graphrag-python` package both support this pattern natively.\n\n## Storage\n\n**Property graphs** — nodes and edges carry key-value properties. Neo4j\n(Cypher query language) is the dominant choice; others include Amazon Neptune\n(supports both property graph and RDF) and Memgraph. Most GraphRAG tooling\ntargets property graphs.\n\n**RDF / triple stores** — represent facts as subject–predicate–object triples,\nqueried via SPARQL. Stronger semantic interoperability (W3C standards, ontology\nreasoning) but heavier join overhead at scale. Less common in LLM-era agent\npipelines.\n\n**Tooling**:\n\n- **LlamaIndex `PropertyGraphIndex`** — constructs a property graph from\n  documents via LLM extraction, stores in a pluggable graph backend\n  (Neo4j, in-memory, etc.), and exposes multiple retriever types including\n  keyword-entity lookup and vector-based graph node retrieval.\n  Docs: https://developers.llamaindex.ai/python/framework/module_guides/indexing/lpg_index_guide/\n\n- **LangChain `langchain-neo4j`** (`GraphCypherQAChain`) — generates Cypher\n  queries from natural language against a Neo4j graph. The LLM is given the\n  graph schema; it produces a Cypher query, executes it, and reasons over the\n  result. Docs: https://python.langchain.com/docs/integrations/graphs/neo4j_cypher/\n\n- **`neo4j-graphrag-python`** — Neo4j's own Python package for building RAG\n  pipelines over Neo4j, including a Knowledge Graph Builder pipeline that\n  extracts entities from unstructured text.\n  Docs: https://neo4j.com/docs/neo4j-graphrag-python/current/\n\n## Tradeoffs\n\n| Dimension | Vector RAG | GraphRAG |\n|---|---|---|\n| Build cost | Low (embed chunks) | High (many LLM calls per chunk) |\n| Update / freshness | Re-embed changed chunks | Re-extract affected subgraph |\n| Multi-hop queries | Poor | Strong |\n| Global summarization | Poor | Strong |\n| Operational complexity | Low | High |\n| Best for | Fact lookup, semantic search | Relational, entity-centric, whole-corpus |\n\nUse GraphRAG when: your queries span multiple entities and require traversing\nrelationships; you need \"what is the overall picture\" summaries; or entities\nappear under many surface forms across documents.\n\nStick with plain RAG when: questions are single-hop or semantic; the corpus\nis small or fast-changing; or build cost/latency constraints are tight.\n\n## Agentic angle\n\nAn agent can treat a knowledge graph as a **tool**: issue graph queries\n(Cypher, SPARQL, or a higher-level API) as discrete tool calls, inspect the\nsubgraph returned, and decide whether to traverse further. This fits naturally\ninto MCP or function-calling patterns — each traversal step is a tool call\nwith a verifiable intermediate result.\n\nThe most robust production pattern combines vector retrieval (fast chunk\nlookup) with graph traversal (relational context): the vector index answers\n\"what chunks are relevant?\" and the graph answers \"how are these entities\nconnected?\".\n\nCross-links: /resources/reliable-tool-calling · /resources/embeddings-vector-search · /resources/agent-memory-context\n\n## Verified sources\n\n- Microsoft GraphRAG repo: https://github.com/microsoft/graphrag\n- Microsoft GraphRAG docs: https://microsoft.github.io/graphrag/\n- Microsoft GraphRAG query modes overview (Local/Global/DRIFT/Basic/Question Generation): https://github.com/microsoft/graphrag/blob/main/docs/query/overview.md\n- Microsoft GraphRAG DRIFT search page (acronym expansion): https://github.com/microsoft/graphrag/blob/main/docs/query/drift_search.md\n- GraphRAG paper (arXiv:2404.16130): https://arxiv.org/abs/2404.16130\n- LightRAG repo (HKUDS, arXiv:2410.05779): https://github.com/HKUDS/LightRAG\n- HippoRAG repo (OSU-NLP-Group, arXiv:2405.14831): https://github.com/OSU-NLP-Group/HippoRAG\n- HippoRAG 2 (arXiv:2502.14802): https://arxiv.org/abs/2502.14802\n- LlamaIndex PropertyGraphIndex guide: https://developers.llamaindex.ai/python/framework/module_guides/indexing/lpg_index_guide/\n- LangChain Neo4j integration: https://python.langchain.com/docs/integrations/graphs/neo4j_cypher/\n- Neo4j GraphRAG Python package: https://neo4j.com/docs/neo4j-graphrag-python/current/",
  "sources": [
    "https://github.com/microsoft/graphrag",
    "https://microsoft.github.io/graphrag/",
    "https://github.com/microsoft/graphrag/blob/main/docs/query/overview.md",
    "https://github.com/microsoft/graphrag/blob/main/docs/query/drift_search.md",
    "https://arxiv.org/abs/2404.16130",
    "https://github.com/HKUDS/LightRAG",
    "https://github.com/OSU-NLP-Group/HippoRAG",
    "https://arxiv.org/abs/2502.14802",
    "https://developers.llamaindex.ai/python/framework/module_guides/indexing/lpg_index_guide/",
    "https://python.langchain.com/docs/integrations/graphs/neo4j_cypher/",
    "https://neo4j.com/docs/neo4j-graphrag-python/current/"
  ]
}