arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.02815cs.CL
收藏

FlexSQL:灵活探索与执行打造更优的文本到SQL智能体

FlexSQL: Flexible Exploration and Execution Make Better Text-to-SQL Agents

Simon Fraser University(西蒙菲莎大学);University of Waterloo(滑铁卢大学);Snowflake(雪花公司);University of Alberta(阿尔伯塔大学)

Quang Hieu Pham, Yang He, Ping Nie, Canwen Xu, Davood Rafiei, Yuepeng Wang, Xi Ye, Jocelyn Qiaochu Chen

AI总结:

FlexSQL是一种文本到SQL智能体,通过灵活的数据库交互机制,在Spider2-Snow数据集上使用gpt-oss-120b取得65.4%得分,优于相关基线,集成到Claude Code中可实现超10%的相对提升

摘要:

针对大型分析数据库的文本到SQL任务,需要处理复杂的模式、解决模糊查询问题并基于实际数据做出决策。当前多数系统遵循固定流程:一次性检索所有模式元素,仅在事后修复时才重新访问数据库,这限制了从早期错误中恢复的能力。我们提出FlexSQL,其核心设计原则是灵活的数据库交互:智能体可在推理的任意阶段探索模式结构、检查数据值并运行验证查询。FlexSQL生成多样的执行计划以覆盖多种查询解释,根据任务将每个计划实现为SQL或Python代码,并采用双层修复机制,可从代码级错误回溯至计划级修订。在Spider2-Snow数据集上,使用gpt-oss-120b模型时,FlexSQL取得65.4%的得分,优于使用更强更大模型(如gpt-o3和DeepSeek-R1)的强开源基线。当集成到通用编码智能体(作为Claude Code中的技能)时,我们的方法在Spider2-Snow上实现了超过10%的相对提升。进一步分析表明,灵活探索与灵活执行共同促成了方法的有效性,凸显灵活性是关键设计原则。我们的代码可在:this https URL获取

英文摘要:

Text-to-SQL over large analytical databases requires navigating complex schemas, resolving ambiguous queries, and grounding decisions in actual data. Most current systems follow a fixed pipeline where schema elements are retrieved once upfront and the database is only revisited for post-hoc repair, limiting recovery from early mistakes. We present FlexSQL, a text-to-SQL agent whose core design principle is flexible database interaction: the agent can explore schema structure, inspect data values, and run verification queries at any point during reasoning. FlexSQL generates diverse execution plans to cover multiple query interpretations, implements each plan in either SQL or Python depending on the task, and uses a two-tiered repair mechanism that can backtrack from code-level errors to plan-level revisions. On Spider2-Snow, using gpt-oss-120b, FlexSQL achieves a 65.4\% score, outperforming strong open-source baselines that use stronger, larger models such as gpt-o3 and DeepSeek-R1. When integrated into a general-purpose coding agent (as skills in Claude Code), our approach yields over 10\% relative improvement on Spider2-Snow. Further analysis shows that flexible exploration and flexible execution jointly contribute to the effectiveness of our approach, highlighting flexibility as a key design principle. Our code is available at: https://github.com/StringNLPLAB/FlexSQL

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