Skip to main content
QUICK REVIEW

[论文解读] DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction

Mohammadreza Pourreza, Davood Rafiei|arXiv (Cornell University)|Apr 21, 2023
Topic ModelingComputer Science被引用 56
一句话总结

DIN-SQL 将 text-to-SQL 分解为模式链接、分类/分解、使用 NatSQL 的 SQL 生成和自我校正,利用上下文学习显著提高执行准确率,并在 holdout 上超越 Spider SOTA,在 BIRD 上创下新 SOTA。

ABSTRACT

There is currently a significant gap between the performance of fine-tuned models and prompting approaches using Large Language Models (LLMs) on the challenging task of text-to-SQL, as evaluated on datasets such as Spider. To improve the performance of LLMs in the reasoning process, we study how decomposing the task into smaller sub-tasks can be effective. In particular, we show that breaking down the generation problem into sub-problems and feeding the solutions of those sub-problems into LLMs can be an effective approach for significantly improving their performance. Our experiments with three LLMs show that this approach consistently improves their simple few-shot performance by roughly 10%, pushing the accuracy of LLMs towards SOTA or surpassing it. On the holdout test set of Spider, the SOTA, in terms of execution accuracy, was 79.9 and the new SOTA at the time of this writing using our approach is 85.3. Our approach with in-context learning beats many heavily fine-tuned models by at least 5%. Additionally, when evaluated on the BIRD benchmark, our approach achieved an execution accuracy of 55.9%, setting a new SOTA on its holdout test set.

研究动机与目标

  • 缩小提示驱动的大型语言模型与在文本到 SQL 基准(如 Spider 与 BIRD)上的微调模型之间的差距。
  • 提出一个分解的、多模块的提示方法,以提升 LLM 在 SQL 生成中的推理能力。
  • 研究模块专用提示(模式链接、分类/分解、基于 NatSQL 的生成以及自我校正)对性能的影响。
  • 展示自我校正提示和跨查询难度的自适应提示选择的有效性。

提出的方法

  • 将 NL2SQL 任务分解为四个带提示功能的模块:模式链接、分类/分解、以 NatSQL 中间表示的 SQL 生成,以及一个自我校正步骤。
  • 针对每个模块和每个查询类别使用来自训练集的少量示例演示。
  • 使用三路分类(简单、非嵌套的复杂、嵌套的复杂)来为 SQL 生成选择专门的提示。
  • 采用 NatSQL 作为中间表示,以简化非嵗嵌套查询的 NL 到 SQL 转换。
  • 在生成后应用自我校正模块,使用通用或温和的提示来修正小的 SQL 错误。
  • 使用 GPT-4 和 CodeX 变体进行评估,采用贪婪解码、零温度以及特定的最大 token 设置来控制生成与校正。
Figure 1 : Statistics of simple few-shot failures using CodeX Davinci (Op refers to operators, Cond refers to conditions, and cols refers to columns)
Figure 1 : Statistics of simple few-shot failures using CodeX Davinci (Op refers to operators, Cond refers to conditions, and cols refers to columns)

实验结果

研究问题

  • RQ1分解文本到 SQL 为模式链接、分类/分解以及中间表示是否能在性能上超越简单的少量示例提示?
  • RQ2基于查询难度的自适应提示和自我校正对 Spider 与 BIRD 的执行准确率和精确匹配(EM)有何影响?
  • RQ3与在跨领域文本到 SQL 基准上的微调 SOTA 方法相比,该方法有何差异?
  • RQ4结合模式链接和 NatSQL 中间表示是否能缓解常见的失败模式如连接、嵌套和模式歧义?

主要发现

  • 在 Spider holdout 上,使用 GPT-4 实现 85.3% 的执行准确率,创下当时的新 SOTA。
  • 在 Spider holdout 上,使用 CodeX Davinci 实现 78.2% 的执行准确率,60% 的精确集匹配(EM)。
  • 在 BIRD 基准上,使用 GPT-4 在 holdout 集达到 55.9% 的执行准确率,创造新的 SOTA(开发集上 GPT-4 的 EM 为 50.72%)。
  • 分解提示在大多数语言模型上普遍将少量示例提示的性能提高约 10%。
  • 消融研究显示每个模块都对性能有贡献,其中模式链接在非简单查询上尤为显著地带来提升。
  • 自我校正提示(CodeX 使用通用提示,GPT-4 使用温和提示)减少 SQL 缺陷并提高执行准确率。
Figure 2 : An overview of the proposed methodology including all four modules
Figure 2 : An overview of the proposed methodology including all four modules

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。