Bridging Global Intent with Local Details: A Hierarchical Representation Approach for Semantic Validation in Text-to-SQL

📅 2025-12-27
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
Weak semantic validation in Text-to-SQL systems—where existing methods prioritize syntactic correctness over alignment between user intent and SQL semantics—limits reliability and interpretability. To address this, we propose HEROSQL, a novel framework featuring: (1) a dual-granularity hierarchical representation that jointly encodes global logical plans (LPs) and local abstract syntax trees (ASTs); (2) a nested message-passing neural network (NMPNN) for cross-level semantic aggregation between LPs and ASTs; and (3) an AST-driven sub-SQL augmentation strategy to generate high-quality negative samples. Evaluated on both in-domain and out-of-domain benchmarks, HEROSQL achieves +9.40% AUPRC and +12.35% AUROC over state-of-the-art methods. Moreover, it enables fine-grained localization of semantic errors, thereby enhancing the granularity of large language model feedback and improving query platform interpretability.

Technology Category

Application Category

📝 Abstract
Text-to-SQL translates natural language questions into SQL statements grounded in a target database schema. Ensuring the reliability and executability of such systems requires validating generated SQL, but most existing approaches focus only on syntactic correctness, with few addressing semantic validation (detecting misalignments between questions and SQL). As a consequence, effective semantic validation still faces two key challenges: capturing both global user intent and SQL structural details, and constructing high-quality fine-grained sub-SQL annotations. To tackle these, we introduce HEROSQL, a hierarchical SQL representation approach that integrates global intent (via Logical Plans, LPs) and local details (via Abstract Syntax Trees, ASTs). To enable better information propagation, we employ a Nested Message Passing Neural Network (NMPNN) to capture inherent relational information in SQL and aggregate schema-guided semantics across LPs and ASTs. Additionally, to generate high-quality negative samples, we propose an AST-driven sub-SQL augmentation strategy, supporting robust optimization of fine-grained semantic inconsistencies. Extensive experiments conducted on Text-to-SQL validation benchmarks (both in-domain and out-of-domain settings) demonstrate that our approach outperforms existing state-of-the-art methods, achieving an average 9.40% improvement of AUPRC and 12.35% of AUROC in identifying semantic inconsistencies. It excels at detecting fine-grained semantic errors, provides large language models with more granular feedback, and ultimately enhances the reliability and interpretability of data querying platforms.
Problem

Research questions and friction points this paper is trying to address.

Validates semantic alignment between natural language questions and generated SQL queries
Integrates global user intent with local SQL structural details for validation
Generates high-quality negative samples to detect fine-grained semantic inconsistencies
Innovation

Methods, ideas, or system contributions that make the work stand out.

Hierarchical SQL representation integrating global intent and local details
Nested Message Passing Neural Network for schema-guided semantics aggregation
AST-driven sub-SQL augmentation strategy for fine-grained semantic validation
🔎 Similar Papers
R
Rihong Qiu
Peking University
Z
Zhibang Yang
Peking University
X
Xinke Jiang
Peking University
Weibin Liao
Weibin Liao
Peking University
Large Language ModelReinforcement LearningMedical Image Analysis
X
Xin Gao
Peking University
X
Xu Chu
Peking University
Junfeng Zhao
Junfeng Zhao
Assistant Professor at Arizona State University, Director of BELIV Lab
Connected & Automated VehicleMotion Planning & ControlsElectric VehiclesAI/ML
Y
Yasha Wang
Peking University