Table of Contents
Fetching ...

RingSQL: Generating Synthetic Data with Schema-Independent Templates for Text-to-SQL Reasoning Models

Marko Sterbentz, Kevin Cushing, Cameron Barrie, Kristian J. Hammond

TL;DR

RingSQL tackles data scarcity in text-to-SQL by marrying schema-independent templates with LLM-based paraphrasing. It introduces SQR templates and Rings to decouple query templates from specific database schemas, enabling scalable, correct query generation across diverse schemas, then uses LLMs to paraphrase questions for linguistic diversity. The authors create RingSQL-Gen (5,000 QA pairs across 160 databases) and show that models trained on RingSQL-Gen achieve a $+2.32\%$ average accuracy gain over strong synthetic baselines across six benchmarks, with notable improvements on hard query subsets. Ablation studies reveal that language grounding via rephrasing substantially boosts generalization, while template-grounded questions provide essential semantic alignment, demonstrating RingSQL as a robust, reusable data-generation framework for text-to-SQL learning with practical scalability.

Abstract

Recent advances in text-to-SQL systems have been driven by larger models and improved datasets, yet progress is still limited by the scarcity of high-quality training data. Manual data creation is expensive, and existing synthetic methods trade off reliability and scalability. Template-based approaches ensure correct SQL but require schema-specific templates, while LLM-based generation scales easily but lacks quality and correctness guarantees. We introduce RingSQL, a hybrid data generation framework that combines schema-independent query templates with LLM-based paraphrasing of natural language questions. This approach preserves SQL correctness across diverse schemas while providing broad linguistic variety. In our experiments, we find that models trained using data produced by RingSQL achieve an average gain in accuracy of +2.3% across six text-to-SQL benchmarks when compared to models trained on other synthetic data. We make our code available at https://github.com/nu-c3lab/RingSQL.

RingSQL: Generating Synthetic Data with Schema-Independent Templates for Text-to-SQL Reasoning Models

TL;DR

RingSQL tackles data scarcity in text-to-SQL by marrying schema-independent templates with LLM-based paraphrasing. It introduces SQR templates and Rings to decouple query templates from specific database schemas, enabling scalable, correct query generation across diverse schemas, then uses LLMs to paraphrase questions for linguistic diversity. The authors create RingSQL-Gen (5,000 QA pairs across 160 databases) and show that models trained on RingSQL-Gen achieve a average accuracy gain over strong synthetic baselines across six benchmarks, with notable improvements on hard query subsets. Ablation studies reveal that language grounding via rephrasing substantially boosts generalization, while template-grounded questions provide essential semantic alignment, demonstrating RingSQL as a robust, reusable data-generation framework for text-to-SQL learning with practical scalability.

Abstract

Recent advances in text-to-SQL systems have been driven by larger models and improved datasets, yet progress is still limited by the scarcity of high-quality training data. Manual data creation is expensive, and existing synthetic methods trade off reliability and scalability. Template-based approaches ensure correct SQL but require schema-specific templates, while LLM-based generation scales easily but lacks quality and correctness guarantees. We introduce RingSQL, a hybrid data generation framework that combines schema-independent query templates with LLM-based paraphrasing of natural language questions. This approach preserves SQL correctness across diverse schemas while providing broad linguistic variety. In our experiments, we find that models trained using data produced by RingSQL achieve an average gain in accuracy of +2.3% across six text-to-SQL benchmarks when compared to models trained on other synthetic data. We make our code available at https://github.com/nu-c3lab/RingSQL.
Paper Structure (33 sections, 9 figures, 5 tables)

This paper contains 33 sections, 9 figures, 5 tables.

Figures (9)

  • Figure 1: With RingSQL, schema-independent templates for a specific class of question can be used with any database in order to produce queries that use the elements of the database to produce new questions and queries for training.
  • Figure 2: The high level approach of RingSQL. Schema-independent templates are filled in with schema-specific values. Random filters are generated in order to produce a wider variety of questions and incorporated into the filled plan template. The filled plan templates are then deterministically converted to SQL to produce the final query. An LLM is used to produce more natural sounding question based on the filled question template.
  • Figure 3: An example of the schema-independent query template for generating queries that check if one instance occurred before another.
  • Figure 4: An example of a Ring for a song database. This Ring contains four entities along with their attributes. These are used fill the slots of the SQR template during the data generation process.
  • Figure 5: An example of how the schema-independent template from Figure \ref{['fig:query-template-appendix']} is filled in to produce an intermediate SQR plan and corresponding question. The blue and orange highlighted steps denote the steps generated for the plan inputs |A| and |B| respectively.
  • ...and 4 more figures