Sparks of Tabular Reasoning via T ext2 SQL Reinforcement Learning (2025)

Abstract: This work reframes the Text-to-SQL task as a pathway for teaching large language models (LLMs) to reason over and manipulate tabular data—moving beyond the traditional focus on query generation. We propose a two-stage framework that leverages SQL supervision to develop transferable table reasoning capabilities. First, we synthesize detailed chain-of-thought (CoT) traces from real-world SQL queries, providing step-by-step, clause-level supervision that teaches the model how to traverse, filter, and aggregate table fields. Second, we introduce a Group Relative Policy Optimization (GRPO) reinforcement learning objective that connects SQL execution accuracy to generalizable reasoning by encouraging steps that extend beyond task-specific syntax and transfer across datasets.Empirically, our approach improves performance on standard Text-to-SQL benchmarks and achieves substantial gains on reasoning-intensive datasets such as BIRD, CRT-QA and Tablebench, demonstrating enhanced generalization and interpretability. Specifically, the distilled-quantized LLaMA-8B model achieved a 34% relative increase in exact match scores on CRT-QA when trained on Text-to-SQL tasks, while Qwen-2.5-7B achieved a 10% and Qwen-2.5-14B a 6% relative increase. These results suggest that SQL can serve not only as a target formalism but also as an effective scaffold for learning robust, transferable reasoning over structured data.

## introduction recent advancements in llms have substantially improved performance on text-to-sql tasks, translating natural language into executable sql queries over relational databases @xcite . progress has been driven primarily by supervised fine-tuning (sft) on sql-focused datasets (e.g., * equal contribution † one pancras square, pancras rd, london n1c 4ag spider @xcite , bird @xcite ) or prompt-based adaptation @xcite . however, these methods often narrowly optimize for syntactic correctness or execution accuracy, overlooking deeper reasoning over underlying data structures-resulting in degraded performance in real-world settings @xcite . this highlights a broader issue: text-to-sql is frequently treated as a standalone task, rather than as a facet of the more general challenge of reasoning over tabular data @xcite . sql, as a formal language, provides a vehicle for structured reasoning over relational tables; thus, models generating sql should ideally also support broader forms of table-based question answering (e.g., tab-fact @xcite , wikitq @xcite , finqa @xcite ). yet, models fine-tuned exclusively for text-to-sql often exhibit degraded performance on related tasks, suggesting overfitting to sql-specific patterns at the expense of flexible reasoning @xcite . methods like h-star @xcite integrate symbolic and semantic reasoning for improved table comprehension, while plan-of-sqls (pos) @xcite emphasize interpretability and qa performance. however, both approaches tend to bias the model toward sql-centric reasoning, potentially limiting generalization @xcite . inspired by @xcite , we explore whether reinforcement learning (rl) can foster emergent reasoning capabilities that connect text-to-sql with general tabular qa. we propose a two-stage approach depicted in figure 1 . first, we introduce a supervised finetuning phase leveraging synthetically generated cot reasoning traces to provide structured guidance between the natural language input and its corresponding sql representation. unlike synsql-2.5 @xcite , which emphasizes data scale, our approach focuses on generating high-quality cot traces grounded in real data points. second, we apply grpo @xcite , a reinforcement learning method that compares multiple candidate outputs, aligning sql execution accuracy and query structure with broader reasoning fidelity. while prior work (e.g., reasoning-sql @xcite , sql-r1 @xcite ) has applied rl to sql generation, our key contribution lies in bridging text-to-sql with general tabular reasoning. we show that models trained with our two-stage framework outperform sft baselines not only on sql benchmarks but also on reasoningintensive qa datasets such as crt-qa @xcite and tablebench @xcite , illustrating that sql generation, when properly framed, can serve as a foundation for broader structured data reasoning. our key contributions are: the training and evaluation code is made publicly available foot_1 . ## methodology our methodology is outlined in figure 2 , where we see the breakdown into 6 steps. ## experiments we design our experiments to investigate the following research questions: ## conclusion in conclusion, our experiments demonstrate that integrating reinforcement learning with a supervised pretraining phase significantly enhances the model's ability to reason over tabular data. notably, the distilled quantized llama-8b model achieved a 34.2% relative performance improvement on the crt-qa dataset, while the qwen-2.5-7b model saw a 10.2% increase and the qwen-2.5-14b model 5.5% relative increase, underscoring the efficacy of our two-stage framework in optimizing sql an llm answering a natural language question over a table. while the output is a binary response ("yes"), the model's internal reasoning implicitly follows an sql-like logic: it compares subsets of rows filtered by different conditions to support its answer. this illustrates how models may invoke formal query structures even when the task does not explicitly require sql, reflecting an internal alignment between table qa and sql semantics.