Skip to main content
QUICK REVIEW

[Paper Review] APPT: Boosting Automated Patch Correctness Prediction via Fine-tuning Pre-trained Models

Quanjun Zhang, Chunrong Fang|arXiv (Cornell University)|Jan 29, 2023
Machine Learning in HealthcareComputer Science5 citations
TL;DR

APPT proposes a fine-tuned pre-trained model approach for automated patch correctness prediction in program repair, combining BERT as an encoder with an LSTM and classifier to improve generalization. It achieves 79.7% accuracy and 83.2% recall on Defects4J patches, outperforming SOTA by 4.3% and 6.7% respectively, and exceeds 99% in five metrics on real-world patches.

ABSTRACT

Automated program repair (APR) aims to fix software bugs automatically without human debugging efforts and plays a crucial role in software development and maintenance. Despite promising, APR is still challenged by a long-standing overfitting problem (i.e., the generated patch is plausible but overfitting). Various techniques have thus been proposed to address the overfitting problem. Recently, researchers have employed BERT to extract code features, which are then used to train a classifier for patch correctness prediction. However, BERT is restricted to feature extraction for classifier training without benefiting from the training process, potentially generating sub-optimal vector representations for patched code snippets. In this paper, we propose APPT, a pre-trained model-based automated patch correctness assessment technique by both pre-training and fine-tuning. APPT adopts a pre-trained model as the encoder stack, followed by an LSTM stack and a deep learning classifier. More importantly, the pre-trained model is fine-tuned in conjunction with other components as a whole pipeline to fully adapt it specifically for reasoning about patch correctness. We conduct an extensive experiment on 1,183 Defects4J patches and the experimental results show that APPT achieves prediction accuracy of 79.7% and recall of 83.2%, outperforming CACHE by 4.3% and 6.7%. Our additional investigation on 49,694 real-world patches shows that APPT achieves the optimum performance compared with existing representation learning techniques. We further investigate the impact of each component and find that they all positively contribute to APPT, e.g., the fine-tuning process and the LSTM stack increase F1-score by 10.22% and 4.11%, respectively. We also prove that adopting advanced pre-trained models can further provide substantial advancement, highlighting the generalizability of APPT.

Motivation & Objective

  • Address the overfitting problem in automated program repair (APR), where patches pass test cases but fail on unseen ones.
  • Overcome limitations of static and dynamic patch correctness assessment techniques, which suffer from low precision or high computational cost.
  • Leverage pre-trained models to learn better code representations for patch correctness prediction, improving generalization beyond hand-crafted features.
  • Explore the effectiveness of fine-tuning pre-trained models end-to-end for patch correctness prediction, rather than using them only for feature extraction.
  • Demonstrate the generalizability of the approach across different pre-trained models, including BERT, CodeBERT, and GraphCodeBERT.

Proposed method

  • Use a pre-trained BERT model as the encoder stack to extract contextual representations from buggy and patched code snippets.
  • Integrate an LSTM layer after the encoder to model sequential dependencies between code changes and their context.
  • Feed the LSTM output into a deep learning classifier with two fully connected layers and a softmax activation for binary classification of patch correctness.
  • Fine-tune the entire pipeline—encoder, LSTM, and classifier—end-to-end to adapt the model specifically to patch correctness reasoning.
  • Evaluate the model on both synthetic (Defects4J) and real-world (49,694 patches) datasets to assess robustness and scalability.
  • Compare APPT with existing techniques, including CACHE and hand-crafted feature methods, using standard metrics like precision, recall, F1, and AUC.
Figure 1: Overview of APR
Figure 1: Overview of APR

Experimental results

Research questions

  • RQ1Can end-to-end fine-tuning of a pre-trained model improve patch correctness prediction accuracy compared to feature extraction-only approaches?
  • RQ2How does the integration of an LSTM layer affect the model’s ability to capture dependencies in code changes?
  • RQ3Does APPT generalize across different pre-trained models, such as CodeBERT and GraphCodeBERT, and do they outperform BERT-based APPT?
  • RQ4How does APPT perform on real-world patches compared to existing state-of-the-art techniques?
  • RQ5What is the contribution of each component (e.g., fine-tuning, LSTM) to the overall performance improvement?

Key findings

  • APPT achieves 79.7% accuracy and 83.2% recall on 1,183 Defects4J patches, outperforming the SOTA technique CACHE by 4.3 percentage points in accuracy and 6.7 percentage points in recall.
  • On 49,694 real-world patches, APPT exceeds 99% in five standard evaluation metrics, demonstrating strong generalization and robustness.
  • The fine-tuning process alone increases the F1-score by 10.22%, showing its critical role in adapting the model to the patch correctness task.
  • The LSTM component contributes 4.11% to the F1-score improvement, highlighting its value in modeling sequential dependencies in code changes.
  • Using GraphCodeBERT instead of BERT in APPT improves precision by 2.8% and AUC by 3.3%, confirming the benefit of advanced pre-trained models.
  • Ablation studies confirm that all components—encoder, LSTM, and classifier—positively contribute to performance, validating the design choices.
Figure 2: Overview of APPT
Figure 2: Overview of APPT

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.