This article explores GraphRAG, an advanced Retrieval Augmented Generation (RAG) architecture designed to overcome limitations of standard RAG in answering global queries that require reasoning across an entire dataset. It details how knowledge graphs are constructed from documents, enabling the system to understand relationships between entities and perform hierarchical summarization, leading to more comprehensive and accurate AI-generated answers.
Read original on ByteByteGoStandard RAG systems excel at answering "local" queries where the information is contained within a few document chunks and directly resembles the query. However, they fall short with "global" queries that demand synthesis and understanding across an entire corpus, often leading to superficial or hallucinated answers. This limitation arises because traditional vector search primarily relies on semantic similarity between query and document chunks, not on the underlying relationships or broader contextual patterns.
Imagine querying a knowledge base of incident postmortems for the "most recurring failure causes." A standard RAG system might return documents containing terms like "recurring" or "frequent," but fail to identify the actual patterns distributed across hundreds of reports. Even with larger context windows, models struggle with comprehensive analysis of unrelated retrieved material. This highlights a fundamental architectural gap: standard RAG's design assumes an answer exists in a retrievable location, which is false for global insights.
GraphRAG addresses this by building a knowledge graph. This graph stores entities (nouns like services, teams, incidents) and typed relationships between them (e.g., "team deployed handler"). This allows the system to understand how documents relate beyond simple semantic similarity. The process involves:
| Phase | Description | Cost Implication |
|---|
Key System Design Trade-offs
Building a knowledge graph and generating hierarchical summaries is computationally expensive, especially the entity and relationship merging steps, which Microsoft estimates at ~75% of total indexing cost. This is a significant trade-off: higher indexing cost for substantially improved query quality on global questions. The choice of community level for query processing also impacts response thoroughness, latency, and token cost.
GraphRAG offers both local search (matching queries against entity description embeddings) and global search (leveraging community reports to reason across the entire corpus). This dual approach allows systems to effectively handle diverse query types, improving answer quality and reducing hallucinations for complex, analytical questions.