🤖 AI Summary
Current large language models struggle to simultaneously achieve strong reasoning and robust generalization in Text-to-SQL tasks. This work proposes CoTE-SQL, a self-augmented fine-tuning framework that generates reasoning traces without human annotation by integrating modular, structured chain-of-thought prompting with an error-aware correction mechanism driven by SQL execution feedback. The approach substantially enhances performance on complex queries, attaining state-of-the-art results among open-source LLMs on the Bird and Spider benchmarks: 53.39% exact match (EX) and 59.02% valid execution score (VES) on Bird, and 79.60% EX and 77.19% VES on Spider, with particularly notable gains in challenging, complex query scenarios.
📝 Abstract
Text-to-SQL aims to translate natural language questions into executable SQL queries over structured databases, enabling non-expert users to access data intuitively. While recent advances in large language models (LLMs) have shown promise in this task, existing LLM-based approaches often struggle to strike a balance between strong reasoning capabilities and robust generalization. To address these limitations, we propose CoTE-SQL to enhance the LLM-based text-to-SQL generation with three key innovations: (i) self-enhanced reasoning traces distilled from LLMs without human annotation, (ii) structured chain-of-thought (CoT) prompting with modular decomposition and examples retrieval, and (iii) error-aware revision based on SQL execution feedback. Extensive experiments on the Spider and Bird benchmarks demonstrate that CoTE-SQL achieves new state-of-the-art performance among methods built on open-source LLMs with comparable model sizes on Bird (53.39% EX / 59.02 VES) and strong results on Spider (79.60% EX / 77.19 VES), with especially significant gains on complex queries. Results highlight the effectiveness of combining self-enhancement, structured reasoning, and execution-time feedback within an LLM-based framework for text-to-SQL design.