cs.DBFeb 17, 2025

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

Authors: Shuai Lyu, Haoran Luo, Ripeng Li, Zhonghong Ou, Yifan Zhu, Tiesunlong Shen

Organizations: School of Computer Science, Beijing University of Posts and Telecommunications, China. · College of Computing and Data Science, Nanyang Technological University, Singapore. · State Key Laboratory of Networking and Switching Technology, Beijing University of Posts and Telecommunications, China.

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. 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.

Figures & tables

Explore similar work

CardsList
  1. Integrating Reasoning and Generalization in Text-to-SQL via Self-Enhanced Fine-Tuning

    Jun 14, 2026Feng Lyu, Jinfeng Cen, Sijing Duan +4Execution-Guided Text-to-SQLSelf-Training for Language Models

  2. VCoT-SQL: Enhancing Text-to-SQL Generation through Dual Chain-of-Thought Validation Training

    Oct 31, 2026Rui Zhang, Yujia Su, Ruixuan Li +2Text-to-SQLExecution-Guided Text-to-SQL

  3. FINER-SQL: Boosting Small Language Models for Text-to-SQL

    May 5, 2026Thanh Dat Hoang, Thanh Trung Huynh, Matthias Weidlich +4Reward ModelingSmall Language Models