[Paper Review] LLaMA-Reviewer: Advancing Code Review Automation with Large Language Models through Parameter-Efficient Fine-Tuning
LLaMA-Reviewer introduces a parameter-efficient fine-tuning framework that leverages the LLaMA large language model for automated code review, achieving state-of-the-art performance on code review tasks with less than 1% of trainable parameters. Despite using only the 6.7B-parameter base model and limited fine-tuning epochs, it matches or exceeds existing code-review-specific models in review necessity prediction, comment generation, and code refinement.
The automation of code review activities, a long-standing pursuit in software engineering, has been primarily addressed by numerous domain-specific pre-trained models. Despite their success, these models frequently demand extensive resources for pre-training from scratch. In contrast, Large Language Models (LLMs) provide an intriguing alternative, given their remarkable capabilities when supplemented with domain-specific knowledge. However, their potential for automating code review tasks remains largely unexplored. In response to this research gap, we present LLaMA-Reviewer, an innovative framework that leverages the capabilities of LLaMA, a popular LLM, in the realm of code review. Mindful of resource constraints, this framework employs parameter-efficient fine-tuning (PEFT) methods, delivering high performance while using less than 1% of trainable parameters. An extensive evaluation of LLaMA-Reviewer is conducted on two diverse, publicly available datasets. Notably, even with the smallest LLaMA base model consisting of 6.7B parameters and a limited number of tuning epochs, LLaMA-Reviewer equals the performance of existing code-review-focused models. The ablation experiments provide insights into the influence of various fine-tuning process components, including input representation, instruction tuning, and different PEFT methods. To foster continuous progress in this field, the code and all PEFT-weight plugins have been made open-source.
Motivation & Objective
- To address the high resource cost of training domain-specific models for code review by leveraging pre-trained large language models (LLMs).
- To explore the feasibility and effectiveness of using unified LLMs like LLaMA for automated code review tasks.
- To reduce computational and storage overhead in code review automation through parameter-efficient fine-tuning (PEFT) techniques.
- To evaluate the impact of input representation, instruction tuning, and different PEFT methods on code review performance.
- To provide an open-source, privacy-preserving alternative to closed-source LLM APIs for software engineering workflows.
Proposed method
- Adopts a unified LLaMA-based model fine-tuned via parameter-efficient fine-tuning (PEFT) to minimize trainable parameters.
- Applies PEFT methods such as LoRA (Low-Rank Adaptation) to fine-tune the LLaMA model with less than 1% of the original parameters.
- Designs input representations aligned with the pre-training format of LLaMA to better leverage its in-context learning capabilities.
- Incorporates instruction tuning in a two-stage process to improve the model’s ability to process natural language instructions and generate contextually relevant outputs.
- Uses a plug-in model architecture to optimize storage and enable efficient deployment of fine-tuned weights.
- Employs a three-task pipeline: review necessity prediction, review comment generation, and code refinement, evaluated on two public datasets.
Experimental results
Research questions
- RQ1Can a unified large language model like LLaMA achieve competitive performance in code review automation tasks without task-specific pre-training?
- RQ2How effective is parameter-efficient fine-tuning (PEFT) in reducing computational and storage costs while maintaining high performance in code review tasks?
- RQ3What impact do input representation design and instruction tuning have on the performance of LLMs in code review?
- RQ4Which PEFT method (e.g., LoRA) yields the best trade-off between performance and parameter efficiency for code review tasks?
- RQ5To what extent can a small LLaMA base model (6.7B parameters) with limited fine-tuning epochs match or surpass larger, task-specific models?
Key findings
- LLaMA-Reviewer achieves state-of-the-art performance on code review tasks using only 6.7B parameters and less than 1% of trainable parameters via PEFT.
- The model matches or exceeds the performance of existing code-review-focused models despite minimal fine-tuning and low parameter updates.
- Aligning input representation with the pre-training format of LLaMA significantly improves model performance and capability utilization.
- Instruction tuning in a two-stage process enhances the model’s ability to process natural language inputs and generate accurate, context-aware outputs.
- LoRA with an appropriate rank is the most effective PEFT method for code review tasks with structured input and output formats.
- The plug-in model architecture reduces storage requirements and enables efficient deployment of fine-tuned weights in software engineering workflows.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.