Aha.
正在载入中英对照阅读…

arXiv:2502.11741 · 中英对照阅读

SQL-o1: Automatic Text-to-SQL Program Synthesis via Self-Reward Heuristic Search

Shuai Lyu、Haoran Luo、Ripeng Li、Zhonghong Ou、Yifan Zhu、Tiesunlong Shen

中文速览

复杂问题常让自然语言转成 SQL 时出错,而依赖单次生成的方法也难以直接迁移到开源大模型。SQL-o1 让模型把查询逐步写出来,再用蒙特卡洛树搜索(MCTS)探索不同写法,并依据模型信心和执行结果给候选查询打分、动态剪枝。实验显示,它在复杂的 BIRD 基准上比对照方法高出 10.8 个百分点,也能迁移到多种开源模型,在少样本场景下表现稳健。这说明把 SQL 生成变成有反馈、可控的逐步搜索,有望让数据库问答更准确,也更容易部署到不同模型上。

摘要

Efficient human–database interaction is a core problem in software engineering. Text-to-SQL (Text2SQL) tackles this by mapping natural language questions to executable SQL queries, enabling automatic SQL synthesis and reliable interaction. Although large language models (LLMs) have advanced significantly, 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-point execution accuracy improvement on the complex BIRD dataset, surpassing even GPT-4-based models. 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.

术语表

Text-to-SQL (Text2SQL)
自然语言到 SQL
SQL-o1
SQL-o1
large language model (LLM)
大语言模型(LLM)
self-reward
自奖励
heuristic search
启发式搜索
agent-based architecture
基于智能体的架构
Monte Carlo Tree Search (MCTS)
蒙特卡洛树搜索(MCTS)
dynamic pruning strategy
动态剪枝策略
execution accuracy
执行准确率
Spider
Spider
BIRD
BIRD
few-shot generalization
少样本泛化
cross-model transferability
跨模型迁移能力
single-pass decoding
单次解码
Chain-of-Thought (CoT)
思维链(CoT)
schema linking
模式链接
Progressive SQL Generation (PSG)
渐进式 SQL 生成(PSG)
cold-start fine-tuning
冷启动微调
SQL-prefix generation
SQL 前缀生成
symbolic state-action interface
符号化状态—动作接口
confidence-based dynamic pruning
基于置信度的动态剪枝
execution feedback
执行反馈
execution consistency
执行一致性
rollout
模拟展开
reinforcement learning
强化学习
GRPO
GRPO
policy optimization
策略优化
relational database
关系型数据库
foreign key
外键
search tree
搜索树