一句话:基于 CodeLLaMA 微调出 C4RLLaMA,统一实现代码注释不一致的检测与注释修复,多项指标超越已有方法。
注释与所注释代码片段一致时有助于代码理解,而代码注释不一致(CCI)会损害软件的开发、测试与维护。已有研究主要聚焦于不一致检测且性能参差,但仅检测并不解决问题,完整方案还需修改注释以完成修复,而此类工作十分稀少。本文提出 C4RLLaMA,一个在开源 CodeLLaMA 上微调得到的大语言模型,既能通过修正相关注释内容来修复不一致,又在检测任务上超越当前最优方法。作者在多个数据集上开展实验,结果显示 C4RLLaMA 稳定优于 post hoc 与 just-in-time 两类 CCI 检测方法,并在多项性能指标上大幅领先目前唯一已知的 CCI 修复方法。为进一步考察其修复效果,作者进行了人工评估:在 just-in-time 与 post hoc 设置下,C4RLLaMA 给出正确注释更新的比例分别为 65.0% 与 55.9%,表明其在实际使用中具有真实潜力。
Comments are widely used in source code. If a comment is consistent with the code snippet it intends to annotate, it would aid code comprehension. Otherwise, Code Comment Inconsistency (CCI) is not only detrimental to the understanding of code, but more importantly, it would negatively impact the development, testing, and maintenance of software. To tackle this issue, existing research has been primarily focused on detecting inconsistencies with varied performance. It is evident that detection alone does not solve the problem; it merely paves the way for solving it. A complete solution requires detecting inconsistencies and, more importantly, rectifying them by amending comments. However, this type of work is scarce. In this paper, we contribute C4RLLaMA, a fine-tuned large language model based on the open-source CodeLLaMA. It not only has the ability to rectify inconsistencies by correcting relevant comment content but also outperforms state-of-the-art approaches in detecting inconsistencies. Experiments with various datasets confirm that C4RLLaMA consistently surpasses both post hoc and just-in-time CCI detection approaches. More importantly, C4RLLaMA outperforms substantially the only known CCI rectification approach in terms of multiple performance metrics. To further examine C4RLLaMA's efficacy in rectifying inconsistencies, we conducted a manual evaluation, and the results showed that the percentage of correct comment updates by C4RLLaMA was 65.0% and 55.9% in just-in-time and post hoc, respectively, implying C4RLLaMA's real potential in practical use.
DOI 原文 ·
@inproceedings{paperbot8831,
title = {Code Comment Inconsistency Detection and Rectification Using a Large Language Model},
author = {Guoping Rong and Yongda Yu and Song Liu and Xin Tan and Tianyi Zhang and Haifeng Shen and Jidong Hu},
booktitle = {ICSE},
year = {2025},
doi = {10.1109/icse55347.2025.00035}
}