Skip to main content
QUICK REVIEW

[Paper Review] RepairLLaMA: Efficient Representations and Fine-Tuned Adapters for Program Repair

André Silva, Sen Fang|arXiv (Cornell University)|Dec 25, 2023
Software Testing and Debugging TechniquesComputer Science16 citations
TL;DR

RepairLLaMA presents a repair-adapter approach using code-specific representations and LoRA-based parameter-efficient fine-tuning to achieve state-of-the-art repair performance on Defects4J v2 and HumanEval-Java, including multi-location bugs.

ABSTRACT

Automated Program Repair (APR) has evolved significantly with the advent of Large Language Models (LLMs). Fine-tuning LLMs for program repair is a recent avenue of research, with many dimensions which have not been explored. Existing work mostly fine-tune LLMs with naive code representations and does not scale to frontier models. To address this problem, we propose RepairLLaMA, a novel program repair approach that 1) identifies optimal code representations for APR with fine-tuned models, and 2) pioneers state-of-the-art parameter-efficient fine-tuning technique (PEFT) for program repair. This results in RepairLLaMA producing a highly effective `program repair adapter' for fixing bugs with AI. Our experiments demonstrate the validity of both concepts. First, fine-tuning adapters with program repair specific code representations enables the model to use meaningful repair signals and produce better patches. Second, parameter-efficient fine-tuning helps fine-tuning to converge and clearly contributes to the effectiveness of RepairLLaMA in fixing bugs outside the fine-tuning data distribution. Overall, RepairLLaMA correctly fixes 144 Defects4J v2, 109 HumanEval-Java, and 20 GitBug-Java bugs, outperforming all baselines.

Motivation & Objective

  • Motivate improved automated program repair (APR) by leveraging domain-specific code representations.
  • Investigate how input/output representations with fault localization signals affect repair performance.
  • Evaluate parameter-efficient fine-tuning (LoRA) versus full fine-tuning in the APR context.
  • Demonstrate the effectiveness of a repair adapter plugged into a pre-trained LLM for Java bug fixing.

Proposed method

  • Select an open-source code-pretrained LLM (CodeLLaMA-7B) as the base model.
  • Design APR-specific input and output code representations that incorporate fault localization signals and original buggy code.
  • Train a repair adapter using LoRA to keep fine-tuning lightweight (approx. 4M parameters) while adapting the LLM for program repair.
  • Curate a fine-tuning dataset (Megadiff) and process it into multiple representation pairs with length constraints (≤1024 tokens).
  • Evaluate multiple representation pairs on Defects4J v2 and HumanEval-Java using plausible, AST-match, and exact-match metrics, plus BASelines (infilling prompt, full fine-tuning) for comparison.
Figure 1 . Overview of RepairLLaMA. The core novelties of RepairLLaMA are the APR specific code representations and the engineering of an effective program repair adapter that is plugged into the underlying LLM.
Figure 1 . Overview of RepairLLaMA. The core novelties of RepairLLaMA are the APR specific code representations and the engineering of an effective program repair adapter that is plugged into the underlying LLM.

Experimental results

Research questions

  • RQ1RQ1: What is the best code representation to fine-tune an LLM for program repair?
  • RQ2RQ2: How does parameter-efficient fine-tuning compare to full-parameter fine-tuning for program repair?
  • RQ3RQ3: How does RepairLLaMA compare against state-of-the-art ChatGPT-based APR?

Key findings

  • Code representations with fault localization signals significantly outperform naive representations.
  • Fine-tuning with repair-specific representations yields substantial gains over baseline (no fine-tuning) across Defects4J v2 and HumanEval-Java.
  • RepairLLaMA (IR4xOR2) achieves the best results, plausibly repairing 195 Defects4J v2 bugs and 118 HumanEval-Java bugs, with 125 AST matches and 124 exact matches on Defects4J v2.
  • Parameter-efficient fine-tuning with LoRA outperforms full fine-tuning in this APR setting (RepairLLaMA outperforms IR4xOR2 with full fine-tuning in several metrics).
  • Repair adapters with only ~4M parameters are 1600x smaller than the base CodeLLaMA-7B yet deliver state-of-the-art repair performance, surpassing GPT-4 in reported results.
Figure 2 . Buggy code of the multi-location bug Chart-5 represented in our four different input representations.
Figure 2 . Buggy code of the multi-location bug Chart-5 represented in our four different input representations.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.