arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2405.09593cs.DBcs.AI
收藏

SQL-to-Schema 增强 Text-to-SQL 中的模式链接

SQL-to-Schema Enhances Schema Linking in Text-to-SQL

Peking University(北京大学);Guizhou University(贵州大学);SenseTime Research(商汤科技研究院);University of Cologne(科隆大学);Nanyang Technological University(南洋理工大学)

Sun Yang, Qiong Su, Zhishuai Li, Ziyue Li, Hangyu Mao, Chenxi Liu, Rui Zhao

AI总结:

针对现有Text-to-SQL方法模式链接错误多、训练成本高或性能不佳的问题,提出两步SQL-to-Schema模式链接法,先生成初始SQL再提取精简模式,在相关模型和数据集上表现优异。

摘要:

现有成熟的 Text-to-SQL 方法会出现不同比例的错误,包括模式链接错误(列、表不正确或存在多余列)、连接错误、嵌套错误和分组错误。因此,迫切需要筛选出不必要的表和列,通过模式链接引导语言模型关注相关的表和列,以减少 SQL 生成过程中的错误。此前的方法包括根据表和列与问题的相关性对其排序,选取排名靠前的部分,或是直接识别 SQL 生成所需的表和列。但这些方法存在模型训练时间长、少样本提示中昂贵的 GPT-4 token 消耗高,或是模式链接性能不佳等问题。为此,我们提出了一种新颖的两步模式链接方法:首先,利用完整的数据库模式生成初始 SQL 查询;随后,从初始 SQL 查询中提取表和列,构建精简模式。使用 CodeLlama-34B 时,将主流方法得到的模式与我们的方法得到的模式用于 SQL 生成对比,我们的模式表现最优。借助 GPT-4,我们的 SQL 生成方法在 Spider 数据集上取得了与主流 Text-to-SQL 方法相当的结果。

英文摘要:

In sophisticated existing Text-to-SQL methods exhibit errors in various proportions, including schema-linking errors (incorrect columns, tables, or extra columns), join errors, nested errors, and group-by errors. Consequently, there is a critical need to filter out unnecessary tables and columns, directing the language models attention to relevant tables and columns with schema-linking, to reduce errors during SQL generation. Previous approaches have involved sorting tables and columns based on their relevance to the question, selecting the top-ranked ones for sorting, or directly identifying the necessary tables and columns for SQL generation. However, these methods face challenges such as lengthy model training times, high consumption of expensive GPT-4 tokens in few-shot prompts, or suboptimal performance in schema linking. Therefore, we propose an inventive schema linking method in two steps: Firstly, generate an initial SQL query by utilizing the complete database schema. Subsequently, extract tables and columns from the initial SQL query to create a concise schema. Using CodeLlama-34B, when comparing the schemas obtained by mainstream methods with ours for SQL generation, our schema performs optimally. Leveraging GPT4, our SQL generation method achieved results that are comparable to mainstream Text-to-SQL methods on the Spider dataset.

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

↑