Execution feedback can mislead text-to-SQL selectors when incomplete query outputs are treated as conclusive evidence. BASIL-W represents observations as scope-aware witnesses containing the executed SQL, its output, completion status, and certified scope. An absence claim requires a completed check covering the claimed predicate and domain. A 2x2 factorial experiment varies scope metadata and an explicit instruction while holding the model, candidates, and probes fixed. On the full Spider and WikiSQL test splits with GPT-4.1, execution accuracy increases from 85.98% to 88.50% and from 90.50% to 91.60% (all six paired contrasts Holm-adjusted p<0.006). The combined interface outperforms either factor alone. The arm ordering also holds with Qwen2.5-Coder-32B and Llama-3.3-70B and on BIRD dev, where the gain reaches +3.7 percentage points. Observed margins over the strongest matched selection baseline are +1.58 on Spider, +1.76 on BIRD dev, and +0.15 on WikiSQL; these comparisons lack paired uncertainty estimates. The Spider audit found unsupported absence-claim rates of 12.0% for raw evidence and 4.3% for BASIL-W. The design does not isolate scope content from prompt length or presentation, and the audit does not establish a causal mechanism.
Figures & tables
Figure 1: BASIL-W generation and selection pipeline. BASIL denotes the graph-guided candidate branch; BASIL-W adds scope-aware selection. The 2,048-token limit applies to selected schema records only. The factorial comparison intervenes at the evidence interface while preserving candidate queries and observations.
Observation and execution status
Licensed interpretation
exists over exactly Qϕ
1 : presence; 0 : Qϕ(D)=∅
Ungrouped COUNT(*) over Qϕ
>0 : presence; 0 : absence
Scan with a verified matching tuple
presence, within that tuple’s provenance
Scan without a matching tuple
absence only if Covers(qo;U,ϕ) and co=1 ; else unknown
Error, timeout, or unverified match between probe and claim
unknown
Table 1: Absence requires successful completion and a verified match to the claimed predicate and domain. A matching tuple can establish presence even in an incomplete scan.
Raw observation ( A00 )
Scope-aware witness ( A11 )
probe p1: SELECT name FROM dept ORDER BY id rows shown (preview cap 12): Sales, HR, Legal, …, Audit
query: p1 (same SQL, no LIMIT) outcome: ok boundary: stopped at preview cap 12; cursor not exhausted result_complete: no covers(dept): no absence_established: no
probe p2: SELECT EXISTS(SELECT 1 FROM dept WHERE name = ?) [‘Finance’] rows (1): 1
check: p2 (same SQL and parameter) outcome: ok result_complete: yes scope: predicate dept.name = ‘Finance’ result: true (present)
Instruction ( I=1 ): Absence requires a completed check covering the claimed predicate; a preview or timeout is insufficient.
Figure 2: Illustrative serialization of the same two cached observations for the raw arm (left) and BASIL-W (right): identical SQL, parameters and output; only annotations and the instruction differ. The planner stops reading p1 at the twelve-row cap, so the result is incomplete and does not cover dept, where Finance sits beyond row twelve (with LIMIT 12 it would be complete yet still not cover the table). The completed check p2 finds Finance. Field names are abbreviated for readability.
Test
Arm
Correct
EX (%) [95% CI]
Δ raw
Unsupp. / claims
W / L
Holm p
Spider
Raw ( A00 )
1,846
85.98 [84.45, 87.38]
ref.
72/600 (12.00%)
90 / 36
4.9×10−6
Spider
Metadata ( A10 )
1,870
87.10 [85.61, 88.45]
+1.12
43/560 (7.68%)
70 / 40
5.4×10−3
Spider
Instruction ( A01 )
1,862
86.73 [85.22, 88.10]
+0.75
52/580 (8.97%)
78 / 40
1.2×10−3
Spider
BASIL-W ( A11 )
1,900
88.50 [87.08, 89.78]
+2.52
22/510 (4.31%)
—
—
WikiSQL
Raw ( A00 )
14,370
90.50 [90.04, 90.95]
ref.
220/2,000 (11.00%)
260 / 86
1.1×10−20
WikiSQL
Metadata ( A10 )
14,433
90.90 [90.44, 91.34]
+0.40
155/1,910 (8.12%)
190 / 79
4.1×10−11
Table 2: Factorial comparison on the full Spider ( n=2,147 ) and WikiSQL ( n=15,878 ) test splits with GPT-4.1; all arms share model, candidate pool and cached observations. EX has Wilson 95% intervals; Δ is the gain over raw evidence in percentage points. W/L counts BASIL-W wins/losses against the arm in that row; Holm p tests that same paired contrast, adjusted across all six comparisons. Unsupp. / claims is unsupported over audited absence assertions (Spider: seeded 400-question sample; WikiSQL: descriptive counts over collected assertions from an unrecorded sample, not population estimates).
Selector (same pool, GPT-4.1)
Spider
WikiSQL
BIRD dev
USC-style, no observations
84.54
89.94
63.89
Matched judge, no probes
85.42
90.44
65.06
Raw evidence ( A00 )
85.98
90.50
65.71
Execution-majority voting
86.35
91.45
66.30
MCS-SQL-style selection prompt
86.91
91.37
67.67
BASIL-W ( A11 )
88.50
91.60
69.43
Table 3: Selection baselines using the same candidate pools. Execution accuracy is reported as percentages, with differences in percentage points.
Arm
Claims
Unsupp.
Unres.
κ
Questions
Raw
600
72 (12.00%)
18
0.872
59/400 (14.8%)
Metadata
560
43 (7.68%)
16
0.845
38/400 (9.5%)
Instruction
580
52 (8.97%)
17
0.821
46/400 (11.5%)
BASIL-W
510
22 (4.31%)
14
0.809
20/400 (5.0%)
Table 4: Spider absence-claim audit, GPT-4.1, 400 questions sampled by seed before inspection: all absence assertions per arm, those adjudicated unsupported or unresolved, Cohen’s κ between blinded annotators (raw agreement 95.9–97.7%), and questions with an unsupported assertion.
Test
System
Backbone / strategy
Training
EX (%)
Δ (pp)
Spider
SIRIUS-SQL ( Luo et al., 2026 )
32B specialist + Gemini 3.1 Pro
fine-tuned
91.20
−2.70
Spider
DeepEye-SQL ( Li et al., 2026a )
Qwen3-Coder-30B-A3B, SE-style workflow
prompt-only
89.8
−1.30
Spider
OmniSQL + MV ( Li et al., 2025 )
OmniSQL-32B, majority voting
fine-tuned
89.8
−1.30
Spider
XiYan-SQL ( Liu et al., 2025 )
Qwen2.5-Coder ensemble + GPT-4o
fine-tuned
89.65
−1.15
Spider
MCS-SQL ( Lee et al., 2025 )
GPT-4, multi-prompt, multiple-choice
prompt-only
89.6
−1.10
Spider
Arctic-Text2SQL-R1 ( Yao et al., 2026 )
32B, RL-trained, greedy
RL
88.7
−0.20
Table 5: Published test scores next to BASIL-W: reference points, not matched comparisons (backbones, candidate budgets, training and WikiSQL access differ). DIN-SQL and DAIL-SQL report test-suite accuracy and are omitted.
Figure 3: (a) EX gain over raw evidence per arm (Table 6 ). (b) Unsupported absence-claim rates, GPT-4.1; WikiSQL counts describe the collected assertions only. (c) BASIL-W beside published Spider test scores (Table 5 ).
Benchmark
Backbone
Raw
Metadata
Instruction
BASIL-W
Δ raw
Oracle@3
Headroom
Recovered
γ^
Spider test
GPT-4.1
85.98
87.10
86.73
88.50
+2.52
93.99
8.01
31.4%
+0.65
Spider test
Qwen2.5-Coder-32B
82.25
83.42
83.09
84.54
+2.28
90.13
7.87
29.0%
+0.28
Spider test
Llama-3.3-70B
80.02
80.76
80.53
81.04
+1.02
87.70
7.69
13.3%
−0.23
BIRD dev
GPT-4.1
65.71
67.21
66.62
69.43
+3.72
78.03
12.32
30.2%
+1.30
BIRD dev
Qwen2.5-Coder-32B
60.63
62.45
61.93
63.95
+3.32
74.25
13.62
24.4%
+0.20
BIRD dev
Llama-3.3-70B
57.50
58.87
58.28
59.84
+2.35
71.25
13.75
17.1%
+0.20
Table 6: EX (%) of the four arms across backbones and benchmarks, each with its own fixed three-candidate pool; derived columns computed from integer counts. Headroom: raw selection misses over n (pp); Recovered: share of those misses BASIL-W removes; γ^ : interaction point estimate (pp), no interval.
Text-to-SQL systems increasingly combine candidate generation with query selection. When these two roles share a model, can learning to select better queries also improve generation? Both tasks require judging how faithfully SQL operations express a natural-language question, making candidate comparison a potential source of supervision for generation. We investigate this connection by training a shared model for SQL generation and selection. Starting from a tool-using generator trained with execution rewards, we apply preference learning to candidate selection and use the resulting checkpoint for both roles. We analyze how selection updates can benefit generation through shared parameters and evaluate the generated candidate pools before selection, using the same tools and sampling settings. On BIRD Dev, selection preference training raises generation-only pass@16 from 81.79% to 82.83%, increasing the coverage of questions with at least one correct candidate. The resulting model achieves 74.67% execution accuracy when used for both generation and selection. These findings show that learning to compare SQL candidates provides a training signal that improves candidate generation and raises the ceiling for final query selection.Our model is publicly available at https://huggingface.co/Kwai-AutoSQL/Kwai-AutoSQL-27B.
Text-to-SQL on complex schemas is unreliable on a single pass, so recent systems generate multiple SQL candidates and let voting filter out errors. Yet voting alone is not enough, because the multi-candidate recipe has three coupled weaknesses: 1) sampling more from a single generator produces increasingly redundant candidates, 2) existing pipelines apply one generic correction to every non-clean execution result, while runtime errors, timeouts, and empty results each indicate a different distance from correctness, and 3) existing selectors rely on a single angle such as result-majority voting or pairwise SQL comparison, missing what other angles would have caught. We present SIRIUS-SQL, which addresses all three weaknesses. A difficulty-smoothing RL recipe trains SIRIUS-32B to generate diverse executable SQL candidates, paired with a generalist LLM that fills in gaps left by the specialist. An execution-grounded lifecycle classifies each outcome and applies targeted repair before candidates re-enter the pool. A confidence-gated hybrid selector combines execution-result agreement with pairwise SQL-form judgment, escalating only near-tied cases to a deterministic structural check. SIRIUS-SQL reaches 75.88% on BIRD dev and 91.20% on SPIDER test. Two of three generalist pairings surpass Agentar-Scale-SQL, the strongest published multi-candidate system on BIRD dev.
Leo Luo, Haining Xie, Siqi Shen +8
TEG, Tencent Inc., China · 2Peking University, China
LLM-based agents for text-to-SQL often struggle with latency-performance trade-off, where performance improvements come at the cost of latency or vice versa. We reformulate text-to-SQL generation within the lens of software test coverage where the original query is prepared with a suite of test cases with simpler, atomic SQLs that are executed in parallel and together ensure semantic coverage of the original query. After iterating on test case coverage, the final SQL is generated only when enough information is gathered, leveraging the explored test case SQLs to ground the final generation. We validated our framework on a state-of-the-art benchmark for text-to-SQL, Spider 2.0, achieving a new state-of-the-art with 70.2% execution accuracy.