Skip to content

PATTERN Cited by 1 source

Metric semantic layer as AI knowledge base

Pattern

Expose a structured, code-friendly metric semantic layer (YAML configurations with deterministic SQL definitions) as the grounding knowledge base for AI agents, enabling natural-language metric queries with reduced hallucination.

Mechanism

Because metric definitions are stored as clean, machine-parseable YAML with precise SQL logic, they naturally serve as context for AI agents:

  1. An MCP (Model Context Protocol) server wraps the metric library with tools to browse, search, and query metric definitions
  2. Users ask natural-language questions ("what's rides_completed by region last month?")
  3. The AI agent resolves the question against the authoritative YAML definitions, generating SQL from the governed template โ€” not from the LLM's parametric memory
  4. Guardrails use ground-truth evaluation and LLM-as-a-judge techniques to validate outputs

(Source: sources/2026-06-10-lyft-metric-semantic-layer)

Why this works better than unstructured docs

  • Deterministic SQL generation eliminates hallucinated metric logic
  • Structured YAML provides unambiguous context (dimension names, types, allowed granularities)
  • Governed ownership metadata lets the agent surface who to contact for clarification
  • Works across multiple AI surfaces: Claude, Cursor, Hex BI tool, custom agents

Relationship to headless BI

This pattern is the AI-consumption extension of concepts/headless-bi-semantic-layer โ€” the same "define once, consume everywhere" principle applied to LLM consumers alongside human consumers and dashboards.

Seen in

Last updated ยท 542 distilled / 1,571 read