MCTS-SQL: 轻量级大语言模型可通过蒙特卡洛树搜索掌握文本到SQL
MCTS-SQL: Light-Weight LLMs can Master the Text-to-SQL through Monte Carlo Tree Search
AI总结:
MCTS-SQL通过蒙特卡洛树搜索引导轻量级大语言模型高效生成SQL查询,实验证明其在文本到SQL任务中优于现有方法。
摘要:
文本到SQL是自然语言处理领域中的基础但具有挑战性的任务,旨在将自然语言问题转换为SQL查询。尽管近年来大语言模型的进展显著提升了性能,但大多数现有方法依赖于具有数十亿参数的模型或昂贵的API,限制了其在资源受限环境中的应用。在现实世界中,尤其是在边缘设备上,确保文本到SQL的成本效益至关重要。因此,使轻量级模型能够处理文本到SQL具有重要的实际意义。然而,较小的LLM通常在处理复杂的用户指令、冗余的模式链接或语法正确性方面遇到困难。为了解决这些挑战,我们提出了MCTS-SQL,一种新的框架,利用蒙特卡洛树搜索通过多步骤细化来引导SQL生成。由于轻量级模型的单次预测性能较弱,我们通过多次试验和反馈生成更好的结果。然而,直接应用基于MCTS的方法不可避免地会导致显著的时间和计算开销。受此问题的驱动,我们提出了一种令牌级前缀缓存机制,在迭代过程中存储先前信息,有效提高了执行速度。在SPIDER和BIRD基准测试中的实验结果证明了我们方法的有效性。使用一个小型开源的Qwen2.5-Coder-1.5B模型,我们的方法在ChatGPT-3.5上表现更优。当利用更强大的Gemini 2.5模型探索性能上限时,我们实现了与SOTA相当的结果。我们的发现表明,即使小型模型在正确策略下也能有效部署在实际的文本到SQL系统中。
英文摘要:
Text-to-SQL is a fundamental yet challenging task in the NLP area, aiming at translating natural language questions into SQL queries. While recent advances in large language models have greatly improved performance, most existing approaches depend on models with tens of billions of parameters or costly APIs, limiting their applicability in resource-constrained environments. For real world, especially on edge devices, it is crucial for Text-to-SQL to ensure cost-effectiveness. Therefore, enabling the light-weight models for Text-to-SQL is of great practical significance. However, smaller LLMs often struggle with complicated user instruction, redundant schema linking or syntax correctness. To address these challenges, we propose MCTS-SQL, a novel framework that uses Monte Carlo Tree Search to guide SQL generation through multi-step refinement. Since the light-weight models' weak performance of single-shot prediction, we generate better results through several trials with feedback. However, directly applying MCTS-based methods inevitably leads to significant time and computational overhead. Driven by this issue, we propose a token-level prefix-cache mechanism that stores prior information during iterations, effectively improved the execution speed. Experiments results on the SPIDER and BIRD benchmarks demonstrate the effectiveness of our approach. Using a small open-source Qwen2.5-Coder-1.5B, our method outperforms ChatGPT-3.5. When leveraging a more powerful model Gemini 2.5 to explore the performance upper bound, we achieved results competitive with the SOTA. Our findings demonstrate that even small models can be effectively deployed in practical Text-to-SQL systems with the right strategy.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。