[Paper Review] MAC-SQL: A Multi-Agent Collaborative Framework for Text-to-SQL
MAC-SQL proposes a multi-agent collaborative framework for Text-to-SQL that uses a Decomposer agent for chain-of-thought reasoning, a Selector agent for sub-database extraction, and a Refiner agent for SQL validation and correction using external tools. It achieves a new state-of-the-art execution accuracy of 59.59% on the BIRD benchmark using GPT-4, demonstrating strong performance on complex, real-world databases.
Recent LLM-based Text-to-SQL methods usually suffer from significant performance degradation on "huge" databases and complex user questions that require multi-step reasoning. Moreover, most existing methods neglect the crucial significance of LLMs utilizing external tools and model collaboration. To address these challenges, we introduce MAC-SQL, a novel LLM-based multi-agent collaborative framework. Our framework comprises a core decomposer agent for Text-to-SQL generation with few-shot chain-of-thought reasoning, accompanied by two auxiliary agents that utilize external tools or models to acquire smaller sub-databases and refine erroneous SQL queries. The decomposer agent collaborates with auxiliary agents, which are activated as needed and can be expanded to accommodate new features or tools for effective Text-to-SQL parsing. In our framework, We initially leverage GPT-4 as the strong backbone LLM for all agent tasks to determine the upper bound of our framework. We then fine-tune an open-sourced instruction-followed model, SQL-Llama, by leveraging Code Llama 7B, to accomplish all tasks as GPT-4 does. Experiments show that SQL-Llama achieves a comparable execution accuracy of 43.94, compared to the baseline accuracy of 46.35 for vanilla GPT-4. At the time of writing, MAC-SQL+GPT-4 achieves an execution accuracy of 59.59 when evaluated on the BIRD benchmark, establishing a new state-of-the-art (SOTA) on its holdout test set (https://github.com/wbbeyourself/MAC-SQL).
Motivation & Objective
- To address performance degradation of LLM-based Text-to-SQL methods on large databases and complex, multi-step questions.
- To overcome the limitation of existing methods in leveraging external tools and collaborative reasoning.
- To design a modular, extensible framework where specialized agents handle distinct sub-tasks in SQL generation.
- To fine-tune an open-source 7B model, SQL-Llama, to match GPT-4’s performance in a collaborative agent setup.
- To establish a new state-of-the-art result on the BIRD benchmark through multi-agent collaboration.
Proposed method
- The framework employs three specialized agents: a Decomposer for question decomposition and chain-of-thought SQL generation, a Selector for extracting relevant sub-databases to reduce noise, and a Refiner for executing and correcting SQL via external tools.
- The Decomposer uses few-shot chain-of-thought prompting to generate step-by-step reasoning before producing SQL.
- The Selector dynamically simplifies large databases by isolating relevant tables and columns based on the question.
- The Refiner uses an external SQL executor to validate generated queries and iteratively correct errors using feedback.
- The system supports plug-in extensibility, allowing integration of new tools or agents for evolving requirements.
- An instruction-tuned dataset derived from BIRD and Spider is used to fine-tune the open-source SQL-Llama (7B) model to replicate GPT-4’s agent behaviors.
Experimental results
Research questions
- RQ1Can a multi-agent collaborative framework improve Text-to-SQL performance on complex, real-world databases with high schema complexity?
- RQ2How effective is chain-of-thought reasoning combined with external tool usage in reducing SQL generation errors?
- RQ3To what extent can a fine-tuned 7B open-source LLM match the performance of GPT-4 in a multi-agent Text-to-SQL pipeline?
- RQ4Does sub-database selection significantly reduce interference from irrelevant schema elements in large databases?
- RQ5Can a modular agent architecture generalize across diverse error types and support extensibility for new tools?
Key findings
- MAC-SQL+GPT-4 achieves a new state-of-the-art execution accuracy of 59.59% on the BIRD benchmark’s holdout test set.
- The fine-tuned SQL-Llama (7B) model achieves 43.94% execution accuracy, closely approaching GPT-4’s baseline of 46.35%.
- The framework significantly reduces schema linking errors and improves robustness on complex, multi-step questions compared to prior methods.
- The use of external tools via the Refiner agent enables effective feedback-driven SQL correction, reducing execution errors.
- The modular agent design allows for dynamic activation and extensibility, supporting integration of new tools and reasoning modules.
- The released agent-instruction dataset and SQL-Llama model provide a foundation for reproducible, open-source research in collaborative Text-to-SQL.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.