Zucchetti LLM Course — Lecture 6

Graph RAG
& Knowledge Graphs

When vector search isn’t enough — follow the relationships

Kamyar Zeinalipour

Today’s Agenda

Section 1 — When Vector Search Isn’t Enough

Section 2 — Knowledge Graph Fundamentals

Section 3 — Building a KG from Documents (LLM-Powered)

☕ Break

Section 4 — Graph RAG — Retrieval That Follows Relationships

Section 5 — The Graph RAG Landscape

Section 1 of 5

When Vector Search
Isn’t Enough

The relationship problem

The Relationship Problem

Some questions can’t be answered by finding similar documents

The Question

“Which employees in the Rome office report to managers hired before 2020?”

What This Requires

Rome Office
→
Employees
→
Their Managers
→
hire_date < 2020

4 hops across different entities. No single chunk contains this.

In L5 we called this a multi-hop failure and solved it with query decomposition. But decomposition still searches for documents — it can’t follow relationships. That’s a graph problem.

Vector Search vs Graph Search

Query TypeVector SearchGraph Search
“What is the sick leave policy?”✅ Finds the documentOverkill
“Who reports to Mario?”❌ Finds docs mentioning Mario✅ Follows reports_to edge
“Which drugs interact with Patient X’s medications?”❌ Can’t chain: Patient → Meds → Interactions✅ Multi-hop traversal
“What changed in the policy since last year?”❌ Finds both versions✅ Temporal edges
Remember from L2: embeddings capture meaning (cosine similarity). Graphs capture structure (who connects to whom). Both live in your retrieval stack.

The Retrieval Spectrum

Where Graph RAG fits in the techniques you’ve learned

L4   Simple factual → Vector Search

L5   Vocabulary mismatch → HyDE / Query Rewriting

L5   Multi-source → Semantic Routing

L6   Relationship reasoning → Knowledge Graphs  YOU ARE HERE

L7   Multi-step autonomous → Agentic RAG

Each lecture adds a new capability. L6 teaches your system to follow connections that vector search can’t see.

Section 2 of 5

Knowledge Graph
Fundamentals

Nodes, edges, and triples

What Is a Knowledge Graph?

Everything is a triple: (Subject, Predicate, Object)

Formal Definition

$\mathcal{G} = (\mathcal{V}, \mathcal{E}, \mathcal{R})$   where   $\mathcal{V}$ = entities,   $\mathcal{R}$ = relation types,   $\mathcal{E} \subseteq \mathcal{V} \times \mathcal{R} \times \mathcal{V}$

Each edge is a triple:   $(h, r, t) \in \mathcal{E}$   where   $h$ = head,   $r$ = relation,   $t$ = tail

Mario — works_in → Engineering — located_in → Rome

Nodes = Entities

  • People (Mario, Luigi)
  • Departments (Engineering, HR)
  • Documents (Remote Work Policy)
  • Concepts (Sick Leave, Training)

Edges = Relationships

  • works_in — employment
  • reports_to — hierarchy
  • authored_by — document ownership
  • eligible_for — policy access
A spreadsheet stores data in rows. A graph stores data in connections. You can walk the chain: Mario → Engineering → Rome → Italy.

Example: An HR Knowledge Graph

Triples Extracted from Documents

SubjectPredicateObject
Mario Rossiworks_inEngineering
Mario Rossireports_toLuigi Bianchi
Mario Rossihired_in2019
Engineeringlocated_inRome Office
Mario Rossieligible_forRemote Work Policy 2024
Luigi BianchimanagesEngineering

Now You Can Answer

“Who is Mario’s manager?” → Mario reports_to → Luigi Bianchi

“Where does Mario work?” → Mario works_in → Engineering located_in → Rome

Types of Knowledge Graphs

TypeStructureBest ForExample
RDF / Triples(Subject, Predicate, Object)Standards-based, semantic webWikidata, DBpedia
Property GraphNodes + edges with propertiesEnterprise, flexible schemasNeo4j, Neptune
LLM-Extracted OUR FOCUSTriples from unstructured textQuick prototyping, document KGsWhat we’ll build
For enterprise RAG, property graphs are the sweet spot — flexible, queryable, and you can attach metadata to every relationship.

