arXiv:2503.13342cs.CLcs.AI2025-03被引 6

用逻辑语法约束生成可执行的SQL,提升语言模型准确性。

Valid Text-to-SQL Generation with Unification-based DeepStochLog

  • 结合神经符号方法与统一化语法,强制生成合法SQL。
  • 在子集语法上所有输出查询均有效,执行准确率显著提升。
  • 适合需要高可靠性SQL生成的应用场景。

大型语言模型常被用于将自然语言问题转化为SQL查询,但缺乏语法和数据库模式的硬约束,导致生成无效查询而无法执行,限制了实际应用。本文提出一种神经符号框架,利用基于统一分解的确定性条款语法(unification-based definite clause grammars)施加SQL语法和模式约束,确保生成的查询始终有效。该框架还构建双向接口连接语言模型,保留其自然语言理解能力。在部分SQL语法子集上的评估显示,所有输出查询均合法。本工作首次实现将语言模型与基于统一分解的语法结合,显著提升了生成查询的有效性、执行准确率及与真实答案的一致性。代码已公开于https://github.com/ML-KULeuven/deepstochlog-lm。

原文摘要 · Abstract (English)

Large language models have been used to translate natural language questions to SQL queries. Without hard constraints on syntax and database schema, they occasionally produce invalid queries that are not executable. These failures limit the usage of these systems in real-life scenarios. We propose a neurosymbolic framework that imposes SQL syntax and schema constraints with unification-based definite clause grammars and thus guarantees the generation of valid queries. Our framework also builds a bi-directional interface to language models to leverage their natural language understanding abilities. The evaluation results on a subset of SQL grammars show that all our output queries are valid. This work is the first step towards extending language models with unification-based grammars. We demonstrate this extension enhances the validity, execution accuracy, and ground truth alignment of the underlying language model by a large margin. Our code is available at https://github.com/ML-KULeuven/deepstochlog-lm.

文本转SQL神经符号有效性保证

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。