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/build_pool.py from Horizon-Labs/multilingual-hate-speech-base: direct link, hf CLI and curl.
- Browser
- Download file 975 Bytes
-
https://huggingface.co/Horizon-Labs/multilingual-hate-speech-base/resolve/main/code/hate/build_pool.py
- Command line
-
hf download hf://Horizon-Labs/multilingual-hate-speech-base/code/hate/build_pool.py
-
curl -L -o build_pool.py https://huggingface.co/Horizon-Labs/multilingual-hate-speech-base/resolve/main/code/hate/build_pool.py
975 Bytes
| """Real-comment pool for hate-speech training: Civil Comments (CC0) and their machine translations from the toxicity v1.0 data | |
| (tox/build_tox.py): 60k rows with identity_attack >= 0.2 + 60k other random rows; eval overlap removed. Labels come from the | |
| teacher (hate/teacher_hate.py label). python hate/build_pool.py TOX_V0_TRAIN.parquet OUT.parquet""" | |
| import glob, os, re, sys | |
| import pandas as pd | |
| norm = lambda s: re.sub(r"\W+", " ", s.lower()).strip() | |
| ev = {norm(t) for p in glob.glob(os.path.join(os.path.dirname(os.path.abspath(__file__)), "evals", "*.parquet")) for t in pd.read_parquet(p).text} | |
| v = pd.read_parquet(sys.argv[1]); v = v[~v.text.map(norm).isin(ev)] | |
| ia = v.identity_attack >= 0.2 | |
| d = pd.concat([v[ia].sample(60000, random_state=0), v[~ia].sample(60000, random_state=0)])[["text", "lang"]].assign(source="civil") | |
| d = d.sample(frac=1, random_state=0).reset_index(drop=True); d.to_parquet(sys.argv[2]); print(len(d), d.lang.value_counts().head(5).to_dict()) | |