Using Transformer-based Pre-trained Language Model for Automated Evaluation of Comments to Aid Software Maintenance

Debjyoti Paul, Bitan Biswas, Rudrani PaulFire (working Notes) 2022

Introduction

Software maintenance is a critical phase of the software development lifecycle, often consuming more resources than initial development. High-quality code comments serve as essential documentation, improving readability and maintainability. However, many comments are "not useful"—either too brief, ambiguous, or merely decorative boilerplate—which adds noise and slows down developers. This paper explores the use of transformer-based models like BERT, GPT-2, and CodeBERT to automatically distinguish between useful and non-useful comments, achieving high accuracy and providing interpretability through Explainable AI (XAI) techniques.

Methodology

The researchers moved away from traditional manual feature engineering, such as keyword counting, in favor of Transfer Learning. They fine-tuned three prominent transformer architectures:

  1. BERT-Base: A bidirectional model trained on natural language, serving as a baseline.
  2. GPT-2: An autoregressive model trained on diverse web text, including technical content.
  3. CodeBERT: A bimodal model specifically pre-trained on both natural language (NL) and programming language (PL) simultaneously.

To understand the decision-making process of these models, the authors employed LIME (Local Interpretable Model-agnostic Explanations) and attention visualizations. These tools allow researchers to see which specific words in a comment or code snippet influence the model's classification.

Dataset and Class Characteristics

The study utilized data from the FIRE 2022 IRSE track, consisting of code-comment pairs. The dataset was relatively balanced, with approximately 53.9% Useful and 46.1% Not Useful examples. Analysis of the classes revealed distinct patterns: "Not Useful" comments were often characterized by structural symbols and boilerplate, while "Useful" comments contained semantic keywords and documentation tags like @param.

Common words and symbols found in Useful vs. Not Useful comment classes.

Key Results and Insights

The models demonstrated high efficacy in binary classification:

  • CodeBERT was the top performer with 91.21% accuracy, highlighting the importance of bimodal pre-training for understanding code context.
  • GPT-2 followed closely with 91.15% accuracy, proving that generative architectures are also robust classifiers in this domain.
  • BERT-Base achieved 84.16% accuracy, showing that while general language models are effective, domain-specific training provides a significant performance boost.

A key insight from the XAI analysis was the concept of Semantic Bridging. The models successfully identified "Useful" comments by linking descriptive terms in the text to specific code constructs. For example, the model might associate the word "allocation" in a comment with the presence of malloc in the source code.

LIME visualization showing how specific terms like 'allocation' and 'malloc' contribute to a 'Useful' classification.

Conclusion and Future Work

This research demonstrates that transformer-based models can effectively automate the evaluation of code comment quality, significantly outperforming traditional methods. By leveraging models like CodeBERT, developers can filter out documentation noise and focus on meaningful context. Future work aims to expand this evaluation to more programming languages like Java and Python and to move from evaluation toward the automated generation of high-quality comments.

Summary updated

BibTeX
@inproceedings{paul2022using,
  author = {Debjyoti Paul and Bitan Biswas and Rudrani Paul},
  title = {{Using Transformer-based Pre-trained Language Model for Automated Evaluation of Comments to Aid Software Maintenance}},
  booktitle = {Fire (working Notes)},
  year = {2022},
}
Figure