Graph Database Landscape

ToolTypeWhen to UseQuery Language
Neo4jFull graph DBProduction, complex queriesCypher
Amazon NeptuneManaged cloudAWS shops, no infra managementopenCypher / Gremlin / SPARQL
NetworkX START HEREPython libraryPrototyping, small graphsPython API
In-memory dictCustomTiny graphs, embedded in pipelinePython
Start with NetworkX for prototyping. Move to Neo4j when the graph exceeds 100K nodes or you need concurrent access.

Section 3 of 5

Building a KG
from Documents

LLM-powered entity and relation extraction

From Documents to Graph — The Problem

You have 10,000 documents. How do you turn them into a graph?

The Raw Text

Mario Rossi, hired in 2019, works in the Engineering department
under the supervision of Luigi Bianchi. He is eligible for the
2024 remote work policy. The Engineering department is located
in the Rome office.

What We Need

Mario — reports_to → Luigi   |   Mario — works_in → Engineering — located_in → Rome
We need to extract entities (who/what) and relationships (how they’re connected) from unstructured text.

The Extraction Pipeline

Document
→
Chunk
→
LLM: Extract
Entities
→
LLM: Extract
Relations
→
Deduplicate
& Merge
→
Knowledge
Graph

Old Way: Train NER Models

  • Need labeled training data
  • Domain-specific models
  • Months of development
  • Brittle on new entity types

New Way: Prompt the LLM OUR APPROACH

  • Zero training data needed
  • Works across domains
  • Minutes to set up
  • Handles new entity types naturally

Step 1: Entity Extraction

Ask the LLM to find all entities — using structured JSON output from L3

The Prompt

Extract all entities from this text.
Return JSON: [{"entity": "...", "type": "PERSON|ORG|POLICY|DATE",
               "description": "brief description"}]

Text: "Mario Rossi, hired in 2019, works in Engineering..."

LLM Output

EntityTypeDescription
Mario RossiPERSONEmployee
Luigi BianchiPERSONSupervisor
EngineeringORGDepartment
Remote Work Policy 2024POLICYPolicy document
2019DATEHire year
No NER model training needed. The LLM handles it. This is the structured JSON output technique from L3 — same pattern, new use case. Cost: ~$0.01 per document.

Step 2: Relation Extraction

Ask the LLM to find how entities connect

The Prompt

Given these entities and text, extract relationships as triples:
[{"subject": "...", "predicate": "...", "object": "..."}]

Entities: Mario Rossi, Luigi Bianchi, Engineering, ...
Text: "Mario Rossi, hired in 2019, works in Engineering..."

LLM Output

SubjectPredicateObject
Mario Rossiworks_inEngineering
Mario Rossireports_toLuigi Bianchi
Mario Rossieligible_forRemote Work Policy 2024
Mario Rossihired_in2019
Engineeringlocated_inRome Office
Two LLM calls per chunk — one for entities, one for relations. You can also combine them into a single call.

Step 3: Deduplication THE HARD PART

Extraction is easy. Cleaning is where projects fail.

Entity Resolution

ProblemDoc A SaysDoc B SaysSolution
Different names“Mario Rossi”“M. Rossi”Fuzzy matching + LLM
Conflicting factsMario in EngineeringMario in Sales (old)Use timestamps
Ambiguous refs“the employee”“he”Coreference resolution

“The employee” / “he” / “Mr. Rossi” / “the engineer” → all = Mario Rossi — LLMs handle this with overlapping chunks (L4)

Entity Matching Score

$\text{sim}(e_1, e_2) = \frac{\text{embed}(e_1) \cdot \text{embed}(e_2)}{\|\text{embed}(e_1)\| \times \|\text{embed}(e_2)\|}$    If $\text{sim} > \tau$ → merge   ($\tau \approx 0.85$)

