Ontology

On this page 8

An ontology is a formal, explicit specification of a shared conceptualization: a machine-readable model that names the classes, relations, properties and logical constraints of a domain so that software can interpret data consistently. In artificial intelligence, and especially in retrieval and knowledge systems, an ontology supplies the schema of meaning behind a knowledge graph, a semantic search index or a question answering pipeline.

Where an embedding captures similarity statistically, an ontology states meaning explicitly and verifiably. It tells a system that a cardiologist is a kind of physician, that a drug treats a condition rather than causes it, and that every invoice must have exactly one issuer. This combination of vocabulary and logic is what lets machines reason over facts instead of merely matching text.

How an ontology structures domain knowledge

An ontology structures knowledge by separating the terminological layer from the assertional layer. The terminological layer, often called the TBox, defines classes and the rules that connect them. The assertional layer, the ABox, records concrete individuals and facts that conform to those definitions.

The core building blocks are few but expressive. A class hierarchy arranges concepts through subclass relations, object properties link individuals to one another, and datatype properties attach literal values such as dates or amounts. Axioms then constrain the model, for example by declaring two classes disjoint or a property functional.

The following table summarizes the main components and the role each plays in a working ontology.

ComponentWhat it definesIllustration
ClassA category of thingsPhysician, Hospital, Drug
Subclass relationHierarchy between categoriesCardiologist is a Physician
Object propertyRelation between individualsworksAt links Physician to Hospital
Datatype propertyAttribute with a literal valuedateOfBirth as an xsd:date
AxiomLogical rule or constraintDrug and Disease are disjoint
IndividualA concrete instanceA specific clinic in a city
Core components of an ontology

Because the semantics are formal, a reasoner can derive facts that were never stated. If every cardiologist is a physician and a given person is a cardiologist, the reasoner infers that the person is a physician, and it flags any data that violates declared constraints.

Ontology languages and standards

Most production ontologies are expressed in W3C Semantic Web standards, which give them a shared syntax and well-defined logic. The choice of language determines how much a reasoner can infer and how expensive that inference becomes.

The table below compares the languages that practitioners meet most often and the typical purpose of each.

LanguageExpressivenessTypical use
RDF Schema (RDFS)Classes, subclasses, domains and rangesLightweight vocabularies
OWL 2 DLDescription logic with decidable reasoningRich domain models, consistency checking
OWL 2 profiles (EL, QL, RL)Restricted subsets for scaleLarge biomedical or database-backed models
SKOSConcepts, broader and narrower termsThesauri and controlled vocabularies
SHACLShape constraints on graph dataData validation rather than inference
Common ontology and schema languages

A key distinction is the open-world assumption of OWL versus the closed-world validation of SHACL. In OWL, a missing fact is simply unknown; in SHACL, a missing required value is an error to report. Many teams therefore model meaning in OWL and enforce data quality with SHACL shapes.

An ontology is the most formal member of a family of knowledge structures that are frequently confused. The difference lies in how much logical meaning each one carries and whether it describes types or instances.

StructureMain contentSupports logical inference
OntologyClasses, relations and axiomsYes, through a reasoner
Knowledge graphEntities and facts, usually typed by an ontologyOnly when paired with an ontology
TaxonomyA single broader and narrower hierarchyLimited to inheritance
ThesaurusTerms with synonyms and associationsNo formal inference
Database schemaTables, columns and keysNo, only integrity constraints
How an ontology differs from neighboring concepts

In practice, a knowledge graph is the populated data and the ontology is its schema and rulebook. GraphRAG and knowledge graph question answering depend on that pairing, because consistent entity types and relation names are what make multi-hop traversal reliable.

The role of ontologies in retrieval and RAG systems

In retrieval-augmented generation, an ontology adds structured meaning to pipelines that otherwise rely on vector similarity alone. It improves precision, explainability and consistency at several points of the pipeline.

  • Entity linking and normalization map different surface forms, such as an abbreviation and a full drug name, to one canonical concept.
  • Query expansion uses subclass and synonym relations to add narrower or equivalent terms before search.
  • Metadata filtering applies ontology classes as facets, so a query about pediatric cardiology retrieves only matching documents.
  • Extraction schemas constrain a language model to emit triples whose types and relations exist in the model.
  • Answer validation checks generated claims against axioms and rejects combinations that the ontology forbids.

The main benefit is that an ontology reduces ambiguity that embeddings tolerate. Two passages may be semantically close yet describe incompatible entity types, and an ontology-aware filter can separate them deterministically before the generator sees them.

Designing and maintaining an ontology

Good ontology design starts from competency questions, the concrete questions the model must be able to answer. Engineers then reuse established ontologies where possible, such as upper-level models or domain standards, rather than inventing parallel vocabularies.

The decision table below shows how project conditions shape the recommended approach.

SituationRecommended approachReason
Small search vocabularySKOS concept schemeLow cost, enough for synonyms and facets
Regulated or clinical domainReuse a standard OWL ontologyShared identifiers enable interoperability
Very large instance dataOWL 2 EL or RL profileReasoning remains tractable at scale
Data quality is the prioritySHACL shapes over an RDFS modelClosed-world checks catch missing values
Rapid prototype for RAGLLM-assisted draft, expert reviewSpeed without losing correctness
Choosing an ontology strategy

Maintenance matters as much as design. Ontologies need version control, persistent identifiers and a deprecation policy, because downstream graphs and indexes break silently when a class is renamed or removed.

Limitations and common mistakes

Ontologies are powerful but costly, and their failures are usually organizational rather than technical. The most frequent problems are listed below.

  • Over-modeling: encoding every nuance produces a model that nobody can populate or maintain.
  • Confusing classes with instances: treating a specific product as a class breaks inference and querying.
  • Misreading the open-world assumption: expecting OWL to report missing data, which it does not do.
  • Unchecked LLM-generated axioms: language models propose plausible but logically inconsistent hierarchies.
  • Ignoring reasoning cost: full OWL 2 DL reasoning can become impractically slow on millions of individuals.

A further limitation is coverage. An ontology describes only what its authors anticipated, so retrieval systems usually combine it with dense and sparse retrieval rather than replacing them.

Stripped to the essentials

An ontology is a shared dictionary with rules that a computer can read. It lists the kinds of things in a subject, such as doctors, hospitals and medicines, and says exactly how they relate to one another.

Think of it as the rulebook of a board game. The pieces are the data, and the rulebook says which moves are allowed. With that rulebook, an AI system can draw correct conclusions and notice when something does not make sense, instead of only guessing from similar words.

Where it is applied

A hospital network builds an internal assistant that answers clinicians’ questions from guidelines, drug leaflets and research summaries. Pure vector search returns passages about adult dosing when a nurse asks about children, because the texts are semantically similar.

The team links every document chunk to concepts from a standard clinical ontology covering about 40,000 conditions and drugs. Queries are expanded with narrower terms, chunks are filtered by patient group and drug class, and generated answers are checked against contraindication axioms before display.

After the change, reviewers find that answers cite the correct patient group far more consistently, and every rejected answer comes with a traceable reason drawn from the ontology, which makes audits by the clinical safety team considerably faster.