
TL;DR
AI assistants guess when your data doesn't carry its own meaning: what "revenue" is, who counts as "enterprise", which tables join.
Ontology defines what things mean. Knowledge graph records the connected facts. Semantic layer turns governed business logic into consistent, executable queries.
Together they let an AI agent select governed definitions instead of inventing SQL. Published benchmarks show large accuracy gains, though they are early and often vendor-run.
Start small: one domain, 20 to 50 real questions, a thin ontology and a semantic layer. Add graph depth where relationships matter.
The problem: AI guesses when meaning is missing
Ask an LLM-powered assistant, "What was Q3 revenue from enterprise customers in EMEA?" and you may get a confident, fluent, wrong answer.
The model isn't broken. It is filling gaps. Does "revenue" mean booked, billed or recognized? Which of three tables holds customers? How is "enterprise" defined? Which countries are in EMEA? Column names like rev_amt_2 don't say.
A bigger model or a longer prompt doesn't fix this. Giving the AI the meaning of your data, in structured and governed form, does. Three components do that job.
The three components
1. Ontology: the model of meaning
An ontology is a formal, machine-readable description of the concepts in a domain, how they relate, and the rules that govern them. It is usually written in W3C standards: OWL 2 for concepts, relationships and logic, and SHACL for validating data against constraints.
flowchart LR
classDef cls font-size:22px,stroke-width:2px
Order["Order"] -->|placedBy| Customer["Customer"]
Customer -->|locatedIn| Region["Region"]
Region -->|partOf| Region
Enterprise["EnterpriseCustomer"] -->|subClassOf| Customer
class Order,Customer,Region,Enterprise clsThe same model in Turtle (OWL), plus a SHACL constraint:
@prefix : <https://example.com/ontology/retail#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
:Customer a owl:Class .
:EnterpriseCustomer a owl:Class ;
rdfs:subClassOf :Customer ;
rdfs:comment "Customer above the agreed enterprise contract threshold." .
:Order a owl:Class .
:Region a owl:Class .
:placedBy a owl:ObjectProperty ; rdfs:domain :Order ; rdfs:range :Customer .
:locatedIn a owl:ObjectProperty ; rdfs:domain :Customer ; rdfs:range :Region .
:partOf a owl:ObjectProperty, owl:TransitiveProperty ;
rdfs:domain :Region ; rdfs:range :Region .
# SHACL: every Order must have exactly one Customer
:OrderShape a sh:NodeShape ;
sh:targetClass :Order ;
sh:property [ sh:path :placedBy ; sh:class :Customer ;
sh:minCount 1 ; sh:maxCount 1 ] .Axioms such as rdfs:domain and rdfs:range drive inference. SHACL shapes drive validation. They solve different problems, and mature setups use both.
2. Knowledge graph: the facts
If the ontology is the blueprint, the knowledge graph is the city built from it. It stores real instances as nodes and edges and connects data across sources. It can be an RDF triple store (queried with SPARQL) or a property graph database.
flowchart LR
acme["Acme GmbH<br/>(EnterpriseCustomer)"] -->|locatedIn| de["Germany<br/>(Region)"]
de -->|partOf| emea["EMEA<br/>(Region)"]
o["Order 4812"] -->|placedBy| acmeThe same facts in Turtle, and a SPARQL query that finds enterprise customers in EMEA:
# same prefixes as above
:acme a :EnterpriseCustomer ; rdfs:label "Acme GmbH" ; :locatedIn :germany .
:germany a :Region ; :partOf :emea .
:emea a :Region .
:order4812 a :Order ; :placedBy :acme .PREFIX : <https://example.com/ontology/retail#>
SELECT ?customer WHERE {
?customer a :EnterpriseCustomer ;
:locatedIn/:partOf* :emea . # resolves EMEA through the hierarchy
}No hard-coded country list: "EMEA" resolves through the relationships, so when a region changes, every query changes with it.
3. Semantic layer: the governed interface
The semantic layer sits between raw data and its consumers (dashboards, apps and AI agents). It defines metrics, dimensions and joins once, applies access policies (how depends on the platform), and compiles requests into correct queries. Here is a dbt MetricFlow sketch in the column-level syntax that dbt's current docs describe (dbt v1.12 and later; older versions use a different semantic_models and measures format, so check the docs for your version):
models:
- name: fct_orders
semantic_model:
enabled: true
agg_time_dimension: order_date
columns:
- name: order_id
entity:
type: primary
name: order
- name: customer_id
entity:
type: foreign
name: customer
- name: order_date
granularity: day
dimension:
type: time
metrics:
- name: net_revenue
label: Net revenue
description: Order amount minus refunds, by order date.
type: simple
agg: sum
expr: net_amount # column in fct_orders: order_amount - refund_amount
- name: dim_customers
semantic_model:
enabled: true
columns:
- name: customer_id
entity:
type: primary
name: customer
- name: customer_tier
dimension:
type: categorical
name: customer_tier
- name: region
dimension:
type: categorical
name: regionmf query --metrics net_revenue --group-by customer__region \
--where "{{ Dimension('customer__customer_tier') }} = 'Enterprise'"The two models join through the shared customer entity, which is why customer__region and customer__customer_tier are valid names. One definition of net_revenue now serves every dashboard, notebook and agent.
How they fit together
flowchart TB
A["AI agent / LLM / BI tool"] --> B["Semantic layer<br/>metrics, dimensions, access policies"]
A --> C["Knowledge graph<br/>entities and relationships"]
C --> D["Ontology<br/>concepts, rules, shared vocabulary"]
B --> E[("Warehouse / lakehouse")]
C --> E
C --> F[("Documents, APIs, other sources")]
B -.->|"aligned terms"| DComponent | Answers | Typical consumers |
|---|---|---|
Ontology | What do things mean? | Modelers, reasoners, integration teams |
Knowledge graph | What is connected to what? | Search, GraphRAG, agents |
Semantic layer | How do we calculate and expose it consistently? | BI tools, apps, LLMs |
Here is what happens when an agent answers a question:
sequenceDiagram
actor U as User
participant A as AI agent
participant K as Knowledge graph
participant S as Semantic layer
participant W as Warehouse
U->>A: Net revenue from enterprise customers in EMEA for Q3?
A->>K: Resolve enterprise, EMEA and revenue to defined terms
K-->>A: EnterpriseCustomer, Region EMEA, metric net_revenue
A->>S: Request net_revenue by region with tier filter for Q3
S->>S: Apply metric definition and the user's access policy
S->>W: Generate and run governed SQL
W-->>S: Result
S-->>A: Value with definition and lineage
A-->>U: Answer that shows its definition and sourceWhy this stops AI from guessing
Grounding replaces assumption. Terms are defined, not inferred from column names, and ambiguous ones resolve to typed entities: "Apple" is a customer, a supplier or something else.
Metrics are computed, not improvised. The agent selects a governed metric and the semantic layer generates the SQL deterministically, so once the same metric is selected, two people asking the same question get the same number.
Relationships enable multi-hop reasoning. "Which customers are exposed to this supplier delay?" is a graph traversal, not a similarity guess.
Governance can be enforced in the layer. When the agent queries on behalf of the user, access policies apply to what it can return.
Answers are explainable. A number can be traced to a named metric and, where the graph is involved, to a path through it.
Hallucination shrinks but doesn't vanish. The model can still pick the wrong metric. Structure narrows the error space and makes mistakes easier to catch.
What the evidence says
Source | Setup | Reported result |
|---|---|---|
data.world benchmark (Sequeda, Allemang, Jacob, 2023) | GPT-4, zero-shot, enterprise insurance schema: questions over SQL vs. over a knowledge graph representation of the same database | Accuracy rose from 16.7% to 54.2% |
Same group, 2024 | Ontology-based query checking plus LLM repair of generated SPARQL | About 72% accuracy, plus 8% "I don't know" answers, leaving roughly a 20% error rate |
Microsoft Research, GraphRAG | Graph-based retrieval vs. naive vector RAG on "global" questions over text, scored by an LLM judge | ~70-80% win rate on comprehensiveness and diversity |
dbt Labs (vendor-reported) | Replication using the dbt Semantic Layer | 83% of addressable natural-language questions answered correctly |
Analyst signals point the same way. In March 2026 Gartner predicted that by 2030 universal semantic layers will be treated as critical infrastructure, alongside data platforms and cybersecurity. Gartner research, as cited by a knowledge graph vendor, also found that organizations using semantic modeling such as ontologies and knowledge graphs are about 2.2 times more likely to achieve high effectiveness in AI data engineering, yet only about 40% have done it.
Read these numbers carefully. The 2023 benchmark used one insurance schema and the GPT-4 of its day, and a community review on PREreview noted it left cost, latency and maintenance effort unmeasured. The knowledge graph and semantic layer figures come largely from vendors with a stake in the answer, the Gartner prediction is a forecast rather than a measurement, and the 2.2x figure is second-hand. GraphRAG indexes unstructured text and carries upfront indexing costs. Treat all of it as directional, and benchmark on your own questions.
A worked example (illustrative scenario)
A hypothetical B2B equipment distributor. A supplier announces a two-week shipment delay. The COO asks: "Which enterprise customers in EMEA have open orders affected, and how much net revenue is at risk?"
flowchart LR
S["Supplier<br/>delayed shipment"] -->|supplies| P["Product"]
P -->|appearsIn| L["Open order lines"]
L -->|belongsTo| O["Orders"]
O -->|placedBy| C["Enterprise customers"]
C -->|"locatedIn / partOf*"| R["EMEA"]
O -.->|"net_revenue metric"| M["Revenue at risk"]Without the architecture | With the architecture | |
|---|---|---|
Finding affected customers (knowledge graph) | The LLM guesses a join path through several tables, probably missing the supplier link | Graph traversal from supplier to customer follows modeled relationships |
"Enterprise" and "EMEA" (ontology) | Guessed from a | Resolved from ontology definitions and the region hierarchy |
"Net revenue at risk" (semantic layer) | Whatever | The governed |
The tooling landscape (as of November 2026)
Layer | Standards and tools | Notes |
|---|---|---|
Ontology | OWL 2, RDFS, SHACL | W3C standards. OWL 2 ontologies can also be viewed as RDF graphs. |
Knowledge graph | RDF triple stores with SPARQL; property graph databases; Microsoft's open-source GraphRAG | Either data model can back a knowledge graph. GraphRAG builds its graph from text using an LLM. |
Semantic layer | dbt MetricFlow, Snowflake Semantic Views, Databricks Unity Catalog metric views, Cube, LookML | MetricFlow's engine has been Apache 2.0 since v0.209.0 (Oct 2025), while dbt's hosted service layer and APIs stay proprietary. Databricks metric views support agent metadata such as synonyms. |
Interchange | Apache Ossie (Incubating), formerly Open Semantic Interchange (OSI) | Vendor-neutral, Apache 2.0 specification for the semantic layer and ontology. Reference converters exist for formats such as dbt, GoodData, Polaris and Salesforce. Snowflake, Salesforce and dbt Labs were among the founding organizations. |
You'll also hear the term context layer. Gartner uses it for the wider layer of knowledge an AI agent needs at runtime. The three components in this post are its foundation, and context graphs (decision logic, workflows, tribal knowledge) are an emerging extension on top.
Do you need all three?
flowchart TD
Q1{"Do metrics differ across tools,<br/>or text-to-SQL is unreliable?"} -->|Yes| SL["Start with a semantic layer"]
Q1 -->|No| Q2{"Are questions relational,<br/>multi-hop or multi-source?"}
SL --> Q2
Q2 -->|Yes| KG["Add a knowledge graph"]
Q2 -->|No| Done["Semantic layer may be enough"]
KG --> Q3{"Need shared vocabulary across domains,<br/>inference or rule validation?"}
Q3 -->|Yes| ON["Formalize an ontology"]
Q3 -->|No| Light["Keep a lightweight glossary<br/>with typed relationships"]A practical roadmap
Pick one high-value domain (revenue, supply chain) and 20 to 50 real business questions.
Agree the vocabulary with business owners: entities, relationships, metric definitions.
Model a minimal ontology covering only what those questions need.
Map your sources to the model, either by materializing a graph or by querying data in place.
Build the semantic layer with governed metrics, dimensions, joins and access policies.
Expose it to AI through well-described tools or APIs (for example, via MCP servers) so agents query governed definitions rather than raw tables.
Evaluate continuously against your question set: accuracy, consistency and permission correctness.
Assign owners. Definitions need stewards and a change process.
Common pitfalls
Boiling the ocean: modeling the whole enterprise before delivering value.
Treating it as a one-off project: the business changes, so the model and its owners must keep changing with it. Without stewardship, definitions drift and trust erodes.
Duplicate definitions: metrics defined separately in dashboards, notebooks and prompts defeat the purpose.
Stale graphs: if the graph lags source systems, the AI will confidently cite outdated facts.
Conclusion
AI guesses when meaning is missing. Define that meaning in an ontology, connect it in a knowledge graph, and govern it in a semantic layer, and your agents have far less left to guess.
The model matters less than the context you give it. Build the context layer first.
Sources
Checked 25 November 2026. Vendor documentation and tools change quickly, so verify details against current docs before building.
Sequeda, Allemang, Jacob. A Benchmark to Understand the Role of Knowledge Graphs on LLM Accuracy for Question Answering on Enterprise SQL Databases (2023)
Allemang, Sequeda. Increasing the LLM Accuracy for Question Answering: Ontologies to the Rescue! (2024)
PREreview. Review of the data.world benchmark
Microsoft Research. GraphRAG: New tool for complex data discovery now on GitHub
dbt Labs. Announcing open source MetricFlow and MetricFlow on GitHub
dbt Docs. Semantic models and MetricFlow commands
Snowflake Docs. Overview of semantic views
Databricks Docs. Unity Catalog metric views
Apache Ossie (Incubating). Project site and dbt Labs, OSI is now Apache Ossie
W3C. OWL 2 Web Ontology Language Document Overview and SHACL
Gartner. Gartner Announces Top Predictions for Data and Analytics in 2026 (11 March 2026) and Knowledge Engineering Unlocks Context for AI Agents (June 2026)
Digital Science. Why Your AI Agents Are Only as Good as the Knowledge Behind Them, citing Gartner for the 2.2x and 40% figures
Comments(0)
Join the discussion by logging into your account.
No comments yet. Be the first to comment!