When LLM agents query enterprise databases directly, hallucinated joins or invented metrics create immediate business risk. Accurate, auditable numbers matter far more than fast guesses. NVIDIA’s open-source Auto-Ontology sits alongside existing databases to ground agents in verified context, compiling raw schema metadata into business glossary terms, certified SQL formulas, and join graphs.

Turning Database Metadata into a Certified Ontology

Building an ontology starts with source ingestion across three stages: an ingestion service profiles database catalogs and maps tables to business concepts, infers join paths and schema relationships from foreign keys and data patterns, and stores the resulting graph in PostgreSQL with pgvector embeddings.

Operationally, the framework follows five stages: Discover, Ground, Certify, Validate, and Expose. Ground assigns a single canonical definition per business concept across tables. Certify lets data teams edit and approve business terms and SQL expressions via web UI or API. Validate checks whether an incoming question can actually be answered before running queries and returns both generated SQL and reasoning steps. Expose serves that context to agents over MCP (Model Context Protocol) and REST APIs - pairing human sign-off with structured retrieval to curb SQL hallucinations.

Selective Ontology Retrieval vs. Raw Schema Dumping

Standard Text-to-SQL pipelines stuff entire database schemas into the prompt context window. As table counts grow, token costs spike and agents guess join conditions from ambiguous column names alone. Auto-Ontology retrieves only the glossary terms, formulas, and tables relevant to the specific question.

It also handles unanswerable questions differently. Ask a naive schema-stuffed agent for Return on Ad Spend (ROAS) against the Wide World Importers sample database - which contains zero ad-spend tables - and it will often fabricate a plausible-looking query anyway. An Auto-Ontology agent runs check_answerable first, detects missing schema coverage, and asks the user for clarification instead of returning bogus numbers.

Deployment Setup and Benchmark Evaluation

The companion auto-ontology-eval repository benchmarks ontology-grounded agents against raw schema-in-prompt baselines across BIRD, BEAVER, and FDABench-Lite, scoring exact execution match to quantify accuracy gains.

Local deployment spins up PostgreSQL, pgAdmin, and the web UI via Docker Compose. After adding an NVIDIA API key and database connection string to .env, running semantic compilation indexes the target database - so a query asking for June 2015 product revenue in Pennsylvania resolves business relationships through the ontology and returns both verified SQL and step-by-step reasoning.

For enterprise data teams, putting a human-certified semantic layer in front of Text-to-SQL agents turns database access into a governable engineering workflow.

Summary

  • Replaces full-schema prompt stuffing with targeted retrieval of certified ontology terms and join paths, cutting both token spend and SQL hallucinations.
  • Uses check_answerable coverage checks to catch unsupported metrics up front and ask follow-up questions rather than fabricating SQL.
  • Exposes the semantic layer over MCP and REST APIs for clean integration into existing LLM agent stacks.