[KongchangAI]
· 2 min read· 1,026 words

Confidence Estimation for Text-to-SQL: Teaching Models When to Abstain

Confidence Estimation for Text-to-SQL: Teaching Models When to Abstain

A dual-LLM confidence estimation framework uses two-step calibration to provide finite-sample risk guarantees for Text-to-SQL abstention decisions.

Targeting the hidden failure mode in Text-to-SQL where queries execute but are semantically wrong, this study proposes a confidence estimation framework with finite-sample guarantees. It separates generation from verification: a generator LLM writes and executes SQL, a critic LLM independently judges the query and execution results, and these are fused with verbalized confidence, token-level uncertainty, and SQL structural features into a random forest. Two-step calibration via Learn-then-Test thresholds and conformal p-values controls both the error rate among accepted queries and the false abstention rate. On Spider, under a 15% risk budget it accepts 52.4% of queries on average with a 9.1% observed error rate, well below the 22.6% without abstention. In cross-dataset transfer, confidence remains informative, but the risk guarantees fail due to violated exchangeability, requiring recalibration.

Text-to-SQL systems have a hidden failure mode: the generated query executes successfully but answers the wrong question. This kind of error is extremely hard to catch in deployment, because verifying whether execution is correct requires a gold query, and gold queries only exist in annotated data. To address this pain point, a paper titled "Know When to Abstain: Conformal Confidence Estimation for Text-to-SQL" proposes a confidence estimation framework with finite-sample guarantees.

Overview of Text-to-SQL confidence estimation research

The Core Problem: Successful Execution Does Not Mean a Correct Answer

In Text-to-SQL tasks, a SQL statement running successfully does not mean it accurately captured the user's natural language intent. The researchers treat this "silent error" as the central challenge of the deployment phase: the model has no access to ground truth at inference time, so it cannot directly judge whether it answered correctly.

Their solution reframes confidence estimation as probabilistic query verification under a latent variable—during calibration, correctness can be observed through gold SQL execution; during deployment, this variable is hidden. The entire estimator separates generation from verification: a generator LLM writes and executes the query, and an independent critic LLM judges the query and its execution results.

Dual-LLM Architecture with Multi-Dimensional Feature Fusion

The key design of this framework is the separation of generation and verification. The generator LLM (GPT-OSS-120B in the experiments) writes and executes SQL, while the critic LLM (Gemma-4-31B) scores from two angles: a verification judgment of the query itself, and an alignment score based on execution results.

These two types of scores are combined with the generator's own verbalized confidence, token-level uncertainty, and SQL structural features, and fed into a random forest for fusion. The entire pipeline calls the LLM only twice, keeping computational cost manageable.

Two-Step Calibration Brings Finite-Sample Guarantees

Confidence scores alone are not enough, so the researchers introduce two calibration steps to provide statistical guarantees.

  • Learn-then-Test thresholding: ensures, with probability 1-δ, that the error rate among accepted queries stays below a user-specified risk budget.
  • Conformal p-values: provide a bound on the false abstention rate.

The significance of this design is that the system not only scores each query but also statistically controls the risk of both types of decisions: "accept" and "abstain."

Learn-then-Test (LTT) is a hypothesis-testing-based calibration framework: it transforms a risk constraint into a sequential test over a set of candidate thresholds, and controls the false discovery rate under finite samples through fixed-sequence p-value aggregation (such as Bonferroni correction or fixed-sequence testing), thereby selecting a threshold that satisfies the risk budget with probability 1-δ. Unlike the traditional approach of minimizing empirical risk and then directly taking a threshold, LTT does not rely on asymptotic normality assumptions and is suitable for small-sample or non-parametric settings.

Conformal p-values originate from the Conformal Prediction framework. The core idea is to construct p-values using nonconformity scores on a calibration set, such that under the exchangeability assumption, the p-values for new samples have finite-sample validity—that is, the error coverage does not exceed the nominal level. In the abstention setting, conformal p-values can be used to bound the false abstention rate: when the p-value is below the significance level, the system tends to accept the query; otherwise it abstains.

Experimental Results: The Abstention Mechanism Significantly Reduces Error Rates

On the Spider dataset, the estimator achieves an AUARC of 0.899. Without abstention enabled, 22.6% of queries are wrong. When a 15% risk budget is set (δ=0.1), the threshold is certified on all 10 resampling splits, and the system accepts 52.4% of queries on average, with an observed error rate of 9.1%.

The study also tested five different critic models, with similar results, indicating that the framework is not sensitive to the choice of critic. In a controlled comparison on Spider using Olmo-3-32B as the generator, the estimator achieved an AUARC of 89.5, versus 81.2 for the strongest logit-based baseline.

Cross-Dataset Transfer: Information Retained, Guarantees Not Transferred

When the model is applied directly to the BIRD dataset without retraining, the confidence scores remain informative (AUROC of 0.72, versus 0.79 on Spider), but the risk guarantees do not transfer—the researchers note that this is expected in the absence of the exchangeability assumption.

This result also delineates the boundaries of the method: conformal guarantees rely on exchangeability and require recalibration when deployed across distributions. For practical systems, this means the abstention mechanism is trustworthy in-distribution, while out-of-distribution it requires an additional verification process.

The exchangeability assumption is the cornerstone of finite-sample guarantee methods such as conformal prediction and LTT. It requires that the calibration set and test samples are statistically interchangeable, i.e., their joint distribution is symmetric with respect to sample order. Under independent and identically distributed (i.i.d.) sampling, exchangeability holds naturally; but in cross-dataset transfer, the source and target domains have different distributions, exchangeability is broken, and therefore the p-values and risk guarantees obtained from source-domain calibration cannot be directly applied to the target domain. This is precisely the theoretical explanation for the "information retained, guarantees not transferred" phenomenon described in the paper—confidence scores can still distinguish correct from incorrect (AUROC > 0.5), but the statistical guarantees fail, and recalibration on the new distribution is required.

One-line Summary

Proposes a dual-LLM confidence estimation framework that uses two-step calibration to provide finite-sample risk guarantees for Text-to-SQL abstention decisions.

Paragraph Summary

Targeting the hidden failure mode in Text-to-SQL where queries execute but are semantically wrong, this study proposes a confidence estimation framework with finite-sample guarantees. The framework separates generation from verification: a generator LLM writes and executes SQL, a critic LLM independently judges the query and execution results, and verbalized confidence, token-level uncertainty, and SQL structural features are fused into a random forest score. Through two-step calibration with Learn-then-Test thresholds and conformal p-values, the system can control the error rate among accepted queries with probability 1-δ and bound the false abstention rate. On Spider, under a 15% risk budget it accepts 52.4% of queries on average with an observed error rate of 9.1%, significantly lower than the 22.6% without abstention. In cross-dataset transfer, confidence remains informative, but the risk guarantees fail because the exchangeability assumption does not hold, requiring recalibration.

#Text-to-SQL#confidence estimation#conformal prediction#Learn-then-Test#abstention#LLM#SQL verification
Share:

Related articles