Skip to main content
QUICK REVIEW

[Paper Review] Evaluating Representation Learning of Code Changes for Predicting Patch Correctness in Program Repair

Haoye Tian, Kui Liu|arXiv (Cornell University)|Aug 7, 2020
Software Engineering ResearchComputer Science65 references6 citations
TL;DR

This paper evaluates distributed representation learning techniques—specifically BERT, Doc2Vec, code2vec, and CC2Vec—for predicting patch correctness in automated program repair. By training a logistic regression classifier on BERT-based code change embeddings, the approach achieves an AUC of 0.8 on a deduplicated dataset of 1,000 labeled patches, demonstrating that learned embeddings can effectively identify incorrect patches and outperform dynamic analysis-based methods like PATCH-SIM.

ABSTRACT

A large body of the literature of automated program repair develops approaches where patches are generated to be validated against an oracle (e.g., a test suite). Because such an oracle can be imperfect, the generated patches, although validated by the oracle, may actually be incorrect. While the state of the art explore research directions that require dynamic information or rely on manually-crafted heuristics, we study the benefit of learning code representations to learn deep features that may encode the properties of patch correctness. Our work mainly investigates different representation learning approaches for code changes to derive embeddings that are amenable to similarity computations. We report on findings based on embeddings produced by pre-trained and re-trained neural networks. Experimental results demonstrate the potential of embeddings to empower learning algorithms in reasoning about patch correctness: a machine learning predictor with BERT transformer-based embeddings associated with logistic regression yielded an AUC value of about 0.8 in predicting patch correctness on a deduplicated dataset of 1000 labeled patches. Our study shows that learned representations can lead to reasonable performance when comparing against the state-of-the-art, PATCH-SIM, which relies on dynamic information. These representations may further be complementary to features that were carefully (manually) engineered in the literature.

Motivation & Objective

  • To investigate whether learned code representations can improve the prediction of patch correctness in automated program repair.
  • To evaluate the effectiveness of pre-trained and retrained neural networks in generating embeddings that capture semantic and syntactic differences between buggy and patched code.
  • To compare the performance of representation learning-based methods against state-of-the-art approaches relying on dynamic execution traces.
  • To assess the complementarity of learned embeddings with manually engineered static features such as those in ODS.
  • To provide empirical guidance for integrating representation learning into APR pipelines for filtering incorrect patches.

Proposed method

  • Employed multiple representation learning models—BERT, Doc2Vec, code2vec, and CC2Vec—on code change fragments (buggy and patched code) to generate dense vector embeddings.
  • Used cosine similarity between buggy and patched code embeddings to compute similarity scores for filtering incorrect patches.
  • Trained supervised machine learning classifiers (Logistic Regression, DecisionTree, Naive Bayes) on the learned embeddings to predict patch correctness.
  • Retrained BERT and other models on the APR dataset to improve domain-specific representation quality.
  • Applied a deduplication process to the dataset of 1,000 labeled patches to ensure evaluation robustness.
  • Combined learned embeddings with hand-crafted static features (e.g., ODS features) to assess complementarity in prediction performance.

Experimental results

Research questions

  • RQ1Can pre-trained and fine-tuned neural network models generate code change embeddings that effectively distinguish correct from incorrect patches?
  • RQ2How do different representation learning models (e.g., BERT, Doc2Vec, code2vec, CC2Vec) compare in their ability to capture patch correctness signals?
  • RQ3To what extent can learned embeddings filter out incorrect patches using similarity thresholds based on cosine similarity?
  • RQ4How does the performance of a machine learning predictor using learned embeddings compare to state-of-the-art methods like PATCH-SIM that rely on dynamic execution traces?
  • RQ5Can learned embeddings be effectively combined with manually engineered static features to improve patch correctness prediction?

Key findings

  • The BERT-based embedding model, when used with logistic regression, achieved an AUC of 0.8 on a deduplicated dataset of 1,000 labeled patches, indicating strong predictive power for patch correctness.
  • Cosine similarity scores derived from learned embeddings filtered out between 31.5% and 94.9% of incorrect patches, depending on the similarity threshold used.
  • The performance of the logistic regression model with BERT embeddings (F-measure: 0.72, AUC: 0.8) outperformed the state-of-the-art dynamic analysis-based method PATCH-SIM in the same evaluation setting.
  • Learned embeddings demonstrated complementary value when combined with hand-crafted static features such as those from ODS, suggesting potential for hybrid prediction approaches.
  • Fine-tuning pre-trained models like BERT on APR-specific data improved the discriminative quality of the learned embeddings compared to using them in a frozen, pre-trained state.
  • Among the evaluated models, BERT and CC2Vec produced the most effective embeddings for correctness prediction, while Doc2Vec and code2vec showed lower performance on this specific task.

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.