AI, decoded

What is the difference between a semantic layer and a context layer for AI?

A semantic layer defines business metrics and how to calculate them consistently. A context layer is a broader, less standardized term for the information an AI system needs to use those definitions correctly, such as the user’s intent, calendar conventions, worked queries and task instructions.

· Chain of Thought

Level 4: How AI systems are built · 4.2 Context and memory engineering

Context ManagementEnterprise AI

Separate metric meaning from question meaning

A metric needs a shared definition. Which customers count as active? Does revenue include refunds? Which tables and joins produce the result? dbt’s Semantic Layer documentation describes defining metrics on existing models and handling joins so different consuming tools can use consistent calculations.

That solves an important part of an analytics question. It does not, by itself, settle every ambiguity in the words a person types. In episode 75, Kapil Chhabra explains why an AI assistant also needs instructions and examples around those definitions. His context-layer framing includes how the question should be interpreted before a query runs.

Work through a quarter-end question

Chhabra’s example is a question about Q1. A finance team may mean a fiscal quarter while another team means a calendar quarter. The metric definition can be correct in both cases, yet the assistant can choose the wrong period.

Illustrative workflow: a user asks for revenue in Q1. The assistant has access to an approved revenue metric, a documented fiscal calendar and the user’s stated reporting context. It resolves the date range from those inputs and shows that range with the answer. If the reporting context does not settle the meaning, it asks which quarter convention to use.

Treat a team-based default as a default, not proof of intent. A finance employee can ask a calendar-year question. Let explicit instructions override the default, and make the interpretation visible enough for the person to catch a mistake.

Put each piece where someone can maintain it

Keep the revenue formula in the system that owns the metric. Add a reference to that definition, the applicable calendar rule and reviewed query examples to the information available to the assistant. Avoid copying the formula into several prompts where it can drift independently.

Chhabra includes examples of good SQL or Python queries in his description of context. Use those examples to document specific conventions: a required filter, a join that avoids double-counting, or how an exception is represented. Label their scope so the assistant does not apply an example from one business unit everywhere.

Assign an owner and revision process to these instructions. When the calendar or metric changes, update the relevant source and rerun questions that depend on it. Test interpretation and calculation separately: selecting the right dates and computing the right metric are two different responsibilities.

Where it falls short

Context layer is an architectural label, not a guarantee that every implementation contains the same components. A semantic system may already represent calendars, access rules and other business concepts. Inventory what yours actually supports before adding another store.

More context can also introduce conflicting instructions. Keep the authoritative source clear and define what the assistant should do when rules disagree. This page concerns business definitions and interpretation; context and memory engineering covers the broader mechanics of assembling information for a model. The practical test is whether the system can explain which definition and interpretation produced its answer.

Hear it from the guest

“And when somebody is saying, asking questions about Q1, the finance team might mean it's a financial quarter versus the marketing team might mean that it is the calendar quarter.”
“So context layer is broader than a catalog and a semantic layer. And it needs to be built and needs to be kept updated as the business evolves.”

Quotes lightly edited to remove filler words.

Go deeper

From the conversation

This explainer is drawn from these episodes — each carries its full transcript.

Concepts in this explainer

Model Drift