When do graph databases outperform vector embeddings for retrieval?
Vector similarity struggles with aggregate and relational queries that require traversing multiple entity connections. Can graph-oriented databases with deterministic queries solve this failure mode in enterprise domain applications?
Vector similarity retrieval has a well-known failure mode that becomes critical in enterprise domain applications: aggregate and relational queries generate too many plausible candidates. The GODB paper illustrates this with a business case example: "give me the volume of cement or concrete sales lost due to humidity issues in 2023." A cosine similarity search on a database of half a million sales notes will return hundreds of candidate vectors — every note mentioning humidity, cement, or sales is a plausible match. The standard solution (take top-k) is not suitable: the answer requires aggregating across all relevant records, not selecting the single most relevant one.
Graph-oriented databases (GODBs) solve this by replacing similarity search with graph traversal. Knowledge is stored as entities and labeled relationships (LLM-generated from source text). Queries are expressed in graph query languages (Cypher for Neo4j) that can precisely specify traversal paths: find all records where cement-sales-loss is connected to humidity-cause in 2023, sum across all matching nodes. The query is deterministic and complete rather than probabilistic and sampled.
The production architecture: (1) LLM extracts entities and relationships from domain documents and constructs the knowledge graph; (2) user queries are translated to Cypher expressions by an LLM agent; (3) graph database executes the traversal and returns structured results; (4) LLM interprets and synthesizes the results into natural language responses. The LLM's role shifts from primary retrieval to query translation and result interpretation — tasks where its language capabilities are well-suited.
The limitation: constructing and maintaining a knowledge graph from domain documents is significantly more expensive than building vector embeddings. The GODB approach scales when the query patterns are relational and the cost of incorrect answers is high — the enterprise domain use case. For simple semantic lookup (find me a document about X), vector embeddings are faster and cheaper.
The LLM+KG integration landscape: A comprehensive survey identifies three integration paradigms: (1) KG-enhanced LLMs — using KG structure to improve LLM reasoning (entity embeddings, structured pretraining); (2) LLM-augmented KGs — using LLMs for KG construction, completion, and question answering; and (3) Synergized LLM+KG — bidirectional collaboration where each improves the other. The GODB approach falls in paradigm (2); HippoRAG and GraphRAG represent paradigm (3). This taxonomy clarifies that "graph vs vector" is not a binary choice but a design space with distinct integration patterns suited to different query types and domain requirements.
A second and distinct failure mode compounds the relational problem: vector embeddings measure semantic co-occurrence, not task relevance. The king/queen/ruler example (OpenAI ADA-002): queen scores 92% similarity to king; ruler scores 83%. Yet for a query about "information about kings in governance," ruler is the more relevant result — kings and rulers are synonyms, while kings and queens are related but play different roles. Embeddings cannot distinguish these because they are trained on co-occurrence, not relevance. This failure occurs even on simple single-hop queries, predating the aggregate/relational failure that GODB addresses. See Do vector embeddings actually measure task relevance?.
This connects to Can organizing knowledge structures beat raw training data volume?: both findings point to structured knowledge organization as a competitive advantage over unstructured volume. In injection, taxonomy structure improves efficiency. In retrieval, graph structure enables query types that vector search cannot support.
Source: Domain Specialization; enriched from Knowledge Graphs
Related concepts in this collection
-
Can organizing knowledge structures beat raw training data volume?
Does structuring domain knowledge into taxonomies during training enable models to learn more efficiently than simply increasing the amount of training data? This challenges assumptions about scaling knowledge injection.
parallel insight: graph structure outperforms flat storage at both injection and retrieval stages
-
How do knowledge injection methods trade off flexibility and cost?
When and how should domain knowledge enter an AI system? This explores the speed, training cost, and adaptability trade-offs across four injection paradigms, and when each approach suits different deployment constraints.
dynamic injection paradigm; graph RAG is a more powerful but costly dynamic injection implementation
-
Does search budget scale like reasoning tokens for answer quality?
Explores whether the test-time scaling law that applies to reasoning tokens also governs search-based retrieval in agentic systems. Understanding this relationship could reshape how we allocate inference compute between thinking and searching.
retrieval architecture determines what's findable; GODB expands the query vocabulary that search agents can execute
-
Do vector embeddings actually measure task relevance?
Vector embeddings rank semantic similarity, but RAG systems need topical relevance. When these diverge—as with king/queen versus king/ruler—does similarity-based retrieval fail in production?
the simpler single-hop failure mode; semantic proximity ≠ task relevance; compounds the relational failure documented here
-
What do enterprise RAG systems need beyond accuracy?
Academic RAG benchmarks focus on question-answering accuracy, but enterprise deployments in regulated industries face five distinct requirements—compliance, security, scalability, integration, and domain expertise—that standard architectures don't address.
graph DBs address enterprise requirements 1 (explainability via auditable traversal) and 5 (domain customization via entity-relationship schemas); the enterprise context is where graph superiority over vector embeddings has the highest stakes
-
Can routing queries to task-matched structures improve RAG reasoning?
Does matching retrieval structure type to task demands—tables for analysis, graphs for inference, algorithms for planning—improve reasoning accuracy over uniform chunk retrieval? This explores whether cognitive fit principles from human learning transfer to AI systems.
graph is one structure type in StructRAG's five-way routing framework; cognitive fit theory provides the theoretical basis for why graph outperforms vectors on relational queries specifically (task-structure match) rather than universally
Click a node to walk · click center to open · click Open full network for a force-directed map
Original note title
graph-oriented databases outperform vector embeddings for domain rag when queries require relational traversal