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

Robert Richardson· July 9, 2026 View original

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.

Who benefits

Data AnalyticsSoftware DevelopmentBusiness IntelligenceFinance (BFSI)Healthcare

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.

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