---
title: 'Track-SQL: Context-Aware Text-to-SQL'
url: https://www.emergentmind.com/topics/track-sql
type: topic
---

# Track-SQL: Context-Aware Text-to-SQL

Track-SQL is a framework for multi-turn, context-dependent, cross-domain Text-to-SQL that enhances generative language models with dual-extractive modules for schema and context tracking in multi-turn interactions. In its specific 2026 formulation, Track-SQL introduces a **Semantic-enhanced Schema Extractor** and a **Schema-aware Context Extractor**, and uses their outputs to present the SQL generator with a shorter, more focused prompt consisting of the dialogue context, an extracted schema subset, and a retrieved historical SQL [2603.05996]. The term also appears informally in adjacent work to denote systems that track SQL interaction states, cross-schema query structures, or longitudinal Text-to-SQL performance and justification quality [2012.04995] [2508.07087] [2509.24212].

## 1. Problem setting and motivation

Track-SQL targets multi-turn Text-to-SQL on datasets such as SParC and CoSQL, where a dialogue up to turn \(m\) is represented as natural-language questions
$$
\mathcal{Q}_{\le m} = (\mathcal{Q}_1, \dots, \mathcal{Q}_m),
$$
over a database schema
$$
\mathcal{S} = \{t_i, c_{i,1}, \dots, c_{i,n_i}\}_{i=1}^{N},
$$
and the task is to generate the SQL query \(s_m\) for the current question \(\mathcal{Q}_m\) conditioned on the whole dialogue and the schema [2603.05996].

The framework is motivated by two difficulties that are pronounced in multi-turn settings. The first is **context tracking**: ellipsis, coreference, corrections, and refinements require the system to determine which prior questions or SQLs remain relevant. The second is **dynamic schema linking**: the set of relevant tables and columns changes across turns, and naïvely linking each turn to the full schema produces a large, noisy graph with many redundant links [2603.05996].

The 2026 Track-SQL paper argues that large decoder-only language models perform strongly in single-turn Text-to-SQL but do not extend equivalently to multi-turn Text-to-SQL because they repeatedly see the full schema and must implicitly infer both relevant schema items and relevant prior turns while also generating SQL. Track-SQL therefore makes two extractive subtasks explicit before decoding: dynamic schema selection and context selection [2603.05996].

A plausible implication is that Track-SQL belongs to a broader line of work that treats Text-to-SQL as a stateful process rather than a turn-local translation problem. Earlier work on IST-SQL explicitly tracked interaction states derived from prior SQLs, and later work such as MTSQL-R1 and SQL-Trail used execution feedback and dialogue memory to refine SQL over multiple internal steps [2012.04995] [2510.12831] [2601.17699].

## 2. Semantic-enhanced Schema Extractor

The **Semantic-enhanced Schema Extractor** (SESE) is the schema-tracking component of Track-SQL. Its purpose is to reduce schema redundancy, exploit semantic information beyond raw schema names, and track schema usage across turns via a history store and special markers [2603.05996].

For the current turn \(m\), SESE constructs an input sequence
$$
\mathcal{X} = \mathcal{Q}_1 \ \texttt{[SEP]} \ \dots \ \texttt{[SEP]} \ \mathcal{Q}_m \ \mid\ t_1 : c_{1,1}, \dots, c_{1,n_1} \ \mid\ \dots \ \mid\ t_N : c_{N,1}, \dots, c_{N,n_N}.
$$
Columns selected in previous turns are tagged with a special token \(\mathbf{[SN]}\), so the extractor can signal that they were previously active [2603.05996].

SESE enriches the schema with LLM-generated annotations produced by GPT-3.5-turbo. Column annotations are generated from the table name, column name, type, and sampled values; table annotations are generated from the table name and its columns. This yields an annotated schema
$$
\hat{\mathcal{S}} = \hat{t}_1 : \hat{c}_{1,1}, \dots, \hat{c}_{1,n_1} \ \mid\ \dots \ \mid\ \hat{t}_N : \hat{c}_{N,1}, \dots, \hat{c}_{N,n_N},
$$
which is encoded alongside the original schema with RoBERTa, followed by a 2-layer BiLSTM and a non-linear FC pooling module [2603.05996].

