Glossary

Knowledge graph vs ontology

An ontology defines the types of things in a domain and the rules for how they can relate, while a knowledge graph is the data itself: specific entities and the relationships between them, usually organised according to an ontology.

An ontology and a knowledge graph sit at different levels of the same structure. An ontology is a formal description of a domain: the classes of thing that exist (Person, Company, Contract), the relationships allowed between them (a Person is employed by a Company, a Contract has parties), and the rules those relationships follow (every Contract has at least two parties, employed by points from a Person to an Organisation). A knowledge graph is a collection of specific facts expressed as nodes and edges: Maya Chen is employed by Acme, Acme is a party to contract 4471. The ontology plays the role of a schema and the knowledge graph plays the role of the data. You can build a knowledge graph with a light or implicit ontology, and you can write an ontology that never gets populated, but in most serious systems the two are designed together so that the graph stays consistent and queryable as it grows.

What an ontology is

An ontology is a shared vocabulary with rules attached. It names the concepts in a domain, arranges them into a hierarchy (a Supplier is a kind of Organisation, which is a kind of Agent), defines the properties each concept can have, and constrains how concepts connect. In the semantic web tradition, ontologies are written in languages such as RDFS and OWL, which support class hierarchies, property domains and ranges, cardinality limits and logical axioms that a reasoner can use to infer new facts. A lighter version of the same idea shows up in Schema.org, the vocabulary websites use to describe products, events and organisations, and in the type definitions of most graph databases.

The value of an ontology is agreement. When two teams, two systems or two agents use the same ontology, “customer” means the same thing to both, and a query written against one dataset works against the other. Ontologies also make implicit knowledge explicit. If the ontology says that a subsidiary’s contracts are visible to its parent company, a reasoner can answer questions about the parent without anyone writing that fact down for every contract.

Ontologies are a branch of knowledge representation, the wider field concerned with how to encode what is known so that a machine can use it. They tend to change slowly. Adding a new class or relationship is a design decision, often reviewed by people who understand the domain, because every fact in the graph depends on it.

What a knowledge graph is

A knowledge graph stores facts as entities connected by typed relationships. Each entity is a node with an identifier and attributes, and each relationship is an edge with a direction and a type. The graph can be stored as subject, predicate and object statements in a triple store, or as nodes and edges with properties in a property graph database such as Neo4j. Either way, queries walk the edges: start at a customer, follow “has contract” to their contracts, follow “governed by” to the jurisdiction, and return every contract under English law.

Knowledge graphs change constantly. New entities arrive, relationships are added and removed, and attributes are corrected. A company knowledge graph might grow by thousands of facts a day as documents are processed, while the ontology underneath it stays the same for months. The explainer on what a knowledge graph is covers the structure in more detail, and graph database describes the storage engines most graphs run on.

Knowledge graph vs ontology at a glance

Ontology

Knowledge graph

Role

Schema and rules for a domain

Instance data organised by that schema

Contains

Classes, relationship types, constraints, axioms

Specific entities, relationships and attributes

Example

A Contract has parties; parties are Organisations

Contract 4471 has parties Acme and Northwind

Rate of change

Slow, deliberate, reviewed

Continuous, often automated

Typical size

Tens to thousands of concepts

Thousands to billions of facts

Languages and tools

OWL, RDFS, SHACL, Protégé

RDF triple stores, property graphs, Cypher, SPARQL

Main question it answers

What kinds of things exist and how can they relate?

What is true about these specific things?

Who maintains it

Domain experts and data architects

Pipelines, extraction models and agents

How they work together

In practice an ontology gives a knowledge graph three things. The first is structure: every node has a known type and every edge a known meaning, so queries are predictable. The second is validation: a constraint language such as SHACL can reject a fact that breaks the rules, for example a contract with one party or an employee who works for a date. The third is inference: if the ontology says that “is a subsidiary of” is transitive, the graph can answer questions about indirect ownership without storing every chain.

Building the graph from unstructured sources is where the two meet most often. Named entity recognition finds the people, companies and products in a document, relation extraction identifies how they connect, and entity resolution decides that “Acme Ltd”, “ACME” and “Acme Limited” are one node. The ontology tells each step what to look for. Without it, extraction produces a loose web of strings with inconsistent relationship names, which is hard to query and harder to trust.

The relationship also runs the other way. Teams often start with a small ontology, populate a graph, and discover from the data which classes are missing or which relationships are too coarse. A graph of supplier contracts might reveal that “party to” needs splitting into “buyer” and “seller”. The ontology evolves from what the graph shows, then the graph is migrated to the new shape.

A worked example

A procurement team wants an agent that can answer questions about supplier risk. The data architect writes a small ontology: Supplier, Contract, Jurisdiction, Person and Incident, with relationships such as “supplies”, “is party to”, “is governed by”, “is contact for” and “was involved in”. Constraints say that every Contract has a start date, at least one Supplier party and exactly one governing Jurisdiction.

An extraction pipeline reads 12,000 contracts and incident reports and writes facts into a property graph. “Northwind Logistics is party to contract 8812”, “contract 8812 is governed by Singapore law”, “Northwind Logistics was involved in incident 311”. Entity resolution merges three spellings of Northwind. A SHACL check flags 40 contracts with no governing law, which turn out to be scanned amendments where the clause sits on a page the parser missed.

