arXiv:2606.31041cs.CL2026-06被引 1

用语义层中介解决企业数据库自然语言转SQL难题

A Semantic-Layer-Mediated Agent for Natural Language to SQL over Heterogeneous Enterprise Databases

论文配图:A Semantic-Layer-Mediated Agent for Natural Language to SQL over Heterogeneous Enterprise Databases
图 1 · 摘自论文原文
  • 通过语义模型查询(SMQ)抽象物理表结构,分步推理意图
  • 在Spider2-snow测试集上达94.15%执行准确率,优于纯模式方法
  • 支持多数据库方言,适合需高精度的金融/企业级应用

真实企业数据库上的自然语言转SQL任务远比学术基准更具挑战性。企业模式通常包含数百个命名晦涩的物理表、异构的SQL方言,以及涉及嵌套聚合、时间推理和多表连接的复杂分析工作负载。本文提出一种语义层中介的NL2SQL智能体,将语义意图与物理SQL执行解耦。该智能体不直接在原始模式上生成SQL,而是通过一个精心构建的语义层,以紧凑的中间表示——语义模型查询(SMQ)进行推理。一个确定性编译器将每个SMQ转换为特定方言的SQL,提供可验证的构建模块,由智能体组合成最终查询。系统采用受限的思考-行动循环,支持SQLite、BigQuery和Snowflake后端,并集成于端到端评估框架中。使用Gemini 3 Pro,在包含547个任务的Spider2-snow基准上达到94.15%的执行准确率,在官方排行榜上位列第三,显著优于仅依赖模式的方法。本文详述系统架构、SMQ表示、智能体流程、评估结果,并讨论语义层质量与增强定位性之间的权衡及过拟合风险。

原文摘要 · Abstract (English)

Natural language-to-SQL (NL2SQL) over real-world enterprise databases remains significantly more challenging than on academic benchmarks. Enterprise schemas often contain hundreds of physical tables with cryptic column names, heterogeneous SQL dialects, and complex analytical workloads requiring nested aggregations, temporal reasoning, and multi-table joins. We present a semantic-layer-mediated NL2SQL agent that decouples semantic intent from physical SQL execution. Rather than generating SQL directly over raw schemas, the agent reasons over a curated semantic layer through a compact intermediate representation called the Semantic Model Query (SMQ). A deterministic compiler translates each SMQ into dialect-specific SQL, providing verified building blocks that the agent composes into the final query. The system employs a constrained think-act loop, supports SQLite, BigQuery, and Snowflake backends, and is integrated into an end-to-end evaluation framework. Using Gemini 3 Pro, the system achieves 94.15% execution accuracy on the 547-task Spider2-snow benchmark, ranking third on the official leaderboard and substantially outperforming schema-only approaches. We describe the system architecture, SMQ representation, agent workflow, evaluation results, and discuss semantic-layer quality and the trade-off between improved grounding and overfitting.

自然语言转SQL语义层企业数据库智能体

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。