arXiv:2501.16607cs.DBcs.AI2025-01AAAI被引 4

轻量模型通过蒙特卡洛树搜索实现精准文本转SQL

MCTS-SQL: Light-Weight LLMs can Master the Text-to-SQL through Monte Carlo Tree Search

  • 用蒙特卡洛树搜索分步优化生成SQL,克服小模型一次预测不足
  • 在SPIDER和BIRD上超越ChatGPT-3.5,1.5B模型达SOTA水平
  • 提出词级别前缀缓存,显著降低计算开销,适合边缘部署

文本转SQL是NLP中的基础且挑战性任务,旨在将自然语言问题转化为SQL查询。尽管大语言模型近年大幅提升性能,但多数方法依赖数十亿参数的模型或昂贵API,限制了在资源受限环境的应用。在实际场景中,尤其在边缘设备上,实现成本效益的Text-to-SQL至关重要。因此,使轻量级模型具备该能力具有重要实践意义。然而,小型模型常难以应对复杂指令、冗余模式链接或语法正确性。为此,我们提出MCTS-SQL框架,利用蒙特卡洛树搜索通过多步精炼引导SQL生成。由于轻量模型单次预测表现弱,我们通过多次尝试与反馈生成更优结果。但直接应用MCTS会带来显著的时间和计算开销。针对此问题,我们提出词级别前缀缓存机制,存储迭代过程中的先验信息,有效提升执行速度。在SPIDER和BIRD基准上的实验表明,使用小型开源模型Qwen2.5-Coder-1.5B,本方法性能超过ChatGPT-3.5;采用更强模型Gemini 2.5时,达到与当前最优(SOTA)相当的结果。研究证明,只要策略得当,小型模型也可高效部署于实际Text-to-SQL系统。

原文摘要 · Abstract (English)

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.

文本转SQL轻量模型蒙特卡洛树搜索边缘计算

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。