[论文解读] Retrieval-augmented GPT-3.5-based Text-to-SQL Framework with Sample-aware Prompting and Dynamic Revision Chain
本文提出了一种基于GPT-3.5的检索增强型Text-to-SQL框架,采用样本感知提示(sample-aware prompting)和动态修订链(dynamic revision chain),以提升SQL生成的准确性。通过简化输入问题并检索语义对齐的示例,再结合执行结果和解释的反馈,迭代优化SQL,该方法在三个基准测试上实现了最先进性能,尤其在复杂查询上显著优于强基线模型。
Text-to-SQL aims at generating SQL queries for the given natural language questions and thus helping users to query databases. Prompt learning with large language models (LLMs) has emerged as a recent approach, which designs prompts to lead LLMs to understand the input question and generate the corresponding SQL. However, it faces challenges with strict SQL syntax requirements. Existing work prompts the LLMs with a list of demonstration examples (i.e. question-SQL pairs) to generate SQL, but the fixed prompts can hardly handle the scenario where the semantic gap between the retrieved demonstration and the input question is large. In this paper, we propose a retrieval-augmented prompting method for a LLM-based Text-to-SQL framework, involving sample-aware prompting and a dynamic revision chain. Our approach incorporates sample-aware demonstrations, which include the composition of SQL operators and fine-grained information related to the given question. To retrieve questions sharing similar intents with input questions, we propose two strategies for assisting retrieval. Firstly, we leverage LLMs to simplify the original questions, unifying the syntax and thereby clarifying the users' intentions. To generate executable and accurate SQLs without human intervention, we design a dynamic revision chain which iteratively adapts fine-grained feedback from the previously generated SQL. Experimental results on three Text-to-SQL benchmarks demonstrate the superiority of our method over strong baseline models.
研究动机与目标
- 为解决Few-shot提示学习中检索偏差的问题,即当输入问题与检索示例之间存在语义差距时,静态演示失效的问题。
- 通过使用反映意图和结构化SQL组件的样本感知演示,动态调整提示,以提升LLM-based Text-to-SQL在零样本和少样本场景下的泛化能力。
- 通过利用来自数据库交互的细粒度反馈实现迭代优化,无需人工干预,生成可执行且准确的SQL查询。
- 通过引入基于LLM的提问简化和基于意图的检索(使用问题骨架),提升模型在复杂查询上的鲁棒性。
提出的方法
- 该框架利用LLM生成的输入问题简化版本和问题骨架,检索语义对齐的意图相关示例,以减少语义差距。
- 通过结合SQL操作符和与输入问题意图相关的细粒度信息,构建样本感知演示。
- 引入动态修订链,每轮迭代均基于SQL执行结果、自然语言解释和模式内容的反馈,逐步优化SQL查询。
- 系统使用LLM对原始问题进行简化,统一语法并澄清用户意图,以提升检索效果。
- 检索过程同时利用简化后的问题和结构化问题骨架,以识别语义相似的示例用于提示。
- 动态修订链执行迭代优化:每个新版本的SQL均基于前一轮的反馈生成,实现自我修正。
实验结果
研究问题
- RQ1LLM-based的问题简化能否提升Few-shot Text-to-SQL提示中语义相似示例的检索效果?
- RQ2在LLM-based Text-to-SQL中,结合SQL结构与意图的样本感知演示在多大程度上能增强Few-shot泛化能力?
- RQ3具有细粒度反馈的动态修订链在多大程度上能提升SQL执行准确性并减少复杂查询中的错误?
- RQ4所提出的框架是否在强基线模型上表现更优,尤其是在困难和超难查询类别上?
主要发现
- 所提方法在三个Text-to-SQL基准测试(Spider、Spider-SYN、Spider-DK)上均优于强基线模型,尤其在困难和超难查询层级表现突出。
- 在Spider-DK数据集上,当使用动态修订链时,模型在简单级别查询上执行准确率提升13.6%,在困难级别查询上提升11.0%。
- 消融研究显示,若移除简化模块或修订模块,性能均出现显著下降,其中简化模块对简单级别提升贡献最大(Spider-DK中下降12.5%)。
- 动态修订链在后期迭代中收益最大,Spider-SYN和Spider-DK中第二轮迭代的准确率提升高于第一轮,表明存在渐进式优化过程。
- 案例研究显示,模型能正确识别精确的列值(如“French”国籍),并能自我修正如错误使用COUNT()而未使用GROUP BY等错误,而其他模型无法解决此类问题。
- 模型实现了最先进性能,尤其在复杂查询上提升最大,证实其在处理具有挑战性的现实世界Text-to-SQL场景中的有效性。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。