CAPER: Clause-Aligned Process Supervision for Text-to-SQL
arXiv:2606.03327v1 [cs.DB] 2 Jun 2026
Lujie Ban1 , Jiasheng Shi1 , Jinyang Li2 , Xiaolin Han3 , Tsz Nam Chan4 , Chenhao Ma1∗ 1 The Chinese University of Hong Kong, Shenzhen 2 The University of Hong Kong 3 Northwestern Polytechnical University 4 Shenzhen University 1 [email protected], {shijiasheng,machenhao}@cuhk.edu.cn 2 [email protected] 3 [email protected] 4 [email protected]
Abstract Text-to-SQL systems are typically evaluated by query-level execution correctness, but this terminal signal provides little guidance about which intermediate SQL decision caused success or failure. Token-level dense supervision is also ill-suited: SQL tokens do not align with complete semantic decisions, can penalize executionequivalent queries, and are difficult to label reliably at scale. We therefore propose CAPER, which automatically derives clause-level supervision via counterfactual intervention on the SQL abstract syntax tree, enabling root-cause error localization for reward modeling; the resulting data is used to train CAPER-9B, a lightweight Clause-PRM that provides clause-boundary feedback for policy optimization and candidate verification. Experiments on BIRD and Spider show that clause-aligned supervision not only improves execution accuracy, achieving up to a 15.3% relative EX improvement over GPT-5.4, but also strengthens failure-localization capability, reaching 84.53% accuracy and 90.60% MRR on held-out failures. Our project page is at https://github.com/banrichard/RL-NL2SQL.
1
Introduction
Text-to-SQL aims to translate natural-language questions into executable SQL queries, providing a direct interface between non-expert users and structured databases [1, 2]. In real-world data workflows, it supports natural-language analytics [3, 4], business-intelligence question answering [5, 6], enterprise database operations [7–9], and interactive SQL troubleshooting [10, 11]. Large language models (LLMs) have further expanded the design space through schema linking [12, 13], database retrieval [14, 15], and generation correction [16, 17]. Despite this progress, Text-to-SQL remains a high-precision structured generation problem: a generated query must be syntactically valid, schemagrounded, and semantically equivalent to the intended database operation, and a single wrong join key, aggregation, or predicate can still lead to the wrong execution result. One way to improve Text-to-SQL is to scale supervised fine-tuning (SFT) [18] with larger or richer demonstration corpora. But this shifts the bottleneck to data construction: executable Text-to-SQL annotations are expensive to produce, require SQL expertise, and remain costly to scale [10, 11, 19– 23]. In the LLM era, strong SFT pipelines often also depend on richer supervision such as reasoning traces [24]. Query-level execution outcomes offer a more scalable source of supervision because they are already used to judge whether a generated SQL query retrieves the correct answer [25–28]. However, an execution outcome is only a terminal label: it says whether the full query succeeds, but not which intermediate SQL decision made it succeed or fail. This creates a credit assignment problem for process supervision. As illustrated in Figure 1, a predicted SQL query can be largely correct yet fail because of one decisive semantic error, such as an incorrect relational condition or join path. Execution-level feedback treats this near-miss the same as a completely wrong query: once the final execution result is incorrect, the signal provides little Preprint.
Question Which course had the highest enrollment in 2024, and how many students enrolled? Schema course course_id name
enrollment student_id course_id name
course.course_id = enrollment.course_id
Reward Granularity Comparison
Gold SQL vs. Predicted SQL
Question & Schema
Gold SQL
Predicted SQL
SELECT c.name, COUNT(*)
SELECT c.name, COUNT(*)
FROM course c
FROM course c
JOIN enrollment e
JOIN enrollment e
ON
ON
c.course_id = e.course_id
c.course_id = e.student_id
WHERE e.year=2024
WHERE e.year=2024
GROUP BY c.name
GROUP BY c.name
ORDER BY COUNT(*) DESC
ORDER BY COUNT(*) DESC
LIMIT 1
LIMIT 1
Correct JOIN Relation
Execution Reward
Failed to locate root cause
Predicted SQL
Result Wrong Reward=0
+ + ~ + ~ ~ ~ + SELECT c.name , COUNT ( * ) FROM + ~ + + ~ + + course c JOIN enrollment e ON c.course_id ~ + + ~ + + = e.student_id WHERE e.year = 2024 GROUP
+ BY
+ c.name
~ 1
+ ORDER
+ BY
+ COUNT
~ ~ ~ ( * )
+ DESC
+ LIMIT
Reward= 0.86 error localized
Clause-level Reward(Ours)
+
+
Only the relational-unit is wrong
Reward = 0.42 signal diffused
Token-level Reward
-
FROM-JOIN SELECT FROM course c JOIN SELECT c.name, enrollment e ON COUNT(*) c.course_id=e.student_id
+ WHERE WHERE e.year=2024
GROUP-Having GROUP BY c.name
+ ORDER-LIMIT ORDER BY COUNT(*) DESC LIMIT 1
Figure 1: A near-miss Text-to-SQL case illustrating the granularity gap between execution-level outcomes, token-level feedback, and clause-level SQL decisions. guidance about which intermediate SQL decision should be reinforced, repaired, or discouraged. In other words, query-level outcomes provide supervision without root-cause localization: they tell us that a query is wrong, but not which SQL decision caused the failure. A naïve remedy is to move from execution-level feedback to denser token-level feedback. However, token-level supervision is often too fine-grained for SQL semantics. Individual tokens such as aliases, commas, operators, or column names rarely form complete decisions on their own, while many SQL decisions are expressed by multi-token structures such as selected column sets, predicates, aggregations, or join paths. As a result, token-level feedback can diffuse credit across low-level symbols and require unreliable fine-grained labels. These limitations suggest that the right unit of process supervision should lie between the two extremes: denser than execution-level feedback but more semantically grounded than token-level feedback. We therefore focus on clause-level SQL units, which naturally group tokens into meaningful intermediate decisions such as SELECT, FROM/JOIN, WHERE, and GROUP BY/HAVING. Clause-level supervision preserves the scalability of outcome-derived feedback while assigning credit at a granularity closer to how SQL errors affect execution. The key missing step is to localize the root cause of failure at this semantic granularity before converting it into process supervision. This raises question Q : how can we derive clause-aligned supervision for Text-to-SQL from query-level execution outcomes, without requiring costly manual annotations while preserving execution correctness as the task objective? Our Solution. To solve question Q , we propose 1 CAPER, an automatic framework that uses counterfactual intervention to localize root-cause SQL decisions and construct clause-level preference supervision, and 2 CAPER-9B, a lightweight clause-level process reward model trained for process supervision. Methodologically, CAPER leverages ♣ counterfactual intervention, systematically perturbing the abstract syntax tree (AST) to identify the decisive error step responsible for failure. To enhance data diversity and ensure annotation precision, it further adopts ♠ fault injection, synthetically generating failure instances by perturbing successful ASTs through targeted corruption. Further, we fine-tune Qwen3.5-9B on the annotated dataset to obtain CAPER-9B and deploy it as a process reward model in reinforcement learning (RL) for Text-to-SQL, providing fine-grained clause-level rewards for intermediate SQL decisions. A multi-granular reward is designed to supervise RL training, emphasizing both clause-level and execution-level feedback. During policy optimization, this multi-granular reward design provides the policy model with both clause-level process feedback and execution-level outcome feedback, yielding denser supervision while preserving final execution accuracy as the task objective. In summary, our contributions are: Automated Pipeline. We propose a counterfactual SQL-AST pipeline for root-cause localization and clause-level credit assignment without manual annotation, which yields over 90,000 clauseannotated preference tuples across three datasets. 2 Clause-level PRM. We develop CAPER-9B, a lightweight clause-level process reward model for Text-to-SQL RL optimization through clause-boundary dense rewards, combining intermediate process feedback with final execution correctness. 1
2
3
Empirical Evaluation. Experiments show that RL with CAPER-9B achieves up to a 15.3% relative EX improvement over GPT-5.4, while CAPER-9B also reaches 84.53% top-1 failure-localization accuracy and 90.60% MRR on held-out failures.
2
Preliminary
In this section, we introduce the definition of Text-to-SQL and the objective of a process reward model. Text-to-SQL. Text-to-SQL is a task that converts a natural language question Q into a SQL query y capable of retrieving the correct answer from a database [19]. Given a database D = ⟨C, T ⟩, where C and T denote the sets of columns and tables, respectively, the Text-to-SQL task can be formulated as: y = f (Q, D | θ), (1) where f (· | θ) is the text-to-SQL model parameterized by θ. Process Reward Model. The process reward model (PRM) evaluates the correctness of each intermediate reasoning step, providing step-level supervision beyond the final answer [29]. Given an input x and a step-by-step solution z = (z1 , . . . , zK ), the reward of the k-th step can be formulated as: fψ (x, z≤k ) ∈ R, qψ (ℓk = positive | x, z≤k ) = σ(fψ (x, z≤k )) , (2) where fψ is the real-valued PRM score parameterized by ψ, qψ is the probability induced by the sigmoid link function, z≤k is the solution prefix up to step k, and ℓk is the process label of step zk . A conventional PRM can rank a complete solution by multiplying step probabilities, K Y rank RPRM (x, z) = qψ (ℓk = positive | x, z≤k ), (3) k=1
which estimates the probability that all intermediate steps are correct. In our RL formulation, we instead use the real-valued step scores as additive reward signals under the MDP return objective.
3
Methodology Successful Fault Injection Trajectory
Question Schema
Classification
Rollout
Failed Trajectory
Trajectory Pool
Input Data
Overview Pos. Trajectories
Annotation
Counterfactual Intervention
Neg. Trajectories
Training
I. Trajectory Collection
How many users were from New York? SEL ECT
SELECT COUNT(*) FROM users WHERE Location = 'NY';
User
SELECT … FROM …
Column Swap R
ROOT
COUNT
LLM
FROM
WHERE
=
USERS
LOCA TION
*
Operator Replacement R
'NY'
Correct AST Tree
Trajectory Pool
Filtering
Successful Trajectory
=
F
U
S
CNT
>
W
F
U
S
CNT
W
=
F
U
S
SUM
C NY
* L NY
* L NY
*
SELECT COUNT(*) FROM users WHERE City ='NY';
Wrong Column Wrong Operator
SELECT SUM(*) FROM users WHERE Location = 'NY';
Wrong Aggregator
"
0
-0.2 FROM
USERS
SELECT COUNT(*) FROM users WHERE LOCATION = 'NY';
R
SEL ECT
r s
f
w
…
…
…
AST Tree Failed Trajectory
SUM
*
FROM
USERS
WHERE
=
LOCA TION
Wrong AST Tree
R 'NY'
W
=
F
U
S AVG
…
Candidate Repairs
L
Execution Verification
NY
SUM
*
CNT
MAX
SELECT
S SUM
WHERE
L = NY
FROM
Dependent Path
SEL ECT
SUM
-0.5
-1.0
-0.5
Cause Node 𝑣 ∗
F
*
U
-0.5 -1 -0.5
SELECT FROM WHERE
0 0
0 0
-1 0
0
0
Final Clause Reward
III. Policy Optimization SELECT AVG(*) FROM users WHERE LOCATION = 'NY';
W = NY F U S SUM * Fault Localization
ROOT
Irrelevant Path
Neg. Trajectory Pool
L
AST Parsing
Node Sets
Clause Units
0
ROOT
SELECT COUNT(*) FROM users WHERE Location > 'NY';
𝜏 → AST Perturbation → 𝜏
Reward Aggregation
Node-level Reward
③. Counterfactual Intervention
Trajectory
Execution Result
W
!
②. Classification DB Execution
Aggregation Replacement R
Updated Policy LLM
II. Automatic Reward Annotation
③. Fault Injection
*
①. Rollout Collection
Optimization
Clause-Level PRM
Annotated Dataset
Repaired Trajectory
Counterfactual Intervention
Unsolved Trajectory
Annotated Dataset 𝒟
Clause-PRM Training Positive Clause
Question Trajectory
Negative Clause
Reward
Question Policy Model
RL Optimization
s!
s"
Clause-Level PRM
Clause Reward
Rollout
Policy Update
Execution Optimizer Reward
Figure 2: Overview of the CAPER framework. In this section, we propose CAPER, which first constructs clause-level preference supervision from successful and failed SQL trajectories, then trains a Clause-Level Process Reward Model (ClausePRM) on the resulting annotations, and finally uses it to provide clause-boundary rewards during Text-to-SQL policy optimization, as demonstrated in Figure 2. 3
3.1
Clause-Level Text-to-SQL Formulation
For policy optimization, we model SQL generation as an episodic MDP so that clause-aligned process scores can be incorporated into the trajectory return. At token step t, the state is the input and current SQL prefix st = (x, a<t ) with x = (Q, D), and the action at appends the next SQL token to the prefix. Under a policy πθ (at | st ), a rollout trajectory is τ = (s1 , a1 , r1 , s2 , a2 , r2 , . . . , sT , aT , rT , sT +1 ). Let G(τ ) =
PT
t=1 γ
t−1
(4)
rt denote its return. The policy objective is J(θ) = Eτ ∼πθ [G(τ )].
(5)
Although rollouts are token-level, intermediate feedback should operate at the clause level, since SQL errors usually arise from a small number of incorrect top-level clause decisions. We therefore instantiate the generic PRM step in Equation (2) as a top-level SQL clause unit. Definition 1 (Clause Unit). A clause unit is a semantically coherent top-level SQL component. We denote the k-th clause unit by ukκk , where uk is its content and κk ∈ K is its type: K = {W ITH, S ELECT, F ROM -J OIN, W HERE, G ROUP -H AVING, W INDOW, O RDER -L IMIT, S ET-O P}.
(6)
Here, W ITH covers CTEs; F ROM -J OIN groups FROM/JOIN/ON; G ROUP -H AVING groups GROUP BY/HAVING; W INDOW covers window functions and specifications; O RDER -L IMIT covers ORDER BY/LIMIT/OFFSET; and S ET-O P covers UNION/INTERSECT/EXCEPT. We decompose only the toplevel SQL structure; clauses inside nested subqueries are included in their enclosing clause unit. At the clause level, a generated SQL query is decomposed as y = (uκ1 1 , uκ2 2 , . . . , uκKK ).
(7)
Evaluating the k-th clause requires the preceding clause context, which we denote as κ
k−1 pk = (uκ1 1 , . . . , uk−1 ).
(8)
We then instantiate the PRM in Equation (2) as a real-valued clause preference scorer: fψ (x, pk , uκk k ) ∈ R,
(9)
where higher scores indicate clause units that are more consistent with the correct SQL continuation under (x, pk ). 3.2
Automatic Clause-Level Reward Annotation
The annotation stage of CAPER converts coarse trajectory-level outcomes into fine-grained clauselevel reward annotations. We begin by collecting a trajectory pool from a supervised fine-tuned policy, denoted by πSFT . Let X = {(xi , yi )}N i=1 be the set of training queries, where xi is the input question–schema pair and yi is the corresponding gold SQL query. For each input xi , the SFT model generates one rollout trajectory τi ∼ πSFT (· | xi ), which induces a terminal SQL query ŷ(τi ). This trajectory collection is separate from tuple construction: a single retained rollout can yield multiple clause-level preference tuples because fault injection may perturb several editable nodes and counterfactual repair may proceed across multiple divergent clauses. The collected trajectories are partitioned by their execution outcome. Let 1, if ŷ(τi ) is execution-equivalent to yi , Ω(τi ) = (10) 0, otherwise. be the indicator function for trajectory classification. Accordingly, we define T+ = {τi : Ω(τi ) = 1}, and T− = {τi : Ω(τi ) = 0}. +
(11)
The successful set T provides trusted positive trajectories for fault injection, whereas the failed set T− provides naturally occurring error trajectories for counterfactual intervention. Our goal is to construct clause-level reward annotations by either inducing a root-cause error on T+ or localizing a root-cause error on T− . 4
For each trajectory τ , we parse its terminal SQL y(τ ) into an abstract syntax tree (AST) G(τ ) = (V, E). According to Definition 1, each generated unit is associated with a subset of AST nodes through a clause-to-node mapping ϕ(uκk k ) = Vk ⊆ V . This mapping enables us to translate nodelevel structural errors on the AST into clause-level reward supervision for intermediate decisions along the trajectory. Fault Injection for Successful Trajectories. For τi ∈ T+ , the generated SQL is execution-correct and therefore provides a trusted positive reference. Using its AST, we sample one or more editable key nodes v ⋆ ∈ V and apply a type-preserving mutation operator µ to obtain corrupted trees G′ = µ(G, v ⋆ ). Each corrupted sample is retained only if its execution result differs from that of the original query, ensuring that the mutation induces a genuine semantic error. Counterfactual Intervention for Failed Trajectories. For τi ∈ T− , we recover clause-level supervision by comparing the predicted SQL against its gold counterpart. Let uκk k and ũκk k denote the predicted and gold clause units. We first identify the earliest divergent clause index k ⋆ = min{k : uκk k ̸= ũκk k } and then construct a counterfactual corrected query through an AST-level repair under the same prefix: y
cf
= Intervene(ŷ, pk⋆ , uκk⋆k⋆ 7→ ũκk⋆k⋆ ) ,
(12)
Localized divergent clause Gold SQL
Predicted SQL
ON c.course_id = e.course_id
ON c.course_id = e.student_id
Minimum-cost edit script " Predicted AST G
Corrected AST 𝑮𝒄𝒇
ON
ON
Root-cause node 𝒗∗
=
= e.student_id
e.course_id
c.course_id c.course_id where Intervene(·) reparses the whole SQL after repair, A.substitute(`e.student_id` →`e.course_id`) cost=1 canonicalizes aliases introduced by the repaired clause, and retains the counterfactual only when the resulting B.delete + insert cost=2 query is syntactically valid and executable. If a single repaired clause does not yield a valid counterfactual, we repeat on the earliest remaining divergence; each retained repair contributes a clause-level tuple. Figure 3 illustrates Figure 3: A counterfactual intervention this process. example.
We then identify the node-level source of this mismatch. Let Ĝ = Parse(ŷ) and Gcf = Parse(y cf ) denote the ASTs of the predicted and counterfactually corrected queries, and let Ξk⋆ (Ĝ, Gcf ) be the set of valid edit scripts that transform the divergent predicted clause into its corrected counterpart. We select the minimum-cost script and define the root-cause node v ⋆ as the anchor of its first edit: ξ ⋆ = arg
min
|ξ| X
ξ∈Ξk⋆ (Ĝ,Gcf ) m=1
c(ξm ),
v ⋆ = Anchor(ξ1⋆ ),
(13)
where c(ξm ) is the cost of the m-th node or edge edit, and Anchor(ξ1⋆ ) returns the touched node in Ĝ, or its parent attachment node for an insertion. Thus, ξ ⋆ is the smallest local transformation from the predicted clause to its counterfactual correction. Topology-Aware Node-Level Reward. Once the root-cause node v ⋆ is identified or induced, we assign a continuous penalty to each AST node v̂i ∈ V . Equation (13) localizes the clause-level mismatch anchor, while the distance below measures shortest-path distance to that anchor within Ĝ: d (v̂i , v ⋆ )2 Rnode (v̂i ; v ⋆ ) = −α M (v̂i , v ⋆ ) exp − Ĝ , (14) 2σd2 where M (v̂i , v ⋆ ) ∈ {0, 1} is a causal mask, and the graph distance dĜ (v̂i , v ⋆ ) = |ηĜ (v̂i , v ⋆ )| is the shortest-path distance on Ĝ, where ηĜ (v̂i , v ⋆ ) is the unique simple AST path connecting v̂i and v ⋆ , and |ηĜ | is the number of edges on that path. We set M (v̂i , v ⋆ ) = 1 only when v̂i is v ⋆ or an ancestor of v ⋆ within the enclosing clause-level AST region, and 0 otherwise. Here α > 0 is the maximum penalty magnitude, and σd controls the distance-decay bandwidth. The root-cause node itself receives the strongest penalty −α, while structurally upstream nodes on the same dependency path receive Gaussian-decayed negative reward. Unrelated branches are masked out and receive zero reward. Clause-Level Aggregation and Supervision Construction. To obtain supervision at the clause-unit level, we aggregate node-level penalties within each dispreferred unit: − Rclause (uκk k ; v ⋆ ) =
minκ Rnode (v̂i ; v ⋆ ).
v̂i ∈ϕ(uk k )
5
(15)
The minimum operator propagates the strongest node-level penalty inside a clause unit to the clause level, ensuring that a clause containing the decisive error inherits a strong non-positive label. − + − For each supervised clause pair (u+ k , uk ), where uk is the preferred clause unit and uk is the dispreferred clause unit, we use the preferred clause as a zero-penalty reference and define the margin by the dispreferred clause penalty: − ⋆ δk = −Rclause (u− k ; v ),
(16)
− ⋆ Since Rclause (u− k ; v ) ≤ 0 by construction, we have δk ≥ 0, with larger values indicating a more decisive structural error in the dispreferred clause.
Based on these clause-level rewards, we construct local supervision tuples under a shared input–prefix context. For successful trajectories, the original clause unit is preferred over its injected counterpart; for failed trajectories, the counterfactually corrected clause is preferred over the original failed clause. We therefore define D+ = (x, pk , (uκk k )+ , (uκk k )− , κk , δk ) τ ∈ T+ , (17) and
D− = (x, pk⋆ , (ũκk⋆k⋆ )+ , (uκk⋆k⋆ )− , κk⋆ , δk⋆ ) τ ∈ T− .
(18)
The final annotated dataset is D = D+ ∪ D− , where each tuple carries both a discrete preference label and a continuous margin δk reflecting the structural severity of the clause-level error. 3.3
Clause-Level Process Reward Model
Using the clause-level PRM in Equation (9), we train Clause-PRM on D. For each tuple − (x, pk , u+ k , uk , κk , δk ) ∈ D, we optimize the margin-weighted preference objective X 1 δk − LPRM = − log σ fψ (x, pk , u+ (19) 1+ k ) − fψ (x, pk , uk ) , |D| α + − (x,pk ,uk ,uk ,κk ,δk )∈D
where σ(·) is the sigmoid function and α is the maximum penalty magnitude in Equation (14). Thus, clause pairs with larger structural margins contribute stronger preference supervision. For policy optimization, the old policy samples a group of structured responses {z (g) }B g=1 for the same input x. Each response yields a SQL query ŷ (g) = ExtractSQL(z (g) ) and a clause sequence κg,K κg,1 (ûg,1 , . . . , ûg,Kgg ). At the k-th clause boundary, we assign h i κg,k (g) rg,k = Iformat (z (g) ) λfψ (x, p̂g,k , ûg,k ) + (1 − λ)1[k = Kg ]rexec , (20) where rexec = 1[Exec(ŷ (g) ) = Exec(y)]. Thus, the execution reward is added only once at the terminal clause boundary, while intermediate boundaries receive learned clause-level process rewards. The components are: (g)
• Format reward [18]: Iformat (z (g) ) = 1[ValidFormat(z (g) )] checks the response structure rather than SQL syntax; it equals 1 only when z (g) follows the required <think> · · · </think> and <answer> · · · </answer> format. κ
g,k • Clause reward: fψ (x, p̂g,k , ûg,k ) scores the current clause under the predicted prefix.
(g)
• Execution reward: rexec checks whether the predicted and gold SQL produce the same execution result. Instead of collapsing all clause rewards into a single trajectory-level advantage, we compute a PKg j−k clause-level return-to-go Gg,k = j=k γc rg,j where γc is a clause-level discount factor. We use GRPO-style normalization at each clause position. Let Bk = {g : Kg ≥ k} be the valid responses that contain a k-th clause. The clause-level group advantage is Ag,k =
Gg,k − mean({Gh,k : h ∈ Bk }) , std({Gh,k : h ∈ Bk }) + ϵstd 6
(21)
for g ∈ Bk . Let cg (t) ∈ {1, . . . , Kg } map token position t to the clause span whose boundary reward supervises that token. The clipped GRPO objective becomes |z (g) | B X X 1 1 LGRPO (θ) = −Ex,{z(g) } (22) min ρg,t Ag,cg (t) , ρ̄g,t Ag,cg (t) , B g=1 |z (g) | t=1 (g)
(g)
(g)
(g)
where ρg,t = πθ (zt | x, z<t )/πθold (zt | x, z<t ) and ρ̄g,t = clip(ρg,t , 1 − ϵclip , 1 + ϵclip ). This clause-level return-to-go preserves temporal credit assignment: tokens in a clause are optimized with the advantage of the remaining trajectory after that clause boundary, rather than a single trajectorylevel advantage shared by all tokens.
4
Experiments
4.1
Experiment Setup
Data and Models. We evaluate CAPER on BIRD [19] and Spider [20]. We first run Qwen3.5-9B on the training splits and then apply counterfactual intervention and fault injection to build over 90,000 clause-annotated preference tuples from BIRD-train, Spider-dev and SYNSQL-5k-train. We fine-tune Qwen3.5-9B on this data to obtain CAPER-9B as our clause-level PRM. For policy optimization, we start from a Qwen3.5-9B-SFT policy model (fine-tuned on BIRD-train and SYNSQL-5k [26]) and compare GRPO under sparse execution reward, token-level reward, and the clause-level reward from CAPER-9B. Evaluation Protocol. For end-to-end Text-to-SQL, we report execution accuracy (EX) [19] on the development set of BIRD, and both development and test sets of Spider under greedy decoding and Majority Vote@8 [18]. For failure localization, we hold out 10% of the annotated data and evaluate only failed trajectories. Each method ranks the clause units in a trajectory, and we report top-1 localization accuracy (Accloc ), Hit@3, and mean reciprocal rank (MRR). Baselines. For end-to-end evaluation, we compare against representative open- and closed-source Text-to-SQL LLMs, together with backbone-matched Qwen3.5-9B policies, including the supervised policy and GRPO variants under sparse, token, or clause-level rewards. For failure localization, we compare against heuristic selectors, prompted self-debugging, an execution-only reward model, and ablations of our annotation pipeline. For DeepEye-SQL, we use GPT-5.4 as the base model due to limited computational resources. Full baseline lists, hyperparameters, inference details, and hardware setup are provided in Section D. 4.2
Main Results
Our main question is the impact of clause-level supervision on RL itself: does a more semantically aligned reward improve policy optimization over sparse execution feedback or token-level shaping? Since Text-to-SQL is ultimately judged by end-to-end execution accuracy, we first evaluate ClausePRM by its effect on the final GRPO-trained policy on BIRD and Spider. As shown in Table 1, three trends are clear. First, within the backbone-matched setting, GRPO-Clause is the strongest policy under both greedy decoding and Majority Vote@8, showing that clause-level feedback improves both single-sample quality and the quality of sampled candidate sets. Second, the gains are more pronounced under Majority Vote@8, suggesting that clause-level supervision helps the policy produce candidates with more reliable overall semantics, not just locally better next-token decisions. Third, simply making the reward denser is not enough: token-level reward does not match the clause-level variant, and in several cases it also fails to improve over sparse-reward GRPO. Overall, the trend across BIRD and Spider supports our central claim that semantically aligned clause-level credit assignment transfers to better end-to-end Text-to-SQL behavior. 4.3
Failure Localization
We next evaluate whether Clause-PRM learns error attribution rather than only trajectory-level preference by asking each method to rank faulty clauses in held-out failed trajectories. As shown in Table 2, CAPER-9B achieves the best overall results across all three metrics. The strong S ELF D EBUG baseline suggests that prompted LLMs can often identify suspicious regions, but Clause-PRM 7
Table 1: Main execution accuracy (EX, %) on BIRD and Spider under greedy decoding (P@1) and Majority Vote@8 (MV@8), where the backbone-matched block compares Qwen3.5-9B-SFT with GRPO variants trained under sparse, token-level, and clause-level rewards; the best and second-best results are highlighted in bold and underlined, respectively. BIRD
Model
Spider Dev
P@1
MV@8
62.32 55.34 59.58 54.62 /
63.77 66.10 60.36 67.13 68.56
P@1
Spider Test
MV@8
Avg.
P@1
MV@8
P@1
MV@8
78.04 75.04 78.24 74.84 /
83.65 79.97 81.73 78.59 80.44
74.38 68.93 71.89 68.68 /
77.18 74.86 75.12 74.91 74.30
77.55 80.34 53.88 / 78.43
79.69 80.48 76.99 77.96 79.92
63.72 65.14 46.52 / 68.59
71.73 72.09 63.83 70.02 71.81
78.34 73.87
79.83 78.44
67.09 56.49
74.91 66.94
78.71 81.56 82.63 79.17
80.48 82.09 83.87 79.62
71.50 73.97 75.94 71.71
73.84 75.17 79.01 73.07
Closed-source LLMs Gemini-2.5-Pro [30] Claude Sonnet 4 [31] GPT-5.4 [32] Claude Sonnet 4.6 [33] DeepEye-SQL [34]
82.78 76.40 77.85 76.59 /
84.13 78.52 83.26 79.01 73.89
Open-source LLMs (7B–9B) OmniSQL-7B [18] SQL-R1-7B [26] XiyanSQL-7B [35] AlphaSQL [36] Qwen3.5-9B [37]
36.83 36.57 30.64 / 51.90
OmniSQL-14B [18] XiyanSQL-14B [35]
45.96 37.15
56.38 56.58 35.00 58.51 58.91
76.78 78.52 55.03 / 75.44
79.11 79.21 79.49 73.59 76.59
Open-source LLMs (≥14B) 65.71 42.11
76.98 58.46
79.20 80.27
Backbone-Matched Policies Qwen3.5-9B-SFT [37] GRPO-Sparse GRPO-Clause GRPO-Token
57.56 60.21 63.56 57.36
61.34 62.19 69.61 60.49
78.23 80.15 81.63 78.59
79.69 81.22 83.55 79.11
provides more reliable clause rankings through explicit clause-level supervision. The ablations further clarify where this gain comes from. Removing topology causes a large drop in top-1 accuracy while keeping Hit@3 relatively high, which suggests that the model can still place the faulty clause near the top of the list but struggles to rank it precisely without structural propagation. Removing fault injection or counterfactual supervision is even more damaging, pushing performance much closer to heuristic and execution-only baselines. Together, these trends indicate that strong failure localization does not come from generic reward modeling alone; it depends on combining clause-level supervision with topology-aware propagation and counterfactual error construction. Table 2: Failure localization on held-out failures. All metrics are reported in percentages. Accloc (%) ↑
Hit@3 (%) ↑
MRR (%) ↑
R ANDOM -C LAUSE L AST-C LAUSE Qwen3.5-9B (S ELF -D EBUG) Exec-RM-9B w/o Topology w/o Fault Injection w/o Counterfactual
25.90 9.82 82.78 25.93 45.50 22.20 26.02
76.34 53.49 93.56 71.50 89.96 80.17 83.06
52.51 38.60 86.35 50.82 67.34 51.24 54.31
CAPER-9B
84.53
96.58
90.60
Method
4.4
Clause-PRM as a Candidate Verifier
Beyond using Clause-PRM as a reward model for policy optimization, we further evaluate whether it can serve as a plug-and-play verifier for candidates generated by closed-source LLMs. This setting is motivated by black-box Text-to-SQL deployment, where practitioners often cannot update the generator but can sample multiple candidates and rerank them with an external verifier. For each question, all non-greedy selectors operate on the same eight sampled SQL candidates, so the comparison isolates the candidate selection rule rather than generation quality. As shown in Figure 4, CAPER-9B consistently improves over Majority Vote@8 across four closed-source generators and 8
Figure 4: Candidate verification gains over Majority Vote@8, where each selector ranks the same eight sampled SQL candidates and ∆EX measures the absolute execution-accuracy change over majority voting. three evaluation splits, with gains ranging from +0.7 to +1.6 EX points. In contrast, Exec-RM and random selection are less stable and often stay near or below majority voting. This suggests that majority voting can be limited by execution-result frequency, while terminal-label reward models provide only coarse candidate-level signals; clause-level process supervision offers a more transferable semantic quality signal for identifying candidates with reliable intermediate SQL decisions.
5
Related Work
Text-to-SQL. Text-to-SQL has progressed from early semantic parsing systems such as Seq2SQL [25] to cross-domain benchmarks like Spider [20], with later work improving structural modeling through intermediate representations, relation-aware schema encoding, and constrained decoding [38–40]. Recent studies further extend evaluation to more realistic settings, including BIRD and Spider 2.0, and increasingly rely on LLM-based decomposition and self-correction [19, 21, 41, 42, 24]. Despite this progress, surveys consistently highlight persistent brittleness under schema shift and spurious language-SQL correlations [43, 1]. Our work is most related to this robustness direction, focusing on counterfactual supervision rather than new parser architectures or prompting pipelines. Credit Assignment. Credit assignment remains difficult when rewards are sparse or delayed. Prior work addresses this problem through counterfactual attribution in logged feedback and RL, including Counterfactual Risk Minimization and its variants, COMA, and counterfactual off-policy evaluation [44–48]. Process supervision similarly shows that intermediate feedback can be more informative than pure outcome signals for long-horizon reasoning [49, 29]. In Text-to-SQL, recent work explores execution rewards, graph-based shaping, stepwise PRM guidance, and clause-wise critics [25–28, 50, 51]. Our method follows this credit-assignment perspective, but derives semantically grounded clause-level supervision from counterfactual AST perturbations for reward modeling and policy optimization.
6
Conclusion
This paper studies how to construct semantically meaningful process supervision for Text-to-SQL from coarse query-level outcomes. By attributing execution success and failure to clause-level SQL decisions, CAPER provides a practical credit assignment mechanism that avoids both sparse terminal labels and brittle token-level supervision. The resulting Clause-PRM improves failure localization, candidate verification, and GRPO-based policy optimization on BIRD and Spider, suggesting that clause-aligned process supervision is a scalable direction for structured generation.
9
References [1] Xinyu Liu, Shuyu Shen, Boyan Li, Peixian Ma, Runzhi Jiang, Yuxin Zhang, Ju Fan, Guoliang Li, Nan Tang, and Yuyu Luo. A survey of text-to-sql in the era of llms: Where are we, and where are we going? IEEE Transactions on Knowledge and Data Engineering, 37(10):5735–5754, 2025. doi: 10.1109/TKDE.2025.3592032. URL https://dblp.org/rec/journals/tkde/ LiuSLMJZFLTL25. [2] Zijin Hong, Zheng Yuan, Qinggang Zhang, Hao Chen, Junnan Dong, Feiran Huang, and Xiao Huang. Next-generation database interfaces: A survey of llm-based text-to-sql. IEEE Transactions on Knowledge and Data Engineering, 2025. [3] Yuyu Luo, Nan Tang, Guoliang Li, Wenbo Li, Tianyu Zhao, and Xiang Yu. Deepeye: A data science system for monitoring and exploring covid-19 data. IEEE Data Eng. Bull., 43(2): 121–132, 2020. [4] Yuyu Luo, Xuedi Qin, Chengliang Chai, Nan Tang, Guoliang Li, and Wenbo Li. Steerable self-driving data visualization. IEEE Transactions on Knowledge and Data Engineering, 34(1): 475–490, 2020. [5] Mounica Maddela, Lingjue Xie, Daniel Preoţiuc-Pietro, et al. Starqa: A question answering dataset for complex analytical reasoning over structured databases. In Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing, pages 34475–34487, 2025. [6] Vadim Sheinin, Elahe Khorashani, Hangu Yeo, Kun Xu, Ngoc Phuoc An Vo, and Octavian Popescu. Quest: a natural language interface to relational databases. In Proceedings of the Eleventh International Conference on Language Resources and Evaluation (LREC 2018), 2018. [7] Yongnan Chen, Zhuo Chang, Shijia Gu, Yuanhang Zong, Mei Zhang, Shiyu Wang, Zixiang He, HongZhi Chen, Wei Jin, and Bin Cui. ADEPT-SQL: A high-performance text-to-SQL application for real-world enterprise-level databases. In Pushkar Mishra, Smaranda Muresan, and Tao Yu, editors, Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations), pages 275–283, Vienna, Austria, July 2025. Association for Computational Linguistics. ISBN 979-8-89176-253-4. doi: 10.18653/v1/2025.acl-demo.27. URL https://aclanthology.org/2025.acl-demo.27/. [8] Keyan Xu, Dingzirui Wang, Xuanliang Zhang, Qingfu Zhu, and Wanxiang Che. Abacussql: a text-to-sql system empowering cross-domain and open-domain database retrieval. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations), pages 118–128, 2025. [9] Jichuan Zeng, Xi Victoria Lin, Steven C.H. Hoi, Richard Socher, Caiming Xiong, Michael Lyu, and Irwin King. Photon: A robust cross-domain text-to-SQL system. In Asli Celikyilmaz and Tsung-Hsien Wen, editors, Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics: System Demonstrations, pages 204–214, Online, July 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-demos.24. URL https: //aclanthology.org/2020.acl-demos.24/. [10] Jinyang Li, Xiaolong Li, Ge Qu, Per Jacobsson, Bowen Qin, Binyuan Hui, Shuzheng Si, Nan Huo, Xiaohan Xu, Yue Zhang, Ziwei Tang, Yuanshuai Li, Florensia Widjaja, Xintong Zhu, Feige Zhou, Yongfeng Huang, Yannis Papakonstantinou, Fatma Ozcan, Ma Chenhao, and Reynold Cheng. Swe-sql: Illuminating llm pathways to solve user sql issues in realworld applications. In Advances in Neural Information Processing Systems, volume 38, pages 97085–97120, 2025. URL https://proceedings.neurips.cc/paper_files/paper/ 2025/file/8bfbf4ec87e1e331f0b1adc483b53b6b-Paper-Conference.pdf. [11] Nan Huo, Xiaohan Xu, Jinyang Li, Per Jacobsson, Shipei Lin, Bowen Qin, Binyuan Hui, Xiaolong Li, Ge Qu, Shuzheng Si, Linheng Han, Edward Alexander, Xintong Zhu, Rui Qin, Ruihan Yu, Yiyao Jin, Feige Zhou, Weihao Zhong, Yun Chen, Hongyu Liu, Chenhao Ma, Fatma Ozcan, Yannis Papakonstantinou, and Reynold Cheng. BIRD-INTERACT: Re-imagining text-toSQL evaluation via lens of dynamic interactions. In The Fourteenth International Conference on Learning Representations, 2026. URL https://openreview.net/forum?id=nHrYBGujps. 10
[12] Yihan Wang, Peiyu Liu, and Xin Yang. Linkalign: Scalable schema linking for real-world large-scale multi-database text-to-sql. In Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing, pages 977–991, 2025. [13] Yujian Gan, Xinyun Chen, and Matthew Purver. Re-appraising the schema linking for textto-SQL. In Anna Rogers, Jordan Boyd-Graber, and Naoaki Okazaki, editors, Findings of the Association for Computational Linguistics: ACL 2023, pages 835–852, Toronto, Canada, July 2023. Association for Computational Linguistics. doi: 10.18653/v1/2023.findings-acl.53. URL https://aclanthology.org/2023.findings-acl.53/. [14] Mayank Kothyari, Dhruva Dhingra, Sunita Sarawagi, and Soumen Chakrabarti. CRUSH4SQL: Collective retrieval using schema hallucination for Text2SQL. In Houda Bouamor, Juan Pino, and Kalika Bali, editors, Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pages 14054–14066, Singapore, 2023. Association for Computational Linguistics. doi: 10.18653/v1/2023.emnlp-main.868. URL https://aclanthology.org/ 2023.emnlp-main.868/. [15] Zhenhe Wu, Zhongqiu Li, Jie Zhang, Zhongjiang He, Jian Yang, Yu Zhao, Ruiyu Fang, Bing Wang, Hongyan Xie, Shuangyong Song, et al. Ucs-sql: uniting content and structure for enhanced semantic bridging in text-to-sql. In Findings of the Association for Computational Linguistics: ACL 2025, pages 8156–8168, 2025. [16] Wenbo Xu, Haifeng Zhu, Liang Yan, Chuanyi Liu, Peiyi Han, Shaoming Duan, and Jeff Z Pan. Ts-sql: Test-driven self-refinement for text-to-sql. In Findings of the Association for Computational Linguistics: EMNLP 2025, pages 2864–2889, 2025. [17] Ge Qu, Jinyang Li, Bowen Qin, Xiaolong Li, Nan Huo, Chenhao Ma, and Reynold Cheng. Share: An slm-based hierarchical action correction assistant for text-to-sql. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 11268–11292, 2025. [18] Haoyang Li, Shang Wu, Xiaokang Zhang, Xinmei Huang, Jing Zhang, Fuxin Jiang, Shuai Wang, Tieying Zhang, Jianjun Chen, Rui Shi, et al. Omnisql: Synthesizing high-quality text-to-sql data at scale. Proceedings of the VLDB Endowment, 18(11):4695–4709, 2025. [19] Jinyang Li, Binyuan Hui, Ge Qu, Jiaxi Yang, Binhua Li, Bowen Li, Bailin Wang, Bowen Qin, Ruiying Geng, Nan Huo, Xuanhe Zhou, Chenhao Ma, Guoliang Li, Kevin Chen-Chuan Chang, Fei Huang, Reynold Cheng, and Yongbin Li. Can llm already serve as a database interface? a big bench for large-scale database grounded text-to-sqls. In Advances in Neural Information Processing Systems 36, 2023. URL https://proceedings.neurips.cc/paper_files/paper/2023/hash/ 83fc8fab1710363050bbd1d4b8cc0021-Abstract-Datasets_and_Benchmarks.html. [20] Tao Yu, Rui Zhang, Kai Yang, Michihiro Yasunaga, Dongxu Wang, Zifan Li, James Ma, Irene Li, Qingning Yao, Shanelle Roman, Zilin Zhang, and Dragomir Radev. Spider: A large-scale human-labeled dataset for complex and cross-domain semantic parsing and text-to-sql task. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pages 3911–3921, Brussels, Belgium, 2018. Association for Computational Linguistics. doi: 10.18653/v1/D18-1425. URL https://aclanthology.org/D18-1425/. [21] Fangyu Lei, Jixuan Chen, Yuxiao Ye, Ruisheng Cao, Dongchan Shin, Hongjin SU, ZHAOQING SUO, Hongcheng Gao, Wenjing Hu, Pengcheng Yin, Victor Zhong, Caiming Xiong, Ruoxi Sun, Qian Liu, Sida Wang, and Tao Yu. Spider 2.0: Evaluating language models on real-world enterprise text-to-SQL workflows. In The Thirteenth International Conference on Learning Representations, 2025. URL https://openreview.net/forum?id=XmProj9cPs. [22] Tomer Wolfson, Daniel Deutch, and Jonathan Berant. Weakly supervised text-to-SQL parsing through question decomposition. In Findings of the Association for Computational Linguistics: NAACL 2022, pages 2528–2542, Seattle, United States, July 2022. Association for Computational Linguistics. doi: 10.18653/v1/2022.findings-naacl.193. URL https://aclanthology.org/2022.findings-naacl.193/. 11
[23] Jipeng Zhang, Haolin Yang, Kehao Miao, Ruiyuan Zhang, Renjie Pi, Jiahui Gao, and Xiaofang Zhou. ExeSQL: Self-taught text-to-SQL models with execution-driven bootstrapping for SQL dialects. In Findings of the Association for Computational Linguistics: EMNLP 2025, pages 24305–24326, Suzhou, China, November 2025. Association for Computational Linguistics. ISBN 979-8-89176-335-7. doi: 10.18653/v1/2025.findings-emnlp.1320. URL https:// aclanthology.org/2025.findings-emnlp.1320/. [24] Mingqian He, Yongliang Shen, Wenqi Zhang, Qiuying Peng, Jun Wang, and Weiming Lu. Star-sql: Self-taught reasoner for text-to-sql. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 24365–24375, Vienna, Austria, 2025. Association for Computational Linguistics. doi: 10.18653/v1/2025. acl-long.1187. URL https://aclanthology.org/2025.acl-long.1187/. [25] Victor Zhong, Caiming Xiong, and Richard Socher. Seq2sql: Generating structured queries from natural language using reinforcement learning. CoRR, abs/1709.00103, 2017. doi: 10.48550/arXiv.1709.00103. URL https://arxiv.org/abs/1709.00103. [26] Ma Peixian, Xialie Zhuang, Chengjin Xu, Xuhui Jiang, Ran Chen, and Jian Guo. Sql-r1: Training natural language to sql reasoning model by reinforcement learning. In The Thirty-ninth Annual Conference on Neural Information Processing Systems, 2025. [27] Zhewei Yao, Guoheng Sun, Lukasz Borchmann, Gaurav Nuti, Zheyu Shen, Minghang Deng, Bohan Zhai, Hao Zhang, Ang Li, and Yuxiong He. Arctic-text2sql-r1: Simple rewards, strong reasoning in text-to-sql, 2025. URL https://arxiv.org/abs/2505.20315. [28] Han Weng, Puzhen Wu, Cui Longjie, Yi Zhan, Boyi Liu, Yuanfeng Song, Dun Zeng, Yingxiang Yang, Qianru Zhang, Dong Huang, Xiaoming Yin, Yang Sun, and Xing Chen. Graphreward-SQL: Execution-free reinforcement learning for text-to-SQL via graph matching and stepwise reward. In Findings of the Association for Computational Linguistics: EMNLP 2025, pages 12917–12943, Suzhou, China, November 2025. Association for Computational Linguistics. ISBN 979-8-89176-335-7. doi: 10.18653/v1/2025.findings-emnlp.694. URL https://aclanthology.org/2025.findings-emnlp.694/. [29] Hunter Lightman, Vineet Kosaraju, Yuri Burda, Harrison Edwards, Bowen Baker, Teddy Lee, Jan Leike, John Schulman, Ilya Sutskever, and Karl Cobbe. Let’s verify step by step. In The twelfth international conference on learning representations, 2023. [30] Gheorghe Comanici, Eric Bieber, Mike Schaekermann, Ice Pasupat, Noveen Sachdeva, Inderjit Dhillon, Marcel Blistein, Ori Ram, Dan Zhang, Evan Rosen, et al. Gemini 2.5: Pushing the frontier with advanced reasoning, multimodality, long context, and next generation agentic capabilities. arXiv preprint arXiv:2507.06261, 2025. [31] Anthropic. Claude Sonnet 4, 2025. URL https://www.anthropic.com/news/claude-4. [32] OpenAI. Introducing GPT-5.4, March 2026. introducing-gpt-5-4/.
URL https://openai.com/index/
[33] Anthropic. Introducing Claude Sonnet 4.6, February 2026. URL https://www.anthropic. com/research/claude-sonnet-4-6. [34] Boyan Li, Chong Chen, Zhujun Xue, Yinan Mei, and Yuyu Luo. Deepeye-sql: A softwareengineering-inspired text-to-sql framework. 2025. doi: 10.48550/arXiv.2510.17586. URL https://arxiv.org/abs/2510.17586. [35] Yifu Liu, Yin Zhu, Yingqi Gao, Zhiling Luo, Xiaoxia Li, Xiaorong Shi, Yuntao Hong, Jinyang Gao, Yu Li, Bolin Ding, and Jingren Zhou. Xiyan-sql: A novel multi-generator framework for text-to-sql. IEEE Transactions on Knowledge and Data Engineering, pages 1–14, 2026. doi: 10.1109/TKDE.2026.3657851. [36] Boyan Li, Jiayi Zhang, Ju Fan, Yanwei Xu, Chong Chen, Nan Tang, and Yuyu Luo. Alpha-SQL: Zero-shot text-to-SQL using Monte Carlo tree search. In Proceedings of the 42nd International Conference on Machine Learning, volume 267 of Proceedings of Machine Learning Research, pages 36810–36830. PMLR, 2025. URL https://proceedings.mlr.press/ v267/li25dt.html. 12
[37] QwenTeam. Qwen3.5: Towards native multimodal agents, 2026. URL https://qwen.ai/ blog?id=qwen3.5. [38] Jiaqi Guo, Zecheng Zhan, Yan Gao, Yan Xiao, Jian-Guang Lou, Ting Liu, and Dongmei Zhang. Towards complex text-to-sql in cross-domain database with intermediate representation. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 4524–4535, Florence, Italy, 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1444. URL https://aclanthology.org/P19-1444/. [39] Bailin Wang, Richard Shin, Xiaodong Liu, Oleksandr Polozov, and Matthew Richardson. Ratsql: Relation-aware schema encoding and linking for text-to-sql parsers. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 7567–7578, Online, 2020. Association for Computational Linguistics. doi: 10.18653/v1/2020.acl-main.677. URL https://aclanthology.org/2020.acl-main.677/. [40] Torsten Scholak, Nathan Schucher, and Dzmitry Bahdanau. Picard: Parsing incrementally for constrained auto-regressive decoding from language models. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pages 9895–9901, Online and Punta Cana, Dominican Republic, 2021. Association for Computational Linguistics. doi: 10. 18653/v1/2021.emnlp-main.779. URL https://aclanthology.org/2021.emnlp-main. 779/. [41] Mohammadreza Pourreza and Davood Rafiei. Din-sql: Decomposed in-context learning of textto-sql with self-correction. In Advances in Neural Information Processing Systems, volume 36, pages 36339–36348, 2023. URL https://proceedings.neurips.cc/paper_files/ paper/2023/file/72223cc66f63ca1aa59edaec1b3670e6-Paper-Conference.pdf. [42] Dawei Gao, Haibin Wang, Yaliang Li, Xiuyu Sun, Yichen Qian, Bolin Ding, and Jingren Zhou. Text-to-sql empowered by large language models: A benchmark evaluation. Proceedings of the VLDB Endowment, 17(5):1132–1145, 2024. doi: 10.14778/3641204.3641221. URL https://dblp.org/rec/journals/pvldb/GaoWLSQDZ24. [43] Naihao Deng, Yulong Chen, and Yue Zhang. Recent advances in text-to-sql: A survey of what we have and what we expect. In Proceedings of the 29th International Conference on Computational Linguistics, pages 2166–2187, Gyeongju, Republic of Korea, 2022. International Committee on Computational Linguistics. URL https://aclanthology.org/2022.coling-1.190/. [44] Adith Swaminathan and Thorsten Joachims. Counterfactual risk minimization: Learning from logged bandit feedback. In Proceedings of the 32nd International Conference on Machine Learning, volume 37 of Proceedings of Machine Learning Research, pages 814–823, Lille, France, 2015. PMLR. URL https://proceedings.mlr.press/v37/swaminathan15.html. [45] Ben London and Ted Sandler. Bayesian counterfactual risk minimization. In Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pages 4125–4133. PMLR, 2019. URL https://proceedings. mlr.press/v97/london19a.html. [46] Houssam Zenati, Eustache Diemert, Matthieu Martin, Julien Mairal, and Pierre Gaillard. Sequential counterfactual risk minimization. In Proceedings of the 40th International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, pages 40681– 40706. PMLR, 2023. URL https://proceedings.mlr.press/v202/zenati23a.html. [47] Jakob N. Foerster, Gregory Farquhar, Triantafyllos Afouras, Nantas Nardelli, and Shimon Whiteson. Counterfactual multi-agent policy gradients. In Proceedings of the Thirty-Second AAAI Conference on Artificial Intelligence, pages 2974–2982. AAAI Press, 2018. doi: 10.1609/ AAAI.V32I1.11794. URL https://dblp.org/rec/conf/aaai/FoersterFANW18.html. [48] Michael Oberst and David Sontag. Counterfactual off-policy evaluation with gumbel-max structural causal models. In Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pages 4881–4890. PMLR, 2019. URL https://proceedings.mlr.press/v97/oberst19a.html. 13
[49] Jonathan Uesato, Nate Kushman, Ramana Kumar, Francis Song, Noah Siegel, Lisa Wang, Antonia Creswell, Geoffrey Irving, and Irina Higgins. Solving math word problems with process- and outcome-based feedback. 2022. doi: 10.48550/ARXIV.2211.14275. URL https://arxiv.org/abs/2211.14275. [50] Yuxin Zhang, Meihao Fan, Ju Fan, Mingyang Yi, Yuyu Luo, Jian Tan, and Guoliang Li. RewardSQL: Boosting text-to-SQL via stepwise reasoning and process-supervised rewards, 2025. URL https://arxiv.org/abs/2505.04671. [51] Jikai Chen, Leilei Gan, Ziyu Zhao, Zechuan Wang, Dong Wang, and Chenyi Zhuang. SQLCritic: Correcting text-to-SQL generation via clause-wise critic, 2025. URL https://arxiv.org/ abs/2503.07996.
14
A
Limitations
While our proposed method demonstrates significant improvements in Text-to-SQL reinforcement learning, there are several limitations to consider. First, the clause-level reward model is trained on a specific set of datasets and may not generalize well to other domains or SQL dialects without further fine-tuning. Second, we focus on SQL Generation rather than Chain of Thought (CoT) reasoning, and our method may not directly apply to other structured generation tasks that require different forms of intermediate supervision. Third, CAPER currently decomposes SQL only at the top-level clause granularity, which can still be coarse when the decisive error lies inside a clause, such as one predicate in a conjunctive WHERE condition or an internal subquery; although the same annotation procedure can in principle be applied recursively to obtain hierarchical rewards at the clause, sub-clause, and token levels, we restrict this work to the first level to keep the experimental cost manageable. Finally, the automated annotation pipeline introduces additional computational and engineering overhead because it requires SFT rollouts, AST parsing, counterfactual repair or fault injection, and repeated execution checks; this cost is higher than using sparse terminal execution rewards alone, although the resulting annotations can be reused for PRM training.
B
Theoretical Analysis of Reward Propagation
This section gives deterministic bounds for the topology-aware reward in Equation (14) and the clause-level aggregation in Equation (15). These results do not require any distributional assumption; they follow directly from the bounded mask, nonnegative AST distance, and the monotonicity of the Gaussian kernel. Lemma 1 (Bounds of Gaussian node propagation). Let α > 0, σd > 0, Mi = M (v̂i , v ⋆ ) ∈ {0, 1}, and di = dĜ (v̂i , v ⋆ ) ≥ 0. The node-level reward d2i ⋆ Rnode (v̂i ; v ) = −αMi exp − 2 2σd satisfies −α ≤ Rnode (v̂i ; v ⋆ ) ≤ 0. If Mi = 0, then Rnode (v̂i ; v ⋆ ) = 0. If Mi = 1 and di ≤ D, then D2 ⋆ −α ≤ Rnode (v̂i ; v ) ≤ −α exp − 2 . 2σd Moreover, for unmasked nodes, Rnode is monotone nondecreasing in di , equivalently the error severity −Rnode is monotone nonincreasing in di . Proof. Since di ≥ 0 and σd > 0, d2 0 < exp − i2 2σd
≤ 1.
Together with Mi ∈ {0, 1}, this gives d2 0 ≤ Mi exp − i2 2σd
≤ 1.
Multiplying by −α yields −α ≤ Rnode (v̂i ; v ⋆ ) ≤ 0. If Mi = 0, the reward is exactly zero. If Mi = 1 and di ≤ D, the Gaussian term is decreasing in di , so D2 d2 exp − 2 ≤ exp − i2 ≤ 1. 2σd 2σd Multiplying by −α gives the stated local bound. Finally, when Mi = 1, ∂Rnode αdi d2i = 2 exp − 2 ≥ 0, ∂di σd 2σd so the negative reward becomes weaker as the node moves farther from the anchor, while the corresponding severity −Rnode decreases with distance. 15
Lemma 2 (Bounds of minimum clause aggregation). For a nonempty clause unit u, define the active node set A(u; v ⋆ ) = {v̂i ∈ ϕ(u) : M (v̂i , v ⋆ ) = 1}. The clause-level reward in Equation (15) satisfies − −α ≤ Rclause (u; v ⋆ ) ≤ 0. − If A(u; v ⋆ ) = ∅, then Rclause (u; v ⋆ ) = 0. Otherwise, let
dmin (u) =
min
v̂i ∈A(u;v ⋆ )
dĜ (v̂i , v ⋆ ),
Du =
max
v̂i ∈A(u;v ⋆ )
dĜ (v̂i , v ⋆ ).
Then the minimum aggregation has the exact form − Rclause (u; v ⋆ ) = −α exp
dmin (u)2 − 2σd2
,
and therefore D2 − −α ≤ Rclause (u; v ⋆ ) ≤ −α exp − u2 ≤ 0. 2σd Proof. By Theorem 1, every node reward lies in [−α, 0]. The minimum over the nonempty set ϕ(u) must therefore also lie in [−α, 0], proving the global bound. If A(u; v ⋆ ) = ∅, then every node in the clause has mask value zero, hence every node reward is zero and the minimum is zero. If A(u; v ⋆ ) ̸= ∅, inactive nodes have reward zero and cannot determine the minimum because active nodes have nonpositive rewards. Thus d (v̂i , v ⋆ )2 − Rclause (u; v ⋆ ) = min ⋆ −α exp − Ĝ . 2σd2 v̂i ∈A(u;v ) The Gaussian term is decreasing in distance, and the leading negative sign means the most negative reward is achieved by the active node closest to v ⋆ . Therefore the minimum equals dmin (u)2 . −α exp − 2σd2 Since dmin (u) ≤ Du , the same monotonicity gives the stated upper bound. Equivalently, if si = −Rnode (v̂i ; v ⋆ ) ≥ 0 denotes node-level error severity, then − −Rclause (u; v ⋆ ) = max si , v̂i ∈ϕ(u)
so minimum reward aggregation is exactly maximum severity aggregation over nodes in the clause. This preserves the decisive local error rather than diluting it by clause length.
C
Algorithm Details
The details of the annotation pipeline are shown in Algorithm 1. Complexity Analysis. Let M = |T+ | + |T− | be the number of trajectories to annotate, and let N upper-bound the SQL length, number of clause units, AST size, and tokenized Clause-PRM input length for any trajectory. Clause splitting, AST traversal, fault injection, and clause-to-node reward aggregation are linear in N . The only super-linear algorithmic component is F IRST D IVERGENCE, which performs clause-restricted edit-script computation; using a standard tree-edit dynamic program, this step costs O(N 3 ) in the worst case. For database execution, let D upper-bound the number of rows in any table and let J be the maximum number of joined tables in a generated query. Without assuming a particular index or query plan, one execution has worst-case cost O(DJ ). Therefore, the worst-case offline annotation complexity is O M (N 3 + DJ ) . The storage complexity is O(M N ) when storing the retained clause preference tuples explicitly, or O(M ) if the tuples store references to the original SQL strings. During policy optimization, a rollout 16
Algorithm 1 Automatic Clause-Level Reward Annotation Input: T− , T+ , µ, ϕ Output: D 1: D − ← ∅, D + ← ∅ 2: /* Part 1: Fault Injection on T+ */ 3: for τ ∈ T+ do 4: G ← Parse(ŷ), Vedit ← SampleEditable(G) 5: for v ⋆ ∈ Vedit do 6: G′ ← µ(G, v ⋆ ) 7: if Exec(Decode(G′ )) ̸= Exec(Decode(G)) then ′ 8: k ← ClauseIndex(v ⋆ ; ϕ), u+ u− k ← [ClauseSplit(ŷ)]k , k ← [ClauseSplit(Decode(G ))]k − − ⋆ 9: δk ← −Rclause (uk ; v ) − 10: D+ ← D+ ∪ {(x, pk , u+ k , uk , κk , δk )} 11: end if 12: end for 13: end for 14: /* Part 2: Counterfactual Intervention on T− */ 15: for τ ∈ T− do 16: x ← x(τ ), ŷ ← y(τ ), ỹ ← y gt (τ ) 17: Kdiv ← {k : uk ̸= ũk } 18: for k⋆ ∈ Kdiv do 19: y cf ← Repair(ŷ, ỹ, pk⋆ ) 20: if Valid(y cf ) then 21: v ⋆ ← FirstDivergence(Parse(ŷ), Parse(y cf )) cf ⋆ ⋆ 22: ũ+ u− k⋆ ← [ClauseSplit(y )]k , k⋆ ← [ClauseSplit(ŷ)]k − ⋆ 23: δk⋆ ← −Rclause (u− ; v ) k⋆ − ⋆ ⋆ 24: D− ← D− ∪ {(x, pk⋆ , ũ+ k⋆ , uk⋆ , κk , δk )} 25: end if 26: end for 27: end for 28: return D ← D − ∪ D +
group of size B contains at most BN clause boundaries. A Transformer Clause-PRM forward pass over an O(N )-length input costs O(N 2 ) when the model architecture is fixed, so reward scoring and terminal execution together add O B(N 3 + DJ ) , where the BN 3 term comes from BN clause-boundary PRM calls and the BDJ term comes from one terminal execution per rollout. In practice, clause-boundary PRM scores are batched, which improves wall-clock efficiency without changing the asymptotic bound.
D
Experimental Setup Details
CAPER-9B Data Split. We train CAPER-9B on the final clause-annotated training split and use a heldout evaluation split for model selection and failure-localization evaluation. As shown in Table 3, the final split contains 82,081 training rows and 9,166 held-out evaluation rows, drawn from BIRD-train, SYNSQL-5k-train, and Spider-dev. Table 3: CAPER-9B training and held-out evaluation data statistics. Split
Total Rows
BIRD-Train
SYNSQL-5k-Train
Spider-Dev
Train Eval
82,081 9,166
58,090 6,488
19,668 2,197
4,323 481
Training Configuration. We fine-tune Qwen3.5-9B on the clause-annotated dataset to obtain CAPER-9B. For policy optimization, we first train a supervised Qwen3.5-9B-SFT policy and then initialize GRPO from this checkpoint. We set the maximum penalty magnitude α in Equation (14) to 1.0, the Gaussian distance bandwidth σd in Equation (14) to 1.0, and the balance factor λ in Equation (20) to 0.5. RL training uses batch size 16, 8 rollouts, and learning rate 1 × 10−6 . 17
GRPO-Token Baseline. GRPO-Token uses the same initialization checkpoint, GRPO objective, rollout number, batch size, learning rate, and terminal execution reward as GRPO-Clause, but replaces the learned clause-level process reward with heuristic token-level dense shaping. Specifically, after extracting the SQL from the <answer> field, we canonicalize keyword casing and whitespace, tokenize the generated and gold SQL strings, and assign a token process reward 1[ŝt = s⋆t ] at each SQL-token position t when both positions exist, and 0 otherwise. The terminal execution reward is still added only once at the final token. This baseline isolates the effect of making rewards dense at the token level without training an additional token-level PRM. Inference and Metrics. For end-to-end evaluation, we report execution accuracy (EX) [19]. Given N evaluation examples with predicted SQL ŷi and gold SQL yi , N
EX =
1 X 1[Exec(ŷi ) = Exec(yi )] . N i=1
(23)
Greedy decoding with temperature 0 corresponds to P@1. For Majority Vote@8, we sample candi(m) dates {ŷi }8m=1 with temperature 0.8, group them by execution result, and choose a candidate from the largest group: 8 i h X 1 Exec(ŷi(m) ) = r ,
riMV = arg max r
(m)
ŷiMV@8 ∈ {ŷi
(m)
: Exec(ŷi
) = riMV }.
(24)
m=1
The reported MV@8 is EX computed with ŷi = ŷiMV@8 . For candidate verification, we report the absolute gain over majority voting, ∆EX = EX(ŷ selector ) − EX(ŷ MV@8 ).
(25)
For failure localization, each method ranks the clause units in a failed trajectory. Let πi denote the predicted ranking from most to least likely faulty for held-out failure i, ki⋆ denote the annotated faulty clause, and ρi = rankπi (ki⋆ ). For M held-out failures, we compute M
Accloc =
1 X 1[ρi = 1], M i=1
M
Hit@3 =
1 X 1[ρi ≤ 3], M i=1
M
MRR =
1 X 1 . M i=1 ρi
(26)
Full Baseline List. For end-to-end evaluation, we compare against representative Text-toSQL models of varying scales, including Gemini-2.5-Pro [30], Claude Sonnet 4 [31], GPT-5.4 [32], Claude Sonnet 4.6 [33], DeepEye-SQL [34], OmniSQL-7B [18], SQL-R1-7B [26], XiyanSQL-7B [35], AlphaSQL [36], Qwen3.5-9B [37], OmniSQL-14B [18], and XiyanSQL-14B [35]. Within the backbone-matched policy block, we additionally compare the supervised Qwen3.5-9B-SFT policy and GRPO variants trained under sparse, clause-level, and token-level rewards, as listed in Table 1. For failure localization, we compare CAPER-9B against four classes of baselines: (1) heuristic selectors, including R ANDOM -C LAUSE and L AST-C LAUSE; (2) prompted self-debugging with Qwen3.5-9B, which directly predicts the faulty clause from the failed trajectory; (3) an execution-only reward model Exec-RM-9B trained from terminal execution labels without clause-level supervision; and (4) ablated variants of our approach, including w/o Topology, w/o Fault Injection, and w/o Counterfactual Intervention. Environment. All experiments are conducted on a server with 8 NVIDIA A100 (80GB) GPUs. RL training is implemented with OpenRLHF1 . We summarize the measured compute for the main local training and evaluation stages in Table 4; GPU-hours are computed as the number of GPUs multiplied by wall-clock hours. Existing Assets and Licenses. We use public datasets, model checkpoints, software, and API services under their stated licenses or access terms, summarized in Table 5. For derived artifacts released with this submission, the supplemental code package includes a README with asset links, preprocessing steps, release notes, and applicable terms. 1 https://github.com/openrlhf/openrlhf
18
Table 4: Compute resources for the main local training and evaluation stages. Stage Clause-PRM training GRPO policy optimization Evaluation
Hardware
Wall-clock Time
GPU-hours
8 A100 (80GB) 8 A100 (80GB) 2 A100 (80GB)
4 h 39 m 19 h 1 m 46 s 2h
37.2 152.2 4.0
Table 5: Existing assets used in this work and their licenses or access terms. Asset
Use in this work
License / access terms
BIRD [19] Spider [20] SynSQL-Complex-5K [26] Qwen3.5-9B [37] OmniSQL-7B/14B [18] SQL-R1-7B [26] XiYanSQL-7B/14B [35] AlphaSQL [36] DeepEye-SQL [34] OpenRLHF GPT, Claude, and Gemini APIs [32, 31, 33, 30]
Training and evaluation data Training and evaluation data Synthetic training data Base policy and PRM backbone Open-source Text-to-SQL baselines Open-source Text-to-SQL baseline Open-source Text-to-SQL baselines Baseline system and reported comparison Baseline system and reported comparison RL training framework Closed-source LLM baselines and candidate generation
CC BY-SA 4.0 Apache-2.0 Apache-2.0 Apache-2.0 Apache-2.0 Hugging Face releases: 7B, 14B Apache-2.0 Apache-2.0 Hugging Face releases: 7B, 14B MIT MIT Apache-2.0 Provider terms: OpenAI Service Terms, Anthropic Commercial Terms, Gemini API Additional Terms
E
Candidate Verification Case Study
We provide a qualitative example from BIRD Dev to illustrate why clause-level verification can be more reliable than selecting candidates by sampling frequency or terminal-only reward scores. As shown in Figure 5, the question asks for the Italian flavor text of the card Ancestor’s Chosen in the card_games database. The gold query must join cards with foreign_data through uuid, because the card name is stored in cards, whereas the localized flavor text and language are stored in foreign_data. Dataset: BIRD Dev
|
Generator: GPT-5.4
|
Database: card_games
Question: What is the Italian flavor text of the card 'Ancestor's Chosen'? CAPER-9B| Correct
Gold SQL SELECT T2.flavorText FROM cards AS T1 JOIN foreign_data AS T2 ON T2.uuid = T1.uuid WHERE T1.name = 'Ancestor's Chosen' AND T2.language = 'Italian'; requires cards <-> foreign_data join
Random | Mismatch
SELECT fd.flavorText FROM `foreign_data` AS fd JOIN `cards` AS c ON fd.`uuid` = c.`uuid` WHERE c.`name` = 'Ancestor's Chosen' AND fd.`language` = 'Italian';
SELECT `flavorText` FROM `foreign_data` WHERE `name` = 'Ancestor's Chosen' AND `language` = 'Italian';
selected: correct join structure
missing join path
Majority Vote | Mismatch
Exec-RM | Mismatch
SELECT `flavorText` FROM `foreign_data` WHERE `language` = 'Italian' AND `name` = 'Ancestor's Chosen';
SELECT `flavorText` FROM `foreign_data` WHERE `name` = 'Ancestor's Chosen' AND `language` = 'Italian';
missing join path
missing join path
Figure 5: Candidate verification case study on BIRD Dev with GPT-5.4 candidates. Random, Majority Vote@8, and Exec-RM select candidates that directly filter foreign_data by card name and therefore miss the required cards–foreign_data join. CAPER-9B selects the only candidate that matches the gold join structure. This example exposes a common failure mode for simpler selectors. The incorrect candidates mention the requested output column and language condition, but they omit the schema-level dependency between the English card name and its localized foreign record. As a result, Random, Majority Vote@8, and Exec-RM all choose candidates that fail execution correctness. In contrast, CAPER-9B selects the candidate that preserves the required clause structure: the join between cards and foreign_data, the name filter on cards, and the language filter on foreign_data. This case suggests that clause-level process supervision provides a transferable structural quality signal when terminal-only or frequency-based selectors prefer superficially plausible SQL. 19
F
Evaluation Prompt Example Example Evaluation Prompt Task Overview: You are a data science expert. Below, you are provided with a database schema and a natural language question. Your task is to understand the schema and generate a valid SQL query to answer the question. Database Engine: SQLite Database ID: formula_1 Database Schema: CREATE TABLE ‘circuits‘ ( ‘circuitId‘ INTEGER, ‘circuitRef‘ TEXT, ‘name‘ TEXT, ‘location‘ TEXT, ‘country‘ TEXT, ‘lat‘ REAL, ‘lng‘ REAL, ‘alt‘ INTEGER, ‘url‘ TEXT, PRIMARY KEY (‘circuitId‘) ); CREATE TABLE ‘constructors‘ ( ‘constructorId‘ INTEGER, ‘constructorRef‘ TEXT, ‘name‘ TEXT, ‘nationality‘ TEXT, ‘url‘ TEXT, PRIMARY KEY (‘constructorId‘) ); CREATE TABLE ‘drivers‘ ( ‘driverId‘ INTEGER, ‘driverRef‘ TEXT, ‘number‘ INTEGER, ‘code‘ TEXT, ‘forename‘ TEXT, ‘surname‘ TEXT, ‘dob‘ DATE, ‘nationality‘ TEXT, ‘url‘ TEXT, PRIMARY KEY (‘driverId‘) ); CREATE TABLE ‘seasons‘ ( ‘year‘ INTEGER, ‘url‘ TEXT, PRIMARY KEY (‘year‘) ); CREATE TABLE ‘races‘ ( ‘raceId‘ INTEGER, ‘year‘ INTEGER, ‘round‘ INTEGER, ‘circuitId‘ INTEGER, ‘name‘ TEXT, ‘date‘ DATE, ‘time‘ TEXT, ‘url‘ TEXT, PRIMARY KEY (‘raceId‘) ); CREATE TABLE ‘constructorResults‘ ( ‘constructorResultsId‘ INTEGER, ‘raceId‘ INTEGER, ‘constructorId‘ INTEGER, ‘points‘ REAL, ‘status‘ TEXT, PRIMARY KEY (‘constructorResultsId‘) ); CREATE TABLE ‘constructorStandings‘ ( ‘constructorStandingsId‘ INTEGER, ‘raceId‘ INTEGER,
20
‘constructorId‘ INTEGER, ‘points‘ REAL, ‘position‘ INTEGER, ‘positionText‘ TEXT, ‘wins‘ INTEGER, PRIMARY KEY (‘constructorStandingsId‘) ); CREATE TABLE ‘driverStandings‘ ( ‘driverStandingsId‘ INTEGER, ‘raceId‘ INTEGER, ‘driverId‘ INTEGER, ‘points‘ REAL, ‘position‘ INTEGER, ‘positionText‘ TEXT, ‘wins‘ INTEGER, PRIMARY KEY (‘driverStandingsId‘) ); CREATE TABLE ‘lapTimes‘ ( ‘raceId‘ INTEGER, ‘driverId‘ INTEGER, ‘lap‘ INTEGER, ‘position‘ INTEGER, ‘time‘ TEXT, ‘milliseconds‘ INTEGER, PRIMARY KEY (‘raceId‘, ‘driverId‘, ‘lap‘) ); CREATE TABLE ‘pitStops‘ ( ‘raceId‘ INTEGER, ‘driverId‘ INTEGER, ‘stop‘ INTEGER, ‘lap‘ INTEGER, ‘time‘ TEXT, ‘duration‘ TEXT, ‘milliseconds‘ INTEGER, PRIMARY KEY (‘raceId‘, ‘driverId‘, ‘stop‘) ); CREATE TABLE ‘qualifying‘ ( ‘qualifyId‘ INTEGER, ‘raceId‘ INTEGER, ‘driverId‘ INTEGER, ‘constructorId‘ INTEGER, ‘number‘ INTEGER, ‘position‘ INTEGER, ‘q1‘ TEXT, ‘q2‘ TEXT, ‘q3‘ TEXT, PRIMARY KEY (‘qualifyId‘) ); CREATE TABLE ‘status‘ ( ‘statusId‘ INTEGER, ‘status‘ TEXT, PRIMARY KEY (‘statusId‘) ); CREATE TABLE ‘results‘ ( ‘resultId‘ INTEGER, ‘raceId‘ INTEGER, ‘driverId‘ INTEGER, ‘constructorId‘ INTEGER, ‘number‘ INTEGER, ‘grid‘ INTEGER, ‘position‘ INTEGER, ‘positionText‘ TEXT, ‘positionOrder‘ INTEGER, ‘points‘ REAL, ‘laps‘ INTEGER, ‘time‘ TEXT, ‘milliseconds‘ INTEGER, ‘fastestLap‘ INTEGER, ‘rank‘ INTEGER, ‘fastestLapTime‘ TEXT, ‘fastestLapSpeed‘ TEXT, ‘statusId‘ INTEGER, PRIMARY KEY (‘resultId‘) ); -- Foreign Keys: -- ‘races‘.‘circuitId‘ can be joined with ‘circuits‘.‘circuitId‘ -- ‘races‘.‘year‘ can be joined with ‘seasons‘.‘year‘ -- ‘constructorResults‘.‘constructorId‘ can be joined with ‘constructors‘.‘constructorId‘
21
-- ‘constructorResults‘.‘raceId‘ can be joined with ‘races‘.‘raceId‘ -- ‘constructorStandings‘.‘constructorId‘ can be joined with ‘constructors‘.‘constructorId‘ -- ‘constructorStandings‘.‘raceId‘ can be joined with ‘races‘.‘raceId‘ -- ‘driverStandings‘.‘driverId‘ can be joined with ‘drivers‘.‘driverId‘ -- ‘driverStandings‘.‘raceId‘ can be joined with ‘races‘.‘raceId‘ -- ‘lapTimes‘.‘driverId‘ can be joined with ‘drivers‘.‘driverId‘ -- ‘lapTimes‘.‘raceId‘ can be joined with ‘races‘.‘raceId‘ -- ‘pitStops‘.‘driverId‘ can be joined with ‘drivers‘.‘driverId‘ -- ‘pitStops‘.‘raceId‘ can be joined with ‘races‘.‘raceId‘ -- ‘qualifying‘.‘constructorId‘ can be joined with ‘constructors‘.‘constructorId‘ -- ‘qualifying‘.‘driverId‘ can be joined with ‘drivers‘.‘driverId‘ -- ‘qualifying‘.‘raceId‘ can be joined with ‘races‘.‘raceId‘ -- ‘results‘.‘statusId‘ can be joined with ‘status‘.‘statusId‘ -- ‘results‘.‘constructorId‘ can be joined with ‘constructors‘.‘constructorId‘ -- ‘results‘.‘driverId‘ can be joined with ‘drivers‘.‘driverId‘ -- ‘results‘.‘raceId‘ can be joined with ‘races‘.‘raceId‘ This schema describes the database’s structure, including tables, columns, primary keys, foreign keys, and any relevant relationships or constraints. Question: Please list the location coordinates of the US circuits. Output Rules: 1. You must output exactly one <think>...</think> block followed by one <answer>...</answer> block. 2. Inside <answer>, include exactly one ‘‘‘sql ... ‘‘‘ block containing runnable SQLite SQL. 3. Do not output any text before <think> or after </answer>. 4. Do not use <sql>...</sql>. 5. Keep <think> concise (<=120 words) so the final <answer> is never dropped. Evidence: location coordinates refers to (lat, lng); the US refers to country = ’USA’; Instructions: - Make sure you only output the information that is asked in the question. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more. - The generated query should return all of the information asked in the question without any missing or extra information. - Note that while the reasoning process and SQL query need to be enclosed within <think> </think> and <answer> </answer> tags respectively, this should not affect the quality of the SQL generation. - The answer must contain the SQL query within ‘‘‘sql ‘‘‘ tags. Output Format: In your answer, please enclose the generated SQL query in a code block: """sql -- Your SQL query """ Take a deep breath and think step by step to find the correct SQL query.
22
NeurIPS Paper Checklist 1. Claims Question: Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? Answer: [Yes] Justification: We claimed in the abstract and introduction that we proposed an automatic annotation pipeline for clause-level reward annotation, developed a lightweight clause-level process reward model, improved Text-to-SQL execution accuracy, and improved failure localization. Guidelines: • The answer [N/A] means that the abstract and introduction do not include the claims made in the paper. • The abstract and/or introduction should clearly state the claims made, including the contributions made in the paper and important assumptions and limitations. A [No] or [N/A] answer to this question will not be perceived well by the reviewers. • The claims made should match theoretical and experimental results, and reflect how much the results can be expected to generalize to other settings. • It is fine to include aspirational goals as motivation as long as it is clear that these goals are not attained by the paper. 2. Limitations Question: Does the paper discuss the limitations of the work performed by the authors? Answer: [Yes] Justification: We discuss limitations in Section A, including dataset and SQL-dialect scope, clause-granularity limits, and the computational overhead of annotation. Guidelines: • The answer [N/A] means that the paper has no limitation while the answer [No] means that the paper has limitations, but those are not discussed in the paper. • The authors are encouraged to create a separate “Limitations” section in their paper. • The paper should point out any strong assumptions and how robust the results are to violations of these assumptions (e.g., independence assumptions, noiseless settings, model well-specification, asymptotic approximations only holding locally). The authors should reflect on how these assumptions might be violated in practice and what the implications would be. • The authors should reflect on the scope of the claims made, e.g., if the approach was only tested on a few datasets or with a few runs. In general, empirical results often depend on implicit assumptions, which should be articulated. • The authors should reflect on the factors that influence the performance of the approach. For example, a facial recognition algorithm may perform poorly when image resolution is low or images are taken in low lighting. Or a speech-to-text system might not be used reliably to provide closed captions for online lectures because it fails to handle technical jargon. • The authors should discuss the computational efficiency of the proposed algorithms and how they scale with dataset size. • If applicable, the authors should discuss possible limitations of their approach to address problems of privacy and fairness. • While the authors might fear that complete honesty about limitations might be used by reviewers as grounds for rejection, a worse outcome might be that reviewers discover limitations that aren’t acknowledged in the paper. The authors should use their best judgment and recognize that individual actions in favor of transparency play an important role in developing norms that preserve the integrity of the community. Reviewers will be specifically instructed to not penalize honesty concerning limitations. 3. Theory assumptions and proofs 23
Question: For each theoretical result, does the paper provide the full set of assumptions and a complete (and correct) proof? Answer: [Yes] Justification: We provide the lemmas and corresponding proofs in Section B. Guidelines: • The answer [N/A] means that the paper does not include theoretical results. • All the theorems, formulas, and proofs in the paper should be numbered and crossreferenced. • All assumptions should be clearly stated or referenced in the statement of any theorems. • The proofs can either appear in the main paper or the supplemental material, but if they appear in the supplemental material, the authors are encouraged to provide a short proof sketch to provide intuition. • Inversely, any informal proof provided in the core of the paper should be complemented by formal proofs provided in appendix or supplemental material. • Theorems and Lemmas that the proof relies upon should be properly referenced. 4. Experimental result reproducibility Question: Does the paper fully disclose all the information needed to reproduce the main experimental results of the paper to the extent that it affects the main claims and/or conclusions of the paper (regardless of whether the code and data are provided or not)? Answer: [Yes] Justification: The paper provides detailed descriptions of the dataset curation process, model and parameter configuration, benchmarks and evaluation metrics, baselines, and the environment used for experiments in the main text. Additional details on data splits, hyperparameters, and other experimental settings are provided in the supplemental material. Guidelines: • The answer [N/A] means that the paper does not include experiments. • If the paper includes experiments, a [No] answer to this question will not be perceived well by the reviewers: Making the paper reproducible is important, regardless of whether the code and data are provided or not. • If the contribution is a dataset and/or model, the authors should describe the steps taken to make their results reproducible or verifiable. • Depending on the contribution, reproducibility can be accomplished in various ways. For example, if the contribution is a novel architecture, describing the architecture fully might suffice, or if the contribution is a specific model and empirical evaluation, it may be necessary to either make it possible for others to replicate the model with the same dataset, or provide access to the model. In general. releasing code and data is often one good way to accomplish this, but reproducibility can also be provided via detailed instructions for how to replicate the results, access to a hosted model (e.g., in the case of a large language model), releasing of a model checkpoint, or other means that are appropriate to the research performed. • While NeurIPS does not require releasing code, the conference does require all submissions to provide some reasonable avenue for reproducibility, which may depend on the nature of the contribution. For example (a) If the contribution is primarily a new algorithm, the paper should make it clear how to reproduce that algorithm. (b) If the contribution is primarily a new model architecture, the paper should describe the architecture clearly and fully. (c) If the contribution is a new model (e.g., a large language model), then there should either be a way to access this model for reproducing the results or a way to reproduce the model (e.g., with an open-source dataset or instructions for how to construct the dataset). (d) We recognize that reproducibility may be tricky in some cases, in which case authors are welcome to describe the particular way they provide for reproducibility. In the case of closed-source models, it may be that access to the model is limited in 24
some way (e.g., to registered users), but it should be possible for other researchers to have some path to reproducing or verifying the results. 5. Open access to data and code Question: Does the paper provide open access to the data and code, with sufficient instructions to faithfully reproduce the main experimental results, as described in supplemental material? Answer: [Yes] Justification: We provide anonymized supplemental materials for data construction, model training, and evaluation, including scripts and instructions for reproducing the main experimental results. Guidelines: • The answer [N/A] means that paper does not include experiments requiring code. • Please see the NeurIPS code and data submission guidelines (https://neurips.cc/ public/guides/CodeSubmissionPolicy) for more details. • While we encourage the release of code and data, we understand that this might not be possible, so [No] is an acceptable answer. Papers cannot be rejected simply for not including code, unless this is central to the contribution (e.g., for a new open-source benchmark). • The instructions should contain the exact command and environment needed to run to reproduce the results. See the NeurIPS code and data submission guidelines (https: //neurips.cc/public/guides/CodeSubmissionPolicy) for more details. • The authors should provide instructions on data access and preparation, including how to access the raw data, preprocessed data, intermediate data, and generated data, etc. • The authors should provide scripts to reproduce all experimental results for the new proposed method and baselines. If only a subset of experiments are reproducible, they should state which ones are omitted from the script and why. • At submission time, to preserve anonymity, the authors should release anonymized versions (if applicable). • Providing as much information as possible in supplemental material (appended to the paper) is recommended, but including URLs to data and code is permitted. 6. Experimental setting/details Question: Does the paper specify all the training and test details (e.g., data splits, hyperparameters, how they were chosen, type of optimizer) necessary to understand the results? Answer: [Yes] Justification: The paper specifies the dataset curation process, model and parameter configuration, benchmarks, evaluation metrics, baselines, and experimental environment in the main text and appendix. Additional data splits, hyperparameters, and inference details are provided in Section D. Guidelines: • The answer [N/A] means that the paper does not include experiments. • The experimental setting should be presented in the core of the paper to a level of detail that is necessary to appreciate the results and make sense of them. • The full details can be provided either with the code, in appendix, or as supplemental material. 7. Experiment statistical significance Question: Does the paper report error bars suitably and correctly defined or other appropriate information about the statistical significance of the experiments? Answer: [No] Justification: We do not report error bars, confidence intervals, or statistical significance tests because full repeated RL training with large language models is computationally expensive. We instead report controlled comparisons, ablations, and results across multiple datasets and decoding settings. 25
Guidelines: • The answer [N/A] means that the paper does not include experiments. • The authors should answer [Yes] if the results are accompanied by error bars, confidence intervals, or statistical significance tests, at least for the experiments that support the main claims of the paper. • The factors of variability that the error bars are capturing should be clearly stated (for example, train/test split, initialization, random drawing of some parameter, or overall run with given experimental conditions). • The method for calculating the error bars should be explained (closed form formula, call to a library function, bootstrap, etc.) • The assumptions made should be given (e.g., Normally distributed errors). • It should be clear whether the error bar is the standard deviation or the standard error of the mean. • It is OK to report 1-sigma error bars, but one should state it. The authors should preferably report a 2-sigma error bar than state that they have a 96% CI, if the hypothesis of Normality of errors is not verified. • For asymmetric distributions, the authors should be careful not to show in tables or figures symmetric error bars that would yield results that are out of range (e.g., negative error rates). • If error bars are reported in tables or plots, the authors should explain in the text how they were calculated and reference the corresponding figures or tables in the text. 8. Experiments compute resources Question: For each experiment, does the paper provide sufficient information on the computer resources (type of compute workers, memory, time of execution) needed to reproduce the experiments? Answer: [Yes] Justification: The paper reports the GPU type and memory, the RL framework, key training hyperparameters, and measured wall-clock time and GPU-hours for Clause-PRM training, GRPO policy optimization, and evaluation in Section D. Guidelines: • The answer [N/A] means that the paper does not include experiments. • The paper should indicate the type of compute workers CPU or GPU, internal cluster, or cloud provider, including relevant memory and storage. • The paper should provide the amount of compute required for each of the individual experimental runs as well as estimate the total compute. • The paper should disclose whether the full research project required more compute than the experiments reported in the paper (e.g., preliminary or failed experiments that didn’t make it into the paper). 9. Code of ethics Question: Does the research conducted in the paper conform, in every respect, with the NeurIPS Code of Ethics https://neurips.cc/public/EthicsGuidelines? Answer: [Yes] Justification: The work uses public Text-to-SQL benchmarks, model checkpoints, software, and API services under their stated licenses or access terms; does not involve human subjects, crowdsourcing, or newly collected personal data; and documents limitations, potential negative societal impacts, compute resources, release documentation, and asset licenses in the paper, appendix, checklist, and supplementary material. Guidelines: • The answer [N/A] means that the authors have not reviewed the NeurIPS Code of Ethics. • If the authors answer [No], they should explain the special circumstances that require a deviation from the Code of Ethics. 26
• The authors should make sure to preserve anonymity (e.g., if there is a special consideration due to laws or regulations in their jurisdiction). 10. Broader impacts Question: Does the paper discuss both potential positive societal impacts and negative societal impacts of the work performed? Answer: [Yes] Justification: The paper discusses positive impacts from improving the efficiency and accessibility of Text-to-SQL systems, as well as potential negative impacts from incorrect SQL generation, over-reliance on automated database access, and misuse on sensitive databases. Guidelines: • The answer [N/A] means that there is no societal impact of the work performed. • If the authors answer [N/A] or [No], they should explain why their work has no societal impact or why the paper does not address societal impact. • Examples of negative societal impacts include potential malicious or unintended uses (e.g., disinformation, generating fake profiles, surveillance), fairness considerations (e.g., deployment of technologies that could make decisions that unfairly impact specific groups), privacy considerations, and security considerations. • The conference expects that many papers will be foundational research and not tied to particular applications, let alone deployments. However, if there is a direct path to any negative applications, the authors should point it out. For example, it is legitimate to point out that an improvement in the quality of generative models could be used to generate Deepfakes for disinformation. On the other hand, it is not needed to point out that a generic algorithm for optimizing neural networks could enable people to train models that generate Deepfakes faster. • The authors should consider possible harms that could arise when the technology is being used as intended and functioning correctly, harms that could arise when the technology is being used as intended but gives incorrect results, and harms following from (intentional or unintentional) misuse of the technology. • If there are negative societal impacts, the authors could also discuss possible mitigation strategies (e.g., gated release of models, providing defenses in addition to attacks, mechanisms for monitoring misuse, mechanisms to monitor how a system learns from feedback over time, improving the efficiency and accessibility of ML). 11. Safeguards Question: Does the paper describe safeguards that have been put in place for responsible release of data or models that have a high risk for misuse (e.g., pre-trained language models, image generators, or scraped datasets)? Answer: [N/A] Justification: The paper does not release data or models that have a high risk for misuse; the released artifacts are limited to Text-to-SQL annotation, training, and evaluation assets. Guidelines: • The answer [N/A] means that the paper poses no such risks. • Released models that have a high risk for misuse or dual-use should be released with necessary safeguards to allow for controlled use of the model, for example by requiring that users adhere to usage guidelines or restrictions to access the model or implementing safety filters. • Datasets that have been scraped from the Internet could pose safety risks. The authors should describe how they avoided releasing unsafe images. • We recognize that providing effective safeguards is challenging, and many papers do not require this, but we encourage authors to take this into account and make a best faith effort. 12. Licenses for existing assets 27
Question: Are the creators or original owners of assets (e.g., code, data, models), used in the paper, properly credited and are the license and terms of use explicitly mentioned and properly respected? Answer: [Yes] Justification: We cite the original papers for datasets, models, and software, summarize their licenses or provider access terms in Table 5, and include asset links and release notes in the supplemental README. Guidelines: • The answer [N/A] means that the paper does not use existing assets. • The authors should cite the original paper that produced the code package or dataset. • The authors should state which version of the asset is used and, if possible, include a URL. • The name of the license (e.g., CC-BY 4.0) should be included for each asset. • For scraped data from a particular source (e.g., website), the copyright and terms of service of that source should be provided. • If assets are released, the license, copyright information, and terms of use in the package should be provided. For popular datasets, paperswithcode.com/datasets has curated licenses for some datasets. Their licensing guide can help determine the license of a dataset. • For existing datasets that are re-packaged, both the original license and the license of the derived asset (if it has changed) should be provided. • If this information is not available online, the authors are encouraged to reach out to the asset’s creators. 13. New assets Question: Are new assets introduced in the paper well documented and is the documentation provided alongside the assets? Answer: [Yes] Justification: We release a new clause-annotated dataset and a clause-level process reward model; the README in the supplemental code package documents data construction, splits, training configuration, evaluation protocol, and limitations. Guidelines: • The answer [N/A] means that the paper does not release new assets. • Researchers should communicate the details of the dataset/code/model as part of their submissions via structured templates. This includes details about training, license, limitations, etc. • The paper should discuss whether and how consent was obtained from people whose asset is used. • At submission time, remember to anonymize your assets (if applicable). You can either create an anonymized URL or include an anonymized zip file. 14. Crowdsourcing and research with human subjects Question: For crowdsourcing experiments and research with human subjects, does the paper include the full text of instructions given to participants and screenshots, if applicable, as well as details about compensation (if any)? Answer: [N/A] Justification: The paper does not involve crowdsourcing or research with human subjects. Guidelines: • The answer [N/A] means that the paper does not involve crowdsourcing nor research with human subjects. • Including this information in the supplemental material is fine, but if the main contribution of the paper involves human subjects, then as much detail as possible should be included in the main paper. 28
• According to the NeurIPS Code of Ethics, workers involved in data collection, curation, or other labor should be paid at least the minimum wage in the country of the data collector. 15. Institutional review board (IRB) approvals or equivalent for research with human subjects Question: Does the paper describe potential risks incurred by study participants, whether such risks were disclosed to the subjects, and whether Institutional Review Board (IRB) approvals (or an equivalent approval/review based on the requirements of your country or institution) were obtained? Answer: [N/A] Justification: The paper does not involve crowdsourcing or research with human subjects. Guidelines: • The answer [N/A] means that the paper does not involve crowdsourcing nor research with human subjects. • Depending on the country in which research is conducted, IRB approval (or equivalent) may be required for any human subjects research. If you obtained IRB approval, you should clearly state this in the paper. • We recognize that the procedures for this may vary significantly between institutions and locations, and we expect authors to adhere to the NeurIPS Code of Ethics and the guidelines for their institution. • For initial submissions, do not include any information that would break anonymity (if applicable), such as the institution conducting the review. 16. Declaration of LLM usage Question: Does the paper describe the usage of LLMs if it is an important, original, or non-standard component of the core methods in this research? Note that if the LLM is used only for writing, editing, or formatting purposes and does not impact the core methodology, scientific rigor, or originality of the research, declaration is not required. Answer: [Yes] Justification: The paper describes the use of LLMs as the Text-to-SQL policy, clause-level process reward model, and evaluation baselines in the methodology and experimental setup. LLM assistance used only for writing and editing did not affect the core methodology, scientific rigor, or originality of the work. Guidelines: • The answer [N/A] means that the core method development in this research does not involve LLMs as any important, original, or non-standard components. • Please refer to our LLM policy in the NeurIPS handbook for what should or should not be described.
29