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模型已取得显著性能,但由于数据集的限制,其有效性主要局限于SQLite。然而,实际应用需要跨多种语法和专用功能各异的SQL方言生成SQL,这对当前模型仍构成挑战。构建方言感知模型的主要障碍在于获取高质量的方言特定数据。仅通过静态提示生成的数据——未通过执行验证SQL——往往存在噪声且不可靠。此外,训练循环中缺乏真实执行环境,导致模型无法将其预测基于可执行语义,尽管数据过滤带来了表面改进,但泛化能力仍然受限。本研究提出ExeSQL,一种具备执行驱动、智能引导机制的文本到SQL框架。该方法包括迭代查询生成、基于执行的过滤(例如拒绝采样)和基于偏好的训练,使模型能够通过可验证、反馈引导的学习适应新的SQL方言。实验表明,ExeSQL在文本到SQL任务中弥合了方言差距,在PostgreSQL、MySQL和Oracle上,相较于GPT-4o,在多个不同难度数据集上平均分别提升了15.2%、10.38%和4.49%。