Table of Contents
Fetching ...

HES-SQL: Hybrid Reasoning for Efficient Text-to-SQL with Structural Skeleton Guidance

Suming Qiu, Jing Li, Zhicheng Zhou, Junjie Huang, Linyuan Qiu, Zhijie Sun

TL;DR

HES-SQL tackles the dual challenge of semantic accuracy and execution efficiency in Text-to-SQL by integrating a hybrid thinking framework with Group Relative Policy Optimization. The method introduces skeleton-completeness and latency-aware rewards, plus a progressive self-distillation SFT phase to preserve reasoning capabilities while RL fine-tuning, enabling the model to switch between fast and slow thinking. Empirical results on MySQL 8.0 and SQLite 3.42 show competitive execution accuracies (e.g., 79.14% on BIRD and 54.9% on KaggleDBQA) and latency reductions of 11–20% relative to baselines. This work establishes a new paradigm for Text-to-SQL that balances semantic correctness with practical execution costs, with potential impact on robust NL-to-DB interfaces and broader structured-generation tasks.

Abstract

We present HES-SQL, a novel hybrid training framework that advances Text-to-SQL generation through the integration of thinking-mode-fused supervised fine-tuning (SFT) with Group Relative Policy Optimization (GRPO). Our approach introduces three key innovations: (1) a skeleton-completeness scoring mechanism that enhances preference alignment between generated queries and optimal SQL structures; (2) a query-latency-aware reward system that incentivizes the generation of computationally efficient SQL queries; (3) a self-distillation process for thinking-mode completion that prevents degradation of the model's reasoning capabilities. This framework enables hybrid thinking models to switch between reasoning and non-reasoning modes while improving SQL query accuracy and execution efficiency. Experimental evaluation, conducted on MySQL 8.0 and SQLite 3.42 under controlled single-user conditions, demonstrates that HES-SQL achieves competitive performance with execution accuracies of 79.14\% and 54.9\% on the BIRD and KaggleDBQA benchmarks, respectively. Query latency is measured as the end-to-end execution time of generated queries on the DBMS, averaged over multiple runs to mitigate variance. Efficiency gains range from 11\% to 20\% relative to supervised baselines. Our results establish a new paradigm for Text-to-SQL systems that effectively balances semantic accuracy with computational efficiency through execution-informed reinforcement learning (RL). The proposed methodology has significant implications for developing robust natural language interfaces to databases and can be extended to broader structured generation tasks requiring both correctness and efficiency optimization.

HES-SQL: Hybrid Reasoning for Efficient Text-to-SQL with Structural Skeleton Guidance

TL;DR

HES-SQL tackles the dual challenge of semantic accuracy and execution efficiency in Text-to-SQL by integrating a hybrid thinking framework with Group Relative Policy Optimization. The method introduces skeleton-completeness and latency-aware rewards, plus a progressive self-distillation SFT phase to preserve reasoning capabilities while RL fine-tuning, enabling the model to switch between fast and slow thinking. Empirical results on MySQL 8.0 and SQLite 3.42 show competitive execution accuracies (e.g., 79.14% on BIRD and 54.9% on KaggleDBQA) and latency reductions of 11–20% relative to baselines. This work establishes a new paradigm for Text-to-SQL that balances semantic correctness with practical execution costs, with potential impact on robust NL-to-DB interfaces and broader structured-generation tasks.

Abstract

We present HES-SQL, a novel hybrid training framework that advances Text-to-SQL generation through the integration of thinking-mode-fused supervised fine-tuning (SFT) with Group Relative Policy Optimization (GRPO). Our approach introduces three key innovations: (1) a skeleton-completeness scoring mechanism that enhances preference alignment between generated queries and optimal SQL structures; (2) a query-latency-aware reward system that incentivizes the generation of computationally efficient SQL queries; (3) a self-distillation process for thinking-mode completion that prevents degradation of the model's reasoning capabilities. This framework enables hybrid thinking models to switch between reasoning and non-reasoning modes while improving SQL query accuracy and execution efficiency. Experimental evaluation, conducted on MySQL 8.0 and SQLite 3.42 under controlled single-user conditions, demonstrates that HES-SQL achieves competitive performance with execution accuracies of 79.14\% and 54.9\% on the BIRD and KaggleDBQA benchmarks, respectively. Query latency is measured as the end-to-end execution time of generated queries on the DBMS, averaged over multiple runs to mitigate variance. Efficiency gains range from 11\% to 20\% relative to supervised baselines. Our results establish a new paradigm for Text-to-SQL systems that effectively balances semantic accuracy with computational efficiency through execution-informed reinforcement learning (RL). The proposed methodology has significant implications for developing robust natural language interfaces to databases and can be extended to broader structured generation tasks requiring both correctness and efficiency optimization.

Paper Structure

This paper contains 37 sections, 7 equations, 12 figures, 5 tables, 1 algorithm.

Figures (12)

  • Figure 1: The error categories in BIRD benchmark using the Qwen3-32B model.
  • Figure 2: The architecture of the proposed hierarchical reward framework for enhanced SQL generation quality and execution efficiency.
  • Figure 3: The skeleton accuracy mechanism adopted in reward design.
  • Figure 4: The execution accuracy comparison across models and Text-to-SQL benchmarks.
  • Figure 5: The CDF analysis of SQL query similarity using Jaccard coefficient on BIRD and Spider benchmarks.
  • ...and 7 more figures