Skip to content

Graph-RAG: The Foundation

Graph-RAG enhances Retrieval-Augmented Generation by using knowledge graphs to capture relationships that vector search alone misses.


Graph-RAG is an architecture pattern that combines:

  1. Retrieval-Augmented Generation (RAG): Using external documents to ground LLM responses
  2. Knowledge Graphs: Storing entities and their relationships as nodes and edges

The key insight: relationships between entities are as important as the entities themselves.


Traditional RAG uses vector similarity to find relevant text chunks:

┌─────────────────────────────────────────────────────────────────┐
│ TRADITIONAL RAG │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Documents ──▶ Chunks ──▶ Embeddings ──▶ Vector Database │
│ │
│ Query ──▶ Embedding ──▶ Similarity Search ──▶ Top-K Chunks │
│ │
│ Problem: Chunks are ISOLATED. No relationships captured. │
│ │
└─────────────────────────────────────────────────────────────────┘

Example failure:

Query: “How did Sarah’s research influence Bob’s work?”

Traditional RAG returns:

  • Chunk 1: “Sarah published a paper on neural networks…”
  • Chunk 2: “Bob’s latest project uses deep learning…”

But it cannot connect that Bob’s work was based on Sarah’s research, because:

  • The relationship isn’t in either chunk
  • Vector similarity doesn’t understand causation

Graphs explicitly model relationships:

┌─────────────────────────────────────────────────────────────────┐
│ KNOWLEDGE GRAPH │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ │
│ │ SARAH │ │ BOB │ │
│ │ (PERSON) │ │ (PERSON) │ │
│ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │
│ ┌──────────┴───────────────────────┴──────────┐ │
│ │ │ │
│ v v │
│ ┌───────────┐ ┌───────────────┐ │
│ │ PUBLISHED │ │ BASED_ON │ │
│ └─────┬─────┘ └───────┬───────┘ │
│ │ │ │
│ v v │
│ ┌───────────────────┐ ┌─────────────────┐ │
│ │ NEURAL_NETWORKS │◀───────────────────│ BOB'S_PROJECT │ │
│ │ (CONCEPT) │ uses_concepts │ (PROJECT) │ │
│ └───────────────────┘ └─────────────────┘ │
│ │
│ Now we can TRAVERSE: Sarah → published → Neural Networks │
│ Neural Networks ← based_on ← Bob's work │
│ │
└─────────────────────────────────────────────────────────────────┘

With this graph, querying “How did Sarah influence Bob?” becomes a graph traversal problem.


EdgeQuake implements Graph-RAG with these components:

ComponentPurposeImplementation
Entity ExtractionFind entities in textLLM-based with tuple parsing
Relationship ExtractionFind connectionsSame LLM call, explicit edges
Knowledge GraphStore structurePostgreSQL + Apache AGE
Vector EmbeddingsSemantic searchpgvector
Hybrid RetrievalQuery both6 query modes
┌─────────────────────────────────────────────────────────────────┐
│ EDGEQUAKE PIPELINE │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Document ──▶ [Chunk] ──▶ [Extract] ──▶ [Store] ──▶ Query │
│ │ │ │
│ │ ├─▶ Entities (nodes) │
│ │ ├─▶ Relations (edges) │
│ │ └─▶ Embeddings (vectors)│
│ │ │
│ └─▶ LLM extracts entities + │
│ relationships in one pass │
│ │
└─────────────────────────────────────────────────────────────────┘

BenefitDescription
Multi-hop reasoningFollow chains of relationships
Entity disambiguation”Apple” (company) vs “apple” (fruit)
Implicit connectionsDiscover relationships across documents
Contextual answersInclude related entities in responses


The Graph-RAG orchestration lives in: