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.
翻译:文本到SQL旨在将自然语言问题转化为可执行的结构化数据库SQL查询,使非专业用户能够直观地访问数据。尽管近期大型语言模型(LLMs)的进展在这一任务中展现出潜力,但现有基于LLM的方法往往难以在强大的推理能力与稳健的泛化性之间取得平衡。为解决这些局限,我们提出CoTE-SQL,通过三项关键创新增强基于LLM的文本到SQL生成:(i)从LLM中提炼、无需人工标注的自增强推理轨迹;(ii)结合模块化分解与示例检索的结构化思维链提示;(iii)基于SQL执行反馈的错误感知修正。在Spider和Bird基准上的大量实验表明,CoTE-SQL在基于开源LLM且模型规模相当的方法中,于Bird数据集上达到新最优性能(53.39% EX / 59.02% VES),并在Spider数据集上取得强劲结果(79.60% EX / 77.19% VES),尤其在复杂查询上提升显著。实验结果凸显了在基于LLM的文本到SQL设计框架中融合自增强、结构化推理与执行时反馈的有效性。