The central mechanism is a gated fusion of raw schema names and annotations. For tables, Track-SQL defines
$$
\mathbf{g}_i^t = \sigma\left(\mathbf{W}_g^t \big[ \mathbf{W}_1^t T_i + \mathbf{b}_1^t \ ;\ \mathbf{W}_2^t \hat{T}_i + \mathbf{b}_2^t \big] + \mathbf{b}_g^t \right),
$$
$$
T_i^{G} = \text{Norm}\big(T_i + (\mathbf{g}_i^t \circ T_i + (1-\mathbf{g}_i^t)\circ \hat{T}_i)\big),
$$
and an analogous construction is used for columns:
$$
\mathbf{g}_{i,k}^c = \sigma\left(\mathbf{W}_g^c \big[ \mathbf{W}_1^c C_{i,k} + \mathbf{b}_1^c \ ;\ \mathbf{W}_2^c \hat{C}_{i,k} + \mathbf{b}_2^c \big] + \mathbf{b}_g^c \right),
$$
$$
C_{i,k}^{G} = \text{Norm}\big(C_{i,k} + (\mathbf{g}_{i,k}^c \circ C_{i,k} + (1-\mathbf{g}_{i,k}^c)\circ \hat{C}_{i,k})\big).
$$
The paper motivates this by ambiguity in raw names, such as a column named `continent` denoting a name rather than an identifier [2603.05996].

Given these semantic-enhanced embeddings, SESE predicts binary relevance probabilities for tables and columns:
$$
\hat{y}_i = \sigma\big( (T_i^G U_1^t + b_1^t) U_2^t + b_2^t \big),
$$
$$
\hat{y}_{i,k} = \sigma\big( (C_{i,k}^G U_1^c + b_1^c) U_2^c + b_2^c \big).
$$
The labels are derived from whether the table or column appears in the gold SQL. Because positives are sparse, the extractor uses a focal-loss objective
$$
L_1 = \frac{1}{N}\sum_{i=1}^{N} FL(y_i, \hat{y}_i) + \frac{1}{M} \sum_{i=1}^{N} \sum_{k=1}^{n_i} FL(y_{i,k}, \hat{y}_{i,k}),
$$
with \(M = \sum_i n_i\) [2603.05996].

At inference time, Track-SQL keeps items whose probability exceeds threshold \(s\):
$$
\hat{V}^t = \{ i \mid \hat{y}_i \ge s \}, \qquad
\hat{V}^c = \{ (i,k) \mid \hat{y}_{i,k} \ge s \}.
$$
The selected tables and columns are sorted by probability and serialized, together with foreign keys, into the extracted schema \(E(\mathcal{S})\) [2603.05996].

SESE also implements **All-Column Intent Detection** (ACID). Each table receives a special “\(*\)” column that is predicted like any other column. If its probability is sufficiently high, “\(*\)” is inserted into the serialized schema so that the generator can learn full-row intentions such as `SELECT * FROM country` [2603.05996].

## 3. Schema-aware Context Extractor and generator integration

The **Schema-aware Context Extractor** (SACE) retrieves the most relevant historical question-SQL pair for the current turn. Its role is to provide a strong structural prior for ellipsis, coreference, and correction by selecting a base historical SQL, denoted \(SQL_{\text{base}}\) [2603.05996].

SACE scores each prior turn \(h < m\) with two signals. The first is question semantic similarity from SentenceBERT:
$$
\mathcal{S}^{sim}_h = \text{SentenceBERT}(\mathcal{Q}_h, \mathcal{Q}_m).
$$
The second is schema-usage similarity derived from SESE’s probability vectors over tables and columns. Let \(\hat{\mathcal{Y}}^m\) and \(\hat{\mathcal{Y}}^h\) be normalized schema probability vectors for the current and historical turns. Their average is
$$
\bar{\mathcal{Y}} = \frac{1}{2}(\hat{\mathcal{Y}}^m + \hat{\mathcal{Y}}^h),
$$
and the paper defines a Jensen-Shannon-based dissimilarity
$$
\mathcal{P}^{sim}_h = \frac{1}{2 \ln 2} \left( D_{KL}(\hat{\mathcal{Y}}^m \Vert \bar{\mathcal{Y}}) + D_{KL}(\hat{\mathcal{Y}}^h \Vert \bar{\mathcal{Y}}) \right),
$$
where the Kullback–Leibler divergence is written explicitly over both tables and columns [2603.05996].

The final relevance score is
$$
\mathcal{R}_h = \mathcal{S}^{sim}_h + (1 - \mathcal{P}^{sim}_h),
$$
and SACE selects
$$
h^* = \arg\max_{1 \le h < m} \mathcal{R}_h, \qquad
SQL_{\text{base}} = s_{h^*}.
$$
This scoring makes context retrieval schema-aware rather than purely lexical, so two utterances can rank highly even when they are syntactically dissimilar but share the same schema focus [2603.05996].

