arXiv:2505.19956cs.AIcs.CL2025-05ACL被引 13

构建语义图谱提升小模型文本转SQL能力

DCG-SQL: Enhancing In-Context Learning for Text-to-SQL with Deep Contextual Schema Link Graph

  • 用上下文模式链接图表示问题与数据库关系
  • 在Spider数据集上小模型性能提升显著
  • 适合资源有限但需高效SQL生成的场景

文本转SQL任务通过大语言模型的上下文学习取得进展,但现有方法对演示样本的利用效率低,且在小型模型(如Llama 3.1-8B)上性能下降明显,表明其依赖超大规模模型的内在能力而非有效检索演示。本文提出DCG-SQL,构建深度上下文模式链接图,包含问题与数据库模式项间的语义关系与关键信息。该图结构能有效表征文本转SQL样本,并实现高质量演示的检索。在Spider基准上的实验表明,该方法在超大规模模型和小模型上均实现稳定的性能提升,显著改善生成效果与效率。代码已开源。

原文摘要 · Abstract (English)

Text-to-SQL, which translates a natural language question into an SQL query, has advanced with in-context learning of Large Language Models (LLMs). However, existing methods show little improvement in performance compared to randomly chosen demonstrations, and significant performance drops when smaller LLMs (e.g., Llama 3.1-8B) are used. This indicates that these methods heavily rely on the intrinsic capabilities of hyper-scaled LLMs, rather than effectively retrieving useful demonstrations. In this paper, we propose a novel approach for effectively retrieving demonstrations and generating SQL queries. We construct a Deep Contextual Schema Link Graph, which contains key information and semantic relationship between a question and its database schema items. This graph-based structure enables effective representation of Text-to-SQL samples and retrieval of useful demonstrations for in-context learning. Experimental results on the Spider benchmark demonstrate the effectiveness of our approach, showing consistent improvements in SQL generation performance and efficiency across both hyper-scaled LLMs and small LLMs. The code is available at https://github.com/jjklle/DCG-SQL}{https://github.com/jjklle/DCG-SQL.

文本转SQL图神经网络小模型优化

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