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: 993 Bytes
c1e5dc4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | """Merge the generated hate-speech texts (hate/gen_hate.py shards), dedupe, drop eval overlap -> OUT parquet (text, lang, category, platform, intended).
python hate/build_gen.py OUT.parquet SHARD.jsonl..."""
import json, sys, os, re, glob
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}
rows = []
for p in sys.argv[2:]:
for line in open(p, encoding="utf-8"):
try:
rows.append(json.loads(line))
except json.JSONDecodeError:
pass
df = pd.DataFrame(rows); n0 = len(df)
k = df.text.map(norm); df = df[(k.str.len() >= 3) & ~k.isin(ev)].drop_duplicates("text").reset_index(drop=True)
print("rows", n0, "->", len(df), "eval overlap", int(k.isin(ev).sum()))
print(df.lang.value_counts().to_string()); print(df.intended.value_counts().head(5).to_string())
df.to_parquet(sys.argv[1])
|