LAURA: 通过上下文增强的检索增强大语言模型提升代码审查生成
LAURA: Enhancing Code Review Generation with Context-Enriched Retrieval-Augmented LLM
AI总结:
LAURA通过整合审查范例检索、上下文增强和系统引导,提升代码审查生成的准确性和质量。
摘要:
代码审查对于确保软件质量和可维护性至关重要。随着软件规模和复杂性的快速增长,代码审查已成为开发过程中的瓶颈,因为其耗时、知识密集且缺乏经验丰富的开发者愿意进行审查。已经提出了几种基于检索、神经机器翻译、预训练模型或大语言模型(LLMs)的自动代码审查生成方法。这些方法主要利用历史代码更改和审查评论。然而,大量对代码审查至关重要的信息,如代码更改的上下文和先前审查知识,已被忽视。本文提出了一种基于LLM的审查知识增强、上下文感知的代码审查生成框架,名为LAURA。该框架整合了审查范例检索、上下文增强和系统引导,以提高ChatGPT-4o和DeepSeek v3在生成代码审查评论方面的性能。此外,鉴于现有数据集中存在大量低质量审查,我们还构建了一个高质量的数据集。实验结果表明,对于两种模型,LAURA在42.2%和40.4%的情况下生成的审查评论要么完全正确,要么至少对开发者有帮助,显著优于SOTA基线。此外,我们的消融研究证明,LAURA的所有组件都对提高评论质量有积极贡献。
英文摘要:
Code review is critical for ensuring software quality and maintainability. With the rapid growth in software scale and complexity, code review has become a bottleneck in the development process because of its time-consuming and knowledge-intensive nature and the shortage of experienced developers willing to review code. Several approaches have been proposed for automatically generating code reviews based on retrieval, neural machine translation, pre-trained models, or large language models (LLMs). These approaches mainly leverage historical code changes and review comments. However, a large amount of crucial information for code review, such as the context of code changes and prior review knowledge, has been overlooked. This paper proposes an LLM-based review knowledge-augmented, context-aware framework for code review generation, named LAURA. The framework integrates review exemplar retrieval, context augmentation, and systematic guidance to enhance the performance of ChatGPT-4o and DeepSeek v3 in generating code review comments. Besides, given the extensive low-quality reviews in existing datasets, we also constructed a high-quality dataset. Experimental results show that for both models, LAURA generates review comments that are either completely correct or at least helpful to developers in 42.2% and 40.4% of cases, respectively, significantly outperforming SOTA baselines. Furthermore, our ablation studies demonstrate that all components of LAURA contribute positively to improving comment quality.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。