用知识增强生成合成数据,提升低资源场景下文本转SQL的准确率
Knowledge Distillation for Low-Resource Open-source Text-to-SQL Model

- 构建包含模式语义和业务逻辑的知识库,注入训练与推理过程
- 在7个基准上显著提升开源与闭源大模型性能,尤其在低资源领域
- 适合需要快速适配新数据库的开发者或数据分析师使用
文本转SQL将自然语言问题转化为可执行的SQL查询,使非技术用户也能访问关系型数据库进行分析与智能数据服务。在真实场景中,性能常受限于低资源设置——高质量的<问题, SQL>标注对稀缺,尤其是特定领域的数据库。此外,模式定义不透明、缩写泛滥及隐含业务逻辑未在模式中显式表达,也带来挑战。现有数据合成与提示技术虽能扩大覆盖范围,但往往生成的任务无关、语义脱节的示例,难以满足数据库约束。为此,我们提出一种知识感知的文本转SQL框架,构建包含模式语义、缩写、业务逻辑与查询模式的任务特定知识库,并将其注入训练与推理。该框架生成多样化、上下文相关的合成训练数据,并通过定向知识检索增强推理。在七个涵盖通用与领域专用数据集的基准上实验表明,该方法显著提升开源与闭源大语言模型在文本转SQL任务中的表现,尤其在低资源领域,增强了泛化性、鲁棒性与适应性。
原文摘要 · Abstract (English)
Text-to-SQL converts natural language questions into executable SQL queries, enabling non-technical users to access relational databases for analytics and intelligent data services. In real-world scenarios, performance is often constrained by low-resource settings, where high-quality annotated \texttt{<question, SQL>} pairs are scarce, particularly for domain-specific databases. Additional challenges include opaque schema definitions, abbreviations, and implicit business logic that are not explicitly encoded in the schema. Existing data synthesis and prompting techniques improve coverage but often fail to produce task-specific, semantically grounded examples aligned with database constraints. To address these challenges, we propose a knowledge-aware Text-to-SQL framework that constructs task-specific knowledge base including schema semantics, abbreviations, business logic, and query patterns, and injects them into both training and inference. This framework generates diverse, contextually grounded synthetic training data and enhances inference through targeted knowledge retrieval. Experiments on seven benchmarks, covering both general and domain-specific datasets, demonstrate that our approach substantially improves the performance of open-source and closed-source large language models in Text-to-SQL tasks, especially in low-resource domain-specific settings, enhancing generalization, robustness, and adaptability.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。