SDE-SQL: Enhancing Text-to-SQL Generation in Large Language Models via Self-Driven Exploration with SQL Probes

Wenxuan Xie, Yaxun Dai, Wenhao Jiang · 2025

Read SDE-SQL: Enhancing Text-to-SQL Generation in Large Language Models via Self-Driven Exploration with SQL Probes by Wenxuan Xie, Yaxun Dai, Wenhao Jiang (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2506-07245.txt.

Introduction

Wenxuan Xie, Yaxun Dai, and Wenhao Jiang let language models explore a database before answering in this 2025 paper. The task is text-to-SQL: turning a plain question into a database query. Models usually get a fixed packet of database facts, which may miss what the question needs.

Their framework, SDE-SQL, has the model fire off probe queries and read the results. Each probe updates the model's picture of the data before it writes the final query. No worked examples are supplied at all. On a standard benchmark, the method lifted accuracy notably over the same model without exploration. Fine-tuning added a further small gain on top.

Catalog record

CREATORWenxuan Xie, Yaxun Dai, Wenhao Jiang
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE32 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2506-07245

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

SDE-SQL: Enhancing Text-to-SQL Generation in Large Language Models via Self-Driven Exploration with SQL Probes Wenxuan Xie, Yaxun Dai, Wenhao Jiang Abstract Recent advances in large language models (LLMs) have led to substantial progress on the Text-to-SQL task. However, existing approaches typically depend on static, pre-processed database information supplied at inference time, which restricts the model’s capacity to deeply comprehend the underlying database content. In the absence of dynamic interaction, LLMs are limited to fixed, human-curated context and lack the ability to autonomously query or explore the data. To overcome this limitation, we introduce SDE-SQL , a novel framework that empowers LLMs to perform Self-Driven Exploration of databases during inference. This is achieved through the generation and execution of SQL probes , enabling the model to actively retrieve information and iteratively refine its understanding of the database. Unlike prior methods, SDE-SQL operates in a zero-shot setting, requiring no in-context demonstrations or question-SQL pairs. Evaluated on the BIRD benchmark with Qwen2.5-72B-Instruct , SDE-SQL achieves an 8.02% relative improvement in execution accuracy over the vanilla Qwen2.5-72B-Instruct baseline, establishing a new state-of-the-art among open-source methods without supervised fine-tuning (SFT) or model ensembling. Furthermore, when combined with SFT, SDE-SQL delivers an additional 0.52% performance gain. 1 Introduction Text-to-SQL is a long-standing task in natural language processing that focuses on translating natural language questions into executable SQL queries. This capability not only empowers non-expert users to interact with structured databases seamlessly, but also mitigates hallucination issues in question-answering systems by grounding responses in factual, database-stored information. Recent advances in large language models (LLMs) have led to significant improvements in the performance and accuracy of Text-to-SQL systems. LLM-based approaches have surpassed 90% execution accuracy on the original Spider dataset ( Yu et al. 2019 ) , and have demonstrated promising results on more complex and diverse benchmarks such as BIRD Li et al. 2023 . Despite these advances, a noticeable gap remains between current model performance and human-level capabilities—particularly on the recently introduced Spider 2.0 benchmark ( Lei et al. 2025 ) , which poses more realistic and challenging scenarios for semantic parsing. Figure 1: The Workflow of SDE-SQL, which consists of three parts: 1) Schema Linking: which retrieves and selects useful database schema; 2)SQL Generation: performing zero-shot SQL generation based on two-phase self-driven exploration; 3)SQL Refinement: which refines the SQL with the execution results of the Sub-SQLs and SQL Probes. Contemporary large language model (LLM)-based approaches to Text-to-SQL typically comprise three core components: schema linking, SQL generation, and SQL refinement. In the schema linking stage, prior work has primarily focused on aligning natural language questions with relevant database schema elements, improving precision and contextual relevance. During SQL generation, various methods have been proposed to decompose complex questions and incorporate reasoning strategies. In the refinement stage, the categorization of SQL error types has become more systematic, enabling the development of targeted correction mechanisms. Despite these advances, one crucial aspect of SQL remains largely underexplored: its inherent interactivity as a database interface that supports fast and informative execution. This underutilized property may partially account for the performance gap between LLM-based systems and human experts. To address this, we propose SDE-SQL , a novel framework that incorporates Self-Driven Exploration into both the generation and refinement stages, as illustrated in Figure 1 . In addition to generating the final SQL query that directly answers the natural language question, the model autonomously generates and executes a sequence of auxiliary queries—termed SQL Probes —designed specifically to explore and extract informative signals from the database. For schema linking, we leverage entity-based techniques including value retrieval and soft linking. During the generation phase, the model engages in a two-stage exploration process based on the question and schema, enabling it to iteratively refine its understanding of the database content and perform zero-shot reasoning grounded in the retrieved information. Following generation, we incorporate a two-stage exploration process into the refinement phase. For SQL queries that return explicit execution errors, the model directly revises them based on the error feedback. For queries that execute successfully but return empty results, the first stage of exploration uses the execution results of decomposed sub-queries ( Sub-SQLs ) to help the model diagnose the underlying issue. In the second stage, the model generates targeted SQL Probes to explore possible solutions, and selects the most promising one to produce the final refined query. Empirically, SDE-SQL achieves an execution accuracy of 67.67% on the BIRD benchmark using Qwen2.5-72B-Instruct in a zero-shot setting. With supervised fine-tuning (SFT), the performance further improves to 68.19% . Our main contributions are as follows: • We propose SDE-SQL , a novel framework that leverages Self-Driven Exploration to enhance the reasoning and interaction capabilities of LLMs in the Text-to-SQL task, significantly narrowing the gap with human experts. • We introduce a unified exploration mechanism across both SQL generation and refinement stages, enabling LLMs to actively query the database, diagnose potential errors, and iteratively improve query quality. • We conduct extensive experiments on the BIRD and Spider benchmarks, along with ablation studies, validating the effectiveness of Self-Driven Exploration. • We build a small-scale dataset for supervised fine-tuning (SFT) on exploration and generation tasks, and show that targeted module-level fine-tuning further improves the performance of SDE-SQL. 2 Related Work Transforming natural language questions into database queries is a classic task, the earliest works used inductive logic programming and human-designed templates to accomplish this task ( Zelle and Mooney 1996 ) . In recent years, the advancement of Text-to-SQL technologies can be broadly categorized into two stages, driven by progress in natural language processing. 2.1 Traditional Seq2Seq Model-Based Methods Previous work primarily focused on improving encoding or decoding methods, as the seq2seq model framework consists of two main components, the encoder and the decoder. IRNet employed a bidirectional LSTM to encode the question and a self-attention mechanism to encode the database schema, ultimately using an LSTM as a grammar-based decoder ( Guo et al. 2019 ) . In order to effectively capture the relationship between the database schema and the question, RAT-SQL develops an encoder with a relation-aware self-attention mechanism ( Wang et al. 2020 ) . After that, Cai et al. 2022 and Cao et al. 2021 utilized graph neural networks to encode the relationships between the schema and the query. Leveraging the exceptional capabilities of pre-trained language models (PLMs) across various NLP tasks, Hwang et al. 2019 was the first to incorporate BERT as its encoder. For improvements in the decoder, Xu et al. 2017 and Choi et al. 2020 focused on sketch- based decoding method. To reduce time consumption during inference, SDSQL presented the Schema Dependency Learning and removed execution-guided (EG) decoding strategy ( Hui et al. 2021 ) . 2.2 LLM-Based Methods With the advent of LLMs, the Text-to-SQL field has experienced a groundbreaking innovation, bringing about significant changes in the approach to the task. Methods Based on Prompt Engineering Rajkumar et al. 2022 evaluated the potential of LLMs in the Text-to-SQL task, demonstrating the remarkable capability of LLMs in this task. Building on in-context learning, DAIL-SQL ( Gao et al. 2023 ) introduced a novel prompt engineering approach that improves the Text-to-SQL performance of LLMs through question representation, demonstration selection, and demonstration organization. Based on Chain-of-Thought(CoT) reasoning

Read the complete text