用结构化推理链提升小模型文本转SQL能力
Knowledge Distillation with Structured Chain-of-Thought for Text-to-SQL
- 用查询执行计划构建结构化思维路径进行知识蒸馏
- 小模型性能提升8.1%,语法错误显著减少
- 适合需要安全高效数据库交互的企业应用
在企业级部署中,高精度文本转SQL系统面临成本、安全性和性能的三难困境。现有方案被迫在昂贵的专有大语言模型(LLM)和表现差的小语言模型(SLM)之间二选一。当前提升SLM的方法多依赖从大LLM蒸馏非结构化思维链(CoT),过程存在固有模糊性。本文提出结构化推理框架Struct-SQL,通过查询执行计划作为正式逻辑蓝图,引导小模型学习结构化推理。实验表明,采用结构化CoT蒸馏的小模型相较非结构化基线绝对提升8.1%。详细错误分析显示,性能提升主要源于语法错误大幅减少。这证明以结构化逻辑蓝图指导推理有助于小模型生成更可靠的SQL。
原文摘要 · Abstract (English)
Deploying accurate Text-to-SQL systems at the enterprise level faces a difficult trilemma involving cost, security and performance. Current solutions force enterprises to choose between expensive, proprietary Large Language Models (LLMs) and low-performing Small Language Models (SLMs). Efforts to improve SLMs often rely on distilling reasoning from large LLMs using unstructured Chain-of-Thought (CoT) traces, a process that remains inherently ambiguous. Instead, we hypothesize that a formal, structured reasoning representation provides a clearer, more reliable teaching signal, as the Text-to-SQL task requires explicit and precise logical steps. To evaluate this hypothesis, we propose Struct-SQL, a novel Knowledge Distillation (KD) framework that trains an SLM to emulate a powerful large LLM. Consequently, we adopt a query execution plan as a formal blueprint to derive this structured reasoning. Our SLM, distilled with structured CoT, achieves an absolute improvement of 8.1% over an unstructured CoT distillation baseline. A detailed error analysis reveals that a key factor in this gain is a marked reduction in syntactic errors. This demonstrates that teaching a model to reason using a structured logical blueprint is beneficial for reliable SQL generation in SLMs.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。