TL;DR
SpotIt introduces a formal verification pipeline to expose a major flaw in how we evaluate Text-to-SQL models: current benchmarks are "optimistic" and often mark incorrect queries as right simply because they happen to produce the same result on a single test database. By using SMT-based verification to find counterexample databases, the authors show that state-of-the-art model accuracy is actually 11%–14% lower than reported, and that many "gold" human-labeled queries are themselves buggy.
What Problem Does This Paper Address?
The standard way to evaluate a Text-to-SQL system (which translates natural language into database queries) is "Execution Accuracy." You take the AI-generated query and a human-written "gold" query, run them both on a static test database, and see if the results match.
The authors argue this is fundamentally unreliable. Two queries can be semantically different but coincidentally return the same rows on one specific dataset—much like how the equations $x + 2$ and $x^2$ both equal $4$ when $x=2$, even though they are not equivalent. This "optimistic" evaluation leads to inflated accuracy scores and potentially misleading leaderboards. Furthermore, human-written gold queries are prone to errors that static testing rarely catches.
Methods
The authors propose SpotIt, a search-based evaluation pipeline. Instead of relying on a single database, SpotIt uses Bounded SQL Equivalence Checking.
Key technical components include:
- SMT-based Verification: It translates SQL queries into Satisfiability Modulo Theories (SMT) formulas. It then tasks a solver (like Z3) to find any database instance (up to a bound $K$ of rows) where the generated query and the gold query produce different outputs.
- Extending VERIEQL: The authors significantly extended the existing VERIEQL verifier to support complex SQL features common in benchmarks, such as string manipulations (
LIKE,SubStr), date/time operations (Strftime,JulianDay), and implicit type casting. - Cross-Checking: To improve efficiency, if a counterexample database is found for one model, SpotIt "cross-checks" it against other models to see if it differentiates their queries as well.
- Validation Phase: Since SMT encodings can sometimes be over-approximated, SpotIt includes a validation step where any discovered counterexample is executed in a real database engine (like SQLite) to ensure the discrepancy is genuine.
Datasets
The study evaluates ten state-of-the-art Text-to-SQL methods using:
- BIRD (Big Bench for Large-scale Database Grounded Text-to-SQLs): The primary focus, specifically the development set consisting of 1,533 question-SQL pairs across 11 professional domains.
- Spider 2.0: Used for additional analysis to test the generalizability of SpotIt on more complex, real-world enterprise SQL tasks.
Key Insights and Ideas
- The "Gold" Standard is Tarnished: Perhaps the most surprising finding is that when SpotIt finds a discrepancy, it is often the human-written gold query that is wrong (64% of sampled cases). Humans frequently make mistakes with inclusive vs. exclusive bounds (e.g., using
BETWEENwhen they should use>) or ordering logic. - Rankings are Fragile: Switching from standard testing to SpotIt doesn't just lower scores; it reshuffles the leaderboard. For example, the top-ranked model on BIRD (CSC-32B) dropped to 4th place under formal verification, while the 2nd-place model (GENA-2) took the top spot.
- The "Semantic Gap" of Ambiguity: About 10% of discrepancies arise from ambiguous natural language. For instance, a question asking for a "count" might be correctly interpreted as either
COUNT(*)orCOUNT(DISTINCT id), but standard benchmarks only reward the one that matches the annotator's specific choice. - Efficiency of Formal Tools: Despite the complexity of formal verification, SpotIt found counterexamples in under 4 seconds on average per query, proving that formal methods are practical for large-scale AI evaluation.
Key Results
- Significant Accuracy Drop: Across all ten tested models, absolute accuracy dropped by 11.3% to 14.2% when moving from standard execution testing to SpotIt.
- Model Performance: The high-performing CSC-32B model saw its accuracy plummet from 71.32% to 57.82%.
- Counterexample Validity: 93% to 96% of the counterexamples found by the SMT solver were validated as "true" discrepancies when run on a real DBMS, proving the high precision of their SMT encoding.
- Bound Justification: The authors found that a bound of $K=5$ (searching for databases with up to 5 rows) was sufficient to catch the vast majority of errors, balancing verification power with computational speed.
Limitations and Future Work
- SQL Coverage: While SpotIt supports a wide range of SQL, it still struggles with window functions (like
RANK()orLAG()) and recursive common table expressions (CTEs). These features appeared in many of the "unsupported" queries in the Spider 2.0 analysis. - Bounded Proofs: Because the verification is "bounded," SpotIt can prove two queries are different, but it cannot provide a mathematical guarantee that they are identical for infinitely large databases (though $K=5$ is practically very strong).
- User Preferences: The authors suggest that future work should incorporate user preferences into the SMT formulation to better handle ambiguous questions where multiple SQL interpretations might be valid.
Summary updated