arXiv:2607.26117cs.SEcs.AI2026-07被引 1

让小模型重试时别看错哪儿,反而比自己改更有效。

Try Again, Don't Look Back: Blind Resampling Outperforms Self-Repair in Small Code Models

  • 重试时不参考错误代码,直接盲重试效果更好
  • 看自己之前的错误会导致重试失败率升6.1分(1.5B模型)
  • 适合做代码生成的小模型,尤其关注成本与效率

自修复——将失败的程序和测试输出返回给模型以请求修正——是代码智能体的标准组件,但其评估常与完全不重试的基线对比。我们指出,这种对比混淆了反馈价值与额外尝试的价值。在MBPP+数据集上,对三个规模(1.5B、3B、7B)的模型进行对照实验,比较四种预算相同的重试策略:盲重采样、仅通知失败、真实执行反馈、以及附加自我反思的反馈。结果显示,在7B以下模型中,盲重采样表现最强,且在7B时与最佳条件无统计差异,但消耗的令牌量仅为后者的2.5-5.5倍;而基于自身失败尝试的条件在1.5B模型上导致性能下降6.1分(p=0.006),执行反馈的信息内容对结果无显著提升。我们归因于锚定效应:当看到前次尝试时,模型在33%-68%的重试中重复相同错误代码,而盲重采样仅2%-14%。进一步实验表明,其他任务的解决方案不影响结果(变动±3.5分),说明伤害源于自我条件而非上下文长度;唯一能减弱锚定的反思仍因成本过高被超越。复制实验排除两种解释:全精度下惩罚不变,且在另一模型族上重现。在六种配置中,锚定代价仅由基线质量决定(r=0.96),即锁定错误初稿本身就是代价。

原文摘要 · Abstract (English)

Self-repair - returning a failed program to the model together with its test output and asking for a correction - is a standard component of code agents, and is almost always evaluated against a baseline that does not retry at all. We argue that this comparison confounds the value of the feedback with the value of the extra attempt. Using a placebo-controlled design on MBPP+ at three model scales (1.5B, 3B, 7B), we compare four matched-budget retry conditions: blind resampling, a content-free failure notice, genuine execution feedback, and feedback augmented with verbal self-reflection. Blind resampling is the strongest condition below 7B, and remains statistically tied with the best condition at 7B, while consuming 2.5-5.5x fewer tokens; conditioning on the model's own failed attempt costs 6.1 points at 1.5B (p=0.006), and the informational content of execution feedback adds nothing measurable over the placebo. We attribute this to anchoring: when shown its previous attempt, a model reproduces a near-identical program in 33-68% of retries, against 2-14% under blind resampling. Two further experiments delimit the effect. Retrieved solutions to other tasks change nothing (bounded to +/-3.5 points), which localizes the harm to self-conditioning rather than context length; and reflection, the only condition that measurably weakens the anchor, remains dominated on cost. Replication rules out two competing explanations: the penalty is unchanged at full precision, and it reproduces on an independent model family. Across six configurations spanning two families and two precisions, its magnitude is predicted by baseline quality alone (r=0.96) - the cost of anchoring is the cost of committing to a bad first attempt.

代码生成模型推理重试机制

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。