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

Track-SQL is a novel framework that enhances generative language models for multi-turn Text-to-SQL tasks by integrating dual-extractive modules for semantic schema and context tracking, achieving state-of-the-art performance on the SparC and CoSQL datasets.

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

Published 2026-03-09
📖 5 min read🧠 Deep dive

Imagine you are trying to give a complex set of instructions to a very smart, but slightly forgetful, assistant who speaks a different language (SQL, the language of databases).

In a single-turn conversation, you say, "Show me all the dogs," and the assistant gets it right. But in a multi-turn conversation, things get messy. You might say:

  1. "Show me all the dogs."
  2. "Now, show me the ones that are brown."
  3. "Actually, just the ones owned by students."

As the conversation gets longer, the assistant starts to get confused. It might forget which table in the database holds "student" info, or it might get lost trying to connect "brown" to the previous "dog" request. It's like trying to navigate a city while someone keeps changing the street signs and adding new neighborhoods without telling you.

This paper introduces Track-SQL, a new framework designed to be the "super-assistant" that never loses its place.

The Two Main Problems

The authors identified two big headaches for AI in these long conversations:

  1. The "Where am I?" Problem (Schema Linking): Databases have thousands of tables and columns. As you talk, the AI needs to know exactly which parts of the database are relevant right now. If it looks at the wrong "street" (table), it gives the wrong answer.
  2. The "What did we just say?" Problem (Context Tracking): The AI needs to remember what you asked in the previous turns to understand your current question. If it forgets the context, it can't connect the dots.

The Solution: Track-SQL's "Dual-Extractive Modules"

Track-SQL doesn't just guess; it uses two specialized tools (modules) to clean up the mess before the main AI even starts writing the SQL code. Think of these as a Research Librarian and a Memory Keeper.

1. The Research Librarian (Semantic-enhanced Schema Extractor)

  • The Metaphor: Imagine you are looking for a specific book in a massive library. A normal AI might try to read every single book title. The Research Librarian, however, knows your current topic.
  • How it works: Before the AI tries to write the answer, this module scans the database and says, "Hey, the user is talking about 'students' and 'pets'. We don't need to look at the 'cars' or 'weather' tables. Let's just pull out the 'Students' and 'Pets' shelves."
  • The Magic: It also fixes confusing names. If a column is named "cont_id" (which is vague), the librarian uses a smart tool to realize it actually means "Continent ID" and clarifies it for the AI. This prevents the AI from getting lost in a sea of irrelevant data.

2. The Memory Keeper (Schema-aware Context Extractor)

  • The Metaphor: Imagine you are writing a story with a friend. You say, "And then the hero..." Your friend needs to know which hero you are talking about. The Memory Keeper looks back at your previous sentences to find the right character.
  • How it works: When you ask a new question, this module looks at your past questions and the SQL answers that were generated before. It finds the most relevant "base" answer from the past and says, "Okay, the user is building on this specific previous answer. Let's use that as a starting point."
  • The Magic: It filters out the noise. Instead of feeding the AI the entire history of the conversation (which might be confusing), it gives the AI a clean, relevant "cheat sheet" of what matters right now.

The Result: A Clearer Path

By using these two tools, Track-SQL acts like a filter. It strips away the confusing, irrelevant parts of the database and the conversation history, leaving the main AI with a clean, focused prompt.

  • Without Track-SQL: The AI is like a driver trying to drive through a city with foggy windows and changing road signs. It often crashes (makes mistakes).
  • With Track-SQL: The fog is cleared, the road signs are fixed, and the driver has a GPS that knows exactly where they've been and where they need to go.

Why It Matters

The researchers tested this on two major datasets (SParC and CoSQL) which are like "final exams" for AI in this field.

  • The Score: Track-SQL scored significantly higher than previous methods.
  • The Improvement: It improved the accuracy of the answers by about 7% to 9.5%. In the world of AI, that's a massive jump. It means the AI is much more reliable at handling complex, back-and-forth conversations about data.

In a Nutshell

Track-SQL is a system that teaches AI to organize its notes and remember its context before it tries to solve a problem. Instead of guessing in the dark, it shines a flashlight on the right parts of the database and the right parts of the conversation, leading to much smarter and more accurate answers.