NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

TrustSQL: A Reliability Benchmark for Text-to-SQL Models with Diverse Unanswerable Questions

Gyubok Lee, Woosog Chay, Seonhee Cho, Edward Choi

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. We evaluate existing methods using a novel penalty-based scoring metric with two modeling approaches: pipeline-based and unified methods. 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.

Introduction

Text-to-SQL models have reached impressive accuracy levels, yet they face a significant hurdle for real-world deployment: reliability. Standard benchmarks typically evaluate models only on "feasible" questions—those that can be answered by the underlying database. However, in practice, users often pose questions that are outside the database's scope, require external knowledge, or involve functionalities beyond SQL's capabilities.

Conceptual overview of deployment scenarios and the transition from standard to reliable Text-to-SQL.

Without a mechanism to abstain, current models often "hallucinate" SQL queries for these infeasible questions, producing incorrect results that can go unnoticed. This lack of honesty undermines user trust, especially in high-stakes domains like medicine or finance. TrustSQL addresses this by introducing a benchmark that evaluates a model's ability to correctly handle both feasible and infeasible inputs.

The TrustSQL Benchmark

The TrustSQL benchmark is built upon four established datasets: ATIS, Advising, EHRSQL, and Spider. The researchers augmented these with 2,500 manually annotated infeasible questions, categorized into types such as schema incompatibility, requests beyond SQL's scope, and questions requiring external knowledge.

Examples of infeasible question types included in the TrustSQL benchmark.

The final dataset comprises approximately 21.4K instances, featuring a balanced 50/50 split of answerable and unanswerable questions in the test sets to rigorously test a model's discernment.

Methodology: Measuring Reliability

To quantify reliability, the authors propose a Reliability Score (RS) that incorporates a penalty factor ($c$).

  • Utility: Models earn points for generating correct SQL for feasible questions and for correctly abstaining from infeasible ones.
  • Risk: Models are penalized by a factor of $c$ for incorrect SQL on feasible questions or for attempting to answer infeasible ones.

By adjusting $c$, researchers can simulate various deployment risks, from lenient experimental settings ($c=0$) to high-stakes environments where errors are catastrophic ($c=N$).

The study evaluates two primary modeling approaches:

  1. Pipeline-based: Modular systems with dedicated components for detecting infeasible questions and post-generation SQL errors.
  2. Unified: Single models (e.g., T5, GPT-3.5) that utilize internal uncertainty estimation—such as token entropy or Mahalanobis distance—to decide whether to generate or abstain.

Key Insights and Results

The experimental results provide a sobering look at current LLM capabilities:

  • The "Silence is Golden" Effect: In high-penalty scenarios, a baseline that simply abstains from every question often outperforms state-of-the-art models. This highlights the "trigger-happy" nature of current LLMs.
  • Uncertainty as a Signal: Unified models using distance-based out-of-distribution (OOD) detection (like T5-3B with FEATMD) proved surprisingly competitive with commercial APIs like GPT-3.5.
  • The Cost of Trust: There is a clear trade-off between utility and reliability. To avoid heavy penalties, models must become significantly more conservative, which can reduce their overall helpfulness in low-risk settings.

Conclusion

TrustSQL shifts the focus of Text-to-SQL evaluation from pure accuracy to operational reliability. The benchmark reveals that current models struggle to identify their own limitations, often prioritizing generation over correctness. Future work should explore agent-based methods for planning and tool-use to resolve uncertainty, as well as improved domain adaptation to make these systems safer for specialized deployment.

Summary updated

BibTeX
@misc{lee2024trustsql,
  author = {Gyubok Lee and Woosog Chay and Seonhee Cho and Edward Choi},
  title = {{TrustSQL: A Reliability Benchmark for Text-to-SQL Models with Diverse Unanswerable Questions}},
  year = {2024},
  eprint = {2403.15879},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.15879},
}
Figure