NeFut Logo NeFut
Admin Login

[CS.AI] Revolutionary Schema-Aware Localization: Live Schema Grounding and Hallucination Validation

Published at: 2026-07-28 22:00 Last updated: 2026-07-29 01:08
#algorithm #AI #Open Source

Large language models often fail to execute SQL generated from natural language on real enterprise Oracle databases due to missing schema grounding, resulting in hallucinated columns and aliases and dialect-specific syntax errors, leading to ORA-00904 invalid-identifier errors.

To address this, we introduce Schema-Aware Localization (SAL), a lightweight middleware layer for Oracle NL2SQL that does not require model retraining. SAL queries Oracle's USER_TAB_COLUMNS catalog to create a live schema map, selects a relevant subset of tables for each question (falling back to the full schema for multi-table queries), and injects this ground-truth context into the LLM prompt.

The generated SQL is then validated by the Hallucination Index (Hidx), which checks every alias.column reference against the live catalog, automatically rewrites predictable prefix errors, and triggers a structured retry with itemized corrections when necessary.

We evaluate SAL on 500 TPC-H natural language questions executed against a live Oracle Autonomous Database 23c instance using GPT-4o-mini. Without any schema grounding, execution-grounded truth (EGT) is merely 2.2% (12/500). A hand-written static schema hint raises the EGT to 62.0%. SAL, without any manual schema curation, achieves 62.6% EGT (96% for simple, 95% for medium, and 40.7% for complex queries) while reducing execution failures from 97.6% to 2.6%.

Blogger's Review: Schema-Aware Localization (SAL) significantly enhances the efficiency of generating SQL from natural language by integrating live schema mapping and hallucination validation. This seamless integration with existing models offers a promising approach to intelligent database querying, especially in complex scenarios, warranting further attention and exploration.

Original Source: https://arxiv.org/abs/2607.22572

[h] Back to Home