Text-to-SQL is the task of translating natural language queries into executable SQL for a given database, enabling non-expert users to access structured data without writing SQL manually. Despite rapid advances driven by large language models (LLMs), existing approaches still struggle with complex queries in real-world settings, where database schemas are large and questions require multi-step reasoning over many interrelated tables. In such cases, providing the full schema often exceeds the context window, while one-shot generation frequently produces non-executable SQL due to syntax errors and incorrect schema linking. To address these challenges, we introduce AV-SQL, a framework that decomposes complex Text-to-SQL into a pipeline of specialized LLM agents. Central to AV-SQL is the concept of agentic views: agent-generated Common Table Expressions (CTEs) that encapsulate intermediate query logic and filter relevant schema elements from large schemas. AV-SQL operates in three stages: (1) a rewriter agent compresses and clarifies the input query; (2) a view generator agent processes schema chunks to produce agentic views; and (3) a planner, generator, and revisor agent collaboratively compose these views into the final SQL query. Extensive experiments show that AV-SQL achieves 70.38% execution accuracy on the challenging Spider 2.0 benchmark, outperforming state-of-the-art baselines, while remaining competitive on standard datasets with 85.59% on Spider, 72.16% on BIRD and 63.78% on KaggleDBQA. Our source code is available at https://github.com/pminhtam/AV-SQL.


翻译:文本转SQL任务旨在将自然语言查询转换为针对给定数据库的可执行SQL语句,使非专业用户无需手动编写SQL即可访问结构化数据。尽管基于大型语言模型的方案推动了该领域的快速发展,但现有方法在处理真实场景中的复杂查询时仍面临挑战——这些场景的数据库模式庞大,且问题需要跨多张关联表进行多步推理。在此情形下,提供完整模式常超出上下文窗口限制,而单次生成则因语法错误和错误模式链接导致SQL不可执行。为应对这些挑战,我们提出AV-SQL框架,该框架将复杂文本转SQL任务分解为专业化LLM智能体流水线。AV-SQL的核心是智能视图概念:由智能体生成的公共表表达式,用于封装中间查询逻辑并从大型模式中过滤相关模式元素。AV-SQL分三阶段运作:(1)重写智能体压缩并澄清输入查询;(2)视图生成智能体处理模式分块以生成智能视图;(3)规划器、生成器和修正智能体协作将这些视图组合为最终SQL查询。大量实验表明,AV-SQL在具有挑战性的Spider 2.0基准上达到70.38%的执行准确率,超越现有最优基线方法,同时在标准数据集上保持竞争力:Spider为85.59%,BIRD为72.16%,KaggleDBQA为63.78%。我们的源代码开源地址为https://github.com/pminhtam/AV-SQL。

0
下载
关闭预览

相关内容

SQL 全名是结构化查询语言,是用于数据库中的标准数据查询语言,IBM 公司最早使用在其开发的数据库系统中。
文本分类算法及其应用场景研究
专知会员服务
19+阅读 · 2024年7月31日
基于深度学习的中文文本分类综述
专知会员服务
25+阅读 · 2024年5月9日
「基于深度学习的 SQL 生成」2022研究综述
专知会员服务
28+阅读 · 2022年8月12日
独家 | 基于TextRank算法的文本摘要(附Python代码)
数据派THU
14+阅读 · 2018年12月21日
干货|当深度学习遇见自动文本摘要,seq2seq+attention
机器学习算法与Python学习
10+阅读 · 2018年5月28日
Tensorflow 文本分类-Python深度学习
Python程序员
12+阅读 · 2017年11月22日
文本聚类:从非结构化数据快速获取见解
Datartisan数据工匠
15+阅读 · 2017年10月12日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
Arxiv
0+阅读 · 3月28日
VIP会员
最新内容
网状网络及其在军事领域的运用
专知会员服务
4+阅读 · 今天6:18
无美国参与的欧洲战争方式(万字长文)
专知会员服务
4+阅读 · 今天5:54
《国防领域敏感性分析白皮书》
专知会员服务
5+阅读 · 今天3:42
综述 | 从问答到任务完成:Agent系统与Harness设计
Agentic RL:框架、实践与长程智能体训练
专知会员服务
4+阅读 · 6月24日
重新思考无人机时代的生存能力
专知会员服务
8+阅读 · 6月24日
装甲突击旅:现代战争思考、战斗与组织
专知会员服务
6+阅读 · 6月24日
在人工智能加速决策环境中拓展OODA循环
专知会员服务
8+阅读 · 6月24日
军事欺骗:供作战战术指挥官使用的工具
专知会员服务
6+阅读 · 6月24日
相关基金
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员