TL;DR
NL2SQLBench is the first modular benchmarking framework designed to dissect LLM-based Natural Language to SQL (NL2SQL) pipelines into three distinct stages: Schema Selection, Candidate Generation, and Query Revision. By evaluating ten representative methods, the authors reveal that semantic misalignment—not syntax—is the primary bottleneck in modern systems and highlight a massive efficiency gap between top-performing research models and what is practical for production.
What Problem Does This Paper Address?
While Large Language Models (LLMs) have revolutionized the ability to turn natural language into SQL queries, systematic evaluation has lagged behind. Most existing benchmarks, like Spider or BIRD, focus solely on "Execution Accuracy"—a binary metric of whether the final query produces the correct result.
This "black-box" approach creates two major issues:
- Diagnostic Blindness: It is impossible to tell why a system failed. Did it pick the wrong tables (Schema Selection)? Did it hallucinate logic (Candidate Generation)? Or did it fail to fix a minor error (Query Revision)?
- Efficiency Oversight: Many top-tier leaderboard solutions achieve high accuracy by using massive prompts or dozens of LLM calls, making them prohibitively expensive and slow for real-world applications.
NL2SQLBench addresses these by providing a modular framework and fine-grained metrics to evaluate each stage of the pipeline independently.
Methods
The authors propose a multi-agent benchmarking framework that treats NL2SQL as a three-stage process:
- Schema Selection: Filtering the database to find relevant tables and columns.
- Candidate Generation: Translating the NL query into one or more SQL drafts.
- Query Revision: Refining drafts based on execution feedback or self-correction.
To evaluate these, they introduced new metrics beyond simple accuracy:
- For Schema Selection: Precision, Recall, and F1-score at both the table and column levels.
- For Candidate Generation: Correct Rate (CR), Incorrect Rate (IR) (syntactically valid but wrong results), and Error Rate (ER) (execution failures).
- For Query Revision: Correctness Improvement Rate (CI) and transition metrics like Incorrect-to-Correct (I2C).
- Efficiency: Systematic tracking of token usage and the number of LLM calls.
The framework uses three specialized agents—Result Collecting, Postprocessing, and Benchmarking—to ensure that different NL2SQL methods can be compared fairly under identical experimental settings (e.g., using DeepSeek-V3 or GPT-4o mini as the backbone).
Datasets
The study evaluates methods on two primary datasets:
- BIRD (Development Set): A large-scale, cross-domain benchmark focusing on large databases and external knowledge.
- ScienceBenchmark: A complex, domain-specific benchmark containing real-world scientific data analysis queries, which typically features denser schemas than academic suites.
Key Insights and Ideas
- The "Gold Schema" Gap: One of the most striking findings is the impact of perfect schema selection. As shown in Figure 2, providing models with the "Gold Schema" (the exact tables/columns needed) instead of having the model select them leads to a massive jump in execution accuracy—up to a 20% relative improvement for some methods.
- Semantic Mismatch is the Primary Killer: The dominant failure mode across all models is the Incorrect Rate (IR). Most failed queries are syntactically perfect SQL that simply joins the wrong tables or uses the wrong filters. This suggests that researchers should focus more on semantic alignment than on fixing syntax errors.
- Diminishing Returns of Multiple Candidates: While generating multiple candidates (Pass@k) increases the potential for a correct answer, the Query Revision modules often fail to select the correct one from the pile. The gap between the theoretical "Pass@5" accuracy and the actual post-revision accuracy remains significant.
- Dataset Noise: The authors discovered that a significant portion of "unsolvable" questions in the BIRD dataset were actually due to inaccurate "gold" SQL annotations in the benchmark itself, highlighting a need for cleaner evaluation data.
Key Results
The benchmarking of ten open-source methods revealed a clear "cost-quality frontier":
- High-Accuracy, High-Cost: Systems like OpenSearch-SQL and CHESS achieve top-tier accuracy but are "token-intensive," sometimes requiring over 80 LLM calls or hundreds of thousands of tokens per query.
- Efficiency Leaders: TA-SQL and DIN-SQL emerged as strong contenders for production, offering near-top performance with only 1–3 LLM calls and significantly lower token costs.
- Revision Limitations: Current Query Revision modules are surprisingly limited. Even the best revision strategies only improved the Correct Rate by a relatively small margin, and in some cases (on ScienceBenchmark), aggressive revision actually decreased accuracy by turning correct queries into incorrect ones.
Limitations and Future Work
- Scope of Models: The study focused on prompt-based methods and did not include fine-tuned or Reinforcement Learning (RL)-trained models due to computational constraints.
- Industry Realism: While ScienceBenchmark is a step forward, the authors acknowledge that current benchmarks still don't fully capture the complexity of enterprise-level "messy" schemas and ambiguous user intent.
- Future Directions: The authors advocate for "do-no-harm" safeguards in revision modules to prevent regressions and suggest that future research should prioritize lightweight, two-stage schema pruning to balance accuracy and latency.
The NL2SQLBench project is open-sourced at https://github.com/neurdb/NL2SQLBench.
Summary updated