arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2501.15854cs.SE
收藏

优化深度学习模型以解决代码注释分类中的类别不平衡问题

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

Moritz Mock, Thomas Borsani, Giuseppe Di Fatta, Barbara Russo

AI总结:

本文通过损失函数加权策略和超参数搜索微调 RoBERTa 模型,在 NLBSE'25 数据集上比 STACC 基线平均 F1c 提升 8.9 个百分点,有效缓解代码注释分类中的类别不平衡问题。

摘要:

开发者依赖代码注释来记录工作、跟踪问题并理解源代码。因此,注释为开发者对代码的理解以及他们在编写周围代码时的各种意图提供了有价值的见解。最近的研究利用自然语言处理和深度学习根据开发者的意图对注释进行分类。然而,这类标注数据往往存在类别不平衡,导致学习模型表现不佳。本研究探讨了使用不同的损失函数加权策略来缓解数据集中某些类别样本稀缺的问题。具体而言,我们通过超参数搜索对各种基于 RoBERTa 的 Transformer 模型进行微调,以确定其最优参数配置。此外,我们还使用不同的损失函数加权策略对 Transformer 进行微调,以解决类别不平衡问题。在 NLBSE'25 工具竞赛数据集上,我们的方法在平均 F1$_c$ 分数方面比 STACC 基线高出 8.9 个百分点,并且在 19 个案例中有 17 个案例超过了基线方法,增益范围从 -5.0 到 38.2。源代码已公开,地址为 https://github.com/moritzmock/NLBSE2025。

英文摘要:

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 F1$_c$ 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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