arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2604.07041cs.DBcs.AIcs.ETcs.HCcs.IR
收藏

AV-SQL:通过代理视图分解复杂文本到SQL查询

AV-SQL: Decomposing Complex Text-to-SQL Queries with Agentic Views

Griffith University(格里菲斯大学);The University of Queensland(昆士兰大学)

Minh Tam Pham, Trinh Pham, Tong Chen, Hongzhi Yin, Quoc Viet Hung Nguyen, Thanh Tam Nguyen

AI总结:

AV-SQL通过代理视图分解复杂文本到SQL查询,提升复杂查询的执行准确率,其在Spider 2.0基准测试中达到70.38%的准确率,优于现有方法。

摘要:

文本到SQL是将自然语言查询转换为可执行SQL的任务,使非专家用户能够访问结构化数据而无需手动编写SQL。尽管大型语言模型(LLMs)的快速发展推动了该领域的发展,但现有方法在现实场景中仍难以处理复杂的查询,其中数据库模式较大且问题需要多步骤推理。在这种情况下,提供完整的模式通常超出上下文窗口,而一次性生成经常产生不可执行的SQL,由于语法错误和错误的模式链接。为此,我们引入了AV-SQL,一个将复杂文本到SQL分解为专门LLM代理流水线的框架。AV-SQL的核心是代理视图的概念:由代理生成的公共表表达式(CTEs)封装中间查询逻辑,并从大型模式中过滤相关元素。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上获得。

英文摘要:

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.

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

↑