Attach confidence scores to each triple. Low confidence? Flag for human review. This is where graph quality is won or lost.

Practical: One-Call Extraction

In practice, combine entity + relation extraction in a single prompt

You are a knowledge graph builder.
Given this text, extract:
1. All entities with their types
2. All relationships between entities as triples

Return JSON:
{
  "entities": [{"name": "...", "type": "...", "description": "..."}],
  "triples": [{"subject": "...", "predicate": "...", "object": "..."}]
}

Rules:
- Use consistent entity names (full names, not abbreviations)
- Predicate should be a short verb phrase (works_in, reports_to)
- Include temporal relationships (hired_in, valid_from)

Text: """[CHUNK]"""
One LLM call per chunk. Process all chunks → merge graphs → deduplicate. Budget: ~$0.50 for 1,000 documents.

Step 0: Schema Design DO THIS FIRST

Before extracting anything, define what you’re looking for

Entity Types

TypeExamples
PERSONEmployees, managers, clients
DEPARTMENTEngineering, HR, Sales
POLICYRemote work, sick leave
LOCATIONRome office, Milan HQ
ROLESenior Engineer, Team Lead

Relation Types

PredicateBetween
works_inPERSON → DEPARTMENT
reports_toPERSON → PERSON
located_inDEPARTMENT → LOCATION
eligible_forPERSON → POLICY
has_rolePERSON → ROLE
Start with 5–7 entity types and 5–10 relation types. Too many types → inconsistent extraction. Too few → you miss connections. Iterate after reviewing the first 100 documents.

Python Implementation

From text to graph in ~15 lines of code

import json, networkx as nx
from google import genai

client = genai.Client()
graph = nx.DiGraph()

def extract_and_add(chunk: str):
    response = client.models.generate_content(
        model="gemini-2.0-flash",
        contents=SCHEMA_PROMPT + chunk,  # our one-call prompt
        config={"response_mime_type": "application/json"}
    )
    data = json.loads(response.text)

    for e in data["entities"]:
        graph.add_node(e["name"], type=e["type"],
                       desc=e["description"])

    for t in data["triples"]:
        graph.add_edge(t["subject"], t["object"],
                       relation=t["predicate"])

# Process all chunks
for chunk in chunks:
    extract_and_add(chunk)
That’s it. response_mime_type: "application/json" forces the LLM to return valid JSON — no parsing errors. The graph grows as you process each chunk.

Common Pitfalls LEARN FROM OTHERS

#PitfallExampleFix
1 Over-extraction LLM extracts “2024” as an entity everywhere Restrict entity types in schema
2 Inconsistent predicates works_at vs works_in vs employed_by Provide allowed predicate list in prompt
3 Hallucinated relations LLM invents “Mario manages Sales” (not in text) Add: “only extract facts explicitly stated”
4 Missing chunk overlap Entity in chunk 1, relationship in chunk 2 Use overlapping chunks (L4)
5 No validation loop Silently building a bad graph Sample 50 triples → human review → fix prompt
The 50-triple test: after processing 100 documents, randomly sample 50 triples. If accuracy is <90%, fix your prompt or schema before processing the rest.

☕

Break

10 minutes

Section 4 of 5

Graph RAG

Retrieval that follows relationships

Graph RAG — The Problem

The Query

“What training courses are required for Mario’s role?”

✗ Naive RAG

Searches for “training courses” + “Mario”

Finds general training documents

Doesn’t know Mario is in Engineering

Misses role-specific courses

✓ Graph RAG

1. Find “Mario” node

2. Mario → works_in → Engineering

3. Engineering → requires → [Java, Cloud, Security]

Finds role-specific courses

Graph RAG doesn’t search for documents — it follows connections to gather the exact context needed.

The Graph RAG Pipeline

