Hate Speech Detection
Collection
Models associated with the detection of hate speech in Twitter/social media. β’ 5 items β’ Updated β’ 2
How to use cardiffnlp/twitter-roberta-base-hate-multiclass-latest with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="cardiffnlp/twitter-roberta-base-hate-multiclass-latest") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-hate-multiclass-latest")
model = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-hate-multiclass-latest")This model is a fine-tuned version of cardiffnlp/twitter-roberta-base-2022-154m for multiclass hate-speech classification. A combination of 13 different hate-speech datasets in the English language were used to fine-tune the model.
{
"sexism": 0,
"racism": 1,
"disability": 2,
"sexual_orientation": 3,
"religion": 4,
"other": 5,
"not_hate":6
}
Install tweetnlp via pip.
pip install tweetnlp
Load the model in python.
import tweetnlp
model = tweetnlp.Classifier("cardiffnlp/twitter-roberta-base-hate-latest")
model.predict('Women are trash 2.')
>> {'label': 'sexism'}
model.predict('@user dear mongoloid respect sentiments & belief refrain totalitarianism. @user')
>> {'label': 'disability'}
@misc{antypas2023robust,
title={Robust Hate Speech Detection in Social Media: A Cross-Dataset Empirical Evaluation},
author={Dimosthenis Antypas and Jose Camacho-Collados},
year={2023},
eprint={2307.01680},
archivePrefix={arXiv},
primaryClass={cs.CL}
}