LLMCup:基于大语言模型且增强排序的注释更新
LLMCup: Ranking-Enhanced Comment Updating with LLMs
AI总结:
提出LLMCup注释更新框架,利用多种提示策略生成候选注释并通过排序模型CupRank选出最佳结果,显著优于现有基线方法。
摘要:
尽管注释对于增强现代软件项目中的代码可读性和可维护性至关重要,但开发者往往倾向于更新代码而非注释,这会导致文档过时或不一致,从而阻碍未来的理解和维护。诸如CUP和HebCup等近期方法分别尝试使用神经序列到序列模型和启发式规则来进行自动注释更新。然而,这些方法在注释更新过程中可能会遗漏或误读关键信息,导致注释不准确,并且它们在复杂的更新场景中常常表现不佳。鉴于这些挑战,一个有前景的方向是利用大语言模型(LLMs),它们在注释生成、代码合成和程序修复等软件工程任务中展现出了令人瞩目的性能。这表明它们在捕捉代码修改背后的逻辑方面具有强大潜力,而这种能力对于注释更新任务至关重要。然而,为每个更新案例的LLM选择合适的提示策略仍然具有挑战性。为了解决这个问题,我们提出了一种新颖的注释更新框架LLMCup,它首先使用多种提示策略通过LLM提供多样化的候选更新注释,然后采用排序模型CupRank选择最佳候选作为最终更新的注释。实验结果证明了LLMCup的有效性,与最先进的基线(CUP和HebCup)相比,在准确率上提升了49.0%-116.9%,在BLEU-4上提升了10.8%-20%,在METEOR上提升了4.6%,在F1上提升了0.9%-1.9%,在SentenceBert相似度上提升了2.1%-3.4%。此外,一项用户研究表明,LLMCup更新的注释有时超越了人工编写的更新,突显了在注释质量评估中纳入人工评估的重要性。
英文摘要:
While comments are essential for enhancing code readability and maintainability in modern software projects, developers are often motivated to update code but not comments, leading to outdated or inconsistent documentation that hinders future understanding and maintenance. Recent approaches such as CUP and HebCup have attempted automatic comment updating using neural sequence-to-sequence models and heuristic rules, respectively. However, these methods can miss or misinterpret crucial information during comment updating, resulting in inaccurate comments, and they often struggle with complex update scenarios. Given these challenges, a promising direction lies in leveraging large language models (LLMs), which have shown impressive performance in software engineering tasks such as comment generation, code synthesis, and program repair. This suggests their strong potential to capture the logic behind code modifications - an ability that is crucial for the task of comment updating. Nevertheless, selecting an appropriate prompt strategy for an LLM on each update case remains challenging. To address this, we propose a novel comment updating framework, LLMCup, which first uses multiple prompt strategies to provide diverse candidate updated comments via an LLM, and then employs a ranking model, CupRank, to select the best candidate as final updated comment. Experimental results demonstrate the effectiveness of LLMCup, with improvements over state-of-the-art baselines (CUP and HebCup) by 49.0%-116.9% in Accuracy, 10.8%-20% in BLEU-4, 4.6% in METEOR, 0.9%-1.9% in F1, and 2.1%-3.4% in SentenceBert similarity. Furthermore, a user study shows that comments updated by LLMCup sometimes surpass human-written updates, highlighting the importance of incorporating human evaluation in comment quality assessment.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。