OmniSQL - An open-source text-to-SQL model that converts natural language into SQL query statements.
OmniSQL is an open-source text-to-SQL model that efficiently converts natural language problems into SQL queries. It uses an innovative data synthesis framework to generate the first million-level text-to-SQL dataset, SynSQL-2.5M, which includes...
What is OmniSQL?
OmniSQL is an open-source text-to-SQL model that efficiently converts natural language problems into SQL queries. It utilizes an innovative data synthesis framework to generate the first million-level text-to-SQL dataset, SynSQL-2.5M, containing 2.5 million high-quality samples covering over 16,000 cross-domain databases and encompassing various complexity levels and language styles. OmniSQL offers 7B, 14B, and 32B model versions, and its fine-tuning incorporates high-quality labeled data from Spider and BIRD datasets.
OmniSQL's main functions
- Text to SQL conversionOmniSQL can understand questions posed by users in natural language and translate them into corresponding SQL query statements.
- Supports multiple databases and complex queriesOmniSQL supports multiple database types and can handle SQL queries of varying complexity, from simple single-table queries to complex multi-table joins, subqueries, function calls, and common table expressions (CTEs).
- Provide mind chain solutionsIn addition to generating SQL queries, OmniSQL provides a thought process solution for each sample. This thought process demonstrates the logical reasoning process from understanding natural language problems to generating SQL queries, helping users better understand the model's decision path and facilitating model debugging and optimization for developers.
- Multiple model version selectionOmniSQL offers three different model sizes: 7B, 14B, and 32B. Users can choose the appropriate model size based on their needs and computing resources. These different sizes strike a balance between performance and resource consumption; smaller models run faster and consume fewer resources, while larger models may perform better in certain complex query scenarios.
OmniSQL's technical principles
- Database automatically generatedOmniSQL analyzes web tables to infer business scenarios and automatically constructs a database structure with multi-table relationships and primary/foreign key constraints using a large language model. Enhancement strategies are employed to increase the number of columns and optimize the structure, making the generated database more closely suited to real-world applications.
- Complexity-aware SQL query generationThis feature defines four complexity levels and, combined with the SQLite function library, such as aggregate functions (SUM, AVG, etc.) and window functions (ROW_NUMBER, RANK, etc.), generates various SQL queries. It can intelligently select the appropriate complexity level based on the user's problem and provide suitable query statements.
- Stylization issues in reverse translationThe system employs an SQL-to-Question strategy to translate SQL queries into natural language questions in nine different language styles. Semantic analysis ensures semantic consistency before and after translation, improving the efficiency and accuracy of natural language to SQL conversion and adapting to different users' language habits.
- CoT solution synthesisThis approach adds intermediate derivation steps to the samples through a step-by-step inference generator. During training, the model learns the transformation from the question to SQL and the logic of each inference step, improving the accuracy and reliability of inference, presenting a transparent inference process to the user, and enhancing trust.
- Large-scale data synthesis and trainingOmniSQL has generated a large-scale, high-quality training dataset, SynSQL-2.5M, based on its data synthesis framework. The dataset contains over 2.5 million samples, covering more than 16,000 cross-domain databases. By training on such a large and diverse dataset, OmniSQL can learn the mapping relationship between natural language expressions and SQL queries across different domains and styles, exhibiting stronger generalization ability and adaptability.
OmniSQL project address
- Github repository:https://github.com/RUCKBReasoning/OmniSQL
- arXiv technical paper:https://arxiv.org/pdf/2503.02240
OmniSQL application scenarios
- Enterprise Data AnalysisOmniSQL enables non-technical users to easily retrieve the information they need from the database through natural language query capabilities.
- EducationIn SQL instruction, OmniSQL's Chained Thinking (CoT) solution helps beginners better understand the transformation process from natural language questions to SQL queries. Instructors can use OmniSQL to generate query examples, allowing students to master SQL concepts and skills through hands-on practice.
- Cross-domain adaptationOmniSQL, based on its data synthesis framework, can quickly generate domain-specific datasets. In the medical field, it can generate EHRSQL datasets to support medical research; in the scientific research field, it can generate ScienceBenchmark datasets to assist in scientific data analysis.