arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2307.05074cs.IRcs.AIcs.DB
收藏

基于检索增强的GPT-3.5文本到SQL框架,具有样本感知提示和动态修订链

Retrieval-augmented GPT-3.5-based Text-to-SQL Framework with Sample-aware Prompting and Dynamic Revision Chain

National University of Defense Technology(国防科技大学)

Chunxi Guo, Zhiliang Tian, Jintao Tang, Shasha Li, Zhihua Wen, Kaixuan Wang, Ting Wang

AI总结:

本文提出一种检索增强的GPT-3.5文本到SQL框架,采用样本感知提示和动态修订链,在三个基准上优于强基线。

摘要:

文本到SQL旨在为给定的自然语言问题生成SQL查询,从而帮助用户查询数据库。基于大型语言模型(LLMs)的提示学习已成为一种近期方法,它通过设计提示引导LLMs理解输入问题并生成相应的SQL。然而,它面临严格的SQL语法要求的挑战。现有工作使用一组演示示例(即问题-SQL对)提示LLMs生成SQL,但固定的提示难以处理检索到的演示与输入问题之间语义差距较大的情况。在本文中,我们提出了一种基于LLM的文本到SQL框架的检索增强提示方法,涉及样本感知提示和动态修订链。我们的方法包含样本感知演示,其中包括SQL运算符的组合以及与给定问题相关的细粒度信息。为了检索与输入问题具有相似意图的问题,我们提出了两种辅助检索的策略。首先,我们利用LLMs简化原始问题,统一语法,从而澄清用户的意图。为了在无需人工干预的情况下生成可执行且准确的SQL,我们设计了一个动态修订链,该链迭代地适应先前生成的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.

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

↑