Table of Contents
Fetching ...

TrustSQL: Benchmarking Text-to-SQL Reliability with Penalty-Based Scoring

Gyubok Lee, Woosog Chay, Seonhee Cho, Edward Choi

TL;DR

TrustSQL introduces a reliability-centric benchmark for text-to-SQL by formalizing reliability as the ability to generate correct SQL for feasible inputs and abstain for infeasible ones, evaluated via a penalty-based score $\phi_c$. The authors implement two modeling paradigms—pipeline-based and unified—with both open-source and API-based variants to study abstention and error-detection strategies, and they construct TrustSQL from ATIS, Advising, EHRSQL, and Spider to cover diverse SQL patterns and infeasibility types. Results show that high penalty settings amplify the value of abstention and uncertainty estimation, revealing that safe deployment hinges on recognizing when not to answer rather than maximizing raw SQL accuracy. The benchmark integrates infeasible-question types (schema-incompatibility, beyond-SQL tasks, and external knowledge) and uses a detailed data-splitting regime to probe familiarity, providing a practical framework for improving trustworthy text-to-SQL systems. The work indicates that TrustSQL fills gaps in existing benchmarks by coupling penalty-based evaluation with abstention-aware data, motivating future directions toward more deliberate planning and broader applicability in real-world deployments.

Abstract

Text-to-SQL enables users to interact with databases using natural language, simplifying the retrieval and synthesis of information. Despite the remarkable success of large language models (LLMs) in translating natural language questions into SQL queries, widespread deployment remains limited due to two primary challenges. First, the effective use of text-to-SQL models depends on users' understanding of the model's capabilities-the scope of questions the model can correctly answer. Second, the absence of abstention mechanisms can lead to incorrect SQL generation going unnoticed, thereby undermining trust in the model's output. To enable wider deployment, it is crucial to address these challenges in model design and enhance model evaluation to build trust in the model's output. To this end, we introduce TrustSQL, a novel comprehensive benchmark designed to evaluate text-to-SQL reliability-defined as a model's ability to correctly handle any type of input question by generating correct SQL queries for feasible questions and abstaining from generating infeasible ones (e.g., due to schema incompatibility or functionalities beyond SQL). We evaluate existing methods using a novel penalty-based scoring metric with two modeling approaches: (1) pipeline-based methods combining SQL generators with infeasible question detectors and SQL error detectors for abstention; and (2) unified methods using a single model for the entire task. Our experimental results reveal that achieving high scores under severe penalties requires significant effort and provide a new perspective on developing text-to-SQL models for safer deployment. TrustSQL is available at https://github.com/glee4810/TrustSQL.

TrustSQL: Benchmarking Text-to-SQL Reliability with Penalty-Based Scoring

TL;DR

TrustSQL introduces a reliability-centric benchmark for text-to-SQL by formalizing reliability as the ability to generate correct SQL for feasible inputs and abstain for infeasible ones, evaluated via a penalty-based score . The authors implement two modeling paradigms—pipeline-based and unified—with both open-source and API-based variants to study abstention and error-detection strategies, and they construct TrustSQL from ATIS, Advising, EHRSQL, and Spider to cover diverse SQL patterns and infeasibility types. Results show that high penalty settings amplify the value of abstention and uncertainty estimation, revealing that safe deployment hinges on recognizing when not to answer rather than maximizing raw SQL accuracy. The benchmark integrates infeasible-question types (schema-incompatibility, beyond-SQL tasks, and external knowledge) and uses a detailed data-splitting regime to probe familiarity, providing a practical framework for improving trustworthy text-to-SQL systems. The work indicates that TrustSQL fills gaps in existing benchmarks by coupling penalty-based evaluation with abstention-aware data, motivating future directions toward more deliberate planning and broader applicability in real-world deployments.

Abstract

Text-to-SQL enables users to interact with databases using natural language, simplifying the retrieval and synthesis of information. Despite the remarkable success of large language models (LLMs) in translating natural language questions into SQL queries, widespread deployment remains limited due to two primary challenges. First, the effective use of text-to-SQL models depends on users' understanding of the model's capabilities-the scope of questions the model can correctly answer. Second, the absence of abstention mechanisms can lead to incorrect SQL generation going unnoticed, thereby undermining trust in the model's output. To enable wider deployment, it is crucial to address these challenges in model design and enhance model evaluation to build trust in the model's output. To this end, we introduce TrustSQL, a novel comprehensive benchmark designed to evaluate text-to-SQL reliability-defined as a model's ability to correctly handle any type of input question by generating correct SQL queries for feasible questions and abstaining from generating infeasible ones (e.g., due to schema incompatibility or functionalities beyond SQL). We evaluate existing methods using a novel penalty-based scoring metric with two modeling approaches: (1) pipeline-based methods combining SQL generators with infeasible question detectors and SQL error detectors for abstention; and (2) unified methods using a single model for the entire task. Our experimental results reveal that achieving high scores under severe penalties requires significant effort and provide a new perspective on developing text-to-SQL models for safer deployment. TrustSQL is available at https://github.com/glee4810/TrustSQL.
Paper Structure (74 sections, 1 equation, 5 figures, 13 tables)

This paper contains 74 sections, 1 equation, 5 figures, 13 tables.

Figures (5)

  • Figure 1: (a) Deployment Scenarios include both feasible and infeasible user questions regarding text-to-SQL tasks (e.g., requests outside the database schema or SQL functionalities). (b) Standard Text-to-SQL aims to maximize correct SQL query generation. This focus can result in incorrect model outputs going unnoticed, increasing risk in deployment. The green and red regions represent correct and incorrect SQL generations, respectively. To effectively utilize a text-to-SQL model, users must be familiar with its capabilities, which vary by model—the types of questions each model can correctly answer—setting a high barrier for potential users. (c) Reliable Text-to-SQL removes this barrier and aims to enhance trust in the model by minimizing incorrect outputs (III) and (IV) through abstention (red arrow), while maximizing correct outputs (I) within the feasible region (green arrow). By shrinking the red regions (III) and (IV), and subsequently the yellow region (II), users will begin to trust the model's outputs. Each region is further explained in the footnote.
  • Figure 2: Samples sorted in descending confidence. 14 samples are illustrated in the figure.
  • Figure 3: Visualization of thresholds chosen for the EHRSQL portion in the validation set. The green region in each plot is considered confident by the model, so samples that fall under this region are used for final SQL generation, while the red region is not confident and thus the samples under this region are abstained from.
  • Figure :
  • Figure :