June 14, 2026
Ontologies, Knowledge Graphs, and Artificial Intelligence (Live Demo)
Ontologies and knowledge graphs are decades-old ideas that most people still mix up. Artificial intelligence is the new force reshaping…

By Vishal Mysore
6 min read
Ontologies and knowledge graphs are decades-old ideas that most people still mix up. Artificial intelligence is the new force reshaping both — and with WebLLM, it now runs in a browser tab. Here's how the three fit together.
Ontologies and knowledge graphs come out of the semantic-web world, and they are constantly confused with each other — people say "knowledge graph" when they mean ontology, and "ontology" when they just mean a diagram with arrows. The two are genuinely different things, and the difference is the first thing this article pins down.
Artificial intelligence isn't a third synonym in that mix — it's the new force acting on both. For decades, building a knowledge graph meant armies of human curators or brittle hand-tuned extractors, and authoring an ontology meant a specialist hunched over a formal editor. Large language models change that: feed an LLM a paragraph and it will hand you back entities and relationships in seconds. The old, painstaking disciplines suddenly have a fast, sloppy, surprisingly capable new engine.
WebLLM makes the shift almost absurd: it runs that LLM entirely in your browser — no server, no cloud inference, no data leaving your machine. The barrier to turning text into a graph drops to a single paste-and-click.
I wanted to make the fundamentals of ontologies and knowledge graphs easier to grasp — not by reading another definition, but by watching them take shape from real text. So I built a small experimental tool, GraphBaby, to do exactly that: paste in text, and a local LLM drafts a real OWL ontology — classes, properties, and individuals — which you can then edit, browse as a hierarchy, visualise as a graph, and export. It puts all three in one place: the AI doing the extraction, the ontology supplying the rules, and the individuals that populate it forming a knowledge graph. Where it deliberately stops turns out to be just as instructive as what it does — but more on that later.
Demo : https://vishalmysore.github.io/graphbaby/
This article uses that little experiment to untangle the three properly. Let's start at the foundation.
GraphBaby's three-pane editor — the class tree (left), the entity editor with its axioms (centre), and a live usage panel (right). Shown here with the bundled Pizza tutorial ontology loaded.
What is an ontology?
An ontology is a formal, explicit specification of the concepts in a domain and the rules that govern how those concepts relate. It is the schema of meaning — the blueprint, not the building.
Borrowed from philosophy (where "ontology" is the study of what exists), in computer science it answers three questions about a domain:
- What kinds of things exist? (classes / types) — e.g.
Person,Organization,Disease,Medication. - How can they relate? (properties / relationships) — e.g. a
PersoncanworksAtanOrganization; aMedicationtreatsaDisease. - What rules must hold? (axioms / constraints) — e.g. "every
Patientis aPerson," "treatsonly connects aMedicationto aDisease," "aPersonhas exactly onedateOfBirth."
The defining feature: rules you can reason over
The thing that makes an ontology an ontology — and not just a labelled diagram — is that it encodes logic a machine can reason with. If your ontology states:
Cardiologistis a subclass ofDoctorDoctoris a subclass ofPerson
…then a reasoner can infer, with no extra data, that every Cardiologist is a Person. Nobody had to write that fact down. That capacity for inference is the heart of the concept.
Ontologies are typically written in formal languages:
LanguageWhat it gives youRDFSbasic classes, subclasses, propertiesOWL (Web Ontology Language)rich logic: cardinality, disjointness, transitivity, equivalenceSHACLshape constraints / validation rules
A tiny ontology fragment in Turtle (RDF syntax) looks like this:
:Doctor rdfs:subClassOf :Person .
:Cardiologist rdfs:subClassOf :Doctor .
:treats rdfs:domain :Medication ;
rdfs:range :Disease .:Doctor rdfs:subClassOf :Person .
:Cardiologist rdfs:subClassOf :Doctor .
:treats rdfs:domain :Medication ;
rdfs:range :Disease .This says nothing about any specific doctor. It describes the shape of reality for the medical domain. That is an ontology: the vocabulary and the rules, divorced from any particular data.
The schema, visualised: GraphBaby's graph view shows the class hierarchy alone — Pizza, PizzaBase and PizzaTopping branching into subclasses, linked by subClassOf and property edges. Not a single concrete pizza in sight; this is the blueprint.
What is a knowledge graph?
A knowledge graph is a network of real, concrete facts represented as a graph: nodes (entities) connected by edges (relationships). It is the data, the populated instance — the building, not the blueprint.
Facts are stored as triples:
(subject) --[predicate]--> (object)(subject) --[predicate]--> (object)For example:
(Albert Einstein) --[developed]--> (Theory of Relativity)
(Albert Einstein) --[worked_at]--> (Princeton University)(Albert Einstein) --[developed]--> (Theory of Relativity)
(Albert Einstein) --[worked_at]--> (Princeton University)A knowledge graph answers questions like "Where did Einstein work?" by traversing edges. It is specific, instance-level, and grows by adding more facts. Google's Knowledge Graph (the info boxes in search results), Wikidata, and enterprise customer-360 graphs are all knowledge graphs: huge collections of concrete entities and relationships.
In GraphBaby these facts live as individuals — Einstein, Princeton — each typed by a class from the ontology and linked by the ontology's object properties. The bare triple is the idea; the typed, schema-bound individual is what the tool actually stores. We'll see why that distinction matters in a moment.
An individual is where the facts live. Here Arjuna (from the bundled Mahabharata tutorial — more on those below) is typed as a Pandava and wired up with concrete assertions: hasParent → Kunti, hasSpouse → Draupadi, allyOf → Krishna, enemyOf → Karna, foughtIn → Kurukshetra War. Every edge points at another real individual; this is the knowledge graph.
Where artificial intelligence enters
Here is the part that makes GraphBaby a 2026 project rather than a 2006 one.
Classically, the ontology came first — painstakingly hand-authored by a specialist in a formal ontology editor — and only then was data poured into its mould by human curators or brittle rule-based extractors. Both halves were slow.
GraphBaby hands both halves to the AI, in the right order. A local large language model — running entirely in the browser via WebLLM on WebGPU — does the work in two passes, and the order is the whole point:
- First, draft the schema. The system prompt is literally "You are an OWL ontology class hierarchy designer." The model reads the text and proposes the classes and their
subClassOfhierarchy — the TBox, the ontology itself. - Then, populate it — under constraint. A second prompt — "You are an OWL individual extractor… DO NOT invent new classes" — feeds the model the already-approved classes and properties and asks it to extract individuals that fit them. The schema from step 1 becomes the leash on step 2.
This is the crux of the experiment, and it cuts both ways:
- AI makes ontologies cheap. What used to need an ontologist and an NLP team is now a paste-and-click. The barrier to a first ontology collapses to near zero.
- AI on its own is unreliable. Left unconstrained, the model invents classes, mislabels types, and asserts nonsense relationships. GraphBaby's answer is to let the AI's own first-pass ontology discipline its second-pass extraction — the schema is the guardrail.
And that is exactly how the three concepts revealed their relationship to me: the AI is the engine, the ontology is the guardrail, and the knowledge graph of individuals is what comes out when you point the first through the second.
The core difference, stated plainly
An ontology is the schema_. A knowledge graph is the_ data_. AI is the_ engine that can produce (or pollute) the data.
The ontology says "a Person can work at an Organization." The knowledge graph says "Einstein works at Princeton." The AI is what turned the sentence "Einstein worked at Princeton" into that triple — guess and all.
A helpful analogy from databases:
And the crucial relationship between the first two:
- A knowledge graph can be built on top of an ontology (then it's a "semantically rich" or "ontology-backed" knowledge graph — it can be validated and reasoned over). This is what GraphBaby produces: every individual is typed by an ontology class.
- A knowledge graph can also exist without one — just nodes and edges with free-form labels, no enforced rules. These are sometimes called "labelled property graphs," and they're what you get from a pure text-to-graph extractor with no schema.
An ontology is the formal schema of a domain — the classes, allowed relationships, and logical rules a machine can reason over. A knowledge graph is the populated data — concrete entities and the facts linking them. Artificial intelligence is the engine that can now turn raw text into both in seconds — brilliantly, and without any built-in guarantee of being right.
I built GraphBaby as an experiment to put all three in one browser tab and watch them interchange, and the surprise was how far an in-browser LLM gets: it drafts a genuine OWL ontology, then fills it with typed individuals that obey it. Where it stops — storing axioms but not reasoning over them — is exactly the line between an ontology you can read and an ontology that thinks. The blueprint, the building, and the machine that pours the concrete: you only really see where each one ends once you've watched a single tool try to be all three.