Abstract
Despite the prevailing narrative that Large Language Models (LLMs) have mastered Natural Language to SQL (NL2SQL) translation, enterprise-grade deployment remains a significant open challenge. This paper, a collaborative effort between Microsoft and Waii, identifies critical hurdles in real-world applications—including schema complexity, inherent linguistic ambiguity, and flawed benchmarking—and proposes a new intent-based framework to better align evaluation with user satisfaction.
The Enterprise Reality Gap
While basic tutorials might suggest that vanilla LLMs have "solved" database querying, real-world enterprise environments present obstacles that toy benchmarks do not capture. The authors highlight four primary challenges:
- Schema Complexity: Unlike curated datasets, enterprise databases often contain thousands of tables and tens of thousands of columns with cryptic, domain-specific naming conventions.
- Ambiguity & Semantic Mismatch: Natural language is inherently imprecise. Users frequently pose questions with multiple valid interpretations or request data that does not exist within the schema.
- Flawed Benchmarking: Current metrics like "exact string match" or "execution match" are overly rigid. They often penalize systems for providing semantically correct or even superior queries (e.g., returning a descriptive name alongside a requested ID).
- Responsible AI: Unchecked NL2SQL systems risk generating biased queries, leaking sensitive information, or executing destructive commands.
Schema Selection and Context Management
A common misconception is that larger context windows solve schema management. However, the authors' experiments on the KaggleDBQA dataset demonstrate that feeding an entire schema into an LLM can actually degrade performance.
As shown in Figure 1, while automated methods like Retrieval-Augmented Generation (RAG) and LLM-based filtering provide a baseline, they still lag significantly behind manual "optimal" selection. Using the full schema yielded only 22.7% accuracy, whereas manual selection of optimal tables and columns boosted performance to 29.7%.
Modeling Ambiguity and Mismatch
Ambiguity is a fundamental feature of human communication, not a bug to be ignored. The study found that human annotators only agree on whether a query is ambiguous 62% of the time. Interestingly, GPT-4 achieved a 65% agreement rate with humans, suggesting it can effectively model uncertainty.
Furthermore, the authors tested "semantic mismatch"—scenarios where a database lacks the data to answer a prompt. While GPT-4 successfully detected these mismatches 100% of the time in cross-dataset tests, GPT-3.5 struggled, catching only 60% and hallucinating schema elements for the remainder.
Rethinking Benchmarks: The Archerfish Framework
To address the limitations of traditional metrics, the authors introduced Archerfish, an open-source benchmarking framework featuring an "intent-based execution match" metric. This approach relaxes strict matching rules to accept queries that satisfy the core user intent, even if they return additional columns or different row orderings.
Figure 3 illustrates how intent-based metrics provide a more realistic view of system utility. On the EMPLOYEE_HIRE_EVALUATION dataset, for instance, success rates jump from a restrictive 26.32% (Exact Match) to 94.74% when evaluating based on intent. This shift is essential for building products that users find genuinely helpful.
Conclusion and Future Directions
The path to enterprise-grade NL2SQL requires moving beyond simple text-to-SQL translation toward systems that can actively clarify ambiguity and safeguard against bias. Future work must focus on developing cheaper models for mismatch detection, creating probabilistic benchmarks that account for multiple valid interpretations, and implementing robust safeguards for safe query execution. NL2SQL is far from solved; it is entering a more nuanced and challenging phase of development.
Summary updated