Augmenting Multi-Turn Text-to-SQL Datasets with Self-Play

Qi Liu, Zihuiwen Ye, Tao Yu, Linfeng Song, Phil Blunsom

Abstract

Multi-turn text-to-SQL systems, which translate natural language dialogues into database queries, are hindered by a severe lack of annotated training data. We propose a self-play framework that addresses this scarcity by enabling a user simulator and a semantic parser to generate synthetic dialogues through goal-oriented interactions. Our approach significantly improves performance on complex, context-dependent benchmarks like SParC and CoSQL, demonstrating enhanced generalization to unseen database domains.

Introduction

Converting natural language into SQL (Text-to-SQL) is essential for making databases accessible to non-experts. While single-turn tasks have seen significant progress, multi-turn, context-dependent tasks remain a major challenge. In conversational settings, users frequently employ coreference (e.g., "What is his salary?") and omission (e.g., "What about her?"), requiring models to maintain a deep understanding of dialogue history.

The primary bottleneck in developing robust multi-turn models is data scarcity. Annotating these dialogues is expensive and requires expertise in both linguistics and database schemas. Existing datasets are often too small to capture the diverse ways humans ask follow-up questions across different domains.

The Self-Play Framework

To overcome the data bottleneck, we introduce a self-play data augmentation method. This framework utilizes two artificial agents that interact to retrieve specific data:

  1. The User Simulator (SQL-to-Text): Given a target "goal" SQL query and dialogue history, this model generates a natural language question to guide the system toward that goal.
  2. The Semantic Parser (Text-to-SQL): The model under training, which takes the user's question and history to produce a SQL query.
The self-play framework architecture, illustrating the interaction between the Text-to-SQL and SQL-to-Text models.

The self-play loop begins with sampling a complex goal SQL query from a database schema. The agents then engage in a multi-turn interaction. To ensure high data quality, the final generated SQL is compared against the original goal; if they match, the synthetic dialogue is added to the training set. We utilize PICARD (constrained decoding) on a T5 baseline to ensure syntactic validity.

Experimental Results

We evaluated our method on the SParC and CoSQL benchmarks, both of which are cross-domain datasets where models are tested on unseen databases. The self-play augmentation consistently outperformed the strong PICARD baseline:

  • SParC: Using a T5-Large model, self-play improved the Question Match (QM) score from 63.0% to 65.5% and the Interaction Match (IM) score from 43.0% to 45.6%.
  • CoSQL: QM scores rose from 54.3% to 55.7%.
Comparison of Question Match (QM) scores by turn number before and after applying self-play augmentation.

As shown in the performance by turn, the self-play method provides a notable boost in the initial turns of an interaction, helping the model establish a stronger foundation for the subsequent dialogue.

Discussion and Analysis

Our analysis reveals several key insights into why self-play is effective. It successfully simulates human conversational patterns such as refinement and theme-entity relations. Furthermore, it bridges the "medium" difficulty gap, providing the most significant gains for queries requiring table joins or specific clauses that are underrepresented in human-annotated data.

Models trained with self-play also exhibited increased robustness to beam size parameters, achieving high accuracy even with smaller beam sizes, which improves inference efficiency.

Limitations

Despite its success, the method faces challenges such as "language drift," where synthetic natural language may diverge from the intended SQL meaning. Additionally, self-play interactions tended to be shorter (mean length 2.53) than human dialogues (mean length 2.97), indicating difficulty in maintaining coherence over very long interactions (4+ turns).

Conclusion

Self-play offers a powerful, automated way to augment multi-turn text-to-SQL datasets. By grounding synthetic dialogues in specific data goals, we can train models that are more robust, efficient, and capable of generalizing to new database domains. Future work will explore reinforcement learning to further refine the interaction process and mitigate language drift.

Summary updated

BibTeX
@inproceedings{liu2022augmenting,
  author = {Qi Liu and Zihuiwen Ye and Tao Yu and Linfeng Song and Phil Blunsom},
  title = {{Augmenting Multi-Turn Text-to-SQL Datasets with Self-Play}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.findings-emnlp.411},
}
Figure