arXiv:2611.00815cs.AIOct 2026

Manuscript Offprint

arXiv:2611.00815

VCoT-SQL: Enhancing Text-to-SQL Generation through Dual Chain-of-Thought Validation Training

Rui Zhang, Yujia Su, Ruixuan Li, Yuhua Li, Yixin Su

Abstract

Open-source LLMs provide a flexible alternative to closed-source models for Text-to-SQL but still struggle with complex queries. Fine-tuning with chain-of-thought (CoT) data improves reasoning, yet standard datasets lack CoT annotations, requiring synthetic generation. Existing synthesis methods only verify the final answer, allowing flawed reasoning steps to corrupt the training data. We propose VCoT-SQL, a framework that improves Text-to-SQL generation through intermediate-step-validated CoT supervision and a dedicated SQL validator, which enables small open-source models to outperform frontier closed-source models. VCoT-SQL trains two complementary models on curated reasoning traces: an SQL generator using clause-level CoT templates where reasoning steps are verified via execution and schema alignment checks, and an SQL validator using diagnostic CoT templates to detect syntactic, semantic, and type-level errors. We further design a hierarchical schema filtering pipeline that integrates and refines complementary retrieval strategies to distill relevant database elements. VCoT-SQL achieves 66.82% execution accuracy on challenging dataset BIRD dev and 86.8% on Spider test, improving the base 7B model by 7% on BIRD. Notably, our CoT synthesis relies on 7B models yet outperforms methods that use 72B-scale or even proprietary closed-source teachers for data generation, demonstrating that rigorous step-level validation can be more effective than scaling up teacher model size. Our dataset and code are available at https://github.com/INTREBID/VCoT-SQL.

1 Introduction

Text-to-SQL is the task of converting natural language questions into executable SQL queries, enabling non-technical users to access and manipulate relational databases. As a fundamental problem at

the intersection of natural language processing and database systems, Text-to-SQL attracts significant attention from both the academia and industry.

LLM-based approaches dominate Text-to-SQL benchmarks, falling into two paradigms: prompt-based and fine-tuned. Prompt-based approaches primarily leverage closed-source LLMs such as GPT-4 (OpenAI, 2023), which remain general-purpose models that are hard to fine-tune for Text-to-SQL, and suffer from high API costs and data privacy risks (Li et al., 2024; Pourreza and Rafiei, 2024; Qin et al., 2025). Fine-tuning approaches train open-source LLMs on task-specific Text-to-SQL datasets, and recent work incorporates Chain-of-Thought (CoT) (Wei et al., 2022) reasoning into the fine-tuning objective to strengthen reasoning capabilities (Pourreza et al., 2025; Zhai et al., 2025; Li et al., 2025). However, existing benchmarks typically provide only question-SQL pairs, and the scarcity of high-quality CoT annotations limits the effectiveness of such methods, particularly on complex queries.

Meanwhile, pipeline-based strategies are proposed to improve Text-to-SQL accuracy by augmenting the generator with schema linking (Li et al., 2024; Pourreza and Rafiei, 2024; Qin et al., 2025; Liu et al., 2026) or Self-Correction (Pourreza and Rafiei, 2023; Liu et al., 2026; Talaei et al., 2024). However, existing schema linking methods either require additional model training or rely on superficial semantic matching that struggles with complex schema correspondences. Moreover, self-correction approaches remain largely ineffective to semantic errors, as they focus on fixing syntax errors via execution feedback.

To address the lack of high-quality reasoning data and further improve the accuracy of generated SQL, we introduce VCoT-SQL, a Text-to-SQL framework built on the principle of dual validation—validating CoT quality during training and validating SQL correctness during inference.

*Corresponding author.

On the training side, we design dedicated CoT templates for SQL generation and SQL validation respectively, and then apply multi-stage verification (execution consistency, schema grounding, and reasoning faithfulness) to curate reliable training data for a CoT-enhanced Generator and Validator. During inference, a cascaded schema filtering pipeline first isolates relevant database elements to provide focused context; the Generator then produces candidate SQL, which the Validator diagnoses and refines by correcting syntactic errors, semantic inconsistencies, and data-type mismatches. This design enables smaller models to achieve strong reasoning and self-correction capabilities with less data, without relying on large teacher models.

Our contributions are as follows:

  1. We propose VCoT-SQL, a dual-validation Text-to-SQL framework with a CoT-enhanced Generator and Validator. To facilitate effective reasoning, we design dedicated CoT templates: clause-driven templates for generation and multi-type correction templates for validation, and then curate high-quality training data from Spider/BIRD via multi-stage filtering on execution consistency, schema grounding, and reasoning faithfulness.

  2. We also introduce a training-free, three-stage schema retrieval framework (Pre-SQL, Column, and Value retrievers), which progressively reduces schema noise, achieving performance superior to that of trained specialized schema filters.

  3. Extensive experiments on six benchmarks validate that our method significantly improves the performance on three different base models. Our best 7B model increases execution accuracy on the BIRD dev set from 59.78% to 66.82%. Furthermore, it surpasses the strong OmniSQL baseline (63.9%) while using only 1/250 of its training data.