Skip to content

SQLConsensus: Confidence Estimation in Text-to-SQL from Structural and Execution Agreement

Jaeyun Park, Yongbin Choi, Donghee Choi, Mujeen Sung

cs.CL

Abstract

While large language models (LLMs) translate natural language questions into Structured Query Language (SQL) with strong accuracy, an incorrect query often executes without error and returns results that users cannot distinguish from correct ones. Reliable deployment thus requires flagging uncertain outputs for review. We address confidence estimation for Text-to-SQL, the task of assigning each generated query a score that reflects how likely it is to answer the question. Existing estimators derive the score from agreement among generated queries but measure it on a single side, either the recurrence of their clauses or their execution results. Clauses that recur in queries returning different results can still raise confidence in an incorrect prediction, and identical results on one database do not show that two queries reach them in the same way. To overcome these limitations, we propose SQLConsensus, which estimates the confidence from both structure and execution, comparing the clause forms of the generated queries only among those that return the result of the prediction. Across four LLMs on two general-domain benchmarks and one clinical-domain benchmark with two databases, SQLConsensus improves the area under the receiver operating characteristic curve (AUROC) over the strongest baseline by 7.0 points on average and makes the fewest errors among its 10% most confident queries in fourteen of the sixteen settings. Analyses show that removing either structure or execution lowers the mean AUROC.

Create a lesson

Metadata

Comments
42 pages, 8 figures, 15 tables