On the Impact of Code Comments for Automated Bug-Fixing: An Empirical Study

📄 arXiv: 2601.23059v1 📥 PDF

作者: Antonio Vitale, Emanuela Guglielmi, Simone Scalabrino, Rocco Oliveto

分类: cs.SE, cs.AI, cs.LG

发布日期: 2026-01-30

备注: Accepted at the 34th IEEE/ACM International Conference on Program Comprehension (ICPC 2026)


💡 一句话要点

探讨代码注释对自动化修复bug的影响

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

关键词: 自动化修复 代码注释 大型语言模型 软件工程 机器学习

📋 核心要点

  1. 现有的自动化修复bug方法通常在训练前移除代码注释,可能导致信息损失。
  2. 本研究提出在训练和推理阶段保留代码注释,以提高LLMs的bug修复能力。
  3. 实验结果表明,注释的存在使ABF准确性提高了三倍,且训练时使用注释不会降低性能。

📝 摘要(中文)

大型语言模型(LLMs)在软件工程研究和实践中日益重要,自动化修复bug(ABF)是其关键应用之一。ABF涉及将有缺陷的方法转换为修复后的等价方法。通常,ABF的预处理步骤会在训练前移除代码中的注释。然而,我们假设注释在修复某些类型的bug时可能发挥关键作用,因为它们提供了有价值的设计和实现见解。本研究调查了注释的存在或缺失在训练和推理阶段对LLMs修复bug能力的影响。我们进行了实证评估,比较了两种模型家族在不同训练和推理条件下的表现,重新审视了在训练中移除注释的常见做法。研究发现,当注释在两个阶段均存在时,ABF的准确性提高了三倍,而在缺少注释的实例中,使用注释进行训练并未降低性能。此外,解释性分析表明,详细描述方法实现的注释在帮助LLMs准确修复bug方面尤其有效。

🔬 方法详解

问题定义:本论文旨在解决在自动化修复bug过程中,代码注释被移除所带来的信息损失问题。现有方法在训练前去除注释,可能导致模型在修复bug时缺乏必要的上下文信息。

核心思路:论文的核心思路是探讨代码注释在训练和推理阶段对LLMs修复bug能力的影响,假设注释能够提供设计和实现的有价值见解,从而提高修复准确性。

技术框架:研究采用了两种模型家族进行比较,评估在不同训练和推理条件下(有无注释)的表现。为了弥补现有数据集中注释的不足,使用LLM自动生成缺失的注释。

关键创新:本研究的创新点在于重新审视了在训练过程中移除注释的常见做法,发现注释在修复特定类型bug时的有效性,尤其是详细描述实现的注释。

关键设计:在实验中,模型训练时使用了生成的注释,并评估了不同条件下的性能。关键参数设置包括注释的生成策略和模型的训练配置,确保在缺少注释的情况下仍能保持性能。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果显示,当注释在训练和推理阶段均存在时,自动化修复bug的准确性提高了三倍。此外,训练时使用注释并未降低在缺少注释实例上的性能,表明注释的有效性。解释性分析进一步指出,详细的实现注释对提高修复准确性尤为重要。

🎯 应用场景

该研究的潜在应用领域包括软件开发、维护和质量保证等。通过提高自动化修复bug的准确性,能够显著降低开发成本和时间,提高软件的可靠性和用户满意度。未来,随着LLMs的进一步发展,注释的有效利用可能会成为软件工程领域的重要研究方向。

📄 摘要(原文)

Large Language Models (LLMs) are increasingly relevant in Software Engineering research and practice, with Automated Bug Fixing (ABF) being one of their key applications. ABF involves transforming a buggy method into its fixed equivalent. A common preprocessing step in ABF involves removing comments from code prior to training. However, we hypothesize that comments may play a critical role in fixing certain types of bugs by providing valuable design and implementation insights. In this study, we investigate how the presence or absence of comments, both during training and at inference time, impacts the bug-fixing capabilities of LLMs. We conduct an empirical evaluation comparing two model families, each evaluated under all combinations of training and inference conditions (with and without comments), and thereby revisiting the common practice of removing comments during training. To address the limited availability of comments in state-of-the-art datasets, we use an LLM to automatically generate comments for methods lacking them. Our findings show that comments improve ABF accuracy by up to threefold when present in both phases, while training with comments does not degrade performance when instances lack them. Additionally, an interpretability analysis identifies that comments detailing method implementation are particularly effective in aiding LLMs to fix bugs accurately.