X-SQL: Schema-Aware Text-to-SQL Framework
- X-SQL is a comprehensive framework for schema-aware Text-to-SQL conversion that integrates supervised fine-tuning for schema linking with natural language schema enrichment.
- Utilizing a multi-LLM orchestration, X-SQL decouples schema linking, explanation, and SQL generation tasks to achieve state-of-the-art execution accuracies on benchmark datasets.
- Innovative features such as enhanced inference strategy in X-Linking and expert prompt-based schema translation in X-Admin ensure precise mapping of natural queries to complex relational data.
X-SQL is a comprehensive framework for Text-to-SQL conversion that addresses the critical role of database schema information in generating high-quality SQL queries. The architecture is distinguished by two expert modules: X-Linking, which employs supervised fine-tuning (SFT) for schema linking, and X-Admin, which enriches schema understanding by translating technical database metadata into detailed, human-readable descriptions. The framework also leverages multiple LLMs (Multi-LLMs) specialized for different system components. These innovations collectively enable X-SQL to achieve state-of-the-art execution accuracies on standard Text-to-SQL benchmarks, positioning it as the leading open-source solution for schema-aware query generation (Peng, 7 Sep 2025).
1. X-Linking: Supervised Fine-Tuning for Schema Linking
X-Linking is a supervised fine-tuning method dedicated to schema linking, i.e., identifying and extracting the relevant schema elements (tables) that must be involved in the target SQL query given a natural language input and the full candidate schema. Formally, for input schema S (tables and columns), foreign key relationships K, and user question Q, the objective is to maximize
where is the set of table names that should be selected.
The module is trained using a cross-entropy loss between the predicted set of table names and the ground truth , with the LLM (e.g., CodeQwen1.5-7B-Chat) receiving M(S, K, Q) as input. A key methodological innovation is the enhanced inference strategy: at prediction time, the order of S and K is shuffled multiple times, and the outputs are aggregated via set union, minimizing ordering biases in the LLM and leading to higher recall and correctness (metrics , ) compared to joint-task or implicit schema linking approaches such as those in DIN-SQL and PET-SQL.
2. X-Admin: Schema Understanding through Natural Language Enrichment
X-Admin bridges the semantic chasm between raw schema specifications and user intent by generating detailed, context-aware natural language descriptions of schema elements. This process involves translating each table/column name, optionally enriched with sample values, into descriptive English that elucidates its semantic role and functional relationships to other tables. For example, the column "prereq(prereq_id)" is described as "unique identifier of course’s prerequisite, useful for connecting with the course table."
This translation allows subsequent LLM modules to align schema semantics with the user's phrasing, thus improving mapping accuracy from natural language to database elements. X-Admin operates through role prompting (database administrator expert) rather than fine-tuning and, in ablation studies, increased end-to-end performance by 1.7%. Its effectiveness is attributed to explicit mention of column purpose and inter-table connectivity, which are typically underspecified in raw schemas.
3. Multi-LLMs System Integration
Instead of a monolithic LLM, X-SQL strategically incorporates multiple LLMs for different system components:
- X-Linking: SFT-tuned model (e.g., CodeQwen1.5-7B-Chat) for high-precision schema linking.
- X-Admin: Prompted "database expert" model to generate natural language schema explanations.
- SQL Generation and Debugging: Separate LLMs may be employed to further reduce self-favoring bias and specialize each stage.
This modular Multi-LLMs deployment delivers measurable gains (up to 2.2% execution accuracy increase on Spider-Test) and empirically overcomes single-model limitations found in end-to-end finetuning or self-consistency-only strategies. By decoupling the schema linking, schema enrichment, and SQL generation tasks, each subtask is handled by an LLM most suited to its operational requirements.
4. Performance Benchmarks and Comparative Results
X-SQL achieves the following execution accuracies:
Dataset | X-SQL Execution Accuracy | Best Previous Open-Source |
---|---|---|
Spider-Dev | 84.9% | 84.1% (RESDSQL) |
Spider-Test | 82.5% | 79.9% (RESDSQL) |
These scores represent new state-of-the-art results for open-source Text-to-SQL systems. Improvements are primarily attributed to:
- X-Linking's schema filtering (7.3% gain)
- X-Admin's schema enrichment (1.7% gain)
- Multi-LLMs orchestration (up to 2.2% additional gain)
Ablation experiments confirm each component’s necessity for optimal performance and demonstrate robustness across schema sizes and query complexities.
5. System Architecture and Workflow
The following diagram summarizes the X-SQL pipeline:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
User NL Query + Full Schema (Tables, Columns, Foreign Keys) | [X-Linking: SFT model] ↓ Pruned Schema (Relevant Tables) | [X-Admin: Expert LLM] ↓ Enriched NL Schema Descriptions | [SQL Generation LLM] ↓ Candidate SQL | [Debugging LLM (if needed)] ↓ Final SQL Query (for execution) |
At each stage, outputs from the prior module (e.g., filtered tables, schema explanations) are leveraged as input context, and Multi-LLMs can be independently swapped or tuned.
6. Methodological Considerations and Implications
The X-SQL framework’s explicit division of labor—schema linking, schema understanding, SQL generation, debugging—mirrors practical DBMS query planning, but is adapted for LLM-driven automation. By treating schema linking as a stand-alone SFT problem and schema understanding as a prompt-driven translation task, X-SQL addresses recurring pitfalls in generic Text-to-SQL systems such as “lost-in-translation” errors, low recall for relevant tables, and hallucination of incorrect joins and filters.
Implications include:
- Expansion of schema-aware generation for complex, multi-table queries.
- Quantifiable accuracy gains validated by controlled ablations.
- Modular extensibility for future LLM improvements, prompt engineering, or expansion to new database backends.
7. Broader Context and Future Directions
X-SQL illustrates a broader trend whereby schema-aware design is recognized as foundational rather than auxiliary in natural language interfaces to databases. The explicit modeling of linking and understanding steps may inform future hybrid or multi-agent LLM frameworks for other structured data applications. Additionally, the framework’s strong empirical performance on Spider-Dev and Spider-Test indicates further gains could come from the inclusion of richer table/column semantics, dynamic schema adaptation, and cross-schema transfer.
A plausible implication is that future X-SQL research will extend to robust handling of non-relational and semi-structured backends, as well as cross-schema migration and federated querying, where schema linking and enrichment become even more central.
In summary, X-SQL is characterized by its expert modules for schema linking and understanding, deployment of multi-LLMs, and demonstrated gains in execution accuracy, notably advancing the state of research on schema-centric Text-to-SQL systems (Peng, 7 Sep 2025).