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

07/11/2023
by   Chunxi Guo, et al.
0

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.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
04/23/2023

Divide and Prompt: Chain of Thought Prompting for Text-to-SQL

Chain-of-thought (CoT) prompting combined with large language models (LL...
research
05/21/2023

Enhancing Few-shot Text-to-SQL Capabilities of Large Language Models: A Study on Prompt Design Strategies

In-context learning (ICL) has emerged as a new approach to various natur...
research
12/17/2022

Know What I don't Know: Handling Ambiguous and Unanswerable Questions for Text-to-SQL

The task of text-to-SQL is to convert a natural language question to its...
research
03/14/2022

S^2SQL: Injecting Syntax to Question-Schema Interaction Graph Encoder for Text-to-SQL Parsers

The task of converting a natural language question into an executable SQ...
research
10/21/2020

DuoRAT: Towards Simpler Text-to-SQL Models

Recent research has shown that neural text-to-SQL models can effectively...
research
04/27/2023

Controllable Data Augmentation for Context-Dependent Text-to-SQL

The limited scale of annotated data constraints existing context-depende...
research
10/21/2020

On the Potential of Lexico-logical Alignments for Semantic Parsing to SQL Queries

Large-scale semantic parsing datasets annotated with logical forms have ...

Please sign up or login with your details

Forgot password? Click here to reset