TL;DR
DexterSQL is a state-of-the-art, non-fine-tuning Text-to-SQL system that dramatically improves how Large Language Models (LLMs) translate natural language into database queries. By introducing deep data-level schema exploration, database-agnostic error correction rules, and dependency-tree-guided query generation, it sets new accuracy records on major benchmarks without changing a single model weight.
What Problem Does This Paper Address?
Translating natural language questions into executable SQL queries (Text-to-SQL) is a crucial step toward making data democratization a reality. While prompting-based (non-fine-tuning) LLM approaches are easy to deploy and scale, they consistently stumble on three major hurdles:
- Coarse-grained schema linking: LLMs often confuse ambiguous columns (e.g., distinguishing a patient's final diagnosis from a preliminary examination diagnosis) because they only look at surface-level schema names or a few sample values.
- Recurring model errors: LLMs repeatedly make the same logical or dialect-specific mistakes (such as integer truncation during division), but standard prompting fails to systematically capture and correct these patterns across different databases.
- Incomplete query generation: For complex questions, free-form LLM decomposition often omits, misplaces, or hallucinates critical constraints or relationships.
Methods
DexterSQL introduces a modular four-phase pipeline that splits the workload into an offline preparation stage and an online inference stage:
- Phase 1: Preprocessing (Offline):
- Deep Schema Explorator: Automatically detects ambiguous column pairs and computes data-level statistics (overlap, coverage, fan-out, agreement) to generate concise "disambiguation notes."
- Rule Creator: Evaluates the LLM on training data to find systematic failures, strips away database-specific details, and synthesizes generalized, database-agnostic correction rules (e.g., fixing integer division by inserting a
CASTstatement). - Phase 2: Schema Linking (Online): Prunes the database schema to a focused subset relevant to the user's question.
- Phase 3: Multi-path SQL Generation (Online): Generates candidates using three complementary paths: few-shot learning, divide-and-conquer, and a novel dependency-tree-based intermediate representation. This new path uses a deterministic dependency parser to map the sentence structure directly to an SQL skeleton, ensuring no constraints are dropped.
- Phase 4: Correction and Selection (Online): Applies the synthesized correction rules to the generated candidates, executes them to cluster identical results, and uses a confidence-aware selection strategy to pick the final query.
Datasets
The authors evaluated DexterSQL on two prominent Text-to-SQL benchmarks:
- BIRD: A large-scale, complex benchmark containing 12,751 natural language question-SQL pairs across 95 databases. Evaluation was performed on the 1,534 pairs in
BIRD-Dev. - Spider: A cross-domain benchmark containing 10,181 question-SQL pairs over 200 databases. Evaluation was performed on the 2,147 pairs in
Spider-Test.
No new benchmarks were introduced; the focus was entirely on outperforming existing methods on these standard datasets.
Key Insights and Ideas
- Data Distribution Over Schema Names: Column names are often deceptive or identical across tables. Looking at the joint data distribution (e.g., checking if a column has a one-to-one or one-to-many relationship with a primary key) provides the fine-grained context an LLM needs to resolve ambiguity.
- Isolating the Error from the Database: LLM mistakes are often structural rather than domain-specific. By filtering out database-specific artifacts from training failures, we can create universal "patches" (rules) that apply beautifully to entirely unseen databases.
- Deterministic Syntax Trees Beat Free-form LLMs: Instead of trusting an LLM to cleanly break down a complex question, using a traditional, deterministic dependency parser preserves the exact linguistic constraints of the question, acting as a rigid guardrail against hallucination.
Key Results
DexterSQL achieves state-of-the-art performance across both open-weight and closed-weight models:
- Open-Weight Performance: Using
GPT-OSS-120B, DexterSQL achieved an execution accuracy (EX) of 70.4% on BIRD-Dev (a 5.5% absolute improvement over the closest baseline, DeepEye-SQL) and 85.6% on Spider-Test. - Closed-Weight Performance: With
GPT-4oandGPT-5.2, DexterSQL reached 72.1% and 72.9% accuracy on BIRD-Dev respectively, outperforming the strongest non-fine-tuning baselines by at least 1.4%. - Schema Linking Superiority: It achieved the highest schema-linking recall (97.09%) and precision (72.26%) on BIRD-Dev, proving it successfully includes necessary columns while filtering out noise.
Limitations and Future Work
Not discussed in the paper.
Summary updated