Learning When to Reason for Text-to-SQL via SFT and DPO

Learning When to Reason for Text-to-SQL via SFT and DPO

通过 SFT 和 DPO 学习何时进行 Text-to-SQL 推理

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. 近期的 Text-to-SQL 方法高度依赖以推理为中心的范式(如思维链 CoT),虽然在复杂基准测试中取得了显著提升,但同时也带来了高昂的推理时间开销。

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. 因此,我们提出了 AutoThinkSQL,这是一个将自动思考机制集成到 Text-to-SQL 的监督微调(SFT)和直接偏好优化(DPO)中的框架。

Our approach enables the model to dynamically bypass reasoning for simple queries while invoking deep CoT for complex queries. 我们的方法使模型能够针对简单查询动态跳过推理过程,同时针对复杂查询调用深度思维链(CoT)。

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. 在 Qwen3-Coder-30B-A3B 模型上,与 Spider 和 BIRD 基准测试中的最佳基线相比,我们的方法在取得持续性能提升的同时,平均输出 Token 分别减少了 24.6% 和 18.3%,平均延迟分别降低了 17.1% 和 11.5%(相较于仅使用 CoT 的生成方式)。

Further analysis indicates that the model learns to align its reasoning decisions with query difficulty. 进一步分析表明,该模型学会了根据查询难度来调整其推理决策。