Text-to-SQL as Dual-State Reasoning: Integrating Adaptive Context and Progressive Generation
Zhifeng Hao, Qibin Song, Ruichu Cai, Boyan Xu
TL;DR
DSR-SQL introduces a dual-state reasoning framework for enterprise-level Text-to-SQL, modeling the task as an interaction between an adaptive context state and a progressive generation state. The context state compresses and aligns schema and knowledge through Refinement, Adaptive Selection, and Schema-aware Alignment, while the generation state evolves SQL via feedback-guided Extend, Revise, Explore, and Finalize steps. In zero-shot settings, it achieves strong results on Spider 2.0-Snow (35.28% EX) and BIRD (up to 68.32% EX), outperforming several baselines without post-training or in-context exemplars. The work demonstrates that coupling context refinement with feedback-driven generation yields robust, scalable Text-to-SQL for complex enterprise schemas, with open-source code to follow.
Abstract
Recent divide-and-conquer reasoning approaches, particularly those based on Chain-of-Thought (CoT), have substantially improved the Text-to-SQL capabilities of Large Language Models (LLMs). However, when applied to complex enterprise databases, such methods struggle to maintain coherent reasoning due to limited context capacity, unreliable schema linking, and weak grounding in database semantics. To overcome these issues, we introduce DSR-SQL, a \textbf{D}ual-\textbf{S}tate \textbf{R}easoning framework that models Text-to-SQL as an interaction between an adaptive context state and a progressive generation state. The first constructs a compact, semantically faithful environment by refining large schemas and selecting relevant structures, while the second formalizes SQL synthesis as feedback-guided state transitions, enabling the model to self-correct and align with user intent. Without any post-training or in-context examples, DSR-SQL achieves competitive performance, reaching 35.28\% execution accuracy on Spider 2.0-Snow and 68.32\% on BIRD development set. Our implementation will be open-sourced at: https://github.com/DMIRLAB-Group/DSR-SQL.
