Characterizing Overconfident Failure in LLM-Based Code Generation

📄 arXiv: 2610.11300v1 📥 PDF

作者: Ravishka Rathnasuriya, Wei Yang

分类: cs.SE, cs.AI

发布日期: 2026-10-08


💡 一句话要点

研究LLM代码生成中的过度自信失败问题

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大型语言模型 代码生成 过度自信 不确定性度量 执行正确性 软件开发工具

📋 核心要点

  1. 现有的代码生成验证方法如测试和程序分析存在不全面和高成本的问题,导致生成的代码可能在执行时失败。
  2. 论文提出通过分析模型的不确定性来识别代码生成中的过度自信现象,探索不确定性指标与执行正确性之间的关系。
  3. 研究发现,现有的不确定性信号提供的执行失败证据有限,且常见的缓解策略未能有效解决过度自信问题。

📝 摘要(中文)

大型语言模型(LLMs)在自动代码生成中越来越受到应用,但生成的程序在语法上看似合理,却常常无法通过执行正确性检查。现有的验证方法如测试和程序分析虽然重要,但往往不够全面、成本高昂或仅在生成后应用。因此,模型衍生的不确定性成为一种早期可靠性信号。本文研究了代码LLM中的过度自信现象,即错误程序的生成与正确程序在token级别的置信度相当。我们分析了四个开源代码模型和三个基于执行的基准,探讨现有不确定性指标是否能可靠地反映执行正确性,并对过度自信进行了全局和局部token级别的特征描述。最后,我们评估了常见的缓解策略是否能减少这一失败模式。研究结果表明,现有的不确定性信号仅提供部分证据,过度自信在程序和token级别均存在,且常见的缓解技术并未可靠解决过度自信失败问题。

🔬 方法详解

问题定义:本文旨在解决大型语言模型在代码生成中产生的过度自信现象,即错误程序与正确程序在置信度上难以区分的问题。现有方法在验证生成代码的正确性时,往往面临不全面和高成本的挑战。

核心思路:论文通过研究模型的不确定性,探讨其是否能作为执行正确性的可靠信号,进而识别和表征代码生成中的过度自信现象。

技术框架:研究首先分析现有的不确定性指标在执行正确性上的有效性,然后在全局和局部token级别上表征过度自信,最后评估常见的缓解策略的有效性。

关键创新:论文的主要创新在于系统性地分析了不确定性指标与执行正确性之间的关系,并揭示了过度自信在程序和token级别的普遍存在。

关键设计:研究中使用了多种不确定性度量方法,结合选择性生成和指令调优等技术,探索其对生成代码正确性的影响。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果显示,现有的不确定性信号仅能提供部分执行失败的证据,且在程序和token级别的过度自信现象普遍存在。常见的缓解策略未能有效解决过度自信失败问题,指令调优虽然提高了错误生成的置信度,但未能改善正确性区分能力。

🎯 应用场景

该研究的潜在应用领域包括自动代码生成、软件开发工具和智能编程助手等。通过提高代码生成的可靠性,能够减少开发者在代码审查和调试过程中的工作量,提升软件开发效率。此外,未来可能推动更智能的编程环境和工具的开发。

📄 摘要(原文)

Large language models (LLMs) are increasingly used for automated code generation, but generated programs can appear syntactically plausible while still failing execution-based correctness checks. Existing validation methods, such as testing and program analysis, remain essential but are often incomplete, costly, or applied only after generation. Model-derived uncertainty is therefore a natural early reliability signal. This paper studies the dilemma of overconfidence in code LLMs where incorrect programs are often generated with token-level confidence comparable to correct programs. We study this dilemma across four open-source code models and three execution-based benchmarks. Our analysis begins by investigating whether existing uncertainty metrics provide reliable proxies for execution correctness in code generation. We then characterize overconfidence at both global and local token levels, asking whether incorrect programs remain indistinguishable from correct ones under confidence and entropy summaries, including selective generation and the limits of instruction tuning. Finally, we evaluate whether common mitigation strategies reduce this failure mode. Our study yields four findings. First, existing uncertainty signals provide only partial and model-dependent evidence of execution failure. Second, overconfidence persists at both program and token levels, and uncertainty-based selection does not consistently improve accepted-set accuracy. Third, instruction tuning can increase certainty on failing generations without consistently improving correctness discrimination. Fourth, common mitigation techniques improve specific aspects of reliability but do not reliably resolve overconfident failure. Our exploratory latent analysis suggests that hidden representations may encode correctness-related signals that output confidence does not expose.