NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Question Generation from SQL Queries Improves Neural Semantic Parsing

Daya Guo, Yibo Sun, Duyu Tang, Nan Duan, Jian Yin, Hong Chi, James Cao, Peng Chen, Ming Zhou

Introduction

Neural semantic parsers, which translate natural language into executable code like SQL, are essential for building natural language interfaces to databases. However, these models are notoriously "data-hungry." Unlike general image classification, annotating SQL-question pairs requires significant domain expertise in both database schemas and query languages, making high-quality datasets expensive and slow to produce.

This paper addresses the data bottleneck by exploring two primary questions: how training data volume impacts parser accuracy and whether automated Question Generation (QG) can create high-quality synthetic data to reduce reliance on human experts.

The STAMP Framework and Question Generation

The authors introduce a two-part framework designed for high-efficiency semantic parsing. The core component is the Syntax- and Table-Aware Semantic Parser (STAMP). STAMP utilizes an encoder-decoder architecture with a specialized pointer network. To ensure the generated SQL is both syntactically valid and grounded in the database schema, the decoder uses a switching gate to choose between three channels: predicting columns, predicting cell values, or predicting SQL keywords (e.g., SELECT, WHERE).

To augment limited supervised data, the authors propose a Question Generation (QG) model that "flips" the parsing task. This model takes a SQL query and generates a corresponding natural language question. It incorporates a copying mechanism to handle specific values or column names and utilizes stochastic latent variables to inject diversity into the generated questions. This diversity is crucial, as it exposes the parser to various ways humans might phrase the same underlying query intent.

Overview of the proposed data augmentation framework using SQL-to-Question generation.

Experimental Results and Data Efficiency

The framework was evaluated primarily on WikiSQL, a large-scale benchmark of over 80,000 question-SQL pairs. The experiments revealed a logarithmic scaling law: as the dataset grows, the marginal gains in accuracy per new example diminish. This observation highlights the importance of data efficiency.

Parser accuracy (Execution and Logical Form) as a function of the number of training examples.

One of the most significant findings is the "30% Success" rule. The STAMP model, when trained on only 30% of the human-labeled data augmented with synthetic QG data, achieved 61.2% logical form accuracy. This outperformed the baseline model trained on 100% of the human-labeled data (60.7%). When using the full dataset plus QG augmentation, the model reached a new state-of-the-art performance of 63.7% logical form accuracy. These results suggest that while SQL patterns are relatively easy to learn, QG is vital for helping models navigate the vast variability of natural language.

Conclusion and Future Directions

While the QG-enhanced model significantly improves performance and data efficiency, manual error analysis shows that approximately 27% of generated questions still contain errors, often omitting details from the WHERE clause. Future work involves developing SQL-aware encoders that better capture the tree-like structure of queries and leveraging richer table metadata to generate more natural and accurate questions. Despite these limitations, the study proves that synthetic data generation is a powerful tool for scaling semantic parsing systems with minimal human intervention.

Summary updated

BibTeX
@inproceedings{guo2018question,
  author = {Daya Guo and Yibo Sun and Duyu Tang and Nan Duan and Jian Yin and Hong Chi and James Cao and Peng Chen and Ming Zhou},
  title = {{Question Generation from SQL Queries Improves Neural Semantic Parsing}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2018},
  doi = {10.18653/v1/d18-1188},
}
Figure