NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Rationalization Models for Text-to-SQL

Gaetano Rossiello, Nhan H Pham, Michael Glass, Junkyu Lee, Dharmashankar Subramanian · DOI

TL;DR

This paper introduces a novel framework for generating "Chain-of-Thought" (CoT) rationales to improve text-to-SQL models. By creating intermediate SQL steps and explanations, their method significantly boosts accuracy, especially for complex queries, and enhances model explainability.

What Problem Does This Paper Address?

The core challenge addressed is improving the accuracy and interpretability of text-to-SQL systems, particularly for complex queries. While large language models (LLMs) have made strides in this area, their performance still falls short of human-level, especially in real-world enterprise scenarios. Existing text-to-SQL datasets often lack the step-by-step reasoning (CoT) that could guide models, and manually creating such annotations is prohibitively expensive. The paper aims to bridge this gap by generating synthetic, high-quality CoT rationales to enhance the fine-tuning of text-to-SQL models.

Methods

The authors propose a multi-stage framework for generating CoT rationales:

  1. Rationale Representation: They define a structured way to represent CoT rationales, which involves breaking down the SQL query construction into incremental steps. This includes identifying relevant tables/columns, building intermediate SQL statements, and providing textual explanations for each step. Markdown formatting is used for easy parsing and visualization.
  2. Knowledge Distillation with Dynamic Few-Shot: This is the core of their synthetic data generation. They use a powerful "teacher" LLM (Llama 3.1 70B) to generate CoTs for existing text-to-SQL training examples. This process is dynamic:
  3. They start with a few manually annotated seed examples.
  4. For each training instance, they rank and select similar validated CoTs from a repository using an SQL-keyword-based vector space model.
  5. The teacher LLM then uses these selected examples in a few-shot prompt to generate a CoT for the current training instance.
  6. A validation component checks the correctness of the generated final SQL.
  7. This iterative process continues until the number of validated CoTs plateaus.
  8. Rationalization Model Fine-Tuning: To achieve full training coverage and handle potentially invalid synthetic rationales, they fine-tune a "rationalization model." This model takes the question, database schema, and the correct gold SQL as input to produce a step-by-step explanation of how to arrive at that SQL. This helps identify inconsistencies in existing training data and ensures all training examples have valid CoTs.

Datasets

  • BIRD dataset: Used for both training and evaluation. The authors note that the BIRD training set does not inherently contain query decomposition steps, making it suitable for their rationale generation approach. The BIRD development set is categorized into "simple," "moderate," and "challenging" SQL statements, allowing for fine-grained evaluation.

Key Insights and Ideas

  • CoT as a stepping stone: The paper demonstrates that explicitly generating intermediate SQL steps (CoTs) is more effective for fine-tuning than just using the final SQL. This mirrors human problem-solving by breaking down complex tasks.
  • Dynamic few-shot learning for data generation: Instead of static few-shot examples, their dynamic approach iteratively refines the selection of examples, leading to more diverse and relevant synthetic rationales.
  • SQL similarity for example selection: Using SQL keyword frequency as a similarity metric is an effective way to find relevant CoT examples, ensuring that the generated rationales for a new query share structural similarities with previously validated ones.
  • Rationalization models for quality control: Fine-tuning a separate model to explain correct SQLs acts as a powerful quality assurance mechanism, helping to identify errors in the original dataset and ensuring the generated rationales are sound.
  • Longer CoTs can be better: The results suggest that longer, more detailed CoTs can lead to better performance, particularly on challenging queries, by providing more granular guidance.

Key Results

  • Improved Execution Accuracy: Fine-tuning smaller LLMs (Llama 3.1 8B) with the generated CoT rationales consistently enhanced execution accuracy on the BIRD dataset.
  • Performance Boost on Complex Queries: The improvement was most pronounced for "moderate" and "challenging" SQL queries. Specifically, fine-tuning with the longest CoTs after applying the rationalization model led to a +1.24% overall improvement and a notable +4.86% increase on challenging queries.
  • Enhanced Explainability: The generated CoTs provide clear, step-by-step explanations of the query-building process, making the model's reasoning more interpretable and actionable.
  • High Training Coverage: The framework achieved near full training coverage (99.02%) of validated CoTs after the rationalization stage.

Limitations and Future Work

  • Manual Annotation Cost: While significantly reduced, the process still requires an initial small set of manual annotations to define the rationale representation.
  • Potential for Invalid Rationales: Despite validation, there's a small chance of synthetically generated rationales containing ambiguities or errors, which the rationalization model helps to mitigate.
  • Future Work: The authors suggest that the fine-tuned rationalization model could be used to generate rationales for other text-to-SQL datasets, even across different domains, without needing to repeat the entire generation process from scratch. This highlights the reusability and generalizability of their approach.

Summary updated

BibTeX
@misc{rossiello2025rationalization,
  author = {Gaetano Rossiello and Nhan H Pham and Michael Glass and Junkyu Lee and Dharmashankar Subramanian},
  title = {{Rationalization Models for Text-to-SQL}},
  year = {2025},
  eprint = {2502.06759},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.06759},
}
Figure