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
File size: 483 Bytes
c1e5dc4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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()))
|