arXiv:2508.12769cs.CLcs.AI2025-08

用聚类检索和执行描述提升大库文本转SQL的准确率

CRED-SQL: Enhancing Real-world Large Scale Database Text-to-SQL Parsing through Cluster Retrieval and Execution Description

  • 通过聚类检索快速定位相关表字段,缓解模式匹配错位
  • 引入中间自然语言表示法,使文本到SQL转化更稳定
  • 在跨领域大数据库上达顶尖性能,适合工业级应用

大语言模型虽显著提升文本转SQL系统的准确率,但自然语言问题与对应SQL之间仍存在语义偏差。该问题在大规模数据库中尤为突出,因语义相近的属性导致模式关联困难、生成过程出现语义漂移,最终降低模型表现。为此,我们提出CRED-SQL框架,整合聚类检索与执行描述机制。该方法首先基于聚类进行大规模模式检索,精准定位与自然语言问题相关的表和列,缓解模式错配。随后引入中间自然语言表示——执行描述语言(EDL),将任务分解为文本转EDL与EDL转SQL两阶段,利用大模型的强大推理能力,减少语义偏离。在两个大规模跨领域基准数据集SpiderUnion和BirdUnion上的实验表明,CRED-SQL达到新SOTA性能,验证了其有效性和可扩展性。代码已开源:https://github.com/smduan/CRED-SQL.git。

原文摘要 · Abstract (English)

Recent advances in large language models (LLMs) have significantly improved the accuracy of Text-to-SQL systems. However, a critical challenge remains: the semantic mismatch between natural language questions (NLQs) and their corresponding SQL queries. This issue is exacerbated in large-scale databases, where semantically similar attributes hinder schema linking and semantic drift during SQL generation, ultimately reducing model accuracy. To address these challenges, we introduce CRED-SQL, a framework designed for large-scale databases that integrates Cluster Retrieval and Execution Description. CRED-SQL first performs cluster-based large-scale schema retrieval to pinpoint the tables and columns most relevant to a given NLQ, alleviating schema mismatch. It then introduces an intermediate natural language representation-Execution Description Language (EDL)-to bridge the gap between NLQs and SQL. This reformulation decomposes the task into two stages: Text-to-EDL and EDL-to-SQL, leveraging LLMs' strong general reasoning capabilities while reducing semantic deviation. Extensive experiments on two large-scale, cross-domain benchmarks-SpiderUnion and BirdUnion-demonstrate that CRED-SQL achieves new state-of-the-art (SOTA) performance, validating its effectiveness and scalability. Our code is available at https://github.com/smduan/CRED-SQL.git

文本转SQL大模型数据库自然语言处理

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