[论文解读] How to Prompt LLMs for Text-to-SQL: A Study in Zero-shot, Single-domain, and Cross-domain Settings
该论文系统地评估了在零-shot、单域和跨域设置下的文本到 SQL 的提示构建,结果表明表格关系与内容、提示归一化及域内演示显著影响大语言模型性能,在零-shot 情况下 Codex 通常优于 ChatGPT,跨域提示长度存在最优点。
Large language models (LLMs) with in-context learning have demonstrated remarkable capability in the text-to-SQL task. Previous research has prompted LLMs with various demonstration-retrieval strategies and intermediate reasoning steps to enhance the performance of LLMs. However, those works often employ varied strategies when constructing the prompt text for text-to-SQL inputs, such as databases and demonstration examples. This leads to a lack of comparability in both the prompt constructions and their primary contributions. Furthermore, selecting an effective prompt construction has emerged as a persistent problem for future research. To address this limitation, we comprehensively investigate the impact of prompt constructions across various settings and provide insights into prompt constructions for future text-to-SQL studies.
研究动机与目标
- 评估数据库提示表示(模式、关系和内容)如何影响零-shot、单域和跨域文本到-SQL 性能。
- 评估在域内与域外演示对 LLM 能力在各种设置中的影响。
- 确定有效的提示构造做法(归一化、内容呈现)以提升文本到-SQL 的准确性。
- 为未来文本到-SQL 工作中的提示设计提供可操作的建议。
提出的方法
- 系统性比较多种数据库提示构造(仅模式到包含关系与内容的增强版本)。
- 归一化提示文本以减少令牌变异性和大小写敏感性。
- 以 Spider 作为跨域基准并使用 Codex 与 ChatGPT 进行评估。
- 在零-shot、单域和跨域的上下文学习设置中,探索不同的演示策略。
- 分析演示数量和提示长度对性能的影响。
- 以执行准确度(EX)作为评估指标呈现结果。
实验结果
研究问题
- RQ1不同提示中对数据库模式与内容的表示方式如何影响零-shot、单域和跨域文本到-SQL 的性能?
- RQ2在提示 LLM 进行文本到-SQL 时,域内与域外演示在不同设置中的作用是什么?
- RQ3提示长度如何影响跨域提示中的 LLM 性能,是否存在甜点点?
- RQ4在提示中包含表关系(外键)和内容(示例行)是否改善结果,这与演示如何互动?
主要发现
- 提示中的表关系和内容对于有效提示至关重要,归一化通常能提升结果。
- 域内演示提高性能,且能降低对提示表示的敏感性,但不能完全替代表格内容知识。
- 提示长度在跨域设置中具有显著影响,Codex 存在一个甜点点,超过该长度会导致性能下降。
- Codex 在零-shot 文本到-SQL 的不同提示构造下通常优于 ChatGPT。
- 在单域设置中,增加域内演示有帮助,表内容仍然重要;但随着演示增多,具体内容呈现的差异性较小。
- 域外演示在跨域提示中提升能力,但不能提供数据库特定知识;审慎的数据库提示设计仍然关键。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。