arXivDaily arXiv每日学术速递 周一至周五更新
北美退伍军人节(Veterans Day),12 日无更新
arXiv 2611.06095cs.AIcs.SE
收藏

代码生成中的推理轨迹溢出:显式推理模型的实证研究

Reasoning-Trace Overflow in Code Generation: An Empirical Study of Explicit Reasoning Models

King’s College London(伦敦国王学院)

Lukas Twist, Helen Yannakoudakis, Jie M. Zhang

AI总结:

本研究针对小型开放权重推理模型,实证研究代码生成中的推理轨迹溢出问题,发现其在难任务及特定模型中常见,提出预算过渡等控制手段可缓解溢出并提升性能。

摘要:

显式推理可帮助语言模型生成代码,但也带来实际风险:模型可能在推理上消耗过多输出预算,导致无法生成可用代码。本研究针对规模相对较小的开放权重推理模型,将该行为定义为推理轨迹溢出。在7种模型和6种代码基准设置下,我们测量固定32k-token输出预算中用于推理的占比、该推理是否提升pass@1指标,以及轻量级推理时控制手段能否缓解溢出。结果显示,推理的价值具有高度条件性:在较简单的函数级任务中溢出罕见,但在更难的代码生成基准及特定模型家族中变得常见——在多组模型-基准配对中,超过半数的生成结果会耗尽全部32k-token预算且仍处于推理状态。多数完全溢出与重复推理循环相关,不过也存在无循环的长推理情况。因此,对易溢出模型而言,禁用推理可产生竞争力,因其能确保生成答案;同时,推理对更强模型在更难的算法及代码理解任务中仍具价值。最后,提示引导可大幅降低部分模型的溢出,但效果不稳定;而预算过渡提供更直接的控制,能提升易溢出模型的性能与token效率。这些发现表明,显式推理应被视为代码生成中可控制的资源,而非始终开启的能力。

英文摘要:

Explicit reasoning can help language models generate code, but it also introduces a practical risk: the model may spend so much of its output budget reasoning that it never produces usable code. We study this behaviour in relatively small open-weight reasoning models, framing it as reasoning-trace overflow. Across seven models and six code benchmark settings, we measure how much of a fixed 32k-token output budget is spent on reasoning, whether that reasoning improves pass@1, and whether lightweight inference-time controls can mitigate overflow. Our results show that the value of reasoning is highly conditional. Overflow is rare on simpler function-level tasks, but becomes common on harder code-generation benchmarks and for particular model families: on several model--benchmark pairs, more than half of generations exhaust the full 32k-token budget while still reasoning. Most complete overflow is associated with repetitive reasoning loops, although substantial long reasoning also occurs without looping. Disabling reasoning can therefore be competitive for overflow-prone models, simply because it ensures that an answer is produced. At the same time, reasoning remains valuable for stronger models on harder algorithmic and code-understanding tasks. Finally, prompt steering can substantially reduce overflow for some models but is inconsistent, while budgeted transitions provide more direct control and can improve both performance and token efficiency for overflow-prone models. These findings suggest that explicit reasoning should be treated as a controllable resource for code generation, rather than an always-on capability.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