Table of Contents
Fetching ...

A Preview of XiYan-SQL: A Multi-Generator Ensemble Framework for Text-to-SQL

Yingqi Gao, Yifu Liu, Xiaoxia Li, Xiaorong Shi, Yin Zhu, Yiming Wang, Shiqi Li, Wei Li, Yuntao Hong, Zhiling Luo, Jinyang Gao, Liyu Mou, Yu Li

TL;DR

XiYan-SQL tackles NL2SQL by marrying a multi-generator ensemble with a dedicated schema representation (M-Schema) and a skeleton-aware in-context-learning strategy, augmented by a SQL refiner and a learned candidate selector. The framework orchestrates Schema Linking, diverse Candidate Generation (fine-tuned and ICL) and a targeted Candidate Selection to produce accurate SQL across relational and graph databases. Empirical results establish state-of-the-art execution accuracy on Spider, Bird, SQL-Eval and NL2GQL benchmarks, underscoring robustness to distribution shifts. The work provides open-source tooling and data representations, highlighting practical potential for scalable NL2SQL deployment in real-world databases.

Abstract

To tackle the challenges of large language model performance in natural language to SQL tasks, we introduce XiYan-SQL, an innovative framework that employs a multi-generator ensemble strategy to improve candidate generation. We introduce M-Schema, a semi-structured schema representation method designed to enhance the understanding of database structures. To enhance the quality and diversity of generated candidate SQL queries, XiYan-SQL integrates the significant potential of in-context learning (ICL) with the precise control of supervised fine-tuning. On one hand, we propose a series of training strategies to fine-tune models to generate high-quality candidates with diverse preferences. On the other hand, we implement the ICL approach with an example selection method based on named entity recognition to prevent overemphasis on entities. The refiner optimizes each candidate by correcting logical or syntactical errors. To address the challenge of identifying the best candidate, we fine-tune a selection model to distinguish nuances of candidate SQL queries. The experimental results on multiple dialect datasets demonstrate the robustness of XiYan-SQL in addressing challenges across different scenarios. Overall, our proposed XiYan-SQL achieves the state-of-the-art execution accuracy of 75.63% on Bird benchmark, 89.65% on the Spider test set, 69.86% on SQL-Eval, 41.20% on NL2GQL. The proposed framework not only enhances the quality and diversity of SQL queries but also outperforms previous methods.

A Preview of XiYan-SQL: A Multi-Generator Ensemble Framework for Text-to-SQL

TL;DR

XiYan-SQL tackles NL2SQL by marrying a multi-generator ensemble with a dedicated schema representation (M-Schema) and a skeleton-aware in-context-learning strategy, augmented by a SQL refiner and a learned candidate selector. The framework orchestrates Schema Linking, diverse Candidate Generation (fine-tuned and ICL) and a targeted Candidate Selection to produce accurate SQL across relational and graph databases. Empirical results establish state-of-the-art execution accuracy on Spider, Bird, SQL-Eval and NL2GQL benchmarks, underscoring robustness to distribution shifts. The work provides open-source tooling and data representations, highlighting practical potential for scalable NL2SQL deployment in real-world databases.

Abstract

To tackle the challenges of large language model performance in natural language to SQL tasks, we introduce XiYan-SQL, an innovative framework that employs a multi-generator ensemble strategy to improve candidate generation. We introduce M-Schema, a semi-structured schema representation method designed to enhance the understanding of database structures. To enhance the quality and diversity of generated candidate SQL queries, XiYan-SQL integrates the significant potential of in-context learning (ICL) with the precise control of supervised fine-tuning. On one hand, we propose a series of training strategies to fine-tune models to generate high-quality candidates with diverse preferences. On the other hand, we implement the ICL approach with an example selection method based on named entity recognition to prevent overemphasis on entities. The refiner optimizes each candidate by correcting logical or syntactical errors. To address the challenge of identifying the best candidate, we fine-tune a selection model to distinguish nuances of candidate SQL queries. The experimental results on multiple dialect datasets demonstrate the robustness of XiYan-SQL in addressing challenges across different scenarios. Overall, our proposed XiYan-SQL achieves the state-of-the-art execution accuracy of 75.63% on Bird benchmark, 89.65% on the Spider test set, 69.86% on SQL-Eval, 41.20% on NL2GQL. The proposed framework not only enhances the quality and diversity of SQL queries but also outperforms previous methods.

Paper Structure

This paper contains 26 sections, 10 figures, 8 tables.

Figures (10)

  • Figure 1: Overview of the proposed XiYan-SQL workflow, which consists of three agents: 1) Schema Linking, which retrieves and selects the most database schema; 2) Candidate Generation: which generates high-quality candidate SQL queries using ICL and SFT generators; 3) Candidate Selection, which picks the final response among the generated candidates. M-Schema is served as schema representation and provided to LLMs.
  • Figure 2:
  • Figure 3: The two-stage and multi-task training pipeline for Fine-tuned SQL generators.
  • Figure 4: An example of natural language to SQLite.
  • Figure 5: An example of natural language to PostgreSQL.
  • ...and 5 more figures