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

在代码审查注释生成中利用审查者经验

Leveraging Reviewer Experience in Code Review Comment Generation

The University of Melbourne(墨尔本大学);Singapore Management University(新加坡管理学院);University of Waterloo(多伦多大学)

Hong Yi Lin, Patanamon Thongtanunam, Christoph Treude, Michael W. Godfrey, Chunhua Liu, Wachiraphan Charoenwet

AI总结:

本文提出经验感知损失函数(ELF),利用审查者的编写和审查经验作为权重,提升代码审查注释生成质量,相比SOTA模型在准确性、信息量和注释类型上表现更优。

摘要:

现代代码审查是一种无处不在的软件质量保证过程,旨在识别新编写代码中的潜在问题。尽管该过程有效,但它需要人工审查者投入大量精力。为了帮助减轻这一工作负荷,研究人员训练了深度学习模型来模仿人类审查者提供自然语言代码审查。正式地,这项任务被称为代码审查注释生成。先前的研究通过利用机器学习技术和神经模型(如迁移学习和transformer架构)改进了这项任务。然而,由于模型训练中使用的开源代码审查数据的质量问题,模型生成的审查质量仍然不理想。这部分是因为数据来自开源项目,这些项目的代码审查在公共论坛中进行,审查者拥有不同水平的软件开发经验,这可能会影响其反馈质量。为了适应这种差异,我们提出了一套经验感知的训练方法,利用审查者过去的编写和审查经验作为审查质量的信号。具体而言,我们提出了经验感知损失函数(ELF),该方法将审查者对项目的编写和审查所有权作为模型损失函数中的权重。通过这种方法,经验丰富的审查者的代码审查对模型行为产生更大的影响。与SOTA模型相比,ELF在准确性、信息量和生成的注释类型方面能够生成更高质量的审查。这项工作的关键贡献在于展示了如何将审查者经验等传统软件工程概念集成到基于AI的自动化代码审查模型的设计中。

英文摘要:

Modern code review is a ubiquitous software quality assurance process aimed at identifying potential issues within newly written code. Despite its effectiveness, the process demands large amounts of effort from the human reviewers involved. To help alleviate this workload, researchers have trained deep learning models to imitate human reviewers in providing natural language code reviews. Formally, this task is known as code review comment generation. Prior work has demonstrated improvements in this task by leveraging machine learning techniques and neural models, such as transfer learning and the transformer architecture. However, the quality of the model generated reviews remain sub-optimal due to the quality of the open-source code review data used in model training. This is in part due to the data obtained from open-source projects where code reviews are conducted in a public forum, and reviewers possess varying levels of software development experience, potentially affecting the quality of their feedback. To accommodate for this variation, we propose a suite of experience-aware training methods that utilise the reviewers' past authoring and reviewing experiences as signals for review quality. Specifically, we propose experience-aware loss functions (ELF), which use the reviewers' authoring and reviewing ownership of a project as weights in the model's loss function. Through this method, experienced reviewers' code reviews yield larger influence over the model's behaviour. Compared to the SOTA model, ELF was able to generate higher quality reviews in terms of accuracy, informativeness, and comment types generated. The key contribution of this work is the demonstration of how traditional software engineering concepts such as reviewer experience can be integrated into the design of AI-based automated code review models.

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

↑