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

Shuai Lyu, Haoran Luo, Ripeng Li, Zhonghong Ou, Yifan Zhu +1 more
2/17/2025
27 citations
cs.DBcs.AI

Official code: ShuaiLyu0110/SQL-o1 (197 stars, Python, last commit 2026-08-27).

Abstract

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

[ACM TOSEM] Official resources for "SQL-o1: Automatic Text-to-SQL Program Synthesis via Self-Reward Heuristic Search".

19721Python, ShellFeb 17, 20253 months ago
heuristic-dynamic-searchmcts-algorithmself-rewardingtext-to-sql

Similar Papers

Cite this paper

@article{lyu2025sqlo,
  title  = {SQL-o1: Automatic Text-to-SQL Program Synthesis via Self-Reward Heuristic Search},
  author = {Shuai Lyu and Haoran Luo and Ripeng Li and Zhonghong Ou and Yifan Zhu and Tiesunlong Shen},
  year   = {2025},
  eprint = {2502.11741},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.11741v4}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.11741.svg)](https://codeofpaper.com/paper/2502.11741)

Discussion