REFORMER: A ChatGPT-Driven Data Synthesis Framework Elevating Text-to-SQL Models

Shenyang Liu, Saleh Almohaimeed, Liqiang Wang · DOI

TL;DR

REFORMER is a training-free data synthesis framework that leverages ChatGPT to generate high-quality, diverse (question, SQL query) pairs to train Text-to-SQL models. By combining a "retrieve-and-edit" template approach with a novel embedding-based cycle-consistency validation, it significantly boosts model generalization across new domains without requiring expensive fine-tuning of the data generator itself.

What Problem Does This Paper Address?

Text-to-SQL models—which translate natural language questions into executable database queries—heavily rely on high-quality training data. However, popular benchmarks like Spider are relatively small, causing models to struggle significantly when deployed in entirely new domains (e.g., moving from a music database to a healthcare database).

While data synthesis can alleviate this scarcity, prior methods often lacked query diversity or relied on complex, zero-shot techniques that produced low-quality, unnatural questions. The authors introduce REFORMER to bridge this gap by generating highly accurate and structurally diverse training pairs tailored to new database schemas.

Methods

REFORMER avoids the need to train a dedicated question-generation model by utilizing ChatGPT via a structured "retrieve-and-edit" pipeline:

  1. Related Query Retrieval & Masking: Given a target SQL query from a new schema, the framework uses tree-edit-distance to find a structurally similar query and its corresponding question from the existing training set. It then masks out schema-specific tokens (words appearing in fewer than 50% of the training schemas) to create a generic question template.
  2. New Question Generation: ChatGPT is prompted to generate a concise, one-sentence natural language explanation of the target SQL query (intentionally avoiding explicit table names to keep the phrasing natural). ChatGPT then fills the masked template using this explanation.
  3. Cycle-Consistency Validation: To filter out low-quality generations, the authors introduce a novel validation step. They generate a second independent explanation of the query using a different prompt. They then compute the cosine similarity between the text embeddings (text-embedding-ada-002) of this second explanation and the newly generated question. If the similarity passes a predefined threshold ($\lambda = 0.85$), the pair is accepted into the new dataset ($D_{new}$).

The overall architecture of REFORMER, alongside alternative paraphrasing strategies explored by the authors, is illustrated below:

Fig. 1: Framework for REFORMER and Paraphrasing-based Data Sythesis methods

The exact prompts engineered to guide ChatGPT through this generation and validation process are detailed in the paper's appendix:

Prompts used for REFORMER and paraphrasing methods

Datasets

The framework was evaluated using the Spider dataset, a widely recognized cross-domain Text-to-SQL benchmark containing 7,000 training pairs and 1,034 development pairs. To rigorously test domain adaptation, the authors isolated and evaluated performance across specific database schema categories: Music, Pets, University, and Country.

Key Insights and Ideas

  • Training-Free Synthesis Wins: Instead of training specialized neural question generators or binary classifiers to filter data, REFORMER achieves state-of-the-art data synthesis purely through clever prompt engineering and large language model (LLM) embeddings.
  • Embedding-Based Cycle Consistency: Traditional cycle consistency checks require translating back and forth between modalities (e.g., SQL $\rightarrow$ Text $\rightarrow$ SQL), which introduces compounding errors from intermediate parsers. REFORMER elegantly bypasses this by validating alignment directly in the semantic embedding space of two independent natural language representations.
  • Negative Constraints Improve Naturalness: Instructing the LLM to avoid intermediate database representations (like explicit table names or SQL keywords like COUNT(*)) prevents the generation of robotic, overly literal questions, resulting in data that better mirrors real human queries.

Key Results

The synthesized datasets were used to fine-tune a baseline SmBop parser, yielding substantial performance gains:

  • Outperforming Baselines: REFORMER achieved an average increase of 3.6% in Exact Match (EM) accuracy and 4.7% in Execution Accuracy (EX) compared to the replicated baseline framework, ReFill.
  • Ablation Validation: The data augmentation module alone improved EM by 2.8%, while adding the cycle-consistency validation module provided an additional 1.5% EM boost, proving the value of the embedding-based filtering step.
  • Direct Paraphrasing Scaling: When exploring direct schema-informed paraphrasing with a similarity threshold of $\lambda = 0.9$, the authors scaled the training set by 43,847 pairs, boosting the baseline SmBop model's performance close to that of much larger models like T5-3B equipped with PICARD.

Limitations and Future Work

Despite its success, the authors note several distinct error modes that still occur during LLM-driven synthesis, such as missing information, template mismatches, and unnatural phrasing:

Fig. 3: Errors from REFORMER

Additionally, the baseline SmBop parser's custom tree structure struggled to process highly complex, crafted SQL templates, forcing a pivot to a T5-small baseline for certain complex query experiments.

For future work, the authors suggest exploring automatic prompt optimization techniques and validating the REFORMER framework across a broader variety of open-source LLMs and alternative Text-to-SQL benchmarks.

Summary updated

BibTeX
@inproceedings{liu2024reformer,
  author = {Shenyang Liu and Saleh Almohaimeed and Liqiang Wang},
  title = {{REFORMER: A ChatGPT-Driven Data Synthesis Framework Elevating Text-to-SQL Models}},
  booktitle = {ICMLA},
  year = {2024},
  url = {https://openreview.net/forum?id=2AxReUk3t9},
}
Figure