Knowledge graph vs vector database: which one your AI system needs
Vector databases find text by meaning. Knowledge graphs find facts by relationship. How they differ, where each one fails and why production systems usually combine them.
This is usually framed as a choice. In practice the two solve different problems, and the useful question is which failures you are seeing today.
Side by side
| Vector database | Knowledge graph | |
|---|---|---|
| Stores | Embeddings of text chunks | Entities and the relationships between them |
| Finds things by | Semantic similarity | Traversing relationships |
| Strong at | Fuzzy questions over unstructured text | Multi-hop questions, completeness, explanation |
| Weak at | Exact identifiers, relationships, combining records | Free text that has not been modelled |
| Setup effort | Low: chunk, embed, index | Higher: ontology, pipelines, entity resolution |
| Answers “why?” | Only by showing similar passages | By showing the path through the graph |
Where vector search runs out
Embeddings capture what a passage is about. They do not capture how the things in it relate to things elsewhere. A question such as “which open orders are affected by this supplier change” depends on a chain of records, and no single passage contains the chain. The system returns text that mentions the supplier and the model writes a confident, incomplete answer.
Exact identifiers are the other weak spot. Part numbers, error codes and names are poorly served by similarity alone, which is why production retrieval adds keyword search alongside vectors.
Where a graph runs out
A knowledge graph only knows what has been modelled and loaded. Long documents, emails and call notes do not arrive as tidy entities. A graph also costs more to build: someone has to design the ontology, write the pipelines and resolve duplicates.
Using both
The combination is straightforward. Graph nodes carry embeddings. A query is embedded and matched against them to find where the question points, and the system then follows relationships from those nodes to collect the connected facts. Unstructured passages stay in the vector index and are attached to the entities they describe.
You do not always need a dedicated graph database for this. PostgreSQL with pgvector can hold embeddings and a graph of moderate depth in one service. A dedicated graph engine such as Neo4j earns its cost when traversals get deep or graph algorithms are needed.
How to decide
- Questions are lookups in documents: a vector index with keyword search is enough.
- Answers are plausible but miss related facts: add a graph.
- Users ask about everything connected to an entity: add a graph.
- You must show how an answer was derived: add a graph.
- The document set is small and stable: do not build either beyond basic hybrid search.
A quick test is to collect twenty questions your system answers badly and count how many need facts from more than one record. If it is most of them, the missing piece is structure.