Confidence Estimation for Error Detection in Text-to-SQL Systems

Oleg Somov, Elena Tutubalina

Abstract

Text-to-SQL systems enable natural language querying of databases but often produce incorrect results when facing distribution shifts or unanswerable questions. This research investigates selective classification—a "reject option"—to enhance system trustworthiness. By evaluating various uncertainty estimation and calibration techniques, the study finds that Gaussian Mixture Models (GMM) can reduce system risk by 80%. Notably, the results reveal that older encoder-decoder models like T5 exhibit superior calibration compared to modern decoder-only architectures like Llama 3.

The Challenge of Silent Failures

Text-to-SQL systems face two primary hurdles: generalization and trustworthiness. Generalization failures occur when models encounter unfamiliar database schemas or complex query structures. Trustworthiness is compromised when models fail "silently," generating incorrect SQL with high apparent confidence. This paper categorizes these failures into "low-generalization" errors and "unanswerable" queries.

Examples of Text-to-SQL outcomes: successful generation, low-generalization error, and unanswerable queries with associated confidence scores.

Selective Classification Methodology

To address these failures, the researchers implement a selective classification framework. Instead of always providing an answer, the system outputs a query along with an uncertainty estimate ($u$). If $u$ exceeds a defined threshold, the system abstains.

Key technical components include:

  • Uncertainty Estimation: Fine-tuned models use a "weakest link" heuristic (maximum entropy of the most uncertain token), while black-box models use Normalized Sequence Probability.
  • Selective Classifiers: The study compares simple thresholding, Logistic Regression, and Gaussian Mixture Models (GMM). The GMM approach models uncertainty scores as distinct distributions for correct and incorrect generations.
  • Calibration: Post-hoc methods like Platt Scaling and Isotonic Regression are used to align predicted probabilities with actual execution accuracy.

Benchmarking Distribution Shifts

The methodology was tested on two primary benchmarks:

  1. PAUQ (Spider-based): Evaluated across cross-database (XSP), novel SQL structures (Template SSP), and target length shifts (TSL SSP).
  2. EHRSQL: A clinical dataset featuring unanswerable questions to test out-of-distribution detection.

Key Findings: Architecture and Calibration

A significant discovery is the "architecture divide": encoder-decoder models (T5) are substantially better calibrated than decoder-only models (Llama 3) or in-context learning approaches (GPT-4). T5 models showed a tight alignment between internal probability estimates and actual accuracy.

Comparison of system risk and coverage across different dataset splits, showing the impact of implementing a rejection classifier.

The GMM emerged as the superior selective classifier, providing the optimal trade-off between coverage and risk. Implementing this classifier reduced system risk by an average of 80% across all tested scenarios. However, this safety comes at a cost: in high-shift environments, the system may reject a large portion of queries to maintain high precision.

Conclusion

While selective classification significantly improves the reliability of Text-to-SQL systems, the high rejection rate in distribution-shift scenarios remains a practical challenge. Future work will focus on improving the precision of error detection to reduce the False Discovery Rate and exploring a broader range of domains.

Summary updated

BibTeX
@inproceedings{somov2025confidence,
  author = {Oleg Somov and Elena Tutubalina},
  title = {{Confidence Estimation for Error Detection in Text-to-SQL Systems}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i23.34699},
}
Figure