Saturday 15 March 2025
Code comments are a crucial part of any software development project, providing valuable insights into a developer’s intentions and understanding of their code. However, classifying these comments has long been a challenging task for machine learning models. A recent study has made significant strides in this area by developing novel approaches to address the imbalance problem that often plagues such classification tasks.
The research focuses on the Natural Language-based Software Engineering (NLBSE) challenge, which provides a dataset of code comments across three programming languages – Java, Python, and Pharo. The goal is to develop models that can accurately classify these comments based on their intended meaning. However, the problem lies in the imbalance of classes within the dataset, with some classes having significantly more instances than others.
To tackle this issue, the researchers employed four different pre-trained language models – RoBERTa, CodeBERT, UniXcoder, and a distilled version of RoBERTa – and fine-tuned them on the NLBSE dataset. They also experimented with various strategies to optimize the loss function weights, including inverse class frequency (ICF) and ranking-based frequency (RBF).
The results show that selecting the best model and combination of hyperparameters can significantly improve performance across all three programming languages. CodeBERT, a pre-trained model for programming and natural languages, emerged as the top performer in this study, indicating the benefit of pre-training on code-related datasets.
Interestingly, the researchers found that the type of loss function weights optimization strategy used can also impact performance. ICF and RBF strategies showed promising results, with RBF outperforming ICF in most cases. However, the FAMO (Fast Adaptive Multi-Task Optimization) approach did not yield the expected results, likely due to the limitations of the dataset.
The study’s findings have important implications for software development and maintenance. By developing more accurate models for classifying code comments, developers can gain a deeper understanding of their code and identify potential issues earlier on. This can lead to improved code quality, reduced debugging time, and enhanced overall productivity.
Furthermore, the research highlights the importance of addressing class imbalance in machine learning tasks. The use of strategies such as ICF and RBF can help mitigate this issue, allowing models to perform more accurately across all classes. As the field of software engineering continues to evolve, the development of novel approaches for tackling class imbalance will be crucial for achieving better results.
Cite this article: “Advances in Classifying Code Comments: A Study on Addressing Imbalance and Optimizing Loss Functions”, The Science Archive, 2025.
Machine Learning, Software Engineering, Code Comments, Classification, Natural Language Processing, Imbalance Problem, Pre-Trained Models, Fine-Tuning, Loss Function Weights, Programming Languages







