[论文解读] Optimizing Small Language Models for NL2SQL via Chain-of-Thought Fine-Tuning
微调小模型并使用显式链式思维(CoT)推理显著提升 NL2SQL 的准确性,而标准微调对大模型有害且对它们的提升有限。该方法实现了成本有效的部署,且准确性具备竞争力。
Translating Natural Language to SQL (NL2SQL) remains a critical bottleneck for democratization of data in enterprises. Although Large Language Models (LLMs) like Gemini 2.5 and other LLMs have demonstrated impressive zero-shot capabilities, their high inference costs limit deployment at scale. This paper explores the efficacy of fine-tuning both large and small language models on NL2SQL tasks. Our research reveals a counter-intuitive scaling phenomenon. Fine-tuning large models (Gemini 2.5 Flash/Lite) on standard datasets yields negligible returns, often leading to overfitting on complex queries. Conversely, small models (Qwen) show significant gains. Fine-tuning improved the small model baseline from 36% to 45%, and further enriching the dataset with explicit Chain-of-Thought (CoT) reasoning surged accuracy to 54.5%(Fig 2). While this is still lower than the accuracy of large models like Gemini 2.5 , it does serve the business goal of significant cost reduction, latency in inference time and also meeting the business critical performance accuracy threshold.This paper demonstrates that transferring reasoning patterns enables compute-efficient smaller models to approach production-grade performance.
研究动机与目标
- 展示微调如何影响不同模型规模(大与小)的 NL2SQL 性能
- 评估 CoT 微调是否提升小模型在推理能力上的 NL2SQL 结果
- 展示大模型与小模型在 NL2SQL 中的准确性、时延和成本的企业级权衡
提出的方法
- 通过执行对影子数据库运行生成的 SQL 来评估执行准确性(Execution Accuracy)
- Spider-1.0 数据集的难度查询聚焦的筛选与 curate
- 基于 JOIN、GROUP BY、ORDER BY、HAVING 和嵌套查询的 SQL 复杂度评分
- 通过模式描述和自纠错提示来降低幻觉生成的概率
- 微调对比:使用 LoRA 的 Large Gemini 2.5 家族与 Small Qwen-7B-Chat
- CoT 微调:构建包含逐步推理轨迹的数据集(查询分析、表选择、列选择、逻辑策略、自我验证)
实验结果
研究问题
- RQ1标准有监督微调(SFT)是否提升大模型(Gemini 2.5)或小模型(Qwen)的 NL2SQL 性能?
- RQ2CoT 微调是否能缩小小模型与大模型在 NL2SQL 的性能差距?
- RQ3面向困难查询的数据集筛选对不同模型规模的 NL2SQL 准确性有何影响?
- RQ4使用 CoT 调整的小模型在 NL2SQL 的企业化含义(成本、延迟)是什么?
主要发现
- 标准微调会降低大模型的 NL2SQL 性能,对某些小变体的提升也有限
- Qwen-7B 基线达到 36.17% 执行准确性,经过标准微调提升到 45.33%
- CoT 微调在 Qwen-7B 上实现 54.50% 的执行准确性,相较 SFT 有 18.33% 的绝对提升
- 在 Spider 数据集上,大规模 Gemini 2.5 模型在标准微调下收益微小甚至负向,且对困难查询出现过拟合
- CoT 调优缩小了小模型达到生产级性能的差距,实现更具成本效益的快速推断部署
- 研究凸显明确的分工:大模型更受益于提示/检索增强(RAG),小模型更能从基于 CoT 的微调中获益
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。