[Paper Review] DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction
DIN-SQL decomposes text-to-SQL into schema linking, classification/decomposition, SQL generation with NatSQL, and self-correction, using in-context learning to significantly improve execution accuracy and surpass prior Spider SOTA on holdout and set new SOTA on BIRD.
There is currently a significant gap between the performance of fine-tuned models and prompting approaches using Large Language Models (LLMs) on the challenging task of text-to-SQL, as evaluated on datasets such as Spider. To improve the performance of LLMs in the reasoning process, we study how decomposing the task into smaller sub-tasks can be effective. In particular, we show that breaking down the generation problem into sub-problems and feeding the solutions of those sub-problems into LLMs can be an effective approach for significantly improving their performance. Our experiments with three LLMs show that this approach consistently improves their simple few-shot performance by roughly 10%, pushing the accuracy of LLMs towards SOTA or surpassing it. On the holdout test set of Spider, the SOTA, in terms of execution accuracy, was 79.9 and the new SOTA at the time of this writing using our approach is 85.3. Our approach with in-context learning beats many heavily fine-tuned models by at least 5%. Additionally, when evaluated on the BIRD benchmark, our approach achieved an execution accuracy of 55.9%, setting a new SOTA on its holdout test set.
Motivation & Objective
- Motivate closing the gap between prompting-based LLMs and fine-tuned models on text-to-SQL benchmarks like Spider and BIRD.
- Propose a decomposed, multi-module prompting approach to improve LLM reasoning for SQL generation.
- Investigate how module-specific prompts (schema linking, classification/decomposition, NatSQL-based generation, and self-correction) affect performance.
- Demonstrate the effectiveness of self-correction prompting and adaptive prompt selection across query difficulties.
Proposed method
- Decompose the NL2SQL task into four prompting-enabled modules: schema linking, classification/decomposition, SQL generation with NatSQL intermediates, and a self-correction step.
- Employ few-shot demonstrations drawn from the training set for each module and each query class.
- Use a three-way classification (easy, non-nested complex, nested complex) to select specialized prompts for SQL generation.
- Adopt NatSQL as an intermediate representation to ease NL-to-SQL translation for non-nested complex queries.
- Apply a self-correction module with generic or gentle prompts to fix minor SQL errors post-generation.
- Evaluate with GPT-4 and CodeX variants, using greedy decoding, zero temperature, and specific max token settings to control generation and correction.

Experimental results
Research questions
- RQ1Can decomposing text-to-SQL into schema linking, classification/decomposition, and intermediate representations improve LLM performance over simple few-shot prompting?
- RQ2What is the impact of adaptive prompting (based on query difficulty) and self-correction on execution and exact-match accuracies on Spider and BIRD?
- RQ3How does the approach compare to fine-tuned SOTA methods on cross-domain text-to-SQL benchmarks?
- RQ4Does incorporating schema linking and NatSQL intermediates mitigate common failure modes such as joins, nesting, and schema ambiguity?
Key findings
- Achieves 85.3% execution accuracy on the Spider holdout with GPT-4, setting a new SOTA at the time.
- Attains 78.2% execution accuracy using CodeX Davinci on Spider holdout, with 60% exact-set-match (EM).
- On the BIRD benchmark, reaches 55.9% execution accuracy on the holdout set with GPT-4, establishing new SOTA (and 50.72% EM on development with GPT-4).
- Demonstrates that decomposed prompting consistently improves few-shot performance by about 10% over simple few-shot prompting across LLMs.
- Ablation shows each module contributes to performance, with schema linking providing notable gains, especially for non-easy queries.
- Self-correction prompts (generic for CodeX, gentle for GPT-4) reduce SQL defects and improve execution accuracy.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.