User Query
→
Entity
Linking
→
Graph
Traversal
→
Context
Enrichment
→
LLM
Synthesis
StepWhat HappensExample
Entity LinkingFind mentioned entity in the graph“Mario” → node Mario Rossi
Graph TraversalWalk N hops to collect related entitiesMario → Engineering → [Java, Cloud, Security]
Context EnrichmentRetrieve documents for discovered entitiesFetch training policy docs for Java, Cloud, Security
LLM SynthesisGenerate answer from graph facts + documents“Mario needs Java Cert, Cloud Training, and Security Basics”

Strategy 1: 1-Hop DIRECT NEIGHBORS

“Who is Mario’s manager?”

How It Works

Rome ← located_in — Engineering ← works_in — Mario — reports_to → Luigi

Start at Mario → look at direct edges → find Luigi Bianchi

When to Use

  • Simple fact lookups
  • “What department is X in?”
  • “Who manages Y?”
  • Fast — O(degree) per node

Limitations

  • Can’t answer indirect questions
  • “Who else is on Mario’s team?” needs 2 hops
  • Small context window
1-hop is your SQL replacement. If the answer is a direct property or neighbor of one entity, use 1-hop. Fastest and cheapest.

Strategy 2: 2-Hop INDIRECT CONNECTIONS

“Who else reports to Mario’s manager?”

How It Works

Mario — reports_to → Luigi ← reports_to — Anna

Hop 1: Mario → Luigi   |   Hop 2: Luigi ← Anna, Paolo, Sara

When to Use

  • Indirect connections
  • “What policies apply to Mario’s department?”
  • “Who are Mario’s colleagues?”
  • The sweet spot for most Graph RAG queries

Watch Out

  • Context grows exponentially with degree
  • $|\mathcal{N}_k(v)| \leq d^k$   where $d$ = avg degree
  • $d{=}50, k{=}2 \Rightarrow 50^2 = 2{,}500$ nodes!
  • Use edge type filtering to control explosion
2-hop is the default for most Graph RAG systems. Filter by edge type to avoid explosion: “follow only reports_to edges, not all edges.”

Strategy 3: Subgraph Extraction FULL NEIGHBORHOOD

“Tell me everything about Mario’s team”

How It Works

Rome ← Engineering ← Mario → Luigi → Policy 2024

Extract the full connected neighborhood of Mario — all nodes, all edges, all types

When to Use

  • Open-ended questions about an entity
  • “Summarize everything about this employee”
  • Building a “profile page” for an entity
  • Compliance audits requiring full context

Implementation

  • NetworkX: nx.ego_graph(G, "Mario", radius=2)
  • Neo4j: MATCH (n)-[*..2]-(m) WHERE n.name = "Mario"
  • Set a max radius to control size
  • Limit total nodes (e.g., top 50 by PageRank)
Subgraph extraction gives the richest context but is the most expensive. Use it for open-ended questions where you don’t know which edges matter.

Strategy 4: Path Finding CONNECTION DISCOVERY

“How is Mario connected to the CEO?”

How It Works

Mario — reports_to → Luigi — reports_to → Sara (VP) — reports_to → CEO

Find the shortest path between two entities — reveals the chain of connections

When to Use

  • “How is drug A related to side effect B?”
  • Compliance: “Who approved this decision?”
  • Connection discovery and audit trails
  • Explaining why two things are related

Implementation

  • NetworkX: nx.shortest_path(G, "Mario", "CEO")
  • Neo4j: MATCH p=shortestPath((a)-[*]-(b))
  • Can also find all paths up to length N
  • Weight edges by confidence for ranked paths
Path finding answers “why” questions: not just that two entities are related, but how they’re connected. Essential for compliance and explainability.

Graph + Vector Hybrid

The real architecture — run both in parallel, then merge

Step 1: Parallel Retrieval

Vector Search (always runs)

Embed query → find top-K similar chunks

Catches broad semantic matches

Graph Traversal (if entity detected)

Detect entity → traverse N hops → gather facts

Catches relationship-based context

StepWhat Happens
2. MergeCombine vector chunks + graph facts → deduplicate overlapping context
3. Re-rankCross-encoder (L5) scores all results together → best evidence to the top
4. LLMGenerate answer from enriched context → final answer
Always run vector search. If the query mentions a known entity, also run graph traversal. Merge both results. This way you never miss context — vectors catch semantics, graphs catch structure.

