Abstract
Current Natural Language to SQL (NL2SQL) models are significantly more brittle than standard benchmarks suggest. This paper introduces a novel "SQL-to-NL" paraphrasing framework to generate semantically identical but linguistically diverse queries. Evaluation of top-tier models like Llama 3.3-70B reveals performance drops exceeding 10% under simple rephrasing, highlighting a critical gap in linguistic robustness.
Introduction
The goal of NL2SQL is to enable users to query databases using everyday language. While models perform well on popular benchmarks like Spider and BIRD, these datasets often feature "clean," straightforward queries that don't reflect the messy, varied way humans actually speak. A major challenge is determining whether a model fails due to a lack of understanding of the database schema or an inability to handle linguistic variation. Most existing robustness tests conflate these two factors. This research introduces a method to isolate linguistic robustness by ensuring test queries are perfectly aligned with the underlying SQL and schema from the outset.
Methodology: The SQL2NL Framework
The authors propose a schema-aligned paraphrasing framework that utilizes a Large Language Model (LLM) in reverse: SQL2NL.
The process involves four main stages:
- Generation: A "Gold SQL" query and its database schema are used to prompt an LLM to generate $k$ different natural language versions. Because the generation starts from the SQL, the resulting text is grounded and mathematically guaranteed to represent the intended logic.
- Validation: Sentence-BERT (SBERT) and human evaluation ensure these paraphrases maintain semantic meaning. Approximately 98% of generated samples were found to be reliable.
- Stress-Testing: These paraphrases are fed back into various NL2SQL models (e.g., GPT-4o, Llama 3 series) to measure Execution Match (EM) accuracy.
- Normalization: A "Normalized Schema Error Rate" (NER) tracks how often models hallucinate or miss columns and tables, helping to distinguish between schema-linking and logical reasoning failures.
Datasets
The study evaluated models across three distinct environments:
- Spider (Dev): A cross-domain benchmark for complex text-to-SQL tasks.
- BIRD (Dev): A dataset focused on large-scale databases and real-world complexity.
- FIBEN: A specialized financial domain dataset characterized by a high number of JOIN operations.
Key Insights
The Fragility of Small Models
While large models (70B+) show some resilience, smaller models (8B) are incredibly fragile. For instance, Llama 3.1-8B saw its accuracy drop by over 20% simply by changing the wording of the prompt.
The Schema Linking Paradox
Surprisingly, paraphrased queries often resulted in lower schema-linking error rates. The SQL2NL process frequently generates more explicit language (e.g., "List the names of the car makers" instead of "Who made these?"). Despite finding the right columns more easily, models still failed the logic of the query more often, suggesting that logical reasoning, rather than schema mapping, is the primary weak point.
Complexity and Fragility
Performance degradation is closely tied to query complexity. As the number of JOIN operations increases, the performance gap between original and paraphrased queries widens significantly.
On the Spider dataset, queries requiring one JOIN saw a 16.4% drop in accuracy when paraphrased, compared to a smaller drop for simpler queries.
Results
The researchers quantified the "Degradation" (absolute drop in accuracy) for several state-of-the-art models on the Spider dataset:
| Model | Original Accuracy | Paraphrased Accuracy | Degradation |
|---|---|---|---|
| Llama 3.1-405B | 79.5% | 69.2% | 10.3% ↓ |
| Llama 3.3-70B | 77.1% | 66.9% | 10.2% ↓ |
| GPT-4o-mini | 77.4% | 65.2% | 12.2% ↓ |
| Llama 3.1-8B | 62.9% | 42.5% | 20.4% ↓ |
On the BIRD dataset, models were slightly more resilient, but the trend remained consistent: paraphrasing hurts performance even when the underlying logic is identical.
Limitations and Future Work
The framework currently focuses on semantically equivalent queries and does not yet address truly ambiguous or unanswerable questions. Additionally, the evaluation is limited to single-turn interactions and assumes a "Gold Schema," bypassing the retrieval stage common in real-world pipelines. Future research will leverage the SQL2NL framework to create high-quality preference datasets for fine-tuning, aiming to improve model robustness through training on diverse paraphrases.
Summary updated