Views
No views yet
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.
1from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
2
3# Load the model
4model_name = "Samanehmoghaddam/AbuseBERT"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
8# Create a pipeline for text classification
9classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
10
11# Example texts to classify
12texts = [
13 "@user You are amazing!",
14 "@user You are stupid!",
15]
16
17# Run the classifier
18results = classifier(texts)
19
20# Print results
21for text, result in zip(texts, results):
22 print(f"Text: {text}")
23 print(f"Prediction: {result}")
24 print("-" * 40)