When to Use Graph RAG

✅ Use Graph RAG when

  • Questions involve named entities and their connections
  • Multi-hop reasoning is required
  • Domain has clear entity types (people, orgs, policies)
  • You need to discover indirect connections
  • Compliance/audit trails matter

❌ Skip Graph RAG when

  • Questions are about document content, not entities
  • Your corpus is small (<100 docs)
  • Entities don’t have meaningful relationships
  • Graph quality would be poor (messy data)
  • You need sub-second index updates (streaming data)
Remember L5’s rule: diagnose first, then pick the fix. If your RAG failures are relationship queries → add Graph RAG. If they’re vocabulary mismatch → stick with HyDE.

Section 5 of 5

The Graph RAG
Landscape

GraphRAG, RAPTOR, LightRAG, HippoRAG & beyond

The Global Query Problem

The Question

“What are the main themes across all 10,000 HR policy documents?”

✗ Vector Search

Returns 5 individual chunks

Each chunk covers one topic. No global view.

✗ Basic Graph RAG

No single entity to start from

“Main themes” isn’t an entity in the graph.

Global questions don’t start with a specific entity and can’t be answered by any single chunk. You need to summarize the entire corpus.

Three Unsolved Problems

Basic Graph RAG (Section 4) can’t handle these — each framework below was designed to solve one

Problem 1: Global Summarization

“What are the main themes across 10,000 documents?”

No starting entity. Need to summarize the entire corpus.

→ Solved by Microsoft GraphRAG (community detection) and RAPTOR (tree summarization)

Problem 2: Index Freshness

New documents arrive daily. GraphRAG requires full rebuild — hours of reprocessing.

→ Solved by LightRAG (incremental updates)

Problem 3: Multi-Hop Cost

Iterative retrieval needs multiple LLM calls per query: retrieve → reason → retrieve again → reason…

→ Solved by HippoRAG (single-step PageRank retrieval)

Microsoft GraphRAG

From Local to Global: the 2024 breakthrough

The Approach

Extract
Entities
→
Build
Graph
→
Community
Detection
→
Summarize
Communities
→
Search
Summaries

Community Detection

The Leiden algorithm maximizes modularity $Q$:

$Q = \frac{1}{2m} \sum_{ij} \left[ A_{ij} - \frac{k_i k_j}{2m} \right] \delta(c_i, c_j)$

$A_{ij}$ = adjacency,   $k_i$ = degree of node $i$,   $m$ = total edges,   $\delta(c_i, c_j) = 1$ if same community

Community A

Mario, Luigi, Engineering, Rome — “Engineering Team”

Community B

Sick Leave, Annual Leave, HR Policy — “Leave Policies”

Community C

Training, Certification, Java — “Employee Development”

Edge et al. (2024) — “From Local to Global: A Graph RAG Approach to Query-Focused Summarization”

GraphRAG — How It Answers Global Queries

Step-by-step: from communities to answers

Step 1: Pre-compute community summaries (offline)

Each community gets an LLM-generated summary describing its members and relationships:

Community A Summary:

“The Engineering team is based in Rome, led by Luigi Bianchi. Mario Rossi is a senior developer hired in 2019.”

Community B Summary:

“HR policies cover sick leave (10 days/year), annual leave (25 days), and parental leave. Updated in 2024.”

Step 2: At query time — search summaries, not raw graph

“What are the main themes?” → vector search over community summaries → returns top communities → LLM synthesizes global answer

The genius: global queries become local vector searches over pre-computed summaries. The graph is only used for community detection — retrieval is just vector search over summaries.

Local vs Global Queries

Query TypeMethodExample
Local ENTITY Entity match + graph traversal “What is Mario’s role?”
Global THEME Search community summaries “What are the main HR policy themes?”
Hybrid BOTH Community + entity traversal “How does remote work affect Engineering?”