The generator is then given a reformulated single-sequence input containing the full multi-turn question context, the extracted schema subset, and the selected base SQL. The prompt format includes fields of the form:

```text
You are a SQL query generator ...
Base SQL: {SQL_base}
database schema: {E(S)}
question: {Q_<=m}
```

and the output is the target SQL followed by `<|end_of_sentence|>` [2603.05996].

This design is deliberately modular. SESE performs dynamic schema linking, SACE retrieves a contextually relevant prior SQL, and the decoder-only language model remains architecturally unchanged apart from LoRA fine-tuning. The paper characterizes this as reducing the input–output gap: the model is no longer expected to infer schema linking and context reasoning entirely from the raw dialogue and full schema [2603.05996].

## 4. Training, objectives, and evaluation protocol

Track-SQL is trained in two stages. First, SESE is trained as a schema classifier using table and column labels extracted from gold SQL. Second, SESE and SACE are run offline to preprocess the multi-turn dataset into single-turn-style training instances for the SQL generator. There is no joint training: extractor parameters are fixed when generator training begins [2603.05996].

The generator is trained with standard token-level cross-entropy on inputs formatted by a function \(\varepsilon(\cdot)\):
$$
\min_{\varepsilon, M^*} \sum_m \mathcal{L}\big(M^*(\varepsilon(\mathcal{Q}_{\le m}, E(\mathcal{S}), SQL_{\text{base}})), s_m\big).
$$
The paper reports LoRA fine-tuning with rank \(=32\), alpha \(=64\), dropout \(=0.1\), and batch size \(=6\) for 7B-scale decoder-only LMs [2603.05996].

Evaluation uses the standard multi-turn Text-to-SQL metrics. At the question level and interaction level, Track-SQL reports **QM** and **IM**, each with **EM** (Exact Match), **EX** (Execution Accuracy), and **TS** (Test Suite Accuracy). The paper also introduces extractor-oriented redundancy metrics. For tables, with gold set \(V^t = \{ i \mid y_i = 1 \}\) and extracted set \(\hat{V}^t = \{ i \mid \hat{y}_i \ge s \}\), the per-sample score is
$$
\text{score}_j =
\begin{cases}
0 & \text{if } V^t = \hat{V}^t,\\[4pt]
\dfrac{|\hat{V}^t - V^t|}{|\hat{V}^t|} & \text{if } V^t \subset \hat{V}^t,\\[4pt]
1 & \text{otherwise,}
\end{cases}
$$
and
$$
TRS@s = \frac{1}{D} \sum_{j=1}^{D} \text{score}_j.
$$
The **Column Redundancy Score** \(CRS@s\) is defined analogously per column [2603.05996].

The implementation profile is also reported. SESE uses RoBERTa-base plus BiLSTM, with schema inputs capped at 512 tokens; large schemas are segmented into sub-schema sets. SACE uses a sliding context window \(L_w = 5\). Typical end-to-end inference is approximately \(1.35\) seconds per sample, consisting of about \(0.2\) seconds for SESE and \(1.15\) seconds for the generator on A800. Training takes about \(30.9\) hours for SESE on SParC, about \(27.5\) hours for SESE on CoSQL, and about \(1.5\) hours per dataset for generator fine-tuning [2603.05996].

## 5. Empirical performance and relation to adjacent approaches

Track-SQL reports state-of-the-art performance on the SParC and CoSQL development sets with 7B-scale language models. On SParC dev with DeepSeek-7B, the baseline SFT model achieves QM-EX \(71.40\), QM-TS \(65.08\), IM-EX \(50.71\), and IM-TS \(43.36\), whereas Track-SQL achieves QM-EX \(75.39\), QM-TS \(69.16\), IM-EX \(57.81\), and IM-TS \(50.71\). On CoSQL dev with DeepSeek-7B, the baseline SFT model achieves QM-EX \(66.03\), QM-TS \(58.88\), IM-EX \(34.12\), and IM-TS \(26.96\), whereas Track-SQL achieves QM-EX \(70.60\), QM-TS \(62.26\), IM-EX \(43.67\), and IM-TS \(32.76\). The headline interaction-level execution improvements are \(+7.10\%\) on SParC and \(+9.55\%\) on CoSQL [2603.05996].

