Text Classification
Transformers
ONNX
Safetensors
Transformers.js
modernbert
hate-speech
hate-speech-detection
content-moderation
trust-and-safety
multi-label-classification
mmbert
text-embeddings-inference
Instructions to use Horizon-Labs/multilingual-hate-speech-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Horizon-Labs/multilingual-hate-speech-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Horizon-Labs/multilingual-hate-speech-base")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Horizon-Labs/multilingual-hate-speech-base") model = AutoModelForSequenceClassification.from_pretrained("Horizon-Labs/multilingual-hate-speech-base", device_map="auto") - Transformers.js
How to use Horizon-Labs/multilingual-hate-speech-base with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-classification', 'Horizon-Labs/multilingual-hate-speech-base'); - Notebooks
- Google Colab
- Kaggle
Download code/hate/metrics.py from Horizon-Labs/multilingual-hate-speech-base: direct link, hf CLI and curl.
- Browser
- Download file 483 Bytes
-
https://huggingface.co/Horizon-Labs/multilingual-hate-speech-base/resolve/main/code/hate/metrics.py
- Command line
-
hf download hf://Horizon-Labs/multilingual-hate-speech-base/code/hate/metrics.py
-
curl -L -o metrics.py https://huggingface.co/Horizon-Labs/multilingual-hate-speech-base/resolve/main/code/hate/metrics.py
483 Bytes
| import numpy as np, pandas as pd | |
| def auc(y, s): | |
| y, s = np.asarray(y).astype(bool), np.asarray(s, float) | |
| if y.all() or not y.any(): | |
| return None | |
| r = pd.Series(s).rank().values; n1 = y.sum(); n0 = len(y) - n1 | |
| return float((r[y].sum() - n1 * (n1 + 1) / 2) / (n1 * n0)) | |
| def f1(y, p): | |
| y, p = np.asarray(y).astype(bool), np.asarray(p).astype(bool); tp = (y & p).sum() | |
| return 0.0 if tp == 0 else float(2 * tp / (2 * tp + (~y & p).sum() + (y & ~p).sum())) | |