Background: The existence of toxic conversations in open-source platforms can degrade relationships among software developers and may negatively impact software product quality. To help mitigate this, some initial work has been done to detect toxic comments in the Software Engineering (SE) domain. Aims: Since automatically classifying an entire text as toxic or non-toxic does not help human moderators to understand the specific reason(s) for toxicity, we worked to develop an explainable toxicity detector for the SE domain. Method: Our explainable toxicity detector can detect specific spans of toxic content from SE texts, which can help human moderators by automatically highlighting those spans. This toxic span detection model, ToxiSpanSE, is trained with the 19,651 code review (CR) comments with labeled toxic spans. Our annotators labeled the toxic spans within 3,757 toxic CR samples. We explored several types of models, including one lexicon-based approach and five different transformer-based encoders. Results: After an extensive evaluation of all models, we found that our fine-tuned RoBERTa model achieved the best score with 0.88 $F1$, 0.87 precision, and 0.93 recall for toxic class tokens, providing an explainable toxicity classifier for the SE domain. Conclusion: Since ToxiSpanSE is the first tool to detect toxic spans in the SE domain, this tool will pave a path to combat toxicity in the SE community.
翻译:背景:开源平台中存在毒性对话会破坏软件开发者之间的关系,并可能对软件产品质量产生负面影响。为缓解这一问题,软件工程领域已有初步工作用于检测毒性评论。目的:由于将整篇文本自动分类为有毒或无毒无法帮助人工审核员理解毒性的具体原因,我们致力于为软件工程领域开发一种可解释的毒性检测器。方法:我们的可解释毒性检测器能从软件工程文本中识别特定的毒性内容片段,通过自动高亮这些片段辅助人工审核员。该毒性片段检测模型ToxiSpanSE基于19,651条带有毒性片段标注的代码评审评论进行训练,其中3,757条有毒代码评审样本由标注员完成毒性片段标注。我们探索了多种模型类型,包括一种基于词典的方法和五种不同的基于Transformer的编码器。结果:在对所有模型进行广泛评估后,我们发现微调后的RoBERTa模型在毒性类别标记上取得了最佳成绩:F1值0.88、精确率0.87、召回率0.93,为软件工程领域提供了可解释的毒性分类器。结论:由于ToxiSpanSE是首个在软件工程领域检测毒性片段的工具,它将为对抗软件工程社区中的毒性问题铺平道路。