Large Language Models (LLMs) have been increasingly adopted in Text-to-SQL systems, yet SQL errors remain a major obstacle in real-world Text-to-SQL inference pipelines. Existing SQL correction approaches either rely on large-scale, high-quality training data with substantial overhead, or adopt single-path agentic workflows that are brittle to early mistakes and prone to error propagation. To develop a practical SQL correctness system for industrial scenarios, we present a training-free framework that formulates SQL correction as a plan-guided, tree-structured debugging process. By maintaining multiple correction strategies and enabling backtracking, the framework mitigates error accumulation during iterative refinement. We further integrate execution-based verification and clause-level diagnostic tools to support strategy pruning and precise error localization. We evaluate the system on the BIRD-Critic benchmark and observe consistent accuracy gains over strong LLM backbones and representative agent-based baselines, achieving a 9.42% improvement over the previous state-of-the-art method. The framework is also deployed in the Torch Log Service (TLS) of Volcano Engine to support an online Text-to-TLS API. In production, it improves execution accuracy from 36.77% to 53.61% on real user queries with a representative strong LLM backbone (GPT-5). These results demonstrate the effectiveness and stability of our approach in real-world deployments.
Figures & tables
Figure 1. A failure mode of linear SQL correction, illustrating how early implicit assumptions and error accumulation lead to semantic drift, causing the final query to deviate from the user’s intent.
Figure 2. Overview of our framework.
Figure 3. An example of the tree-based SQL correction pro- cess. Starting from ambiguity detection, the system branches into alternative semantic interpretations of “overlapping”. The incorrect interpretation (total booking count) is pruned after semantic validation based on evidence obtained from the inspect_columns tool, triggering backtracking. The cor- rect branch (concurrent time overlap) proceeds through SQL generation and syntax repair, ultimately producing a validated query. Each node corresponds to a tool invocation, and branching, backtracking, and acceptance decisions are made by Central Agent based on execution feedback.
Methods
Bird-critic Open
Bird-critic PG
PostgreSQL
MySQL
SQLServer
Oracle
Raw model
Deepseek-R1 ( Guo et al., 2025a )
36.96%
38.78%
32.65%
19.39%
39.62%
GPT-o3 ( OpenAI, 2025 )
41.30%
26.53%
32.65%
18.37%
38.87%
GPT-5 ( , 2025 )
39.13%
28.57%
29.59%
23.71%
35.85%
grok-4 ( , 2025 )
39.49%
35.71%
33.67%
15.31%
39.06%
Agents
SQLFixAgent ( Cen et al., 2025 )
21.38%
22.79%
33.12%
17.68%
40.56%
Table 1. Main results on the BIRD-CRITIC benchmark.
Variants
Bird-critic Open
Bird-critic PG
PostgreSQL
MySQL
SQLServer
Oracle
Full Method
ACTS-SQL (Full)
58.70%
64.29%
53.06%
33.67%
45.85%
Plan Structure
w/ Linear Plan
45.81%
36.93%
38.88%
20.47%
36.56%
Tools
w/o Execution Tool
39.84%
32.66%
29.85%
21.48%
37.92%
w/o Ambiguity Detection
43.89%
27.37%
31.28%
25.67%
38.45%
Table 2. Ablation study of ACTS-SQL on the BIRD-CRITIC benchmark.
Base Model
Critic Strategy
No Critic
LLM Critic
DAC ( Wang et al., 2024a )
MapleRepair ( Shen et al., 2025 )
ACTS-SQL
Acc. ↑
Lat. ↓
Acc. ↑
Lat. ↓
Acc. ↑
Lat. ↓
Acc. ↑
Lat. ↓
Acc. ↑
Lat. ↓
GPT-5 ( , 2025 )
36.77%
6.31
47.42%
26.52
37.74%
72.51
46.83%
15.51
53.61%
218.91
GPT-o3 ( OpenAI, 2025 )
40.55%
18.17
51.89%
35.40
40.55%
139.25
50.41%
17.49
56.36%
277.41
DeepSeek-R1 ( Guo et al., 2025a )
22.68%
6.04
22.96%
13.24
22.68%
96.04
22.68%
14.55
23.85%
38.65
Xiyan ( Liu et al., 2026 )
13.40%
7.01
13.40%
15.67
13.40%
76.54
13.40%
18.90
13.75%
42.56
Table 3. Performance of different critic strategies on the TLS dataset. Accuracy ( Acc. , %, ↑ ) measures exact-match correctness. Latency ( Lat. , seconds, ↓ ) reports the average end-to-end runtime.
Figure 4. Comparison between linear refinement and our tree-structured debugging on a representative SQL correction case. Linear refinement method iteratively applies local fixes under a fixed but incorrect semantic assumption, leading to repeated failure. ACTS-SQL branches on ambiguous interpretations, validates each branch independently, and backtracks from invalid paths, successfully correcting the SQL.
Figure 5. Screenshot of the Text-to-TLS API interface and error TLS repair copilot in the production environment.
Despite the remarkable performance of large language models (LLMs) in text-to-SQL (SQL generation), correctly producing SQL queries remains challenging during initial generation. The SQL refinement task is subsequently introduced to correct syntactic and semantic errors in generated SQL queries. However, existing paradigms face two major limitations: (i) self-debugging becomes increasingly ineffective as modern LLMs rarely produce explicit execution errors that can trigger debugging signals; (ii) self-correction exhibits low detection precision due to the lack of explicit error modeling grounded in the question and schema, and suffers from severe hallucination that frequently corrupts correct SQLs. In this paper, we propose ErrorLLM, a framework that explicitly models text-to-SQL Errors within a dedicated LLM for text-to-SQL refinement. Specifically, we represent the user question and database schema as structural features, employ static detection to identify execution failures and surface mismatches, and extend ErrorLLM's semantic space with dedicated error tokens that capture categorized implicit semantic error types. Through a well-designed training strategy, we explicitly model these errors with structural representations, enabling the LLM to detect complex implicit errors by predicting dedicated error tokens. Guided by the detected errors, we perform error-guided refinement on the SQL structure by prompting LLMs. Extensive experiments demonstrate that ErrorLLM achieves the most significant improvements over backbone initial generation. Further analysis reveals that detection quality directly determines refinement effectiveness, and ErrorLLM addresses both sides by high detection F1 score while maintain refinement effectiveness.
Zijin Hong, Hao Chen, Zheng Yuan +6
The Hong Kong Polytechnic University Kowloon, Hong Kong · City University of Macau Taipa, Macau · Jilin University Changchun, China +3
Recent work has shown that reinforcement learning from execution feedback can substantially improve text-to-SQL performance, often enabling smaller models to match or exceed much larger systems. However, most existing approaches treat SQL generation as a single-turn task, limiting the model's ability to recover from errors through iterative refinement. We present ReToolSQL, a two-stage training framework for text-to-SQL that combines (i) a supervised warm-start on rejection-sampled reasoning traces with (ii) agentic reinforcement fine-tuning (RFT) over multi-turn tool-use trajectories. The key insight is that the two stages act on complementary axes, the supervised fine-tuning (SFT) on verified privileged-teacher traces expands the set of solvable questions (raising pass@k coverage on the hardest cases), while RFT converts that expanded capability into higher single-pass accuracy by teaching the model when to verify, what evidence to retrieve, and how to repair faulty SQL from execution feedback. Applied to Gemma 4 instruction-tuned (31B), RFT alone achieves 73.66% execution accuracy (EX) on the BIRD-SQL development benchmark (74.12% EX with self-consistency). Initializing RFT from the SFT checkpoint (SFT→RFT) yields our strongest model at 74.32% EX single-pass and 74.77% EX with self-consistency. At the time of writing, this ranked first on the BIRD single-model development-set leaderboard. The approach uses composite rewards anchored on execution correctness, requires no human annotation beyond the benchmark itself, and operates within a single dense 31B model, showing that a properly designed SFT→RFT pipeline over tool-use trajectories is a practical path toward robust enterprise-grade text-to-SQL.
Large language models have driven major advances in Text-to-SQL generation. However, they suffer from high computational cost, long latency, and data privacy concerns, which make them impractical for many real-world applications. A natural alternative is to use small language models (SLMs), which enable efficient and private on-premise deployment. Yet, SLMs often struggle with weak reasoning and poor instruction following. Conventional reinforcement learning methods based on sparse binary rewards (0/1) provide little learning signal when the generated SQLs are incorrect, leading to unstable or collapsed training. To overcome these issues, we propose FINER-SQL, a scalable and reusable reinforcement learning framework that enhances SLMs through fine-grained execution feedback. Built on group relative policy optimization, FINER-SQL replaces sparse supervision with dense and interpretable rewards that offer continuous feedback even for incorrect SQLs. It introduces two key reward functions: a memory reward, which aligns reasoning with verified traces for semantic stability, and an atomic reward, which measures operation-level overlap to grant partial credit for structurally correct but incomplete SQLs. This approach transforms discrete correctness into continuous learning, enabling stable, critic-free optimization. Experiments on the BIRD and Spider benchmarks show that FINER-SQL achieves up to 67.73% and 85% execution accuracy with a 3B model -- matching much larger LLMs while reducing inference latency to 5.57~s/sample. These results highlight a cost-efficient and privacy-preserving path toward high-performance Text-to-SQL generation. Our code is available at https://github.com/thanhdath/finer-sql.
Thanh Dat Hoang, Thanh Trung Huynh, Matthias Weidlich +4
Griffith University (Australia) · VinUniversity (Vietnam) · Humboldt-Universitat zu Berlin (Germany) +1