用不确定性信号指导代码生成回滚,提升大模型生成质量。
Do Uncertainty Signals Help? A Systematic Study of Uncertainty-Aware Decoding with Rollback Mechanisms

- 基于不确定性信号识别低可信生成片段并回退,无需重新训练。
- 在多个基准上最高提升0.35的通过率,安全率提升6.4%。
- 信息熵等信号效果最佳,反馈引导回滚是核心增益来源。
预测不确定性是衡量模型置信度的常用指标,广泛应用于模型解释、数据筛选和预测回滚。尽管其价值已被验证,但不确定性量化在大型语言模型(LLMs)代码生成中的潜力仍鲜有研究。本文系统评估了不确定性感知回滚解码策略:在推理阶段利用不确定性信号识别不可靠生成区域,并回退到之前的合法前缀,无需重训模型。我们在七种代码类LLM、五个代码生成基准和八种逐标记不确定性信号下进行统一评估。结果表明,完整回滚框架在多数基准上优于同等预算重启策略,功能代码生成基准上pass@1最高提升0.26,AvgTestPassRate提升0.35,Dsec-Python上的Patch-Aligned Safe Rate绝对提升达6.4%。信息论指标如词元熵和负对数似然表现最优,常取得最佳或接近最佳结果。组件消融分析显示,反馈引导回滚是主要增益来源,而不确定性定位在固定检查、预算、回滚和分支衰减条件下仍带来额外提升。
原文摘要 · Abstract (English)
Prediction uncertainty is a widely adopted metric for quantifying model confidence, with downstream applications spanning model explanation, data selection, and prediction rollback. Despite its demonstrated utility, the potential of uncertainty quantification to enhance code generation in large language models (LLMs) remains largely underexplored, raising a critical question: to what extent can uncertainty serve as an effective signal for improving LLM-based code generation? To answer this question, we study uncertainty-aware rollback decoding, an inference-time strategy that uses uncertainty signals to identify unreliable generation regions and roll back to earlier valid prefixes without retraining the model. We evaluate this framework on seven code LLMs, five code generation benchmarks, and eight token-level uncertainty signals under a unified decoding setup. Our results show that the complete rollback framework improves over equal-budget restart across the evaluated benchmarks and model settings, with gains of up to 0.26 in pass@1 and 0.35 in AvgTestPassRate on functional code generation benchmarks, and an absolute improvement of up to 6.4\% in Patch-Aligned Safe Rate on Dsec-Python. Among the evaluated signals, information-theoretic measures such as token entropy and negative log-likelihood show the most favorable overall trend, frequently achieving the best or near-best results on standard benchmarks. A component-controlled ablation further shows that feedback-guided rollback provides the main improvement, while uncertainty localization provides an additional gain when checking, budget, rollback, and branch decay are held fixed.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。