What is GraphRAG?
GraphRAG (Graph-enhanced Retrieval Augmented Generation) extends traditional RAG by building a knowledge graph from your documents. Instead of relying solely on vector similarity, GraphRAG:- Extracts entities (people, organizations, locations, concepts) from text
- Identifies relationships between entities using LLMs or patterns
- Detects communities of related entities using the Leiden algorithm
- Combines graph and vector search using Reciprocal Rank Fusion (RRF)
Architecture
GraphRAG consists of several modular components:Data Flow
During Ingest:When to Use GraphRAG
Best Use Cases
✅ Multi-hop questions: “Who works at companies founded by Y Combinator alumni?” ✅ Relationship queries: “What is the connection between OpenAI and Microsoft?” ✅ Entity-centric search: “Tell me everything about Sam Altman” ✅ Domain knowledge: Technical documentation with many named concepts ✅ Global understanding: Questions requiring broad context (use community summaries)When Vector Search Alone is Better
❌ Unstructured content: Pure creative writing, narratives without entities ❌ Simple semantic search: “What are best practices for caching?” ❌ Cost-sensitive: GraphRAG requires extra LLM calls and compute ❌ Low-entity documents: Content with few named entities or relationshipsInstallation
GraphRAG is optional and requires separate installation:leidenfold to your dependencies:
Configuration
Enable GraphRAG globally or per-call:Main Functions
Building Graphs
lib/arcana/graph.ex:150 for implementation details.
Searching Graphs
Community Summaries
Finding and Traversing
Integration with Ingest
GraphRAG automatically integrates withArcana.ingest/2:
- Extract entities from each chunk using NER or LLM
- Extract relationships between entities
- Persist entities, relationships, and mentions to the database
- Optionally detect communities and generate summaries
Next Steps
- Entity Extraction - Learn about entity extractors
- Relationships - Configure relationship extraction
- Communities - Understand community detection
- Search - Master graph search and RRF fusion