Introduction
Evaluating Text-to-SQL models is a critical yet difficult task. The goal is to translate natural language into executable code, but determining if a predicted query is truly "correct" remains an open challenge. Current metrics often penalize semantically correct queries that differ in structure (false negatives) or reward incorrect queries that happen to work on a single database (false positives). This paper introduces test suite accuracy, a method that distills a small, high-coverage set of automatically generated databases to provide a highly reliable and efficient approximation of true semantic accuracy.
The Evaluation Gap
Historically, researchers have relied on two primary metrics:
- Exact Set Match (ESM): Compares the structure of the predicted SQL to the gold standard. This is often too strict; for example, it might fail a query for using
NOT INinstead ofEXCEPT, even though they produce identical results. - Single Denotation Accuracy: Executes the query on a single database and compares the output. This is often too loose; a wrong query (e.g., missing a
WHEREclause) might accidentally return the correct answer if the database is small or lacks diverse data.
The authors aim to bridge this gap with a metric that is semantically rigorous but computationally cheaper than formal equivalence proofs, which are often undecidable for complex SQL.
Methodology: Distilled Test Suites
The core idea is to evaluate queries against a distilled test suite—a collection of databases specifically designed to break incorrect queries. The process involves three main stages:
1. Neighbor Query Generation
For every "gold" query, the system automatically generates "neighbors"—queries that are structurally similar but semantically different. These neighbors represent common model mistakes, such as changing comparison operators, swapping column names, or dropping clauses.
2. Database Fuzzing and Distillation
The system generates 1,000 random databases that satisfy the schema's constraints (types, foreign keys, etc.). Using a greedy search, the system then selects a tiny subset of these databases (usually ~42 per query) that can distinguish the gold query from as many of its neighbors as possible. This ensures high "code coverage" and efficiency.
3. Evaluation
At test time, a predicted query is considered correct only if its output matches the gold query's output across all databases in the distilled test suite.
Key Results and Reliability
The distilled test suite approach provides a highly reliable approximation of semantic accuracy. The authors manually verified 100 cases where their metric disagreed with the standard ESM metric; in 100% of these cases, the test suite accuracy made the correct judgment.
Key findings include:
- False Negatives in Spider: The standard Spider metric (ESM) has a 2.5% false negative rate on average, reaching as high as 8.1% for complex queries. This means many correct models are being unfairly penalized.
- False Positives: Single denotation accuracy (using only the original database) has a false positive rate of 6.5% on average.
- Complexity Gap: As queries get more complex, the gap between ESM and true semantic accuracy widens, proving that better metrics are needed as the field progresses.
Conclusion
By providing a semantically rigorous yet computationally efficient evaluation framework, distilled test suites offer a more accurate reflection of Text-to-SQL model performance. This methodology is particularly vital as models tackle increasingly complex queries where structural matching becomes an unreliable proxy for correctness. The authors have released distilled test suites for Spider and ten other popular datasets to support the community.
Summary updated