Predicting Text-to-SQL Correctness: LLM Judges Outperform Self-Consistency

Robert Richardson· July 9, 2026 View original

Summary

A study investigates signals predicting correctness in AI-generated SQL queries from natural language, finding that LLM judges significantly outperform black-box self-consistency methods. Ensemble judges achieve the highest accuracy in identifying correct queries and enabling useful abstention.

This research explores how to reliably predict the correctness of SQL queries generated by AI from natural language prompts, especially for complex multi-table scenarios. The study evaluates various signals to determine their effectiveness in distinguishing correct queries (those that produce the same result as a human-written reference) from incorrect ones. Signals tested included string, structural, and execution self-consistency, schema relevance, query executability, and white-box log-probability. The findings indicate that while black-box signals like self-consistency offer some predictive power, their AUROC scores hover around 0.61 to 0.68. The most effective predictors were verification-based methods, specifically using large language model (LLM) judges. GPT-4o-mini and Claude judges achieved AUROC scores of 0.72 and 0.78, respectively. An ensemble of judges from different providers further boosted performance to 0.82 AUROC, demonstrating well-calibrated probabilities and supporting effective selective abstention strategies. The study also examined training fine-tuned verifiers, which performed well in-distribution but struggled with unseen schemas, suggesting that cross-schema generalization relies more on model scale and reasoning capabilities than fine-tuning. In practice, robust correctness prediction for text-to-SQL applications currently depends on powerful, frozen reasoning models acting as verifiers.

Why it matters

For professionals building or using text-to-SQL systems, understanding how to reliably predict query correctness is crucial for ensuring data integrity, reducing errors, and implementing effective selective prediction strategies.

How to implement this in your domain

  1. 1Integrate LLM-based verification steps into your text-to-SQL pipeline to assess query correctness before execution.
  2. 2Experiment with ensemble approaches using multiple LLM providers as judges to improve prediction accuracy and calibration.
  3. 3Implement selective prediction mechanisms, allowing the system to abstain from executing queries deemed low-confidence by the verifier.
  4. 4Monitor the performance of your text-to-SQL system with and without LLM verification to quantify improvements in reliability and error reduction.

Who benefits

Data AnalyticsSoftware DevelopmentBusiness IntelligenceFinance (BFSI)Healthcare

Key takeaways

  • LLM judges are superior to self-consistency methods for predicting text-to-SQL correctness.
  • Ensembling multiple LLM judges significantly improves prediction accuracy and calibration.
  • Reliable correctness prediction enables effective selective abstention, reducing risks.
  • Cross-schema generalization in verifiers depends more on model reasoning than fine-tuning.

Original post by Robert Richardson

"arXiv:2607.06799v1 Announce Type: new Abstract: Evaluating uncertainty in AI-generated SQL queries requires estimating whether a query is correct, where correct means it executes to the same result as a human-written reference. We study which signals predict correctness on hard m…"

View on X

Originally posted by Robert Richardson on X · view source

Want to go deeper?

Turn these trends into skills with Learnijoy's hands-on AI & tech courses.

Explore courses

More in AI Engineering & DevTools

AI ResearchAI Engineering & DevTools

Transformers Learn Non-Invertible Modular Multiplication via Stratified Fourier Mechanisms.

This research investigates how small transformers learn modular integer multiplication over composite moduli, a non-invertible operation. It proposes the "monoid extension" theory, suggesting models partition input space into hierarchical algebraic regions where Fourier mechanisms apply, explaining how embeddings, attention, and local features contribute to the computation.

Zitong Andrew Chen, Junaid Hasan, Akhil Srinivasan, Hemkesh Bandi, Jarod AlperJul 9, 2026
AI Engineering & DevToolsAI Research

New Interpretable Model Handles Feature Interactions in Tabular Data.

This paper introduces Interaction Aware Interpretable Machine Learning (IAIML), a framework for tabular data that addresses the limitation of traditional interpretable models in capturing feature interactions. IAIML uses adaptive discretization, pairwise interaction scoring, and a partitioned explanation budget to achieve high accuracy while maintaining interpretability.

Srikumar KrishnamoorthyJul 9, 2026
AI ResearchAI Engineering & DevTools

Principles of Deep Feedforward ReLU Networks Unveiled.

This paper systematically studies the mechanisms of deep feedforward ReLU networks, generalizing principles from two-layer networks to deeper architectures. It explains how hidden-layer units form piecewise linear manifolds to divide input space and how paths and their relationships are central to understanding the back-propagation training solution.

Changcun HuangJul 9, 2026