arXiv:2505.22096cs.CLcs.AI2025-05ACL被引 16

构建可复用的文本到SQL知识库,提升大模型生成准确率

Knowledge Base Construction for Knowledge-Augmented Text-to-SQL

  • 基于问题、数据库模式和相关知识自动构建全面知识库
  • 在多个数据集上显著优于现有基线,尤其在跨库场景表现突出
  • 适合需要高精度文本转SQL且涉及多领域数据库的研究者

文本到SQL任务旨在将自然语言查询转化为SQL语句,使非技术人员也能轻松从数据库中获取信息。近年来,许多方法借助大语言模型(LLM)的强大理解与生成能力解决此问题。然而,LLM中的参数化知识难以覆盖多样且特定领域的查询需求,导致生成的SQL准确性不足。为此,我们提出构建面向文本到SQL的知识库,作为基础性知识源,用于检索和生成给定查询所需的上下文知识。不同于现有方法仅人工标注或为每条查询生成少量知识,我们的知识库具有全面性,基于所有可用问题、其关联的数据库模式及相应知识构建,可复用于不同数据集和领域中的未见数据库。我们在多个文本到SQL数据集上验证了该方法,涵盖重叠与非重叠数据库场景,结果表明其显著优于相关基线。

原文摘要 · Abstract (English)

Text-to-SQL aims to translate natural language queries into SQL statements, which is practical as it enables anyone to easily retrieve the desired information from databases. Recently, many existing approaches tackle this problem with Large Language Models (LLMs), leveraging their strong capability in understanding user queries and generating corresponding SQL code. Yet, the parametric knowledge in LLMs might be limited to covering all the diverse and domain-specific queries that require grounding in various database schemas, which makes generated SQLs less accurate oftentimes. To tackle this, we propose constructing the knowledge base for text-to-SQL, a foundational source of knowledge, from which we retrieve and generate the necessary knowledge for given queries. In particular, unlike existing approaches that either manually annotate knowledge or generate only a few pieces of knowledge for each query, our knowledge base is comprehensive, which is constructed based on a combination of all the available questions and their associated database schemas along with their relevant knowledge, and can be reused for unseen databases from different datasets and domains. We validate our approach on multiple text-to-SQL datasets, considering both the overlapping and non-overlapping database scenarios, where it outperforms relevant baselines substantially.

文本到SQL知识库大模型

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