用小模型实现大模型的文本转SQL能力,节省资源。
Auto prompt sql: a resource-efficient architecture for text-to-sql translation in constrained environments
- 分步处理:先筛选数据库模式,再用上下文示例生成SQL。
- 在Spider数据集上准确率达73.2%,接近大模型表现。
- 适合低算力环境使用,尤其对小团队或边缘设备友好。
在资源受限环境下使用高性能文本转SQL方法面临挑战,因其依赖高耗能的开源大模型。本文提出Auto Prompt SQL(AP-SQL),一种新型架构,旨在连接资源高效的小型开源模型与强大封闭模型之间的差距。该方法将任务分解为:模式过滤、基于上下文示例的检索增强型文本转SQL生成,以及提示驱动的模式关联与SQL生成。为提升模式选择准确性,我们微调了大型语言模型。关键的是,我们在全流程中探索提示工程的影响,采用思维链(CoT)和思维图(GoT)模板,显著增强模型推理能力,提高SQL生成准确性。在Spider基准上的全面评估证明了AP-SQL的有效性。
原文摘要 · Abstract (English)
Using the best Text-to-SQL methods in resource-constrained environments is challenging due to their reliance on resource-intensive open-source models. This paper introduces Auto Prompt SQL(AP-SQL), a novel architecture designed to bridge the gap between resource-efficient small open-source models and the powerful capabilities of large closed-source models for Text-to-SQL translation. Our method decomposes the task into schema filtering, retrieval-augmented text-to-SQL generation based on in-context examples, and prompt-driven schema linking and SQL generation. To improve schema selection accuracy, we fine-tune large language models. Crucially, we also explore the impact of prompt engineering throughout the process, leveraging Chain-of-Thought(CoT) and Graph-of-Thought(GoT) templates to significantly enhance the model's reasoning for accurate SQL generation. Comprehensive evaluations on the Spider benchmarks demonstrate the effectiveness of AP-SQL.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。