arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2601.23059cs.SEcs.AIcs.LG
收藏

关于代码注释对自动化修复bug的影响:一项实证研究

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

Politecnico di Torino, University of Molise(托里尼理工大学,莫利塞大学);University of Molise(莫利塞大学)

Antonio Vitale, Emanuela Guglielmi, Simone Scalabrino, Rocco Oliveto

AI总结:

本研究探讨了代码注释对LLM自动化修复bug的影响,发现注释能显著提升修复准确性,且训练时使用注释不影响性能。

摘要:

大型语言模型(LLMs)在软件工程研究和实践中变得越来越相关,自动化修复bug(ABF)是其关键应用之一。ABF涉及将有bug的方法转换为其修复等价物。在ABF中常见的预处理步骤包括在训练前从代码中移除注释。然而,我们假设注释可能在修复某些类型的bug时起关键作用,因为它们提供了有价值的设计和实现见解。在本研究中,我们调查了注释的存在或缺失(在训练和推理过程中)如何影响LLMs的bug修复能力。我们进行了一项实证评估,比较了两个模型家族,每个在所有训练和推理条件的组合下进行评估(有和无注释),从而重新审视训练过程中移除注释的常见做法。为了应对最先进数据集中注释有限的问题,我们使用LLM自动为缺少注释的方法生成注释。我们的发现显示,当注释在两个阶段都存在时,注释可将ABF准确性提高多达三倍,而当实例缺少注释时,使用注释训练不会降低性能。此外,可解释性分析表明,详细说明方法实现的注释在帮助LLM准确修复bug方面特别有效。

英文摘要:

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.

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

↑