弥合全局意图与局部细节:一种用于文本到SQL语义验证的层次表示方法
Bridging Global Intent with Local Details: A Hierarchical Representation Approach for Semantic Validation in Text-to-SQL
AI总结:
HEROSQL通过整合逻辑计划和抽象语法树,提升文本到SQL的语义验证效果,实现更准确的细粒度语义检测。
摘要:
文本到SQL将自然语言问题转换为基于目标数据库模式的SQL语句。确保此类系统的可靠性和可执行性需要验证生成的SQL,但大多数现有方法仅关注语法正确性,很少涉及语义验证(检测问题与SQL之间的不一致)。因此,有效的语义验证仍面临两个关键挑战:捕捉全局用户意图和SQL结构细节,以及构建高质量的细粒度子SQL注释。为解决这些问题,我们引入HEROSQL,一种层次SQL表示方法,整合了全局意图(通过逻辑计划,LPs)和局部细节(通过抽象语法树,ASTs)。为了更好地传播信息,我们采用嵌套消息传递神经网络(NMPNN)来捕捉SQL中的内在关系信息,并在LPs和ASTs之间聚合模式引导的语义。此外,为了生成高质量的负样本,我们提出了一种基于AST的子SQL增强策略,支持对细粒度语义不一致的稳健优化。在文本到SQL验证基准(包括领域内和领域外设置)上进行了广泛的实验,结果表明,我们的方法在识别语义不一致方面优于现有最先进的方法,平均在AUPRC上提高了9.40%,在AUROC上提高了12.35%。它擅长检测细粒度语义错误,为大语言模型提供更精细的反馈,最终提高数据查询平台的可靠性和可解释性。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。