OmniSQL: Synthesizing High-quality Text-to-SQL Data at Scale

Haoyang Li, Shang Wu, Xiaokang Zhang, Xinmei Huang, Jing Zhang, Fuxin Jiang, Shuai Wang, Tieying Zhang, Jianjun Chen, Rui Shi, Hong Chen, Cuiping Li

Abstract

Text-to-SQL systems enable non-technical users to interact with structured databases using natural language. However, the field has been bifurcated between high-performing but expensive proprietary models and open-source alternatives that struggle with complex, real-world schemas. This paper introduces a scalable, automated pipeline for synthesizing high-quality text-to-SQL data, resulting in the SynSQL-2.5M dataset. By fine-tuning open-source models on this massive corpus, we present OmniSQL (7B, 14B, and 32B), which achieves state-of-the-art performance across multiple benchmarks, even surpassing closed-source models like GPT-4o in specialized domains.

Introduction

While large language models (LLMs) have significantly advanced natural language interfaces for databases, the most capable systems typically rely on prompting massive, closed-source models. This dependency introduces significant hurdles regarding API costs, data privacy, and the inability to perform deep domain-specific customization. Conversely, open-source models often fail to generalize to complex database tasks due to the limited scale and diversity of existing training sets like Spider or BIRD.

To bridge this gap, we developed a fully automated synthesis pipeline that generates millions of diverse, realistic, and complex text-to-SQL examples without human intervention. This approach allows smaller open-source models to inherit the reasoning capabilities of larger models while specializing in the nuances of relational algebra and database querying.

The SynSQL-2.5M Synthesis Pipeline

The core contribution of this work is a four-step progressive synthesis pipeline designed to be cost-effective by utilizing smaller, open-source LLMs (such as Qwen2.5-Coder) for data generation.

  1. Web Table-Driven Database Synthesis: Rather than relying on private enterprise data, the pipeline uses millions of public web tables as "seeds." An LLM transforms these seeds into realistic business scenarios, generating full relational databases complete with primary and foreign keys. An enhancement step ensures complexity by forcing the addition of extra columns and tables to prevent models from learning simplistic shortcuts.
  2. Complexity-Aware SQL Generation: To ensure the dataset covers the full spectrum of SQL difficulty, the system prompts LLMs to generate a balanced mix of simple, moderate, complex, and highly complex queries against the synthetic schemas.
  3. Stylized Natural Language (NL) Synthesis: To mirror real-world user behavior, SQL queries are back-translated into NL questions using nine distinct linguistic styles, including formal, colloquial, and vague phrasing. A semantic consistency selector is employed to filter out inaccurate translations.
  4. Chain-of-Thought (CoT) Synthesis: For every sample, the system generates a step-by-step reasoning path. This not only provides better training signals but also acts as a self-correction mechanism; during CoT generation, the LLM often identifies and corrects minor errors in the original synthetic SQL.

Dataset and Experimental Setup

The resulting dataset, SynSQL-2.5M, contains 2.54 million samples across 16,583 synthetic databases. We trained the OmniSQL model family (7B, 14B, and 32B parameters) using a combination of SynSQL-2.5M and enhanced versions of the Spider and BIRD datasets.

Evaluation was conducted across nine benchmarks, ranging from standard sets (Spider, BIRD) to domain-specific challenges (EHRSQL for healthcare, ScienceBenchmark) and robustness tests (Spider-DK, Spider-Realistic).

Key Results

OmniSQL demonstrates that high-quality synthetic data can effectively substitute for massive model scale:

  • State-of-the-Art Performance: OmniSQL-7B achieved 87.9% execution accuracy on the Spider test set, the highest among publicly available methods. OmniSQL-32B reached 67.0% on the BIRD development set, a significant milestone for open-source models.
  • Surpassing Proprietary Models: In the medical domain (EHRSQL), OmniSQL-32B achieved 46.8% accuracy, outperforming GPT-4o (45.5%), despite OmniSQL never being exposed to medical-specific training data.
  • Impact of Scale: Fine-tuning on SynSQL-2.5M provided an average boost of +8.4% in accuracy for the base 7B model across all benchmarks. For larger models like the 32B variant, Parameter-Efficient Fine-Tuning (LoRA) was sufficient to reach state-of-the-art results.

Discussion and Limitations

While OmniSQL excels in structural complexity and linguistic diversity, it shows slight performance regressions on benchmarks requiring deep implicit or commonsense knowledge (e.g., Spider-DK). This suggests that while synthetic data is excellent for teaching SQL logic and schema linking, the broad pre-training of base models still plays a vital role in handling underspecified or knowledge-heavy queries.

Future work will focus on incorporating "commonsense" styles into the synthesis pipeline and exploring multi-agent frameworks to further refine SQL generation through iterative revision and schema linking.

Summary updated

BibTeX
@article{li2025omnisql,
  author = {Haoyang Li and Shang Wu and Xiaokang Zhang and Xinmei Huang and Jing Zhang and Fuxin Jiang and Shuai Wang and Tieying Zhang and Jianjun Chen and Rui Shi and Hong Chen and Cuiping Li},
  title = {{OmniSQL: Synthesizing High-quality Text-to-SQL Data at Scale}},
  journal = {Proc. VLDB Endow.},
  year = {2025},
  doi = {10.14778/3749646.3749723},
}
Figure