Ontology-grounded RAG: why vector search alone stops improving
Vector search finds text that resembles the question. An ontology and a knowledge graph find the facts that answer it. How the two fit together in a production RAG system.
Most retrieval-augmented generation systems follow the same curve. The first version, built on chunked documents and a vector index, is impressive. Tuning chunk sizes and adding a re-ranker makes it better. Then quality flattens, and the remaining failures all look alike: the answer is plausible, partly right, and missing something the business considers obvious.
That plateau is not a model problem. It is a retrieval problem, and more specifically a problem of meaning. Embeddings capture what text is about. They do not capture how the things in your business relate to each other.
What similarity cannot see
Ask a product assistant which orders are affected when a supplier changes a material. The answer depends on a chain: supplier to material, material to product variants, variants to open orders. No single passage contains that chain, so no amount of similarity search will return it. The system retrieves the passages that mention the supplier and writes a confident paragraph around them.
The same gap shows up with terminology. The warehouse, the finance team and the customer portal use different names for the same item. To an embedding model those are three loosely related strings. To the business they are one thing.
Taxonomy, ontology, graph
Three layers fix this, and they are worth keeping distinct.
- A taxonomy is the agreed vocabulary: categories, attributes and the terms that are really synonyms.
- An ontology adds structure: which kinds of entities exist, which relationships are allowed between them and which rules they obey.
- A knowledge graph is the ontology populated with real data, where each product, customer and order is a node connected by real relationships.
The ontology is where most of the value is. It is a design exercise done with the people who run the business, and it forces decisions that were previously left vague. The graph engine underneath is a secondary choice. PostgreSQL carries many graphs comfortably, and a dedicated graph database earns its place when traversals get deep.
Linking the graph to vector search
Graph and vectors are complements. In the knowledge layer I designed at Metis Labs, nodes carry embeddings, so a query can enter through semantic search, land on the right entities and then follow relationships outward. Retrieval becomes two steps: find where the question points, then collect what is connected to it.
The context handed to the model is then a set of facts with known relationships and known sources, which is what makes grounded, cited answers possible. When a user asks why the assistant said something, there is a path through the graph to show them.
Running it on live data
A graph built from a one-off export is out of date within a week. The pipelines that populate the graph need to run against production systems and resolve entities as they arrive, so that one real-world thing stays one node. This is the unglamorous part of the work and the part that decides whether the system is still trusted in six months.
When not to do this
If your questions are lookups in a modest set of documents, hybrid keyword and vector search is cheaper and good enough. An ontology pays for itself when answers depend on relationships, when terminology is inconsistent across systems, or when you have to explain how an answer was reached.
A reasonable test: collect twenty questions your current system answers badly. If most of them need facts from more than one record, the missing piece is structure, and a better model will not supply it.