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

弥合差距:通过抽象查询模式与上下文模式标记将自然语言问题转化为SQL查询

Bridging the Gap: Transforming Natural Language Questions into SQL Queries via Abstract Query Pattern and Contextual Schema Markup

Zhipu AI(智谱AI);Tsinghua University(清华大学)

Yonghui Kong, Hongbing Hu, Dan Zhang, Siyuan Chai, Fan Zhang, Wei Wang

AI总结:

针对Text-to-SQL任务中复杂问题存在的结构与词汇映射差距,本文提出基于大语言模型的PAS-SQL流水线,通过抽象查询模式和上下文模式标记缓解差距,在Spider、BIRD数据集上取得领先性能。

摘要:

大语言模型凭借强大的上下文学习能力,在包括Text-to-SQL在内的众多任务中展现出优异性能,正逐渐成为Text-to-SQL领域的主流方法。然而,这类方法的表现与人类水平仍存在显著差距,在处理复杂问题时尤为明显。随着问题复杂度提升,自然语言问题与SQL查询之间的语义鸿沟会进一步扩大。本文识别出两类关键差距:结构映射差距与词汇映射差距。为解决这两类差距,我们提出PAS-SQL——一种基于大语言模型的高效SQL生成流水线,通过抽象查询模式(Abstract Query Pattern,AQP)和上下文模式标记(Contextual Schema Markup,CSM)来缓解上述差距。AQP通过移除问题中与数据库相关的信息来提取问题的结构模式,从而帮助我们找到结构相似的示例;CSM则将问题中与数据库相关的文本片段与数据库中的特定表或列相关联,以此缓解词汇映射差距。在Spider和BIRD数据集上的实验结果验证了所提方法的有效性。具体而言,PAS-SQL结合GPT-4o在Spider基准上创下新的最优表现,执行准确率达87.9%;在BIRD数据集上也取得领先结果,执行准确率为64.67%。

英文摘要:

Large language models have demonstrated excellent performance in many tasks, including Text-to-SQL, due to their powerful in-context learning capabilities. They are becoming the mainstream approach for Text-to-SQL. However, these methods still have a significant gap compared to human performance, especially on complex questions. As the complexity of questions increases, the gap between questions and SQLs increases. We identify two important gaps: the structural mapping gap and the lexical mapping gap. To tackle these two gaps, we propose PAS-SQL, an efficient SQL generation pipeline based on LLMs, which alleviates gaps through Abstract Query Pattern (AQP) and Contextual Schema Markup (CSM). AQP aims to obtain the structural pattern of the question by removing database-related information, which enables us to find structurally similar demonstrations. CSM aims to associate database-related text span in the question with specific tables or columns in the database, which alleviates the lexical mapping gap. Experimental results on the Spider and BIRD datasets demonstrate the effectiveness of our proposed method. Specifically, PAS-SQL + GPT-4o sets a new state-of-the-art on the Spider benchmark with an execution accuracy of 87.9\%, and achieves leading results on the BIRD dataset with an execution accuracy of 64.67\%.

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

↑