蒸馏期望评论以增强大型语言模型的代码审查能力
Distilling Desired Comments for Enhanced Code Review with Large Language Models
AI总结:
本文提出Desiview数据集蒸馏方法,自动从代码审查数据中识别DRC,并结合KTO对齐微调LLaMA 3/3.1,显著提升LLM生成准确代码审查评论的能力。
摘要:
由于大型语言模型(LLM)在代码理解方面已被证明具备熟练能力,人们越来越关注将其用于代码审查。大多数审查场景的主要目标是生成期望的审查评论(DRC),即明确指出问题以触发代码修复的评论。然而,现有的基于LLM的解决方案在生成DRC方面并不十分有效,原因包括幻觉等。为了增强其代码审查能力,需要使用理想情况下充满DRC的定制数据集对其进行微调。尽管如此,这样的数据集目前尚不可得,而人工标注DRC又过于费力,缺乏实用性。本文提出了一种数据集蒸馏方法Desiview,它能够通过从代码审查数据集中识别DRC,自动构建一个蒸馏数据集。在包含超过150K条审查条目的CodeReviewer数据集上的实验表明,Desiview在Precision、Recall、Accuracy和F1方面分别取得了88.93%、80.37%、86.67%和84.44%的出色性能,超过了最先进的方法。为验证该蒸馏数据集在增强LLM代码审查能力方面的效果,我们首先对最新的LLaMA系列(即LLaMA 3和LLaMA 3.1)进行微调,构建模型Desiview4FT。随后,我们通过将那些被识别为非DRC的审查评论输入LLM,利用KTO对齐增强模型训练效果,得到模型Desiview4FA。验证结果表明,Desiview4FA略优于Desiview4FT,同时两个模型在生成DRC方面均相较基础模型有显著提升。人工评估确认,与基础LLM相比,这两个模型能更准确地识别问题,并且倾向于生成更能描述代码所含问题的审查评论。
英文摘要:
There has been a growing interest in using Large Language Models (LLMs) for code review thanks to their proven proficiency in code comprehension. The primary objective of most review scenarios is to generate desired review comments (DRCs) that explicitly identify issues to trigger code fixes. However, existing LLM-based solutions are not so effective in generating DRCs for various reasons such as hallucination. To enhance their code review ability, they need to be fine-tuned with a customized dataset that is ideally full of DRCs. Nevertheless, such a dataset is not yet available, while manual annotation of DRCs is too laborious to be practical. In this paper, we propose a dataset distillation method, Desiview, which can automatically construct a distilled dataset by identifying DRCs from a code review dataset. Experiments on the CodeReviewer dataset comprising more than 150K review entries show that Desiview achieves an impressive performance of 88.93%, 80.37%, 86.67%, and 84.44% in terms of Precision, Recall, Accuracy, and F1, respectively, surpassing state-of-the-art methods. To validate the effect of such a distilled dataset on enhancing LLMs' code review ability, we first fine-tune the latest LLaMA series (i.e., LLaMA 3 and LLaMA 3.1) to build model Desiview4FT. We then enhance the model training effect through KTO alignment by feeding those review comments identified as non-DRCs to the LLMs, resulting in model Desiview4FA. Verification results indicate that Desiview4FA slightly outperforms Desiview4FT, while both models have significantly improved against the base models in terms of generating DRCs. Human evaluation confirms that both models identify issues more accurately and tend to generate review comments that better describe the issues contained in the code than the base LLMs do.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。