Strengths

  • Only system that handles global summarization
  • Hierarchical communities = multi-resolution
  • Explainable — communities are inspectable

Limitations

  • Full rebuild required when corpus changes
  • High cost — many LLM calls for summaries
  • Slow indexing (hours for large corpora)
This is the key contribution: it handles global summarization queries that no other RAG technique can answer. But you pay for it with rebuild cost.

RAPTOR — Tree-Based Summarization

Same goal as GraphRAG (global queries) — but without a graph

How It Works

Chunks
(leaves)
→
Cluster &
Summarize
→
Cluster &
Summarize
→
Root
(corpus summary)

Build a tree of summaries. Search at all levels. Detailed answers come from leaves, overview answers from higher levels.

Search at Every Level

LevelContentAnswers
RootCorpus summary“What are the main themes?”
L2Topic summaries“Summarize leave policies”
L1Cluster summaries“What types of sick leave exist?”
LeavesOriginal chunks“How many sick days for FT employees?”

Sarthi et al. (2024) — “RAPTOR: Recursive Abstractive Processing for Tree-Organized Retrieval” — ICLR 2024

GraphRAG vs RAPTOR

Both solve global queries — but through very different architectures

GraphRAGRAPTOR
Builds onKnowledge graph + communitiesChunk clustering + summaries
Best forEntity-rich domains (HR, medical)Document-heavy domains
Global queries✅ Community summaries✅ Tree-level summaries
Relationship queries✅ Graph traversal❌ No relationship awareness
Incremental updates⚠️ Possible but complex❌ Full tree rebuild
Setup complexityHigh (graph DB + extraction)Medium (clustering + LLM calls)
CostHigh (many LLM calls)Medium (fewer LLM calls)
GraphRAG when you have entities and relationships. RAPTOR when you need multi-level summarization without a graph. Both solve the global query problem.

RAPTOR — Limitations

1. Hallucination Compounds Upward

Each level summarizes the level below. Small errors at L1 get baked into L2, then L3. The “telephone game” problem.

2. No Incremental Updates

Add one document? Rebuild the entire tree. No way to update a single branch.

3. Clustering Quality

Diverse corpora (HR + IT + Finance) produce vague clusters. Works best with thematically coherent collections.

4. No Relationship Awareness

Clusters by semantic similarity, not by entity connections. “Mario works in Engineering” and “Engineering is in Rome” may end up in different clusters.

LightRAG — Solving the Rebuild Problem 2024

GraphRAG’s biggest weakness: you must rebuild everything when documents change

The Problem with GraphRAG

New
Document
→
Re-extract
ALL entities
→
Rebuild
entire graph
→
Re-detect
ALL communities
→
Re-summarize
ALL

⏱ Hours of reprocessing. Hundreds of dollars in LLM calls.

LightRAG’s Solution: Incremental Updates

New
Document
→
Extract
new entities
→
Merge into
existing graph
→
Done ✓

⏱ Seconds per document. Pennies in cost.

Guo et al. (2024) — “LightRAG: Simple and Fast Retrieval-Augmented Generation”

LightRAG — Dual-Level Retrieval

One graph, two retrieval strategies — no community detection needed

Low-Level Retrieval

Entity-specific queries

“What is Mario’s hire date?”

→ Find entity → follow edges → exact answer

Same as basic Graph RAG (Section 4)

High-Level Retrieval

Theme-based queries

“What are Engineering’s goals?”

→ Search key-value pairs of conceptual relationships

Replaces community detection with indexed KV pairs

Five Query Modes

ModeUsesBest For
NaiveVector search onlySimple factual queries
LocalLow-level KG retrievalEntity-specific questions
GlobalHigh-level KG retrievalTheme/trend questions
Hybrid DEFAULTLow + High combinedMost production queries
MixVector + KG combinedMaximum coverage
80% of GraphRAG’s power, 10% of the operational headache. Start here for most Graph RAG projects.

HippoRAG — Solving Multi-Hop Cost NeurIPS 2024

