Knowledge systemsKnowledge graphs · Vector databases · Data architecture

Knowledge graph or vector search: which one fits your task

A knowledge graph and vector search answer the same request, “find what is relevant”, but they understand relevance differently. Vector search looks for what is similar in meaning; a graph looks for what is connected by structure. Mix them up, and a project spends a long time fixing the wrong place.

What a knowledge graph is

A knowledge graph stores data as entities and the relations between them: “a part belongs to an assembly”, “an employee is responsible for a process”, “a topic builds on another topic”. The meaning is recorded in the relations themselves. That is why a graph can handle questions that take several steps. For example: what happens to production if this particular machine goes down.

What vector search is

A vector database stores text fragments as numbers that reflect their meaning. A query is turned into the same kind of set of numbers, and the database returns the closest fragments. This kind of search copes with rephrasing: “how to book a holiday” will find the policy clause on “provision of annual paid leave”, even though not a single word matches.

What the difference is

Which questions each approach answers

Vector search is stronger when

A knowledge graph is stronger when

How they are combined

In working systems you usually do not have to choose between them. The duties are split roughly like this:

  1. The vector index takes the user’s question in free form and finds an entry point: fragments and the entities they mention.
  2. From that point the graph builds out the context: related objects, dependencies, constraints, the current version.
  3. The model receives both the text fragments and the structured context and answers with references to the sources.

This pairing holds up noticeably better than pure semantic search where completeness matters. And it is noticeably cheaper to fill than an attempt to push absolutely everything into the graph.

Where a graph breaks

An ontology “for every occasion”

The wish to describe the whole domain leads to a schema that cannot be filled and that nobody understands. What works is a minimal ontology for specific questions, extended when new questions appear.

Extracting entities from text

A graph built automatically by a language model comes out as a draft: one entity arrives in three spellings, relations are duplicated, some of them are made up. You need normalisation, deduplication and spot checks by a person. This is real work, and it cannot be skipped.

Keeping it current

A graph that is not updated along with its sources is wrong more convincingly than search, because it looks structured and authoritative. The update rule is designed together with the graph.

How to choose in four questions

  1. Is the answer to a typical question a fragment of text, or does it come from following relations? The first calls for vector search, the second for a graph.
  2. Does an incomplete answer cost much? If missing one item from a list costs money, you need a graph.
  3. Who will maintain the structure? If nobody, the graph will not work. Start with vector search.
  4. How often do the documents change? The more often, the more cheap updates matter, which means vector search or a hybrid.

Our experience

A graph database sits at the core of StudyNinja, the learning platform our methods run on. Its knowledge graph holds topics, skills, solution methods and typical mistakes, and the relations between them say what builds on what. The platform’s tasks (finding a gap in knowledge and choosing the next step) are solved by traversing these relations. There is no vector layer in this system today.

Frequently asked questions

Can you get by with a vector database alone?

Yes, if users’ questions come down to “find and explain” over text. As soon as questions like “list everything that depends on X” or “in what order is this done” appear, pure vector search starts to lose parts of the answer. That shows up clearly on a set of test questions.

Does a knowledge graph have to be built by hand?

Not necessarily by hand, but it cannot be built fully automatically either. The scheme that works: a model extracts candidates, rules normalise them and remove duplicates, a person checks a sample and the disputed cases. Once the ontology settles, there is less manual work.

Which databases do you use?

A graph database for relations and a vector index for semantic search, with the specific product chosen for the task. The product matters less than the data model and the update procedure: replacing an engine costs less than reworking a badly designed ontology.

How we help with this

Read next

Tell us about your problem

If you’re dealing with something similar, describe it in your own words in the form on the homepage. If it has a simpler solution than it seems, we’ll say so.

New write-ups on TelegramEmail hello@xteam.pro