Ablation studies indicate that both extractive modules matter. On SParC dev, removing SESE reduces IM-EX from \(57.81\) to \(51.42\), removing SACE reduces IM-EX to \(51.89\), and removing ACID causes smaller drops. On CoSQL, removing SESE reduces IM-EX by \(6.81\), removing SACE reduces IM-EX by \(5.79\), and removing both SESE and SACE reduces IM-EX by \(9.55\). The paper also reports that SESE yields consistent gains across SQL difficulty levels, while SACE is more beneficial as the number of turns increases; on CoSQL, turns \(>4\) show about \(2.8\%\) gain from SACE [2603.05996].

SESE-specific ablations support the semantic-enhancement design. On CoSQL dev at threshold \(s = 0.5\), full Track-SQL reports \(TRS@0.5 = 12.74\) and \(CRS@0.5 = 25.90\); removing comment-enhancement gives \(13.62\) and \(29.93\), and removing column-enhancement gives \(13.38\) and \(27.42\). The paper states that semantic enhancement significantly reduces column redundancy by about \(4\%\) absolute [2603.05996].

Within the multi-turn Text-to-SQL literature, Track-SQL is positioned against several earlier design choices. EditSQL edits previous SQL in a generative architecture, whereas Track-SQL retrieves a base SQL with SACE and then relies on the language model’s general generation rather than an explicit edit module. IST-SQL, MIGA, HIE-SQL, TP-Link, and STAR focus on interaction states or unified encoder-decoder modeling, while Track-SQL is described as orthogonal because it decouples schema/context extraction from SQL generation and can be integrated with off-the-shelf language models [2603.05996] [2012.04995].

A broader comparison shows that “tracking” has become a recurrent organizing idea in Text-to-SQL research. IST-SQL defines schema-based interaction states and SQL-keyword-based interaction states derived from the last predicted SQL [2012.04995]. MTSQL-R1 treats multi-turn Text-to-SQL as a Markov Decision Process with database execution feedback and persistent dialogue memory, using a propose \(\rightarrow\) execute \(\rightarrow\) verify \(\rightarrow\) refine cycle [2510.12831]. SQL-Trail uses a ReAct-style tool-augmented agent with interleaved feedback and adaptive turn-budget allocation [2601.17699]. ScenarioBench defines a policy-grounded, trace-aware benchmark with SQL correctness by result-set equivalence over clause IDs, trace completeness, trace correctness, trace order, hallucination rate, policy coverage, latency, SDI, and SDI-R as a Track-SQL-style evaluation suite [2509.24212]. SQL-Exchange describes cross-schema SQL mapping as tracking a query’s logical or structural skeleton across heterogeneous schemas [2508.07087]. This suggests that Track-SQL is both a specific architecture and part of a wider methodological shift toward explicit state, structure, and evidence tracking in SQL generation.

## 6. Limitations, extensions, and broader significance

The Track-SQL paper is explicit about several limitations. RoBERTa’s 512-token limit forces schema segmentation for large databases. SACE uses a sliding context window \(L_w = 5\), so longer dialogues may not be fully represented. The extractor-generator pipeline is static: extractors are pre-trained and then fixed, so SESE errors propagate into SACE and the generator. The use of previously generated SQL as \(SQL_{\text{base}}\) can propagate mistakes, especially on EXTRA difficulty samples. The authors also state that Track-SQL’s efficacy “in extremely complex multi-turn dialogues and highly dynamic database schemas remains to be validated” [2603.05996].

The proposed extensions remain consistent with the framework’s modular design. The authors suggest replacing RoBERTa with longer-context or decoder-only classifiers to reduce the schema-length bottleneck, strengthening validation and verification to mitigate error propagation from historical SQL, exploring more powerful language models beyond 7B within the same framework, and improving robustness under highly dynamic schemas and more complex multi-turn patterns [2603.05996].

The broader literature indicates several possible trajectories for the concept. One line emphasizes structured state tracking inside the model, as in IST-SQL’s schema-states and SQL-states [2012.04995]. Another emphasizes environment interaction and long-horizon refinement, as in MTSQL-R1 and SQL-Trail [2510.12831] [2601.17699]. A third emphasizes benchmarked observability, where SQL correctness, trace quality, grounding, and latency are tracked together, as in ScenarioBench [2509.24212]. A fourth emphasizes structural transfer across schemas, as in SQL-Exchange [2508.07087]. 

Taken together, these threads make Track-SQL significant not only as a named 2026 framework but also as a precise formulation of a broader research claim: multi-turn Text-to-SQL benefits when schema focus, conversational context, and prior SQL structure are tracked explicitly rather than left implicit inside a generative model.

Source: https://www.emergentmind.com/topics/track-sql