Introduction
Training high-performing Text-to-SQL parsers typically requires massive amounts of expensive, human-annotated data. While synthetic data has been explored as a solution to this scarcity, previous attempts often produced "illogical" queries—such as calculating the sum of a text field or joining unrelated tables. These low-quality examples fail to improve modern models like T5. This paper introduces a novel framework to synthesize high-quality, logical data by enforcing strong typing, preserving schema relationships, and utilizing an intermediate representation (IR) to bridge the gap between code and natural language.
Methodology: Quality-First Synthesis
The authors propose a two-stage pipeline designed to prioritize data quality over sheer volume, ensuring that synthetic examples reflect real-world logic.
1. Logical SQL Synthesis
To prevent the generation of nonsensical queries, the framework introduces three key constraints:
- Strong Typing: Operators are restricted to compatible column types (e.g., preventing mathematical operations on categorical text).
- Key Relationship Preservation: Complex operations like
INTERSECTor nested subqueries are only performed on columns sharing a verified foreign key relationship. - Schema-Distance-Weighted Sampling: By treating the database schema as a graph, the system favors picking tables that are "close" to each other. This mimics realistic human query patterns and avoids illogical "spaghetti joins" between unrelated data entities.
2. NLQ Synthesis via Intermediate Representation
Directly converting SQL to natural language is challenging due to the technical nature of SQL syntax. The authors introduce an Intermediate Representation (IR) that strips away redundant technical details (like explicit JOIN clauses) and enriches the logic with heuristics. The pipeline follows a SQL → IR → Natural Language Question flow, making the final translation to English much more accurate.
Key Insights
The research demonstrates that logic is the primary bottleneck in synthetic data. When data violates schema common sense, models learn noise rather than useful patterns. By enforcing "closeness" through schema-distance weighting, the synthetic data becomes significantly more representative of real-world use cases. Furthermore, the IR acts as a "pidgin" language, retaining SQL logic while adopting a sentence-like structure that facilitates better model learning.
Experimental Results
The framework was evaluated primarily on the Spider benchmark, a large-scale cross-domain Text-to-SQL task.
- State-of-the-Art Performance: Augmenting a T5-3B + PICARD model with this synthetic data achieved a new SOTA Exact Match (EM) score of 76.9% on the Spider dev set.
- Few-Shot Scenarios: The impact is most pronounced when real data is scarce. In a few-shot setting with only 128 real examples, the addition of synthetic data boosted accuracy from 19.1% to 46.3%—a massive 27.2-point jump.
- Ablation Success: Removing constraints like strong typing or key preservation led to significant performance drops, confirming that logical consistency is the primary driver of the model's success.
Conclusion and Future Work
While highly effective, the current method relies on templates extracted from real data. Future work could involve more flexible grammars to increase query diversity. Additionally, while the "key property" techniques are SQL-specific, the underlying philosophy of logical consistency could be adapted to other structured data domains like SPARQL or Python code generation.
Summary updated