arXiv:2505.17231cs.CLcs.AI2025-05EMNLP被引 10

让AI模型通过执行反馈自学习多数据库SQL生成,提升真实场景可用性。

ExeSQL: Self-Taught Text-to-SQL Models with Execution-Driven Bootstrapping for SQL Dialects

  • 基于执行结果迭代优化生成,用可运行的SQL验证训练数据
  • 在PostgreSQL/MySQL/Oracle上分别提升15.2%、10.38%、4.49%
  • 适合需要跨数据库部署的NLP应用开发者

当前文本转SQL模型性能虽强,但主要局限于SQLite。实际应用需支持多种语法各异的SQL方言,而现有模型难以应对。核心障碍在于缺乏高质量的方言专属数据。纯静态提示生成的数据因无执行验证,存在噪声且不可靠。此外,训练中缺乏真实执行环境,导致模型无法基于可执行语义进行泛化。本文提出ExeSQL框架,采用执行驱动的智能体式自举方法:通过迭代查询生成、基于执行结果的过滤(如拒绝采样)及偏好训练,使模型能通过可验证的反馈逐步适应新方言。实验表明,ExeSQL在多个难度不同的数据集上,对PostgreSQL、MySQL和Oracle的平均准确率分别较GPT-4o提升15.2%、10.38%和4.49%。

原文摘要 · Abstract (English)

Recent text-to-SQL models have achieved strong performance, but their effectiveness remains largely confined to SQLite due to dataset limitations. However, real-world applications require SQL generation across multiple dialects with varying syntax and specialized features, which remains a challenge for current models. The main obstacle in building a dialect-aware model lies in acquiring high-quality dialect-specific data. Data generated purely through static prompting - without validating SQLs via execution - tends to be noisy and unreliable. Moreover, the lack of real execution environments in the training loop prevents models from grounding their predictions in executable semantics, limiting generalization despite surface-level improvements from data filtering. This work introduces ExeSQL, a text-to-SQL framework with execution-driven, agentic bootstrapping. The method consists of iterative query generation, execution-based filtering (e.g., rejection sampling), and preference-based training, enabling the model to adapt to new SQL dialects through verifiable, feedback-guided learning. Experiments show that ExeSQL bridges the dialect gap in text-to-SQL, achieving average improvements of 15.2%, 10.38%, and 4.49% over GPT-4o on PostgreSQL, MySQL, and Oracle, respectively, across multiple datasets of varying difficulty.

文本转SQL多方言执行验证自举学习

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