[论文解读] Enhancing Few-shot Text-to-SQL Capabilities of Large Language Models: A Study on Prompt Design Strategies
本论文研究在上下文学习中进行提示设计,以提升大语言模型在少样本文本到SQL的性能,提出基于语法的演示选择、模式扩充和投票机制以提升 Spider 上的执行准确性。最佳提示超越最先进水平2.5个百分点,超越最佳微调系统5.1个百分点。
In-context learning (ICL) has emerged as a new approach to various natural language processing tasks, utilizing large language models (LLMs) to make predictions based on context that has been supplemented with a few examples or task-specific instructions. In this paper, we aim to extend this method to question answering tasks that utilize structured knowledge sources, and improve Text-to-SQL systems by exploring various prompt design strategies for employing LLMs. We conduct a systematic investigation into different demonstration selection methods and optimal instruction formats for prompting LLMs in the Text-to-SQL task. Our approach involves leveraging the syntactic structure of an example's SQL query to retrieve demonstrations, and we demonstrate that pursuing both diversity and similarity in demonstration selection leads to enhanced performance. Furthermore, we show that LLMs benefit from database-related knowledge augmentations. Our most effective strategy outperforms the state-of-the-art system by 2.5 points (Execution Accuracy) and the best fine-tuned system by 5.1 points on the Spider dataset. These results highlight the effectiveness of our approach in adapting LLMs to the Text-to-SQL task, and we present an analysis of the factors contributing to the success of our strategy.
研究动机与目标
- 通过在大型语言模型的上下文学习中提升文本到SQL 的性能。
- 研究在相似性与多样性之间取得平衡的演示选择标准。
- 通过数据库模式表示与知识增强来增强提示。
- 分析促成文本到SQL 成功提示设计的因素。
提出的方法
- 使用 SQL 语法结构来选择演示,而非仅基于问题的相似性。
- 将数据库表示为代码(CREATE 语句)而非纯文本来构建提示。
- 通过对离散 SQL 语法向量进行 k-means 聚类来实现多样性,选择演示。
- 在提示中增加语义与结构化的模式信息(本体、列定义、ER 摘要)。
- 通过在不同拍数设置的预测结果上进行投票来结合多种提示,以降低执行错误。
- 在 Spider 及相关数据集上使用 Codex(code-davinci-002)和 gpt-3.5-turbo 进行评估,报告执行准确性。

实验结果
研究问题
- RQ1基于 SQL 语法的演示选择如何影响少样本文本到SQL 的性能?
- RQ2在演示中平衡相似性与多样性是否能提升跨文本到 SQL 数据集的执行准确性?
- RQ3模式相关知识增强对零样本与少样本设置下的提示有效性有何影响?
- RQ4集成投票策略是否能提升不同提示配置的鲁棒性?
主要发现
- 相似性-多样性演示策略的执行准确性高于随机、仅相似性或仅多样性的方法。
- 模式扩充提升了性能,语义扩充(列描述)在零样本设置以及某些少样本情况下显示出收益。
- 用 SQL CREATE 查询来表示数据库(code-seq)在提示构建中比文本序列表示表现更好。
- 跨多个拍数配置的集成投票方法始终改善结果并减少执行错误。
- 在 Spider 上,所提出的方法实现了 84.4 的执行准确性,超越最先进水平2.5个百分点,超越最佳微调系统5.1个百分点。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。