TL;DR
OmniSQL introduces a highly scalable, automatic data synthesis framework that generates SynSQL-2.5M, the first million-scale text-to-SQL dataset complete with Chain-of-Thought (CoT) reasoning paths. By training open-source models (ranging from 7B to 32B parameters) on this massive, diverse dataset, the authors create OmniSQL, a model family that matches or outperforms closed-source giants like GPT-4o and DeepSeek-V3 on complex, domain-specific database tasks.
What Problem Does This Paper Address?
Translating natural language questions into executable SQL queries (Text-to-SQL) is essential for democratizing data access. Currently, practitioners face a frustrating trade-off:
- Prompting-based methods rely on massive, closed-source LLMs via APIs. This approach is expensive, introduces severe data privacy risks for enterprise data, and lacks customization.
- Fine-tuning-based methods use smaller, open-source models but suffer from poor generalizability. Because human-annotated datasets like Spider and BIRD are relatively small and narrow, fine-tuned models frequently fail when confronted with real-world, out-of-domain databases.
The bottleneck is data. Human annotation for complex relational databases is notoriously difficult and expensive to scale. This paper introduces an automated pipeline to synthesize high-quality, diverse text-to-SQL data at a million-sample scale without human intervention.
Methods
The authors propose a progressive, four-step data synthesis pipeline that decouples the generation process into manageable tasks handled entirely by open-source LLMs:
- Web Table-Driven Database Synthesis: The pipeline bootstraps from millions of publicly available web tables (using the TabLib corpus). An LLM infers a business scenario from a table and expands it into a fully fleshed-out relational database schema (complete with primary/foreign keys and metadata). A subsequent database enhancement step injects extra columns to ensure real-world complexity.
- Complexity-Aware SQL Query Generation: To prevent the model from generating only trivial queries, the framework explicitly samples across four complexity levels (simple to highly complex) and uses a geometric distribution to constrain column selection, mimicking real-world data analysis needs.
- Stylized NL Question Synthesis: Instead of translating SQL straight back to standard text, the pipeline forces the LLM to adopt one of nine distinct linguistic styles (e.g., colloquial, vague, metaphorical, conversational). A semantic consistency selector filters out inaccurate translations by measuring embedding similarities.
- Chain-of-Thought (CoT) Solution Synthesis: For every sample, the pipeline generates a step-by-step reasoning path explaining how to get from the question to the SQL query. To ensure correctness, the framework generates multiple candidate CoT paths and uses a majority vote based on the execution results of the final SQL queries.
Datasets
The primary contribution is SynSQL-2.5M, containing 2,544,390 text-to-SQL pairs spanning 16,583 distinct synthetic databases.
To evaluate the models trained on SynSQL-2.5M, the authors test across nine distinct benchmarks:
- Standard Benchmarks: Spider (dev/test) and BIRD (dev).
- Domain-Specific Benchmarks: Spider2.0-SQLite, ScienceBenchmark, and EHRSQL (medical domain).
- Robustness Benchmarks: Spider-DK, Spider-Syn, and Spider-Realistic.
Key Insights and Ideas
- Web Tables as a Schema Goldmine: LLMs are surprisingly proficient at generating database schemas because their pre-training data is saturated with
CREATE TABLEstatements. Web tables provide the perfect semantic "seed" to scale domain diversity. - CoT as a Self-Correction Mechanism: During the final step of data synthesis, the authors discovered that generating a step-by-step reasoning path actually helps the LLM identify and fix minor bugs (like incorrect join paths) present in the initially generated SQL queries. In a GPT-4o evaluation of discrepant cases, the CoT-refined SQL was preferred 93.98% of the time.
- Linguistic Diversity Drives Robustness: Real users rarely ask questions with perfect database terminology. By intentionally synthesizing vague, conversational, or metaphorical questions, the dataset prepares the model for messy, real-world deployments.
Key Results
The resulting model, OmniSQL, achieves state-of-the-art performance across the board, frequently beating models many times its size:
- Standard Benchmarks: OmniSQL-7B achieved 87.9% execution accuracy on the Spider test set using greedy decoding, outperforming the top public API-based method on the leaderboard (DAIL-SQL + GPT-4 at 86.6%). OmniSQL-32B achieved 67.0% on BIRD dev, matching specialized GPT-4o fine-tuned pipelines.
- Domain Generalization: On EHRSQL (a highly specialized medical database benchmark), OmniSQL-32B scored 46.8%, outperforming zero-shot GPT-4o by 1.3%, despite never seeing EHRSQL data during training.
- Quality Metrics: When evaluated by GPT-4o across multiple data-quality dimensions, SynSQL-2.5M consistently scored higher than the human-annotated BIRD dataset in areas like schema complexity, field definition, and SQL correctness.
Limitations and Future Work
- The Commonsense Gap: OmniSQL underperformed slightly on Spider-DK, a benchmark specifically designed to test implicit, real-world commonsense knowledge (e.g., knowing that "highly rated" implies looking at a review score column). The authors suggest adding a specific "commonsense" linguistic style to the data synthesis pipeline to mitigate this.
- Single-Step vs. Multi-Agent: OmniSQL was evaluated as a single-turn, single-step model. The authors note that its performance could be amplified even further if integrated into multi-stage agentic frameworks that handle explicit schema linking and iterative SQL refinement.
Summary updated