Papers
Topics
Authors
Recent
Search
2000 character limit reached

Real-Time Toxicity Filtering for Open-Source Code Reviews

Published 10 Apr 2026 in cs.SE | (2604.08886v1)

Abstract: Toxic interactions in open-source software development harm community collaboration. To combat this, we propose ToxiShield, a realtime browser extension that identifies and detoxifies toxic code reviews. The framework comprises three modules: toxicity identification, reasoned multiclass classification, and code review detoxification. Our fine-tuned BERT-based binary classifier achieved a 97% F1-score on 38,761 code review texts. For multiclass classification, Claude 3.5 Sonnet with prompt engineering achieved a 39% MCC and 42% F1 on 1,200 samples. Finally, our fine-tuned Llama 3.2 detoxification model reached 95.27% style transfer accuracy, 97.03% fluency, 67.07% content preservation, and an 84% J-score. Validation with 10 software developers suggests ToxiShield effectively fosters a more inclusive open-source environment.

Summary

  • The paper introduces ToxiShield, a real-time system integrating a BERT classifier, LLM-based multi-label classification, and text style transfer to mitigate toxic comments.
  • The methodology achieves a 97% F1-score for toxicity detection, employs prompt-engineered LLMs for nuanced classification, and uses Llama 3.2 3B for high-accuracy detoxification.
  • User studies with developers validate ToxiShield’s practical benefits in reducing toxic communication and enhancing code review quality.

Real-Time Toxicity Filtering for Open-Source Code Reviews: An Expert Analysis

Introduction

The paper "Real-Time Toxicity Filtering for Open-Source Code Reviews" (2604.08886) introduces ToxiShield, a modular system designed to proactively detect and mitigate toxic communication in open-source software development environments. Recognizing the detrimental effects of toxic interactions—including decreased productivity, newcomer attrition, and lowered code quality—the authors present a browser-integrated framework for real-time detection, categorization, and detoxification of toxic code review comments. This work situates itself within growing concerns regarding communication health in OSS communities, extending prior efforts by providing explainability, actionable feedback, and seamless integration into developers' workflows.

System Architecture and Methodology

ToxiShield comprises three interconnected modules:

1. Toxicity Filter: This module employs a fine-tuned BERT-based binary classifier, trained on a newly curated dataset annotated from over 38,000 code review texts (10,120 toxic and 28,641 non-toxic). The model achieves an F1-score of 0.97 for the toxic class, with precision and recall values of 0.98 and 0.96, respectively. The authors' error analysis identifies persistent challenges, such as accurate interpretation of domain-specific jargon, sarcastic language, and the detection of passive-aggressive or indirect toxicity.

2. Communication Coach: Upon toxicity detection, this module performs multi-class, multi-label categorization according to an established OSS toxicity taxonomy. Owing to limited annotated data, prompt-engineered LLMs (notably Claude 3.5 Sonnet) are used for classification, reaching a Macro-F1 of 0.42 and Macro-MCC of 0.39. The iterative prompt refinement strategy, leveraging in-context learning, is essential for aligning the LLMs' output with the nuanced classification task. Notably, certain subcategories—especially those with subtler or less frequent manifestations—remain more challenging to classify reliably, as reflected in both quantitative results and inter-rater reliability (κ=0.66\kappa = 0.66).

3. Reframer: Detoxification is framed as a text style transfer (TST) problem, transforming toxic reviewer comments into professional yet semantically faithful rewrites. Using a parallel corpus synthesized via prompt-based rewriting by SoTA LLMs, the top-performing student model, Llama 3.2 3B, reaches a J-score of 84%, with 95.27% style transfer accuracy, 97.03% fluency, and 67.07% content preservation. Manual analysis uncovers failure points, particularly with technically dense comments and certain false positives, illustrating the boundary of automated detoxification in domain-specific language.

Empirical and User Evaluation

An integrated browser extension operationalizes ToxiShield, enabling seamless real-time deployment within developers' existing code review interfaces. A user study with 10 professional developers, guided by the Technology Acceptance Model, demonstrates acceptance regarding ease of use and perceived benefit. Nevertheless, identified limitations point to the importance of further refinements in task efficiency and reduction of false positive interventions.

Numerical Results and Claims

  • The binary toxicity classifier, leveraging fine-tuned BERT, achieves a 97% F1-score on the toxic class, marking a high degree of discriminative capability on the curated dataset.
  • The multiclass communication coach achieves a Macro-F1 of 0.42 and Macro-MCC of 0.39 on a balanced dataset of 1,200 comments, with substantial agreement among manual raters.
  • The detoxification model, Llama 3.2 3B, produces 95.27% style transfer accuracy, 97.03% fluency, 67.07% content preservation, and a J-score of 84%, indicating strong performance in balancing style transfer, fluency, and preservation of technical content.

Theoretical and Practical Implications

ToxiShield introduces a methodological advance in real-time, explainable toxicity mitigation within OSS platforms. By integrating multi-stage LLM-based analysis and rewrites, the framework demonstrates the utility of prompt engineering, in-context learning, and fine-tuning on domain-specific constructs. The primary practical implication is the reduction of toxic communication in code reviews, with early indications of positive reception and usability from practitioners.

Theoretically, the work highlights several persistent challenges for NLP in software engineering contexts:

  • Label Scarcity and Class Imbalance: Fine-grained toxicity classification remains constrained by limited annotated data and subtle semantic boundaries between classes.
  • Contextual and Technical Semantics: Both toxicity detection and detoxification models exhibit limitations in handling code-switching, sarcasm, and technical ambiguity.
  • Explainability: By providing explanations for toxicity, ToxiShield advances the interpretability of moderation systems, a critical requirement for wider developer acceptance.

Future Research Directions

Building upon the framework's modularity and empirical validation, several promising research trajectories emerge:

  • Expansion of Parallel Detoxification Corpora: Construction and release of larger, community-validated datasets to further improve model generalization and robustness.
  • Continual Learning and Feedback Adaptation: Incorporating user feedback for active learning, model refinement, and error correction in dynamic OSS environments.
  • Domain Adaptation and Transfer: Extending the approach to other communication domains within SE, such as issue tracking and mailing list discussions, or to adjacent domains with similarly technical discourse.
  • Enhanced Explainability: Leveraging neuro-symbolic approaches for more granular, actionable reasoning behind toxicity classifications.

Conclusion

ToxiShield constitutes a comprehensive, real-time solution to the pressing issue of toxic communication in open-source code reviews. Its integration of transformer-based binary classifiers, LLM-driven multi-class explanations, and advanced text style transfer yields strong empirical results and practical viability. The release of code, annotated data, and the browser extension serves the dual purpose of replicability and community adoption. This work sets the stage for continued advancement in explainable, proactive moderation tools tailored to the distinctive linguistic landscape of software engineering communication.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.