Jadwal Sholat

Memuat jadwal sholatโ€ฆ

Ilmu Komputer & AI editorial

Open AccessOA2026

SafeQL: Search-based Refinement for Safe and Efficient LLM-based Text-to-SQL

A search-based refinement paradigm that redefines the DBMS as an active guide for incremental SQL repair
Geonho Lee; Min-Soo Kimยท 2026ยท DOI 10.48550/arXiv.2608.09260

The core problem

Large language models (LLMs) have advanced Text-to-SQL by enabling natural language interfaces to databases without task-specific fine-tuning. However, existing LLM-based systems remain unreliable, often generating SQL queries that are invalid under the database schema, referencing non-existent tables, attributes, functions, or values. Such errors persist because interactions with the database management system (DBMS) are typically limited to error messages, leaving it in a largely passive role during query refinement. This paper proposes SafeQL, a search-based refinement paradigm that redefines the role of the DBMS as an active guide in the refinement process. Instead of regenerating entire queries after execution failure, SafeQL interprets DBMS feedback to incrementally repair only the erroneous components. Each refinement step is formulated as a guided search within a safe query space, where candidate queries are progressively validated through DBMS execution, thereby converging to an executable query and preventing repeated regeneration of errors. Experiments on the Bird and Spider benchmarks show that SafeQL significantly improves execution accuracy and efficiency compared to

Innovation

Experiments on the Bird and Spider benchmarks show that SafeQL significantly improves execution accuracy and efficiency compared to regeneration-based methods. The paper reports that SafeQL achieves higher execution accuracy and reduces the number of LLM calls and DBMS executions required to reach an executable query. Specifically, on the Bird benchmark, SafeQL improves execution accuracy by a significant margin over baseline regeneration-based methods, and on the Spider benchmark, it achieves similar improvements. The efficiency gains are attributed to the incremental repair strategy, which avoids regenerating entire queries and instead focuses on repairing only the erroneous components. The results demonstrate that the search-based refinement paradigm is effective in reducing repeated errors and converging quickly to executable queries.
Large language models (LLMs) have advanced Text-to-SQL by enabling natural language interfaces to databases without task-specific fine-tuning. However, existing LLM-based systems remain unreliable, often generating SQL queries that are invalid under the database schema, referencing non-existent tables, attributes, functions, or values. Such errors persist because interactions with the database management system (DBMS) are typically limited to error messages, leaving it in a largely passive role during query refinement. This paper proposes SafeQL, a search-based refinement paradigm that redefines the role of the DBMS as an active guide in the refinement process. Instead of regenerating entire queries after execution failure, SafeQL interprets DBMS feedback to incrementally repair only the erroneous components. Each refinement step is formulated as a guided search within a safe query space, where candidate queries are progressively validated through DBMS execution, thereby converging to an executable query and preventing repeated regeneration of errors. Experiments on the Bird and Spider benchmarks show that SafeQL significantly improves execution accuracy and efficiency compared to regeneration-based methods.

SafeQL operates by interpreting DBMS feedback to incrementally repair only the erroneous components of a query, rather than regenerating the entire query after execution failure. Each refinement step is formulated as a guided search within a safe query space, where candidate queries are progressively validated through DBMS execution. This approach converges to an executable query and prevents repeated regeneration of errors. The safe query space is defined as the set of queries that are syntactically valid and semantically consistent with the database schema, and the search is guided by the DBMS's error messages and execution results. Formally, let be the initial query generated by the LLM, and let

be the safe query space. The refinement process seeks a sequence of queries such that ,
, and each is obtained by applying a repair operation to based on DBMS feedback. The search is guided by a scoring function that estimates the likelihood of being executable, and the process terminates when an executable query is found or a maximum number of iterations is reached. The architecture of SafeQL is illustrated in the following Mermaid diagram:

Why it matters

The key insight of SafeQL is the redefinition of the DBMS as an active guide in the refinement process. By interpreting DBMS feedback and incrementally repairing only the erroneous components, SafeQL prevents the repeated regeneration of errors that plagues regeneration-based methods. The safe query space ensures that candidate queries are progressively validated, leading to a more efficient search. The paper's findings suggest that leveraging the DBMS's execution feedback in a structured search can significantly enhance the reliability and efficiency of LLM-based Text-to-SQL systems. This approach is particularly relevant for applications where database schemas are complex and errors are common. Future work could explore extending the safe query space to include more sophisticated constraints and integrating the search with other LLM-based repair techniques. The taxonomy candidates for this work include Architecture, Cybersecurity, Network, and Cryptography, indicating its relevance to secure and efficient database interactions.

Who should read this

CS practitioners and researchers

Opening member contentโ€ฆ