Abstract
Translating natural language into SQL (text-to-SQL) remains a significant challenge for database accessibility. While generative models have made strides, they often suffer from "near-miss" errors where the correct query is generated but not ranked first. We present Bertrand-DR, a discriminative re-ranking framework based on BERT that evaluates candidate queries produced by generative models. By shifting the logical burden from generation to recognition, Bertrand-DR achieves significant accuracy gains on the Spider benchmark, reaching a top-tier position on the leaderboard.
Introduction: The "Near-Miss" Problem
Current state-of-the-art text-to-SQL systems are primarily generative, predicting SQL queries token-by-token. However, these models frequently encounter a "near-miss" scenario: the correct SQL query exists within the model's top guesses (the "beam"), but the model fails to rank it as the primary choice. This suggests that while generative models are capable of producing correct logic, they struggle to consistently identify it. Bertrand-DR addresses this gap by acting as a secondary "discriminator" to filter and re-rank these candidates.
Methodology: The Bertrand-DR Pipeline
Bertrand-DR utilizes a BERT-base architecture fine-tuned for binary classification. The process follows a multi-stage pipeline:
- Candidate Generation: A base generative model (e.g., GNN or EditSQL) produces a "beam" of up to 40 candidate SQL queries.
- Discriminative Classification: Each candidate query is concatenated with the original natural language question, separated by a
[SEP]token. - Scoring: The BERT model predicts the probability of the query being "Gold" (correct) versus "Not Gold."
- Threshold-Based Re-ranking: To ensure stability, a candidate only replaces a higher-ranked query if its discriminative score exceeds the original's by a specific empirical threshold ($t$).
Notably, the authors found that making the re-ranker schema-agnostic improved performance. Excluding database schema information allowed the model to focus on the semantic mapping between the question and the query structure without the interference of complex database metadata.
Experimental Results
The effectiveness of Bertrand-DR was evaluated using the Spider benchmark, a complex, cross-domain dataset. When applied to existing state-of-the-art models, the re-ranker provided substantial performance boosts.
As shown in the results, the GNN model saw a relative improvement of 12.9%, with accuracy rising from 51.3% to 57.9% on the development set. On the official Spider leaderboard, the system achieved a Top 4 ranking at the time of publication.
Analysis and Key Insights
Recognition vs. Generation
The success of Bertrand-DR supports the intuition that it is easier for a model to recognize a correct answer among a few choices than to generate it from scratch. By offloading the final selection to a discriminator, the system better handles the joint probability of language and logic.
Performance by Difficulty
The re-ranker is most effective on "Easy" queries, where there is high semantic similarity between the natural language question and the SQL column names. Conversely, "Extra Hard" queries involving complex joins or sub-queries showed less improvement. This suggests that while semantic matching is a powerful signal for simpler queries, more complex logical structures may require specialized discriminative strategies.
Conclusion and Future Work
Bertrand-DR demonstrates that discriminative re-ranking is a viable and effective method for boosting text-to-SQL performance. While limited by the quality of the initial candidate beam, it successfully recovers many "near-miss" correct queries. Future research may focus on hardness-specific re-rankers, potentially using different architectures for simple semantic mapping versus complex structural logic.
Summary updated