Abstract
Text-to-SQL parsing is essential for democratizing database access, yet it is hindered by the high cost of expert-labeled data, particularly for complex, cross-domain tasks. This paper presents a novel data augmentation framework that addresses the "data bottleneck" through a hierarchical SQL-to-question generation approach. By decomposing complex SQL queries into atomic clauses, translating them into sub-questions, and reassembling them based on execution logic, the proposed method generates high-quality synthetic training data. Evaluated on major benchmarks like Spider and DuSQL, this approach significantly improves parser performance, demonstrating superior generalization to unseen SQL patterns and complex database schemas.
Introduction
The goal of text-to-SQL parsing is to automatically translate natural language questions into executable SQL queries, enabling non-technical users to interact with relational databases. The most challenging frontier in this field is cross-domain parsing, where models must generalize to entirely new database schemas at test time.
Developing robust cross-domain parsers requires large-scale, high-quality labeled datasets. However, manual annotation is prohibitively expensive, requiring experts proficient in both domain-specific logic and SQL syntax. While data augmentation—generating synthetic (question, SQL) pairs—is a common strategy, traditional "flat" translation methods often produce incoherent questions for complex queries. This paper introduces a hierarchical pipeline designed to overcome these limitations by breaking down the translation task into manageable components.
Methodology: Hierarchical SQL-to-Question Generation
The authors propose a three-stage pipeline to automate the generation of synthetic training data without human intervention.
1. SQL Query Generation
The process begins with generating diverse SQL "sketches" using an Abstract Syntax Tree Grammar (ASTG). These templates are populated with table and column names from target databases. To ensure the synthetic data reflects realistic usage, the system ensures that generated queries cover at least 80% of the structural patterns found in existing manual training sets.
2. Hierarchical SQL-to-Question (HIER)
The core innovation lies in the hierarchical translation process. Rather than translating a multi-clause SQL statement in one pass, the model follows a "divide and conquer" strategy:
- Decomposition: The SQL query is split into individual clauses (e.g.,
SELECT,WHERE,ORDER BY). - Translation: Each clause is translated into a corresponding "sub-question" using a Seq2Seq model equipped with a copy mechanism.
- Composition: These sub-questions are then reassembled into a final natural language question, following the logical execution order of the SQL.
3. Smart Sampling
To handle the massive volume of generated data (often 5-10 times the size of the original labeled set), the authors implement a smart sampling strategy. Instead of training on the entire synthetic corpus simultaneously, they randomly sample a subset equal to the size of the labeled data during each training epoch. This maintains high training efficiency while providing the model with a diverse range of examples over time.
Experimental Setup and Results
The framework was rigorously evaluated on three prominent cross-domain benchmarks: WikiSQL (simple, single-table), Spider (complex, multi-table English), and DuSQL (complex, multi-table Chinese).
The hierarchical (HIER) approach consistently outperformed baseline parsers and traditional "flat" augmentation techniques across all datasets:
- Spider: Integration with the RATSQL parser yielded a +2.8% increase in Exact Matching (EM) accuracy.
- DuSQL: The method showed its greatest impact here, with a +6.8% improvement over the baseline.
- WikiSQL: Even on simpler tasks, HIER provided a consistent +1.1% boost.
Key Insights
- Granularity Matters: Breaking down complex queries into atomic clauses makes the translation task significantly more accurate. "Flat" augmentation often resulted in lower-quality data that could actually degrade model performance.
- Structural Generalization: A major finding was the model's improved ability to handle SQL structures that were completely absent from the original human-labeled training data, proving the framework's effectiveness in teaching underlying logic.
- Pattern Coverage: By prioritizing the coverage of SQL patterns (logical structures) rather than just specific data values, the model learns to generalize across different database domains more effectively.
Conclusion and Future Work
The hierarchical SQL-to-question generation framework effectively mitigates the data bottleneck in cross-domain text-to-SQL parsing. While the current approach produces high-quality logic-aligned questions, the resulting sentences can sometimes appear robotic due to fixed composition rules. Future research will focus on enhancing the linguistic diversity and naturalness of the generated questions through advanced rephrasing techniques and applying this hierarchical logic to other structured-to-text domains.
Summary updated