File size: 3,120 Bytes
41974cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0ced76a
41974cd
0ced76a
41974cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0ced76a
 
 
 
 
 
 
41974cd
 
 
 
 
 
 
 
 
 
0ced76a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
language: en
tags:
- text-classification
- abusive-language
- hate-speech
- toxicity
- cyberviolence
- abusive-language-detection
- BERT
license: mit
---

# AbuseBERT

## Model Description

**AbuseBERT** is a **BERT-based classification model** fine-tuned for **abusive language detection**, optimized for **cross-dataset generalization**.

> Abusive language detection models often suffer from poor generalization due to **sampling and lexical biases** in individual datasets. Our approach addresses this by integrating **publicly available abusive language datasets**, harmonizing labels and preprocessing textual samples to create a **broader and more representative training distribution**.

**Key Findings using 10 datasets:**
- Individual dataset models: average F1 = **0.60**  
- Integrated model: F1 = **0.84**  
- Dataset contribution to performance improvements correlates with **lexical diversity (0.71 correlation)**  
- Integration exposes models to diverse abuse patterns, enhancing **real-world generalization**

---

## Conclusion / Takeaways

- No single dataset captures the full spectrum of abusive language; each dataset reflects a **limited slice** of the problem space.  
- Systematically integrating ten heterogeneous datasets significantly improves classification performance on a **held-out benchmark**.  
- Lexically dissimilar datasets contribute more to **enhancing generalization**.  
- The integrated model demonstrates superior **cross-dataset performance** compared to models trained on individual datasets.

---

## Paper Reference

Samaneh Hosseini Moghaddam, Kelly Lyons, Frank Rudzicz, Cheryl Regehr, Vivek Goel, Kaitlyn Regehr,  
“**Enhancing machine learning in abusive language detection with dataset aggregation**,” in *Proc. 35th IEEE Int. Conf. Collaborative Advances in Software Computing (CASC)*, 2025.

---

## Intended Use

**Recommended:**
- Detecting abusive, offensive, or toxic language in text from social media, online forums, or messaging platforms.

- Supporting research on online harassment, cyber violence, and hate speech analysis.

- Assisting human moderators in content review or flagging potentially harmful content.

- Evaluating trends, prevalence, or patterns of abusive language in large-scale textual datasets.

**Not Recommended:**
- Fully automated moderation without human oversight
- High-stakes legal or policy decisions

---

## Usage Example

```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline

# Load the model
model_name = "Samanehmoghaddam/AbuseBERT"  
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)

# Create a pipeline for text classification
classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)

# Example texts to classify
texts = [
    "@user You are amazing!",
    "@user You are stupid!",
]

# Run the classifier
results = classifier(texts)

# Print results
for text, result in zip(texts, results):
    print(f"Text: {text}")
    print(f"Prediction: {result}")
    print("-" * 40)