Definition
What is a knowledge graph?
Last updated
A structured representation of information as entities (nodes) and the explicit relationships (edges) between them, queried by traversing connections rather than matching text similarity.
Knowledge graphs give a retrieval system something vector search lacks: the connections between facts, not just the facts themselves. For AI agents, that makes multi-hop questions (ones whose answer depends on chaining several related facts) tractable, because the relationships are encoded in the index instead of being inferred at generation time.
- Stores information as nodes (entities) and edges (typed relationships), not as a flat list of text chunks.
- Answers multi-hop questions by traversing relationships, which vector retrieval cannot do directly.
- Powers GraphRAG, where graph structure is layered on top of or alongside vector retrieval.
- Costs more to build than a vector index because entities and relationships are usually extracted by an LLM at ingestion.
- Wins on synthesis and global questions, loses to plain vector search on simple fact lookups.
How a knowledge graph works
A knowledge graph models a domain as entities (people, products, concepts, files) connected by typed edges (works-for, depends-on, supersedes). Building one usually means running an extraction pass over source documents, often with an LLM, that pulls out the entities and the relationships that link them. Retrieval then becomes a traversal problem: start at an entity that matches the query and follow edges to gather connected facts.
This is fundamentally different from semantic search, where the index is a cloud of embedding vectors and retrieval means finding the chunks nearest to the query vector. Vector search has no notion of “this fact is connected to that fact.” A knowledge graph makes those connections first-class.
Why knowledge graphs matter for AI
Most retrieval failures on hard questions are connection failures, not lookup failures. A question like “which dependencies of the billing service were changed by the engineer who owns the auth migration” requires chaining several facts that live in different documents. Vector retrieval pulls passages that each look relevant but rarely returns the path between them. A knowledge graph encodes that path in the index, so the model receives the connected structure instead of having to reconstruct it from scattered chunks.
The cost is real: extracting entities and relationships is heavier than embedding text, and graph context can balloon in token count if traversal is not bounded. That tradeoff is why graphs win on multi-hop and global synthesis questions and lose to plain RAG on simple fact lookups.
FAQ
Frequently asked questions
Common questions about Knowledge Graph.
How is a knowledge graph different from a vector database?
What is GraphRAG?
Do knowledge graphs replace RAG?
All terms
View full glossaryPut context into practice
Create your first context container and connect it to your AI tools in minutes.
Create Your First Container