
Augmenting Multi-Turn Text-to-SQL Datasets with Self-Play
Qi Liu1∗
, Zihuiwen Ye2∗
, Tao Yu1, Phil Blunsom2, Linfeng Song3
1The University of Hong Kong, 2University of Oxford, 3Tencent AI Lab, Bellevue, WA, USA
{liuqi, tyu}@cs.hku.hk;{zihuiwen.ye, phil.blunsom}@cs.ox.ac.uk;
lfsong@tencent.com
Abstract
The task of context-dependent text-to-SQL
aims to convert multi-turn user utterances to
formal SQL queries. This is a challenging task
due to both the scarcity of training data from
which to learn complex contextual dependen-
cies and to generalize to unseen databases. In
this paper we explore augmenting the training
datasets using self-play, which leverages con-
textual information to synthesize new interac-
tions to adapt the model to new databases. We
first design a SQL-to-text model conditioned
on a sampled goal query, which represents a
user’s intent, that then converses with a text-
to-SQL semantic parser to generate new inter-
actions. We then filter the synthesized inter-
actions and retrain the models with the aug-
mented data. We find that self-play improves
the accuracy of a strong baseline on SParC
and CoSQL, two widely used cross-domain
text-to-SQL datasets. Our analysis shows that
self-play simulates various conversational the-
matic relations, enhances cross-domain gener-
alization and improves beam-search.1
1 Introduction
Multi-turn text-to-SQL translation is a powerful se-
mantic parsing paradigm that converts natural lan-
guage user utterances into executable SQL queries
in a conversational environment. Compared to reg-
ular text-to-SQL tasks such as Spider (Yu et al.,
2018b) and GeoQuery (Zelle and Mooney,1996),
conversational text-to-SQL requires interpreting
coreference and omission phenomena that fre-
quently appear in human conversations. To be
effective, text-to-SQL models must uncover com-
plex contextual dependencies while grounding user
utterances in task specific database schemas.
Numerous architectures and pretraining methods
have been proposed for tackling context-dependent
∗Equal Contribution
1
Our code is available at:
https://github.com/
leuchine/self_play_picard
text-to-SQL (Suhr et al.,2018;Zhang et al.,2019;
Hui et al.,2021;Scholak et al.,2021;Yu et al.,
2021;Xie et al.,2022). However, the size of the
datasets used has been limited due to the high
cost of annotating multi-turn dialogue and SQL
pairs, which often requires trained experts. Exist-
ing multi-turn text-to-SQL datasets, such as SParC
(Yu et al.,2019b) and CoSQL (Yu et al.,2019a),
require text-to-SQL parsers to generalize to unseen
databases at test time, but doing so is difficult with
limited training context.
In this paper we propose the use of self-play to
augment multi-turn text-to-SQL datasets in order to
achieve more robust generalization. Self-play simu-
lates interactions between multiple artificial agents
in order to generate a training signal in addition to
supervised data. It has been successfully applied
in a wide range of tasks, e.g. board games (Silver
et al.,2016,2018) and multiplayer battle games
(Vinyals et al.,2019;Berner et al.,2019). It has
also been applied in dialogue simulations, during
which a dialogue model converses with a user sim-
ulator to generate synthetic dialogues (Schatzmann
et al.,2006;Gür et al.,2018;Tseng et al.,2021). In
our work, we extend self-play to semantic parsing.
Although self-play has been adopted in task-
oriented dialogue, the need to pre-define a do-
main specific ontology of slot-value pairs (e.g. the
slot value “price=expensive” for a restaurant book-
ing) (Henderson et al.,2014;Wen et al.,2016;
Budzianowski et al.,2018) prevents self-play from
simulating interactions in a new domain. Adding
a new domain for task-oriented dialogue is diffi-
cult and labor-intensive. On the other hand, text-
to-SQL tasks (Yu et al.,2018b,2019b,a) use a
domain-independent formalism, i.e. SQL queries.
We demonstrate that self-play is well-suited to
simulating interactions in a new domain given a
database schema, improving cross-domain general-
ization.
We use PICARD (Scholak et al.,2021) as the
arXiv:2210.12096v1 [cs.CL] 21 Oct 2022