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

PURPLE:让大语言模型成为更好的 SQL 编写者

PURPLE: Making a Large Language Model a Better SQL Writer

School of Computer Science, Fudan University(复旦大学计算机科学学院);Transwarp Technology (Shanghai) Co., Ltd(Transwarp技术(上海)有限公司)

Tonghui Ren, Yuankai Fan, Zhenying He, Ren Huang, Jiaqi Dai, Can Huang, Yinan Jing, Kai Zhang, Yifan Yang, X. Sean Wang

AI总结:

PURPLE通过检索包含所需逻辑算子组合的示范来引导大语言模型生成更准确的SQL,在Spider基准上取得新的最先进性能,并展现出跨基准、跨预算和跨模型的鲁棒性与成本效益。

摘要:

大语言模型(LLM)技术在自然语言到 SQL(NL2SQL)翻译中扮演着越来越重要的角色。经过大规模语料训练的 LLM 具备较强的自然语言理解能力和基本的 SQL 生成能力,无需针对 NL2SQL 任务进行额外微调。现有基于 LLM 的 NL2SQL 方法试图通过强化对用户意图的理解来改进翻译效果。然而,由于 LLM 缺乏组织复杂逻辑算子组合的知识,有时无法生成合适的 SQL。一种有前景的方法是为 LLM 提供示范,这些示范包含来自不同数据库的已知 NL2SQL 翻译。LLM 可以从输入的示范中学习如何针对给定任务组织算子组合。本文提出 PURPLE(Pre-trained models Utilized to Retrieve Prompts for Logical Enhancement,利用预训练模型检索提示以进行逻辑增强),该方法通过检索包含当前 NL2SQL 任务所需逻辑算子组合的示范来提高准确性,从而引导 LLM 生成更好的 SQL 翻译。PURPLE 在流行的 NL2SQL 基准 Spider 的验证集上取得了 80.5% 的精确集匹配准确率和 87.8% 的执行匹配准确率,达到了新的最先进性能。PURPLE 在多种基准、预算约束和不同 LLM 上均保持高准确率,展现出鲁棒性和成本效益。

英文摘要:

Large Language Model (LLM) techniques play an increasingly important role in Natural Language to SQL (NL2SQL) translation. LLMs trained by extensive corpora have strong natural language understanding and basic SQL generation abilities without additional tuning specific to NL2SQL tasks. Existing LLMs-based NL2SQL approaches try to improve the translation by enhancing the LLMs with an emphasis on user intention understanding. However, LLMs sometimes fail to generate appropriate SQL due to their lack of knowledge in organizing complex logical operator composition. A promising method is to input the LLMs with demonstrations, which include known NL2SQL translations from various databases. LLMs can learn to organize operator compositions from the input demonstrations for the given task. In this paper, we propose PURPLE (Pre-trained models Utilized to Retrieve Prompts for Logical Enhancement), which improves accuracy by retrieving demonstrations containing the requisite logical operator composition for the NL2SQL task on hand, thereby guiding LLMs to produce better SQL translation. PURPLE achieves a new state-of-the-art performance of 80.5% exact-set match accuracy and 87.8% execution match accuracy on the validation set of the popular NL2SQL benchmark Spider. PURPLE maintains high accuracy across diverse benchmarks, budgetary constraints, and various LLMs, showing robustness and cost-effectiveness.

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

↑