用自奖励搜索提升文本转SQL准确率,尤其擅长复杂查询。
SQL-o1: A Self-Reward Heuristic Dynamic Search Method for Text-to-SQL
- 基于智能体架构,结合MCTS与动态剪枝进行多步推理
- 在Bird数据集上比现有方法高10.8%执行准确率,超越GPT-4
- 适合作为开源模型的高效文本转SQL解决方案
文本转SQL(Text2SQL)旨在将自然语言问题映射为可执行的SQL查询。尽管大语言模型(LLMs)推动了显著进展,但当前方法在开源模型上的迁移能力弱、对复杂查询中的逻辑与函数错误缺乏鲁棒性,且结构化搜索效率低。我们提出SQL-o1,一种基于智能体架构的自奖励驱动启发式搜索框架,以增强模型推理能力。SQL-o1利用蒙特卡洛树搜索(MCTS)实现结构化的多步探索,并引入动态剪枝策略,在不损失准确率的前提下加速推理。在Spider和Bird基准测试中,SQL-o1在复杂Bird数据集上实现+10.8%的执行准确率提升,甚至超过基于GPT-4的模型。其展现出强少样本泛化能力和跨模型的鲁棒迁移性。代码已公开:https://github.com/ShuaiLyu0110/SQL-o1。
原文摘要 · Abstract (English)
Text-to-SQL (Text2SQL) aims to map natural language questions to executable SQL queries. Although large language models (LLMs) have driven significant progress, current approaches struggle with poor transferability to open-source LLMs, limited robustness against logic and function errors in complex queries, and inefficiencies in structured search. We introduce SQL-o1, a self-reward-driven heuristic search framework built on an agent-based architecture to enhance model reasoning capabilities. SQL-o1 leverages Monte Carlo Tree Search (MCTS) for structured, multi-step exploration, and incorporates a dynamic pruning strategy to accelerate inference without sacrificing accuracy. On the Spider and Bird benchmarks, SQL-o1 achieves a +10.8 execution accuracy improvement on the complex Bird dataset, surpassing even GPT-4-based models. Notably, it exhibits strong few-shot generalization and robust cross-model transferability across open-source LLMs. Our code is available at:https://github.com/ShuaiLyu0110/SQL-o1.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。