The agent can now answer “which suppliers with an incident in the last year have contracts governed by a jurisdiction outside the EU?” by walking the graph. The question depends on both layers. The ontology defines what an incident, a supplier and a jurisdiction are, and the graph holds which specific ones exist.

Where the distinction matters for AI systems

Large language models changed how both are used. Extraction that once needed hand-written rules can now be done by a model prompted with the ontology, which makes knowledge graphs cheaper to build. GraphRAG uses a graph alongside text retrieval to answer questions that span many documents, and the comparison of GraphRAG vs RAG covers when that pays off. Graphs help most with multi-hop retrieval, where the answer depends on following several relationships in sequence.

Ontologies have become lighter in many AI projects. Teams often let a model propose relationship types as it extracts, then consolidate them later, rather than designing a full OWL ontology up front. This is faster but carries a cost: without a fixed vocabulary, the same relationship appears under five names, and queries miss facts. A middle path is a short list of core types the model must use, plus a review step for anything new.

Time is the other complication. Most ontologies describe what can be true, and most knowledge graphs describe what is true now. Agents need to know what was true last month and what changed since. A temporal knowledge graph adds validity periods to edges so that “Maya works at Acme” can end when she moves to Northwind, and contradiction resolution decides which of two conflicting facts should win.

Ontology, knowledge graph and agent memory

Agent memory borrows from both. An agent that remembers a user needs a structure for what it knows (preferences, facts, events, relationships between people and projects) and a store of the specific memories that fill that structure. In the language of this page, the structure is an ontology and the memories form a graph. The difference is that agent memory has to build and repair both automatically from conversations, without a data architect reviewing every new concept, and has to handle facts that change. Semantic memory describes the long-lived factual part of that picture, and memory consolidation describes how related facts are merged over time.

A vector database provides neither layer. It stores embeddings and returns the most similar ones to a query, with no notion of entity types or relationships, which is why vector database vs knowledge graph is a common comparison and why the post on why a vector database is not a memory system exists.

Where Exabase fits

Exabase does not ask you to design an ontology or run a graph database. The Memory API runs on the M-1 engine, which extracts facts, preferences and events from conversations and builds what the product documentation calls a dynamic ontology: a tree-like structure of high-level concepts with individual memories attached, which reorganises itself as new information arrives. It tracks relationships between concepts, resolves contradictions when a fact changes (a move from Toronto to Berlin leaves one current city), and consolidates duplicates. You send text to the create memory endpoint and retrieve with memory search, which combines semantic and keyword matching with recency weighting.

That makes Exabase a substrate for the memory part of a knowledge system rather than a replacement for a formal ontology. If your domain needs OWL reasoning, strict SHACL validation or SPARQL queries across a curated enterprise graph, a dedicated graph platform is the right tool, and the Exabase vs Neo4j page covers that trade-off. If what you need is an agent that keeps an accurate, current picture of users and their work, the agent memory solution describes the approach, and about memories explains how memories are organised. Documents that feed the graph can go through Extract for structured output and Deep Search for passage-level retrieval, and a Worker can refresh memories when the source documents change. The research agents use case shows that combination on a literature corpus where findings contradict each other over time.

Frequently asked questions

Is a knowledge graph the same as an ontology?

No. An ontology defines the kinds of entities and relationships in a domain and the rules they follow. A knowledge graph holds specific entities and relationships. The ontology works like a schema; the knowledge graph is the data.

Can a knowledge graph exist without an ontology?

Yes, but it is harder to keep consistent. Many graphs start with an implicit ontology, a set of node labels and edge types agreed informally. As the graph grows, inconsistent relationship names and duplicate types make queries unreliable, which is usually when teams write the ontology down.

Is an ontology a type of knowledge graph?

An ontology can be stored as a graph, because classes and relationships can be represented as nodes and edges. That is why the terms blur. The distinction is in purpose: the ontology describes what can exist, and the knowledge graph describes what does.

Do LLM applications need a formal ontology?

Not always. Many RAG and memory systems work with a short list of entity and relationship types, or with structures maintained automatically. A formal ontology pays off when several systems share the data, when you need logical inference or validation, or when regulated reporting depends on precise definitions.

What is the difference between a taxonomy and an ontology?

A taxonomy is a hierarchy of categories, such as product types arranged from general to specific. An ontology includes a taxonomy but adds relationships between concepts, properties and rules. Every ontology contains a taxonomy; most taxonomies are not ontologies.

How does Exabase relate to knowledge graphs?

Exabase Memory maintains a self-organising structure of concepts, memories and relationships for each Base, and resolves contradictions as facts change. It is built for agent memory rather than as a general-purpose graph database, so it does not expose SPARQL or Cypher. See the agent memory solution for details.

Related pages: Knowledge graph, Ontology, Vector database vs graph database, Memory vs knowledge base, Context graph, GraphRAG, Best knowledge graph for AI agents, Exabase vs Graphiti, Exabase vs Cognee, How M-1 resolves contradictions

Cut your token spend and give your agent precise context.

Get started in minutes.

Cut your token spend and give your agent precise context.

Get started in minutes.