This technical report introduces XiYan-SQL, a new framework for translating natural language queries into SQL queries (NL2SQL). The authors argue that existing approaches, based on either prompt engineering or supervised fine-tuning (SFT), have limitations in terms of inference overhead or ability to handle complex reasoning and new domains.
XiYan-SQL addresses these limitations by combining prompt engineering and SFT in a multi-generator ensemble strategy. The framework consists of three main components:
This component identifies the relevant parts of the database schema for a given natural language query. It uses a retrieval module to find similar values and columns, and a column selector to narrow down the schema to the essential elements.
This component generates multiple candidate SQL queries using a combination of fine-tuned SQL generators and an in-context learning (ICL) SQL generator. The fine-tuned generators are trained using a two-stage, multi-task approach to produce high-precision candidates with diverse syntactic styles. The ICL generator leverages the power of large language models (LLMs) by providing them with relevant examples from the training set. A SQL Refiner further optimizes the generated candidates by correcting logical or syntactical errors.
This component selects the best SQL query from the generated candidates. Instead of relying solely on self-consistency, XiYan-SQL employs a dedicated selection model fine-tuned to distinguish nuances among candidates.
Furthermore, the authors introduce M-Schema, a new schema representation method designed to improve LLMs' understanding of database structures. M-Schema presents the hierarchical relationships between databases, tables, and columns in a semi-structured format, incorporating data types, primary key markings, column descriptions, and example values.
The authors evaluate XiYan-SQL on several benchmark datasets for both relational and non-relational databases, including Spider, Bird, SQL-Eval, and NL2GQL. The results demonstrate that XiYan-SQL achieves state-of-the-art performance on these benchmarks, outperforming existing methods. Ablation studies further confirm the effectiveness of each component in the framework.
The authors conclude that XiYan-SQL represents a significant advancement in NL2SQL technology, offering high quality and diversity in generated SQL queries. They suggest that the framework has the potential for broader applications in NL2SQL translation tasks.
На другой язык
из исходного контента
arxiv.org
Дополнительные вопросы