Organizations: School of Computer Science, Guangdong University of Technology · Guangdong Laboratory of Artificial Intelligence and Digital Economy (SZ) · Peng Cheng Laboratory · College of Science, Shantou University
Generative language models have shown significant potential in single-turn Text-to-SQL. However, their performance does not extend equivalently to multi-turn Text-to-SQL. This is primarily due to generative language models' inadequacy in handling the complexities of context information and dynamic schema linking in multi-turn interactions. In this paper, we propose a framework named Track-SQL, which enhances generative language models with dual-extractive modules designed to track schema and contextual changes in multi-turn Text-to-SQL. Specifically, Track-SQL incorporates a Semantic-enhanced Schema Extractor and a Schema-aware Context Extractor. Experimental results demonstrate that Track-SQL achieves state-of-the-art performance on the SparC and CoSQL datasets. Furthermore, detailed ablation studies reveal that Track-SQL significantly improves execution accuracy in multi-turn interactions by 7.1% and 9.55% on these datasets, respectively. Our implementation will be open-sourced at https://github.com/DMIRLAB-Group/Track-SQL.
Figures & tables
Figure 1: The overall framework of Dual-Extractive Modules for Schema and Context Tracking. The framework trains a schema item classification model and an SQL generator. Based on the former, we construct a Semantic-enhanced Schema Extractor and a Schema-aware Context Extractor . The extraction results from these two extractors are utilized for subsequent training of the SQL generation model. The core idea of Track-SQL is to reduce the gap between the input and the target SQL before entering the multi-turn SQL generation phase by means of dynamic schema linking and context information extraction.
Model
SparC
CoSQL
QM
IM
QM
IM
EM
EX
TS
EM
EX
TS
EM
EX
TS
EM
EX
TS
In-Context Learning Approach
ACT-SQL Zhang et al. (2023)
51.0
63.8
56.9
24.4
38.9
29.6
46.0
63.7
55.2
13.3
30.7
21.5
CoE-SQL Zhang et al. (2024a)
56.0
70.3
63.3
36.5
50.5
41.9
52.4
69.6
60.6
23.9
39.6
30.4
Fine-tuned Model
Table 1: Performance of Track-SQL and previous works on the SparC and CoSQL dev set.
QM
IM
EX
TS
EX
TS
Track-SQL
75.39
69.16
57.81
50.71
w/o SESE
68.57( ↓6.82 )
62.42( ↓6.74 )
51.42( ↓6.39 )
45.26( ↓5.45 )
w/o ACID
74.56( ↓0.83 )
67.91( ↓1.25 )
56.39( ↓1.42 )
48.57( ↓2.14 )
w/o SACE
72.73( ↓2.66 )
67.16( ↓2 )
51.89( ↓5.92 )
44.78( ↓5.93 )
w/o SACE & SESE
71.40( ↓3.99 )
65.08( ↓4.08 )
50.71( ↓7.10 )
43.36( ↓7.35 )
Table 2: Ablation result on SparC dev set.
QM
IM
EX
TS
EX
TS
Track-SQL
70.60
62.26
43.67
32.76
w/o SESE
64.94( ↓5.66 )
58.98( ↓3.28 )
36.86( ↓6.81 )
31.74( ↓1.02 )
w/o ACID
68.22( ↓2.38 )
61.37( ↓0.89 )
39.24( ↓4.43 )
32.42( ↓0.34 )
w/o SACE
68.81( ↓1.79 )
61.46( ↓0.8 )
37.88( ↓5.79 )
29.01( ↓3.75 )
w/o SACE & SESE
66.03( ↓4.57 )
58.88( ↓3.38 )
34.12( ↓9.55 )
26.96( ↓5.8 )
Table 3: Ablation result on CoSQL dev set.
SparC
CoSQL
TRS@0.5
CRS@0.5
TRS@0.5
CRS@0.5
Track-SQL
8.50
21.46
12.74
25.90
w/o com-enh
9.57
21.05
13.62
29.93
w/o com&col-enh
9.44
28.18
13.38
27.42
Table 4: Ablation results of SESE. com-enh represents comment-enhanced layer, and col-enh represents column-enhanced layer used in RESDSQL.
SESE
SQL Generator
Train
Inference
Train
Inference
SparC
30.9±2.8(h)
0.20(s)
1.5±0.2(h)
1.15(s)
CoSQL
27.5±2.4(h)
0.21(s)
1.6±0.3(h)
1.15(s)
Table 5: Time performance of the Track-SQL framework, Train employs the number of hours required to achieve the optimal model as the performance metric, while Inference bases its evaluation on the time consumed to perform inference on a single batch.
Appendix figures & tables14 assets
Supplementary material from the paper’s appendix.
Appendix
Easy (483)
Medium (441)
Hard (145)
Extra (134)
EM
EX
TS
EM
EX
TS
EM
EX
TS
EM
EX
TS
Track-SQL
81.8
84.9
83.0
64.6
72.8
66.4
44.8
64.8
53.8
35.1
54.5
38.8
w/o SESE
77.6
78.7
77.6
56.5
68.0
59.4
42.8
59.3
46.2
30.6
44.0
35.1
w/o ACID
79.3
85.5
82.8
62.8
72.8
65.8
44.8
63.4
49.7
39.6
53.0
41.0
w/o SACE
79.5
84.1
81.8
63.9
71.9
66.4
39.3
60.0
48.3
32.8
48.5
37.3
w/o SACE & SESE
79.1
80.7
78.5
63.3
71.7
64.2
43.4
59.3
46.9
37.3
50.0
39.6
Appendix
Table 6: Ablation results of Track-SQL on SparC validation set by difficulty. The numbers in brackets () indicate the number of samples.
Easy (417)
Medium (320)
Hard (163)
Extra (107)
EM
EX
TS
EM
EX
TS
EM
EX
TS
EM
EX
TS
Track-SQL
80.6
85.4
82.5
51.6
67.5
55.6
36.2
59.5
46.0
24.3
39.3
28.0
w/o SESE
75.1
79.4
76.7
50.0
60.9
51.6
36.2
53.4
46.0
25.2
38.3
31.8
w/o ACID
78.2
83.5
81.1
52.8
65.0
56.2
31.3
55.8
44.2
22.4
37.4
26.2
w/o SACE
78.2
83.5
80.3
50.0
61.6
51.9
35.6
62.0
48.5
29.0
43.9
36.4
w/o SACE & SESE
75.8
77.7
75.8
48.4
60.9
51.6
38.0
66.3
52.8
16.8
35.5
24.3
Appendix
Table 7: Ablation results of Track-SQL on CoSQL validation set by difficulty. The numbers in brackets () indicate the number of samples.
Turn 1 (422)
Turn 2 (422)
Turn 3 (270)
Turn 4 (88)
Turn > 4 (1)
EM
EX
TS
EM
EX
TS
EM
EX
TS
EM
EX
TS
EM
EX
TS
Track-SQL
74.2
79.6
76.5
65.9
75.6
67.8
57.8
67.4
59.6
51.1
68.2
60.2
0
100
100
w/o SESE
70.1
75.6
71.8
60.9
69.2
61.4
51.1
60.4
53.0
40.9
58.0
52.3
0
0
0
w/o ACID
72.5
80.6
77.3
64.2
75.1
66.6
56.7
67.8
59.3
54.5
64.8
56.8
0
0
0
w/o SACE
72.3
79.1
75.8
63.0
72.3
64.9
55.9
65.9
59.6
51.1
65.9
60.2
0
0
0
w/o SACE & SESE
71.3
77.0
72.7
63.7
70.9
64.0
58.9
67.0
58.5
51.1
61.4
54.5
0
0
0
Appendix
Table 8: Ablation results of Track-SQL on SparC validation set by turn. The numbers in brackets () indicate the number of samples.
Turn 1(293)
Turn 2 (285)
Turn 3 (244)
Turn 4 (114)
Turn > 4 (71)
EM
EX
TS
EM
EX
TS
EM
EX
TS
EM
EX
TS
EM
EX
TS
Track-SQL
64.8
76.5
70.3
58.2
72.3
63.9
56.6
68.0
58.2
55.3
64.9
55.3
40.8
57.7
47.9
w/o SESE
61.4
70.0
64.5
57.9
67.4
62.8
50.8
64.3
54.5
52.6
56.1
51.8
42.3
50.7
47.9
w/o ACID
65.2
73.4
68.6
55.1
69.1
62.8
54.5
66.8
58.6
51.8
62.3
53.5
42.3
57.7
47.9
w/o SACE
66.2
75.8
69.3
52.6
66.7
59.6
57.8
69.3
59.4
52.6
64.0
58.8
42.3
54.9
47.9
w/o SACE & SESE
62.8
71.0
65.2
55.1
68.1
62.5
52.5
65.2
55.7
50.0
58.8
50.0
35.2
52.1
43.7
Appendix
Table 9: Ablation results of Track-SQL on CoSQL validation set by turn. The numbers in brackets () indicate the number of samples.
Figure 2: The results of the ablation study on the Codellama 7B+Track-SQL model on the SparC and CoSQL dev sets (calculated using the multi-turn TS metrics).
Figure 3: The results of the ablation study on the DeepSeek 7B+Track-SQL model on the SparC and CoSQL dev sets (calculated using the multi-turn TS metrics).
Figure 4: The results of the ablation study on the Mistral 7B+Track-SQL model on the SparC and CoSQL dev sets (calculated using the multi-turn TS metrics).
Table-Weighted Avg
Table-Macro Avg
Column-Weighted Avg
Column-Macro Avg
Precision
Recall
F1
Precision
Recall
F1
Precision
Recall
F1
Precision
Recall
F1
SESE
96.48
96.43
96.45
95.74
96.42
96.07
97.09
96.93
96.99
90.95
94.34
92.55
w/o com-enh
96.18
96.11
96.12
95.32
96.16
95.72
96.91
96.68
96.76
90.11
94.24
92.03
w/o com-enh & col-enh
96.58
96.57
96.57
96.09
96.31
96.20
96.70
96.67
96.69
91.31
92.05
91.68
Appendix
Table 10: The general precision index score of the semantic-enhanced schema extractor under the SparC dataset
Table-Weighted Avg
Table-Macro Avg
Column-Weighted Avg
Column-Macro Avg
Precision
Recall
F1
Precision
Recall
F1
Precision
Recall
F1
Precision
Recall
F1
SESE
95.33
95.28
95.30
94.29
94.87
94.57
96.85
96.71
96.77
89.70
92.65
91.11
w/o com-enh
95.32
95.30
95.31
94.47
94.66
94.57
96.81
96.79
96.80
90.90
91.24
91.07
w/o com-enh & col-enh
94.65
94.39
94.45
92.83
94.64
93.64
96.40
95.98
96.13
86.97
92.78
89.59
Appendix
Table 11: The general precision index score of the semantic-enhanced schema extractor under the CoSQL dataset
Case#1
Question#1 Question#2 Question#3
What is every student’s id? Of those ids, which correspond to those who own cats as pets? List all the other ids.
Gold
SELECT stuid FROM student EXCEPT SELECT T1.stuid FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = ’cat’
w/o SACE
SELECT stuid FROM has_pet except SELECT stuid FROM has_pet JOIN pets ON has_pet.petid = pets.petid WHERE pettype = ’cat’
Track-SQL
SELECT stuid FROM student except SELECT student.stuid FROM student JOIN has_pet ON student.stuid = has_pet.stuid JOIN pets ON has_pet.petid = pets.petid WHERE pets.pettype = ’cat’
SQLbase
SELECT student.stuid FROM student JOIN has_pet ON student.stuid = has_pet.stuid JOIN pets ON has_pet.petid = pets.petid WHERE pets.pettype = ’cat’
Case#2
Question#1 Question#2 Question#3
How many car models are produced in total? How many in Germany? How about in Japan?
Gold
SELECT count(*) FROM MODEL_LIST AS T1 JOIN CAR_MAKERS AS T2 ON T1.Maker = T2.Id JOIN COUNTRIES AS T3 ON T2.Country = T3.CountryId WHERE T3.CountryName = ’japan’
Appendix
Table 12: Case analysis of ablation experiments on the SParC dataset
SESE(Inference)
SQL Generator(Inference)
SESE(Train)
SQL Generator(Train)
Total time(s)
Avg Time(s)
Total time(s)
Avg Time(s)
Total time(h)
Avg Time(s)
Total time(h)
Avg Time(s)
SparC
240.348±1.45
0.20±0.00013
1386.98±2.13
1.152±0.025
30.93h±2.78
3.88±0.43
1.45±0.21
11.23±2.31
CoSQL
214.456±2.56
0.21±0.0012
1170.41±1.56
1.15±0.012
27.49h±2.43
3.92±0.29
1.61±0.33
11.43±2.51
Appendix
Table 13: Inference time performance of the Track-SQL framework. Avg Time(s) in terms of training represents the time consumption of a single batch, and Total time(h) represents the time required to obtain the best model. The SQL generator is based on Deepseek 7B
SESE(Inference)
SQL Generator(Inference)
SESE(Train)
SQL Generator(Train)
Graphics Memory(GB)
2.235
16.477
20.997
62.194
Appendix
Table 14: Memory Costs of Training and Inference in the Track-SQL Framework. In the training stage, the batch size is set to 6, and in the inference stage, the batch size is set to 1.The SQL generator is based on Deepseek 7B
Input for generating annotated descriptions of database columns
You are a database schema designer who specializes in generating concise descriptions for table columns based on the provided column names, types, and sample values. The descriptions should be brief, adjective-noun phrases that reflect the nature of the data in the column.
Table Name: {table_name}
Column: {column_name}
Type: {column_type}
Sample Values: {values}
Appendix
Table 15: This table lists LLM input sequences used for generating annotations for database columns and tables
Format for fine-tuning SQL generation
Input :
You are a SQL query generator that converts multi-turn questions along with associated database schema information into corresponding SQL statements. The multi-turn questions will be concatenated using the ‘ & ’ symbol, and you should generate the SQL statement that answers the current turn of the question based on the provided database schema.
Each database schema is provided in the following format:
Table name : Column name1, Column name2 Different tables are separated by the ‘|’ symbol, and the order of table names and column names is relevant to the current question; those appearing earlier are more closely related.
Fine-tuning large language models (LLMs) for specific domain tasks has achieved great success in Text-to-SQL tasks. However, these fine-tuned models often face challenges with multi-turn Text-to-SQL tasks caused by ambiguous or unanswerable questions. It is desired to enhance LLMs to handle multiple types of questions in multi-turn Text-to-SQL tasks. To address this, we propose a novel data augmentation method, called QDA-SQL, which generates multiple types of multi-turn Q&A pairs using LLMs. In QDA-SQL, we introduce a method incorporating validation and correction mechanisms to handle complex multi-turn Text-to-SQL tasks. Experimental results demonstrate that QDA-SQL enables fine-tuned models to exhibit higher performance on SQL statement accuracy and enhances their ability to handle complex, unanswerable questions in multi-turn Text-to-SQL tasks. The generation script and test set are released at https://github.com/mcxiaoxiao/QDA-SQL
Yinggang Sun, Ziming Guo, Haining Yu +5
School of Cyberspace Science · Harbin Institute of Technology · Harbin, China +4
Recent advances in Large Reasoning Models (LRMs) trained with Long Chain-of-Thought have demonstrated remarkable capabilities in code generation and mathematical reasoning. However, their potential in multi-turn Text-to-SQL tasks remains largely underexplored. Existing approaches typically rely on unstable API-based inference or require expensive fine-tuning on small-scale models. In this work, we present Rose-SQL, a training-free framework that leverages small-scale LRMs through in-context learning to enable accurate context-dependent parsing. We introduce the Role-State, a fine-grained representation that bridges the structural gap between schema linking and SQL generation by serving as a structural blueprint. To handle conversational dependencies, Rose-SQL traces the evolution of Role-State through historical context via structural isomorphism checks, guiding the model to infer the possible SQL composition for the current question through verified interaction trajectories. Experiments on the SParC and CoSQL benchmarks show that, within the Qwen3 series, Rose-SQL outperforms in-context learning baselines at the 4B scale and substantially surpasses state-of-the-art fine-tuned models at the 8B and 14B scales, while showing consistent gains on additional reasoning backbones.
Le Zhou, Feng Yao, Fengcai Qiao +3
College of Systems Engineering, National University of Defense Technology · College of Advanced Interdisciplinary Studies, National University of Defense Technology · Institute of Automation, Chinese Academy of Sciences +1
State-of-the-art Text-to-SQL systems are typically multi-agent pipelines centered around two fundamental tasks: schema linking and SQL generation. However, existing work trains separate models for each task, failing to leverage the synergy between these interrelated tasks. In this work, we propose DualSQL, a new Text-to-SQL system consisting of two agents powered by a single model backbone. The agents share the same model weights and agentic scaffold, enabling joint optimization through a robust multi-agent reinforcement learning (RL) framework. We design three database access tools to facilitate effective multi-step reasoning grounded to interactions with the databases. To improve training and avoid model collapse, we introduce a set of rollout guardrail mechanisms that stabilizes multi-agent RL training, supporting DualSQL to keep improving during training. We also introduce a new SQL correctness metric, robust execution match (REX), to more accurately judge SQL correctness and assign reward signals. Being trained on only 3755 examples, DualSQL-4B achieves an impressive 68.0% execution accuracy on the BIRD development set, matching previous 7B models. DualSQL-8B further improves to 71.1%, outperforming previous state-of-the-art single-model solutions with 32B parameters. These results demonstrate the strength of joint multi-agent reinforcement learning for building high performance Text-to-SQL pipelines.