让自然语言转SQL更懂方言,提升跨数据库查询准确率
Dial: A Knowledge-Grounded Dialect-Specific NL2SQL System
- 通过分层知识库和意图分解,精准识别不同数据库语法差异
- 在6个数据库上准确率提升10.25%,方言功能覆盖率达15.77%提升
- 适合需要跨数据库系统部署NL2SQL的工程师与研究者
企业常使用异构数据库系统,每种系统有独特的SQL方言(如语法、内置函数、执行约束不同)。现有大多数NL2SQL方法假设单一方言(如SQLite),难以生成既语义正确又可在目标引擎执行的查询。提示法耦合意图与语法,规则翻译器将原生操作降级为通用形式,多方言微调则受跨方言干扰。本文提出Dial,一种基于知识的方言特异性NL2SQL框架:(1) 引入感知方言的逻辑查询规划模块,通过操作级意图分解与差异感知规范生成方言感知的逻辑计划;(2) 构建分层意图感知知识库HINT-KB,包含标准语法参考、声明式函数库、过程式约束库;(3) 执行驱动的调试与语义验证循环,分离语法修复与逻辑审计,防止语义漂移。我们构建了DS-NL2SQL基准,涵盖6大数据库系统,含2,218个方言特定测试用例。实验表明,Dial在准确率上比最优基线提升10.25%,方言特性覆盖提升15.77%。代码已开源。
原文摘要 · Abstract (English)
Enterprises commonly deploy heterogeneous database systems, each of which owns a distinct SQL dialect with different syntax rules, built-in functions, and execution constraints. However, most existing NL2SQL methods assume a single dialect (e.g., SQLite) and struggle to produce queries that are both semantically correct and executable on target engines. Prompt-based approaches tightly couple intent reasoning with dialect syntax, rule-based translators often degrade native operators into generic constructs, and multi-dialect fine-tuning suffers from cross-dialect interference. In this paper, we present Dial, a knowledge-grounded framework for dialect-specific NL2SQL. Dial introduces: (1) a Dialect-Aware Logical Query Planning module that converts natural language into a dialect-aware logical query plan via operator-level intent decomposition and divergence-aware specification; (2) HINT-KB, a hierarchical intent-aware knowledge base that organizes dialect knowledge into (i) a canonical syntax reference, (ii) a declarative function repository, and (iii) a procedural constraint repository; and (3) an execution-driven debugging and semantic verification loop that separates syntactic recovery from logic auditing to prevent semantic drift. We construct DS-NL2SQL, a benchmark covering six major database systems with 2,218 dialect-specific test cases. Experimental results show that Dial consistently improves translation accuracy by 10.25% and dialect feature coverage by 15.77% over state-of-the-art baselines. The code is at https://github.com/weAIDB/Dial.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。