Track-SQL: Enhancing Generative Language Models with Dual-Extractive Modules for Schema and Context Tracking in Multi-turn Text-to-SQL

Bingfeng Chen, Shaobin Shi, Yongqi Luo, Boyan Xu, Ruichu Cai, Zhifeng Hao

Abstract

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.

Introduction

While Large Language Models (LLMs) excel at generating SQL from single prompts, multi-turn conversations present unique challenges. In these scenarios, models must handle two primary hurdles: Schema Redundancy and Context Tracking. Real-world databases often contain dozens of tables, creating a noisy search space during long conversations. Furthermore, users frequently omit information or use pronouns referring to previous turns, causing generative models to lose the conversational thread or fail to identify which parts of previous SQL queries are reusable.

Methodology: The Track-SQL Framework

Track-SQL addresses these challenges by acting as a sophisticated pre-processor for the LLM. Instead of feeding the entire database schema and chat history into the model, it employs a dual-extractive approach to filter relevant database schemas and track conversational history before generation.

The Track-SQL architecture featuring the Semantic-enhanced Schema Extractor (SESE) and Schema-aware Context Extractor (SACE).

Semantic-enhanced Schema Extractor (SESE)

SESE identifies relevant tables and columns for the current turn. It bridges the "semantic gap" (e.g., mapping a column named contid to its actual meaning, continent_id) by using an LLM to generate descriptive annotations for the schema. It also includes "All-Column Intent Detection" (ACID) to handle SELECT * wildcards more accurately.

Schema-aware Context Extractor (SACE)

SACE identifies the most relevant previous SQL query to serve as a "base" for the current turn. Rather than simple text similarity, it utilizes KL Divergence to measure entity overlap between the current question and historical queries. It also incorporates syntactic error detection to prevent error propagation from previous turns.

Experimental Results

The framework was validated on two authoritative multi-turn Text-to-SQL benchmarks: SParC (cross-domain, 12,000+ questions) and CoSQL (conversational version of Spider, 10,000+ queries).

Performance comparison of Track-SQL across SParC and CoSQL datasets against in-context learning and fine-tuned baselines.

Track-SQL achieved state-of-the-art results, outperforming previous methods including those based on GPT-3.5. Key findings include:

  • Execution Accuracy (EX): Track-SQL improved multi-turn execution accuracy by 7.1% on SParC and 9.55% on CoSQL.
  • Efficiency: The system maintains a low end-to-end response time of approximately 1.35 seconds, making it viable for real-time interactive systems.
  • The Power of Filtering: By aggressively filtering irrelevant schema elements, the generative model can focus its limited attention on the logic of the query rather than sorting through schema noise.

Conclusion and Future Work

Track-SQL demonstrates that enhancing LLMs with specialized extractive modules significantly improves multi-turn Text-to-SQL performance. While the system is robust, current limitations include the 512-token limit of the RoBERTa-based extractor and the training overhead required for the SESE module. Future work will focus on replacing the RoBERTa base with decoder-only models that support larger windows and further improving the system's robustness against erratic user behavior.

Summary updated

BibTeX
@inproceedings{chen2025track,
  author = {Bingfeng Chen and Shaobin Shi and Yongqi Luo and Boyan Xu and Ruichu Cai and Zhifeng Hao},
  title = {{Track-SQL: Enhancing Generative Language Models with Dual-Extractive Modules for Schema and Context Tracking in Multi-turn Text-to-SQL}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=S4t6y58gdp},
}
Figure