Abstract
Most Text-to-SQL research assumes that user inputs are perfectly answerable, an assumption that fails in real-world scenarios where inputs are often off-topic, ambiguous, or beyond the database's scope. This paper introduces TRIAGESQL, a new cross-domain benchmark designed to classify question intent into five distinct categories. Our evaluation using a RoBERTa-base model reveals that identifying question answerability is a significant challenge, with the baseline achieving a Macro F1 score of only 0.60. The results highlight a critical "ambiguity trap" and a tendency for models to hallucinate answers when faced with missing information, underscoring the need for robust triage layers in production-ready Text-to-SQL systems.
Introduction
The standard paradigm for Text-to-SQL research follows a "happy path": given a natural language question and a database schema, the system generates a valid SQL query. However, this assumes the user is an expert who only asks well-formed, answerable questions. In practice, users provide inputs that are off-topic, require external knowledge not present in the database, or fall outside the technical capabilities of current SQL parsers.
When models attempt to force-fit these "illegal" inputs into SQL, they often produce nonsensical queries or incorrect data. To build robust systems, a "triage" layer is necessary to distinguish between answerable questions and those requiring alternative responses, such as clarification or a tutorial.
The TRIAGESQL Framework
The authors propose a five-class classification framework to categorize user intent and guide system behavior:
- Answerable: Standard questions suitable for SQL generation.
- Improper: Small talk or off-topic remarks (e.g., "How are you?").
- Require External Knowledge (ExtKnow): Questions about data not present in the schema.
- Ambiguous: Questions mapping to multiple schema elements (e.g., "Which team?" when the DB has both
home_teamandaway_team). - Non-SQL: Reasonable questions requiring logic beyond standard Text-to-SQL models (e.g., metadata queries).
Dataset Construction
The TRIAGESQL benchmark was constructed by aggregating and modifying 21 existing datasets, including Spider, WikiSQL, and Alexa chit-chat data. The resulting training set contains approximately 390,000 question-database pairs across 34,000 databases.
To distinguish between ExtKnow and Answerable categories, the authors employed "schema ablation," randomly removing columns from databases to test if models could detect missing information. A high-quality test set of 2,500 examples (500 per category) was manually curated to ensure the benchmark tests reasoning rather than simple pattern matching.
Results and Analysis
Using a RoBERTa-base model as a baseline, the study found that the "gatekeeper" task is surprisingly difficult. The model achieved an average Precision of 0.72, Recall of 0.63, and a Macro F1 of 0.60.
The Ambiguity Trap
The Ambiguous category proved to be the most significant bottleneck, yielding a dismal 0.17 F1 score. As shown in the confusion matrix, the model frequently misclassified ambiguous questions as answerable, failing to recognize when a query term could refer to multiple database columns.
Hallucination by Omission
There was significant confusion between ExtKnow and Answerable (0.54 and 0.53 F1, respectively). When a required column was missing from the schema, the model often "hallucinated" that the question was still answerable, likely by mapping the missing concept to an unrelated existing column. Conversely, Non-SQL (0.92 F1) and Improper (0.83 F1) were the easiest to identify due to their distinct linguistic patterns.
Conclusion
The TRIAGESQL benchmark demonstrates that current models struggle to understand the deep relationship between a question's tokens and a specific database schema. Future work must focus on improving schema-linking capabilities and moving beyond simple classification toward generative feedback, where systems can provide helpful suggestions when a question cannot be answered directly.
Summary updated