New Method Estimates Confidence in Text-to-SQL Generation
Researchers have developed a conformal confidence estimation framework for Text-to-SQL systems to prevent incorrect queries from being executed.
Source: Grafy Research LabText-to-SQL systems often encounter a critical failure mode where they generate code that is syntactically correct and executes without error, yet fails to answer the user's actual question. Researchers Avinash Kumar Singh, Bhaskarjit Sarmah, and Stefano Pasquali have proposed a new framework to address this by providing a way to estimate how much a system should trust its own generated queries.
Why is Text-to-SQL confidence hard to measure?
In traditional software testing, correctness is easily verified. However, in Text-to-SQL tasks, determining if a query is "right" usually requires comparing it against a "gold query"—a human-written, perfect version of the SQL statement. According to the research, this gold-standard data is typically only available during the training or calibration phase.
When these systems are deployed in real-world environments, the gold queries are absent. This creates a gap where a system might execute a query that returns a result, but that result is fundamentally disconnected from the user's intent. Because the correctness is a latent variable—meaning it is hidden during deployment—standard validation techniques struggle to detect when the model is hallucinating the logic of the database schema or the question's requirements.
How does the conformal confidence estimator work?
To solve this, the researchers formulated confidence estimation as a probabilistic query validation problem. Their approach involves a two-step process that separates the act of generating the code from the act of validating it.
First, a generator Large Language Model (LLM) is responsible for writing and executing the initial SQL query. Second, a separate critic LLM is introduced to judge the quality of that query. This distinction is vital; by using a different model to act as a critic, the system avoids the inherent biases that might exist if the same model were tasked with both creation and self-correction.
During the calibration phase, the system uses the available gold-SQL data to learn how to map specific generation patterns to actual correctness. Once deployed, the estimator uses these learned patterns to provide a confidence score. This allows the system to "abstain" from providing an answer if the confidence score falls below a certain threshold, preventing the delivery of incorrect data to the user.
What are the benefits of separating generation from validation?
By decoupling the generator and the critic, the framework creates a more robust check against errors. The researchers note that the estimator treats correctness as a latent variable that is observable during calibration via gold-SQL execution, but becomes latent (unobservable) during deployment.
This separation allows for more granular control over the error rates. Instead of simply hoping the model is right, developers can set specific reliability targets. If the system encounters a complex natural language prompt that it cannot confidently translate into a reliable SQL structure, the conformal prediction framework provides a mathematical basis for the system to signal uncertainty rather than providing a false positive.
How can developers apply these concepts?
For developers building agentic workflows or data interfaces, this research highlights the importance of "runtime governance." Rather than treating an LLM output as a final command, developers should implement layers of verification.
Implementing a critic-based architecture—where one model proposes a solution and another evaluates it against constraints—can significantly reduce the risk of automated systems performing incorrect actions on sensitive databases. The move toward conformal prediction suggests a future where AI systems are defined not just by their ability to generate content, but by their ability to quantify their own uncertainty.
Exploring AI research with Grafy
While Grafy does not currently offer a dedicated Text-to-SQL development environment, researchers and developers can use Reader to ingest and analyze complex academic papers like this one. By uploading the full PDF of the research, users can ask specific questions about the mathematical formulations or the experimental setup used by Singh, Sarmah, and Pasquali to deepen their understanding of conformal prediction.
Frequently asked questions
What is the main problem with current Text-to-SQL systems?
Many current systems generate SQL queries that are syntactically valid and run successfully but fail to accurately reflect the user's original question. Because these systems lack a way to verify intent without a human-written gold query, they often provide incorrect data while appearing to function perfectly.
How does the proposed estimator handle deployment?
The estimator handles deployment by treating query correctness as a latent variable. It uses patterns learned during a calibration phase—where gold queries are available—to predict the likelihood of correctness in real-world scenarios where gold queries are missing, allowing the system to abstain from answering when uncertainty is too high.
Why use two different LLMs for this process?
Using a separate critic LLM to judge the output of a generator LLM helps prevent the biases and errors inherent in self-evaluation. By separating the generation of the SQL from the validation of the logic, the framework creates a more reliable check that can more accurately identify when a query is likely to be incorrect.
Source: Grafy Research Lab — Know When to Abstain: Conformal Confidence Estimation for Text-to-SQL


