Text to sql systems learn to spot and refuse flawed requests

PremiseSQL: Evaluating Premise Critique and Abstention in Text-to-SQL Systems

Computation and Language

Summary

Text-to-SQL systems translate natural language questions into database queries but often assume all questions are valid. This can lead to incorrect or misleading database commands if the input is flawed. The authors created PremiseSQL, a test set of flawed queries and original versions, to check if systems can recognize and refuse to answer invalid questions. They found current language models usually trust flawed queries and rarely reject them, though special prompting can help balance detection and correct response.

What this means in practice

Authors

Shuo Lin, Jinzhe Li, Chenlu Guo, Yanhan Li, Yuan Wu, Yi Chang

Abstract

Recent advances in large language models (LLMs) have substantially improved Text-to-SQL performance, yet existing NL2SQL systems largely assume that user queries are valid and answerable. As a result, models often generate executable SQL even for queries with flawed premises. We introduce premise critique ability in NL2SQL, namely the ability to recognize flawed queries and abstain from generating misleading SQL. To evaluate this capability, we propose PremiseSQL, a benchmark containing 1,800 flawed NL2SQL queries across four categories of premise failures, along with their 1,800 original queries. We further design an evaluation framework to measure intrinsic and prompt-induced premise-aware behavior across three prompting settings. Experiments on frontier LLMs show that current models are strongly premise-trusting by default and rarely critique flawed premises. Stronger critique-oriented prompting improves detection and abstention on flawed queries, but also increases false invalid judgments and suppresses SQL generation on originals. The code is available at https://github.com/vegeet/PremiseSQL.