Zero Labs
Industry News / AI

Semantic Models: What They Are, the Types Available, and When to Use Which

Source · Towards AI By Agarwal Astha - Lead AI Architect (Microsoft)

From the publisher’s feed, collected in the ZeroLabs newsroom.

The same question, three different queriesAsk “What was net revenue last quarter?” through three consumers that share one warehouse, and you can get three answers. A finance report filters on ship_date, excludes tax and subtracts refunds. A BI dashboard filters on created_at and sums amount. An LLM-generated query joins orders to refunds and sums amount again, so any order with two refunds is counted twice and cancelled orders stay in. All three queries run without errors, and each is internally consistent.They disagree because the definition of net revenue lives in each consumer’s own query logic, not in one shared place. A semantic model moves it out of the queries and into a single governed object. The metric, its filters, its time dimension, the join path and the grain are declared once, and every consumer compiles its SQL from that declaration.On the left, each consumer carries its own logic. On the right, all three request the metric from one model.The rest of this article covers what a semantic model contains, why raw schemas break LLM-generated SQL, the main types of semantic model, how each is consumed, and how to choose among them. The short rule is to pick the one that lives where your data and your queries already live, and to define every metric once.What a semantic model isA semantic model is a governed description of your data in business terms: entities, metrics, dimensions, relationships and rules. People write it once, and both humans and software read it. Think of it as the glossary and rulebook that sits between raw tables and everyone who asks questions of them.The term has a second meaning in AI work: an embedding model that maps text to vectors so that similar meanings land close together. That powers semantic search over documents and is a separate topic. This article covers the analytics meaning.What a semantic model encodesA semantic model turns database structure into business meaning. It typically defines six kinds of things. The examples are illustrative.The important property is that each definition exists once and every consumer shares it. A dashboard, a notebook and an LLM agent all compute net revenue the same way, because none of them redefines it.Why raw schemas fail LLMsThe most dangerous failure of text-to-SQL is not an error message. It is a query that runs and returns a plausible, wrong number. The model may join tables incorrectly or misread a column’s meaning, and nothing sits between the question and the generated SQL to catch it.Five causes recur in practice.Ambiguous columns. status, amount and date mean different things in different tables. Which date is the order date, and which is the ship date?Undefined metrics. “Revenue”, “active user” and “churn” each have several defensible definitions, and the schema holds none of them.Hidden join paths. Several routes may connect two tables, and only one is correct for the question asked.Fan-out and grain errors. Joining a one-to-many table before aggregating duplicates rows and inflates totals without any warning.Implicit filters. Test accounts, cancelled orders and soft-deleted rows are excluded by convention, not by structure.Better models help but cannot fully fix these, because the missing information is not in the schema. It lives in people’s heads and in old dashboards.Types of semantic modelsSemantic models differ mainly in where they live, because that decides who can use them and how portable they are. Six types cover most of what you will meet.Read the picture from the bottom. Tables sit in the data platform, a semantic model of one of four kinds sits above them, and consumers ask for metrics by name.Three notes on the table.Warehouse-native objects are structured definitions. A Snowflake semantic view describes logical tables, relationships, facts, dimensions and metrics, and it can also carry verified queries and instructions for AI-generated SQL. A Databricks metric view separates measure definitions from dimensions, so the engine computes the right aggregation for whatever grouping a user asks for, and it can carry synonyms for AI accuracy.OSI is about portability. It is a vendor-neutral, open-source format for datasets, metrics, dimensions and relationships, backed by several data and analytics vendors. Treat it as something to watch rather than something to depend on today.Verification scope. The Snowflake, Databricks, Microsoft and OSI details were checked against current vendor documentation. The Looker, Cube, AtScale, code-defined and ontology rows describe the general design and were not benchmarked here. Product names and features change quickly, so confirm against current docs before choosing.How semantic models are consumedA semantic model is only useful when something reads it. Five consumption patterns are common, and one model can serve several of them at once.All five patterns read the same model, and the model generates the SQL that the warehouse runs.The fourth and fifth patterns are where semantic models matter most for AI. Fabric IQ, for example, answers questions over governed models while respecting role-based access and row-level security, so the assistant cannot see more than the user could. A later section walks through how an LLM consumes a model step by step.Which semantic model to use whenStart from where your data lives and where your people already ask questions. The table maps common situations to a starting point.Read the path from the top and stop at the first yes. It is a starting point, not a rule, because many teams combine types.Four questions settle most choices.Where does the data live? Prefer a model that sits next to it.Where do people already ask questions? Prefer the tool they already use.Who owns the definitions? Prefer a home where that team can review and version them.What must be portable? If the answer is “everything”, favor an independent layer or an open format.These types are not exclusive. A common arrangement is one metric layer for numbers plus an ontology for relationships between concepts.Deep dive: consuming a semantic model from an LLMThe semantic model shrinks the LLM’s job from writing SQL to choosing from a menu of defined terms.Questions the model describes flow left to right. Anything it does not describe stops at the semantic layer with an explicit refusal.In a typical design, the LLM decomposes a question into the right combination of metrics and dimensions, and the semantic engine generates the SQL deterministically. If the model picks the right metric and dimensions, the query is correct, and it cannot return numbers that differ subtly from run to run. The trade-off is coverage: only questions the model describes can be answered.A grounded pipeline has five stages.Interpret. The LLM maps the question to metrics, dimensions, filters and a time range, using the names, descriptions and synonyms in the model.Validate. The request is checked against the model. An unknown metric or an invalid combination is rejected.Compile. The semantic engine generates SQL using the defined joins, filters and grain.Execute and explain. The warehouse runs the query, and the answer comes back with the definitions that produced it.Fall back. If the question is not modeled, the system says so clearly and routes it to a guarded alternative or a person.Worked example: one question, two routesThis example is illustrative. The tables, columns and definitions are invented. The question is “What was net revenue by region last quarter?”, asked in October 2026.Route 1: raw schema. Given tables orders, refunds and customers, a model might plausibly write this.SELECT c.region, SUM(o.amount) AS revenueFROM orders oJOIN customers c ON c.id = o.customer_idLEFT JOIN refunds r ON r.order_id = o.idWHERE o.created_at >= '2026-07-01' AND o.created_at GROUP BY c.region;sIt runs and returns numbers, and it is wrong in four ways: it counts cancelled orders, includes tax, filters on creation date instead of ship date, and the join to refunds duplicates any order with more than one refund. It never subtracts a refund at all.Route 2: semantic layer. The model defines net_revenue once: order amount excluding tax and cancelled orders, minus refunds, recognized on ship date. The LLM then only has to produce a structured request.{ "metrics": ["net_revenue"], "group_by": ["customer__region"], "time": { "grain": "quarter", "range": "2026-Q3" }}The engine compiles the correct SQL from the definition. The LLM had no opportunity to get the logic wrong, and every consumer of net_revenue gets the same number.How to measure the impact on your own dataAccuracy depends on the dataset, the question set and the model, so measure the effect on your own data instead of borrowing someone else’s figure. A repeatable evaluation needs five things:Write a golden set of real questions with verified answers.Run each question several times, since consistency is part of trust.Score three outcomes separately: correct, wrong but plausible, and correctly declined.Track coverage, meaning the share of real questions the semantic model can answer.Record cost and latency alongside accuracy.Pitfalls and design guidanceCoverage is the price of determinism. A semantic layer answers only what it models. Grow it from the questions people actually ask, using query logs and declined requests as the backlog.Start small. Model the dozen metrics people argue about first.Keep a fallback, and label it. For exploratory questions, guarded text-to-SQL is reasonable, but mark its answers as unverified. Prefer the semantic layer first and text-to-SQL second for ad hoc work.Give every metric an owner. A definition nobody owns drifts, and drift brings back the inconsistency you built the layer to remove.Version it. Metric changes alter historical numbers, so record when and why a definition changed.Write good descriptions and synonyms. The LLM selects terms by reading them. Vague names produce wrong selections.Do not model everything. An oversized model slows interpretation and invites the same ambiguity you are removing.TakeawaysA semantic model states what your data means once, in business terms, so people and LLMs share one definition instead of guessing.Six types exist: warehouse-native, BI-platform, code-defined, independent, ontology-based and interchange formats. They differ mainly in where they live.Choose by where your data lives and where your people already ask questions, then check who owns the definitions and what must be portable.Dashboards, SQL, APIs, built-in assistants and your own LLM agent can all consume the same model.For LLMs, a semantic layer fails loudly with a clear refusal, while raw-schema text-to-SQL can fail quietly with a plausible wrong number.Start with the dozen contested metrics, give each an owner, version every change, and measure on your own questions.In the layered architecture described later in this series, the semantic model grounds what the system knows, and a decision model governs what it does next.#SemanticLayer #SemanticModel #NL2SQL #TextToSQL #GenerativeAI #LLM #DataEngineering #AnalyticsEngineering #DataGovernance #AIEngineeringSemantic Models: What They Are, the Types Available, and When to Use Which was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.