让大模型自动判断何时该推理,提升文本转SQL效率
Learning When to Reason for Text-to-SQL via SFT and DPO
- 在SFT和DPO中引入自动思考机制,动态决定是否进行多步推理
- 在Spider和BIRD上表现优于基线,输出词数减少24.6%~18.3%,延迟降低17.1%~11.5%
- 适合需要高效文本转SQL的工业场景,尤其对简单查询优化明显
近期文本转SQL方法依赖以推理为核心的范式(如思维链CoT),在复杂基准上取得显著提升,但推理开销高。然而,大量真实查询为简单查找或聚合,无需多步推理解答,强制推理造成浪费。为此,我们提出AutoThinkSQL框架,将自动思考机制集成至监督微调(SFT)与直接偏好优化(DPO)中。该方法使模型能动态跳过简单查询的推理,仅对复杂查询启用深度思维链。在Qwen3-Coder-30B-A3B模型上,相比最佳基线,在Spider与BIRD基准上均实现一致提升,同时平均输出词数减少24.6%和18.3%,平均延迟降低17.1%和11.5%。进一步分析表明,模型学会了根据查询难度合理决策推理行为。
原文摘要 · Abstract (English)
Recent Text-to-SQL methods rely heavily on reasoning-centric paradigms such as Chain-of-Thought (CoT), achieving substantial gains on complex benchmarks at the cost of high inference-time overhead. However, a large fraction of real-world queries are simple lookups or aggregations that can be resolved without multi-step deduction, making forced reasoning wasteful. Thus, we propose AutoThinkSQL, a framework that integrates an auto-thinking mechanism into both Supervised Fine-Tuning (SFT) and Direct Preference Optimization (DPO) on Text-to-SQL. Our approach enables the model to dynamically bypass reasoning for simple queries while invoking deep CoT for complex queries. On Qwen3-Coder-30B-A3B, our method achieves consistent gains compared to the best counterpart baseline on both Spider and BIRD benchmarks while simultaneously reducing average output tokens by 24.6% and 18.3%, and average latency by 17.1% and 11.5% compared to CoT-only generation. Further analysis indicates that the model learns to align its reasoning decisions with query difficulty.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。