NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Enhancing Text-to-SQL with Question Classification and Multi-Agent Collaboration

Zhihui Shao, Shubin Cai, Rongsheng Lin, Zhong MingNAACL 2025

Abstract

The QCMA-SQL framework introduces a novel approach to Text-to-SQL conversion by combining a traditional schema selector with a specialized multi-agent Large Language Model (LLM) system. By categorizing questions by difficulty and filtering relevant schema elements, the framework addresses the dual challenges of schema linking and query complexity. QCMA-SQL achieves a state-of-the-art 87.4% execution accuracy on the Spider benchmark while significantly reducing inference costs compared to existing methods.

Introduction

Converting natural language into SQL (Text-to-SQL) is essential for democratizing data access. However, current systems struggle with two primary issues: precise schema linking in large databases and handling varying query complexities. Standard "one-size-fits-all" prompts often over-complicate simple queries or fail to decompose complex ones. QCMA-SQL addresses these challenges by introducing a "difficulty-aware" workflow that optimizes both accuracy and efficiency.

Methodology

The QCMA-SQL architecture consists of two main stages: a Schema Selector and a Multi-Agent Collaborative Framework.

1. The Schema Selector

A fine-tuned DeBERTa-v3 model acts as a filter. It classifies questions as "Simple" or "Complex" and utilizes cross-attention mechanisms to identify relevant tables and columns. This step reduces noise and token consumption for the subsequent LLM stage by providing an "aligned schema."

2. Multi-Agent Collaborative Framework

Based on the classification, queries are routed to specialized agents within a collaborative loop:

  • SQL Developer: Uses Retrieval-Augmented Generation (RAG) to handle simple questions by referencing similar pairs in a vector database.
  • SQL Researcher: Employs Chain-of-Thought (CoT) and task decomposition for complex questions.
  • SQL Executor & Specialist: The Executor runs syntax checks and attempts execution. If an error occurs, the Specialist analyzes the feedback to "debug" and revise the SQL iteratively.
The QCMA-SQL architecture featuring the Schema Selector and Multi-Agent Collaborative Framework.

Evaluation and Results

The framework was evaluated on the Spider benchmark, CSpider (Chinese), and several robustness variants (Spider-DK, SYN, Realistic). QCMA-SQL achieved 87.4% execution accuracy on the Spider dev set, outperforming previous leaders like MAC-SQL (86.7%) and DIN-SQL (82.8%).

Notably, the model demonstrated its greatest strength in the "Hard" and "Extra" difficulty categories. On "Hard" questions, it achieved an 83.9% accuracy, representing a significant gain over previous baselines.

Execution accuracy of QCMA-SQL compared to baselines across different difficulty levels on the Spider benchmark.

Discussion and Insights

A key finding of the study is the importance of difficulty-awareness. Ablation tests revealed that forcing simple questions through complex decomposition pipelines actually reduced accuracy, as the LLM tended to over-complicate the logic. Furthermore, the hybrid approach is highly cost-effective; processing the Spider dataset cost approximately $60 with QCMA-SQL, compared to over $300 for competing methods like DAIL-SQL.

Despite its success, the system faces limitations. The PLM-based selector has a limited context window, which may hinder performance on extremely large schemas. Additionally, the SQL Developer's performance is tied to the quality of the vector database used for RAG. Future work will focus on scaling the schema selector and automating prompt optimization.

Conclusion

QCMA-SQL demonstrates that a tiered, multi-agent approach—supported by efficient schema filtering—can significantly advance the state-of-the-art in Text-to-SQL tasks. By treating query complexity as a first-class citizen, the framework achieves high accuracy with remarkable cost efficiency.

Summary updated

BibTeX
@inproceedings{shao2025enhancing,
  author = {Zhihui Shao and Shubin Cai and Rongsheng Lin and Zhong Ming},
  title = {{Enhancing Text-to-SQL with Question Classification and Multi-Agent Collaboration}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.findings-naacl.245},
}
Figure