Despite the significant advancements in Text-to-SQL (Text2SQL) facilitated by large language models (LLMs), the latest state-of-the-art techniques are still trapped in the in-context learning of closed-source LLMs (e.g., GPT-4), which limits their applicability in open scenarios. To address this challenge, we propose a novel RObust mUltitask Tuning and collaboration mEthod (ROUTE) to improve the comprehensive capabilities of open-source LLMs for Text2SQL, thereby providing a more practical solution. Our approach begins with multi-task supervised fine-tuning (SFT) using various synthetic training data related to SQL generation. Unlike existing SFT-based Text2SQL methods, we introduced several additional SFT tasks, including schema linking, noise correction, and continuation writing. Engaging in a variety of SQL generation tasks enhances the model's understanding of SQL syntax and improves its ability to generate high-quality SQL queries. Additionally, inspired by the collaborative modes of LLM agents, we introduce a Multitask Collaboration Prompting (MCP) strategy. This strategy leverages collaboration across several SQL-related tasks to reduce hallucinations during SQL generation, thereby maximizing the potential of enhancing Text2SQL performance through explicit multitask capabilities. Extensive experiments and in-depth analyses have been performed on eight open-source LLMs and five widely-used benchmarks. The results demonstrate that our proposal outperforms the latest Text2SQL methods and yields leading performance.
翻译:尽管大语言模型(LLM)显著推动了文本到SQL(Text2SQL)领域的发展,当前最先进的技术仍局限于闭源LLM(如GPT-4)的上下文学习范式,这限制了其在开放场景中的适用性。为应对这一挑战,本文提出一种新颖的鲁棒多任务调优与协作方法(ROUTE),旨在提升开源LLM在Text2SQL任务上的综合能力,从而提供更具实用性的解决方案。我们的方法首先利用多种与SQL生成相关的合成训练数据进行多任务监督微调(SFT)。与现有基于SFT的Text2SQL方法不同,我们引入了多项额外的SFT任务,包括模式链接、噪声校正和续写生成。通过参与多样化的SQL生成任务,模型能够深化对SQL语法的理解,并提升生成高质量SQL查询的能力。此外,受LLM智能体协作模式的启发,我们提出了多任务协作提示(MCP)策略。该策略通过多个SQL相关任务间的协作,减少SQL生成过程中的幻觉现象,从而最大限度发挥显式多任务能力对提升Text2SQL性能的潜力。我们在八个开源LLM和五个广泛使用的基准数据集上进行了大量实验与深入分析。结果表明,所提方法优于最新的Text2SQL技术,并取得了领先的性能表现。