Optimizing Deep Learning Models to Address Class Imbalance in Code Comment Classification

Developers rely on code comments to document their work, track issues, and understand the source code. As such, comments provide valuable insights into developers' understanding of their code and describe their various intentions in writing the surrounding code. Recent research leverages natural language processing and deep learning to classify comments based on developers' intentions. However, such labelled data are often imbalanced, causing learning models to perform poorly. This work investigates the use of different weighting strategies of the loss function to mitigate the scarcity of certain classes in the dataset. In particular, various RoBERTa-based transformer models are fine-tuned by means of a hyperparameter search to identify their optimal parameter configurations. Additionally, we fine-tuned the transformers with different weighting strategies for the loss function to address class imbalances. Our approach outperforms the STACC baseline by 8.9 per cent on the NLBSE'25 Tool Competition dataset in terms of the average F1c score, and exceeding the baseline approach in 17 out of 19 cases with a gain ranging from −5.0 to 38.2. The source code is publicly available at https://github.com/moritzmock/NLBSE2025.

Authors

Institutions

Publication Details

Published
2025-04-27
DOI
https://doi.org/10.1109/nlbse66842.2025.00016
Citations
3
Primary Topic
Natural Language Processing Techniques
Type
article
Field-Weighted Citation Impact
7.44
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Optimizing Deep Learning Models to Address Class Imbalance in Code Comment Classification

Giuseppe Di Fatta, Moritz Mock, Barbara Russo, Thomas Borsani
3 citations
Natural Language Processing Techniques
7.44
article

Optimizing Deep Learning Models to Address Class Imbalance in Code Comment Classification

Giuseppe Di Fatta, Moritz Mock, Barbara Russo, Thomas Borsani
article en
3 citations

Abstract

Developers rely on code comments to document their work, track issues, and understand the source code. As such, comments provide valuable insights into developers' understanding of their code and describe their various intentions in writing the surrounding code. Recent research leverages natural language processing and deep learning to classify comments based on developers' intentions. However, such labelled data are often imbalanced, causing learning models to perform poorly. This work investigates the use of different weighting strategies of the loss function to mitigate the scarcity of certain classes in the dataset. In particular, various RoBERTa-based transformer models are fine-tuned by means of a hyperparameter search to identify their optimal parameter configurations. Additionally, we fine-tuned the transformers with different weighting strategies for the loss function to address class imbalances. Our approach outperforms the STACC baseline by 8.9 per cent on the NLBSE'25 Tool Competition dataset in terms of the average F1c score, and exceeding the baseline approach in 17 out of 19 cases with a gain ranging from −5.0 to 38.2. The source code is publicly available at https://github.com/moritzmock/NLBSE2025.

Free University of Bozen-Bolzano (IT)
Openalex Percentile: Top 3%
Natural Language Processing Techniques
7.44
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.