Multi-hop retrieval is expensive. HippoRAG does it in one step.

The Problem: Iterative Retrieval is Expensive

“What drugs interact with Patient X’s medications?”

Retrieve
Patient X
→
LLM
reasons
→
Retrieve
medications
→
LLM
reasons
→
Retrieve
interactions

3 retrieval steps × 3 LLM calls = slow and expensive

HippoRAG’s Solution: Retrieve by Association

Indexing (offline) — Open IE

No predefined schema. The LLM extracts whatever triples it finds:

“Aspirin interacts with Warfarin, increasing bleeding risk.”

→ (Aspirin, interacts_with, Warfarin)

→ (Aspirin, increases, bleeding_risk)

vs. Section 3: you define entity types (PERSON, ORG) and predicates (works_in, reports_to). Open IE skips all that.

Query (online) — PageRank

Extract query entities → run Personalized PageRank → all relevant nodes found in 1 step.

Query: “What interacts with Patient X’s meds?”

→ Extract Patient_X

→ PPR finds: Aspirin, Warfarin, bleeding_risk…

1 step, 1 LLM call → 6–13× faster, 10–30× cheaper

Gutiérrez et al. (2024) — “HippoRAG: Neurobiologically Inspired Long-Term Memory for LLMs” — NeurIPS 2024

HippoRAG — Brain-Inspired Architecture

Mimics how the human hippocampus indexes long-term memory

The Analogy

Brain ComponentHippoRAG ComponentRole
NeocortexLLMProcesses and understands text
Parahippocampal regionsKnowledge GraphStores entities and relationships
HippocampusPersonalized PageRankRetrieves by association, not just similarity

Personalized PageRank (PPR)

$\text{PPR}(v) = (1 - \alpha) \cdot \mathbf{e}_q + \alpha \sum_{u \in \mathcal{N}(v)} \frac{\text{PPR}(u)}{\deg(u)}$

$\alpha$ = damping factor,   $\mathbf{e}_q$ = query entity indicator vector

PPR scores all nodes by how strongly they associate with the query entity. More paths = stronger association = higher rank.

Key Trade-off

HippoRAG cannot answer global “what are the themes?” queries (no community detection). But for multi-hop entity queries — fastest and cheapest option.

Key insight: your brain doesn’t walk through memories step by step. It retrieves by association. HippoRAG does the same: PageRank replaces iterative LLM calls.

Choosing Your Framework

Decision guide: start with your primary problem

Your Primary ProblemBest FrameworkWhy
“I need global summarization” Microsoft GraphRAG Community detection + summaries = only system for “what are the themes?”
“I need global queries without a graph” RAPTOR Tree of summaries, works with any vector store
“My documents change frequently” LightRAG Incremental updates — no full rebuild
“I need fast, cheap multi-hop” HippoRAG One-shot PageRank — 6–13× faster than iterative
“I want the simplest setup” LightRAG Easiest to set up, five query modes, good enough for most cases
Default recommendation: start with LightRAG. Add GraphRAG if you need global summarization. Add HippoRAG if multi-hop accuracy matters. Use RAPTOR only if you truly can’t maintain a graph database.

Chen et al. (2025) — “PathRAG: Pruning Graph-based RAG with Relational Paths”

Lecture 6 — Key Takeaways

1. Vector search finds similar documents. Graphs find connected entities. Different tools for different questions.

2. LLMs are your extraction engine. No NER model training needed — prompt the LLM to extract triples.

3. Entity resolution is the hard part. Extraction is easy. Deduplication and merging is where projects fail.

4. Graph RAG augments vector RAG, doesn’t replace it. Most queries still use vector search.

5. Microsoft GraphRAG handles global queries through community detection and hierarchical summarization.

6. Start simple: NetworkX + LLM extraction. Scale to Neo4j when you need it.

❓

Questions?

Thank you!


Kamyar Zeinalipour — Zucchetti LLM Course

Next → Lecture 7: Agentic RAG & Autonomous Systems

Theory: Function calling · Tool use · Multi-agent workflows