P1725 min

Knowledge Graph & GraphRAG

Multi-hop questions expose vector search's limits. P8 showed one option — agentic retrieval, where the agent explores at query time. This lesson shows the other — pre-built knowledge graphs that capture entity relationships as a queryable structure. Both work; the trade-off determines which fits your corpus.

SDK Focusstructured outputtool usemulti-step reasoningMCP tools

Why GraphRAG Exists

Vector search finds documents that are semantically similar to a query. It works for single-hop factual questions, but multi-hop questions require traversing relationships between entities:

text
Query: "What is our refund policy?"
Vector search: Finds the refund policy document → Great!

Query: "Which engineers who worked on Project Alpha also contributed to Project Beta?"
Vector search: Finds documents mentioning Project Alpha OR Project Beta separately
              → May not connect the relationship across documents

Vector search treats each document as an independent point in embedding space. It has no native concept of connections. Let an agent explore at query time (P8 agentic RAG) or pre-build a graph index that stores relationships ahead of time.

This lesson teaches the graph path end-to-end: represent facts as triples, extract them from documents, query the graph, add Local and Global GraphRAG search, then evaluate when the graph is worth its indexing cost.

text
Single-hop (vector search works):
  "What is X?" → Find document about X

Multi-hop (vector struggles; graph or agentic search wins):
  "How is X related to Y through Z?" → Traverse X → Z → Y
  "What are all the consequences of event A?" → Follow causal chains
  "Who are the common collaborators between teams B and C?" → Set intersection over relationships

Knowledge graphs support multi-hop queries by storing entities and relationships as a queryable structure.

Knowledge Graph Fundamentals

The Triple: Entity-Relation-Entity

Every fact in a knowledge graph is stored as a triple — two entities connected by a relationship:

Premium lesson preview

Continue with full access

This lesson stays here for preview. Full access unlocks the complete lesson, flashcards, and related practice.

Sign In to Unlock

One purchase unlocks advanced lessons, practice, and future updates.