Tracking Interaction States for Multi-Turn Text-to-SQL Semantic Parsing

Runze Wang, Zhen-Hua Ling, Jingbo Zhou, Yu Hu

Introduction

Translating natural language questions into executable SQL queries is a cornerstone of accessible data analysis. While single-turn text-to-SQL has seen significant progress, real-world applications often involve multi-turn conversations where users refine their queries incrementally. In these scenarios, context is paramount. Users frequently employ coreferences and ellipsis, building upon the logic of previous turns.

Example of a multi-turn text-to-SQL interaction showing coreference and incremental query building.

The primary challenge in multi-turn parsing is "contextual dependency." Previous approaches often relied on simple history concatenation or basic copy mechanisms, which lack a formal structure for tracking the evolving "state" of the interaction—specifically, which database schema elements are in focus and which SQL operations were recently applied.

Methodology: The IST-SQL Model

To address these challenges, the IST-SQL (Interaction State Tracking for SQL) model introduces a framework inspired by Dialogue State Tracking (DST) in task-oriented dialogue systems. The model explicitly maintains and updates two distinct interaction states:

  1. Schema-States: These track database columns and their associated SQL keywords (e.g., SELECT, WHERE) from the previous turn.
  2. SQL-States: These track SQL keywords and the specific columns they operated on in the preceding query.
The IST-SQL architecture, featuring state updaters, encoders, and a decoder with a copy mechanism.

Architectural Components

The model architecture consists of several specialized modules:

  • State Updaters: These extract the current interaction states from the most recently predicted SQL query.
  • State Encoders: Schema-states are encoded using a Relational Graph Neural Network (RGNN) to leverage the structural metadata of the database, such as foreign key relationships. SQL-states are processed through a non-linear layer to capture keyword-to-column mappings.
  • Utterance Encoder: A multi-head attention mechanism integrates the conversation history at the token level, providing fine-grained context awareness.
  • Decoder with Copy Mechanism: The final SQL query is generated by a decoder that can either synthesize new tokens or copy relevant elements from the tracked interaction states and previous queries.

Experimental Evaluation

The IST-SQL model was evaluated on two benchmark datasets for multi-turn, cross-domain text-to-SQL: CoSQL and SParC.

On the CoSQL dataset, a large-scale conversational benchmark, IST-SQL achieved a Question Matching (QM) accuracy of 44.4% on the development set and an Interaction Matching (IM) accuracy of 15.2% on the test set, outperforming the previous state-of-the-art Edit-Net model. Similarly, on the SParC dataset, the model improved QM accuracy to 47.55% and IM accuracy to 29.93%.

Ablation studies highlighted the necessity of both Schema-States and SQL-States. Removing either component resulted in a significant performance decline, particularly in Interaction Matching, which measures the model's ability to correctly parse every turn within a complete dialogue.

Discussion and Conclusion

The core contribution of IST-SQL is the conceptualization of the previous SQL query as a structured "state" rather than mere text. By providing an explicit structural scaffold through RGNNs and state tracking, the model effectively captures the "filtering logic" that often persists across conversational turns.

However, the model faces challenges such as error propagation, where an incorrect prediction in an early turn can corrupt the state for subsequent queries. Future research may focus on more robust state tracking mechanisms and handling dynamic or extremely large-scale database schemas. Despite these limitations, IST-SQL represents a significant step toward bridging the gap between natural human conversation and structured data retrieval.

Summary updated

BibTeX
@inproceedings{wang2021tracking,
  author = {Runze Wang and Zhen-Hua Ling and Jingbo Zhou and Yu Hu},
  title = {{Tracking Interaction States for Multi-Turn Text-to-SQL Semantic Parsing}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i16.17646},
}
Figure