Skip to main content

Toxic Spans Prediction

Project description



We provide state-of-the-art models to detect toxic spans in text. We have evaluated our models on Toxic Spanstask at SemEval 2021 (Task 5).


You first need to install PyTorch. The recommended PyTorch version is 1.6. Please refer to PyTorch installation page regarding the specific install command for your platform.

When PyTorch has been installed, you can install HateSpans from pip.

From pip

pip install hatespans

Pretrained HateSpans Models

We will be keep releasing new models. Please keep in touch.

Models Average F1
small 0.6652


Following code can be used to predict toxic spans in text. Upon executing, it will download the relevant model and return the toxic spans.

from import HateSpansApp

app = HateSpansApp("small", use_cuda=False)
print(app.predict_hate_spans("You motherfucking cunt", spans=True))

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for hate-spans, version 0.1.0b0
Filename, size File type Python version Upload date Hashes
Filename, size hate_spans-0.1.0b0-py3-none-any.whl (44.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size hate_spans-0.1.0b0.tar.gz (39.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page