Why AI context matters
While Omni automatically understands your schema,ai_context allows you to codify company-specific knowledge that isn’t captured in table names or column labels.
Think of this as training your AI analyst on your company’s specific playbook. In a retail environment, this means:
- Defining which status codes (e.g., “Shipped,” “Complete”) represent valid revenue
- Specifying which unique identifier to use when counting orders
- Providing preferred dimensions for “top-n” queries
The AI context hierarchy
To help the AI return accurate, business-aligned answers, you can add context to the underlying data model. For this example, think of the context in three layers: model, topic, and view. Omni applies this logic from the top down - starting at the model level - allowing you to set universal rules that get more specific as you move toward individual fields.| Layer | Purpose | Example |
|---|---|---|
| Model | Universal truths. Global business logic and formatting rules that apply to all queries in the model. | ”Our fiscal year starts in Feb; use USD for all currency.” |
| Topic | The persona. Definitions for specific datasets and how views relate to each other. | ”You are a Retail Analyst; use the Order Items table for all sales queries.” |
| View/Field | Field precision. Specific definitions, synonyms, and allowed values for columns. | ”This ID is internal; don’t show it unless asked. 'Bought at' is a synonym for created_at.” |
Requirements
To implement this example in your own Omni instance, you’ll need:- Familiarity with Omni’s modeling layer
- Permissions in Omni that allow you to edit a shared model
- A connected data source that contains retail-related data
Setting universal rules in the model file
The model file defines your universal rules that will exist across the entire model. These rules act as permanent guardrails, ensuring the AI adheres to your core business standards regardless of which topic in the model a user is exploring.
Model-level context
Setting dataset logic in the topic
Topic-level context defines more specific details scoped to your pre-defined datasets. This example shows how to tell the AI how to handle an ecommerce dataset specifically focused on orders and fulfillment.
Topic-level context
Adding precision at the view level
View-level context eliminates ambiguity when two fields have similar names or when a field has a cryptic database label.
View and field-level context
Iterating on AI context
Improving AI quality is an iterative process. Use this workflow to refine your instance based on real usage:- Monitor: Use the AI usage dashboard in the Analytics section to find queries with negative (👎) feedback.
- Identify: Did the AI fail due to a cryptic name, a missing join, or a lack of business logic?
- Tune: Update the YAML at the appropriate level (model, topic, view).
- Verify: Re-run the prompt in the Query Helper to ensure the fix worked.
Next steps
- Model-level ai_context — Reference for model-level
ai_contextsyntax - Topic-level ai_context — Reference for topic-level
ai_contextsyntax - View-level ai_context — Reference for view-level
ai_contextsyntax - Optimize models for Omni AI — Broader guidance on optimizing your model for AI