text-classification ยท text ยท WASM ยท ~109 MB
A BERT fine-tuned by the IMSyPP project on 100k+ labelled English comments. It reads any text and
picks a spot on a four-step severity ladder โ
acceptable โ inappropriate โ offensive โ
violent โ as a single softmax distribution (the four add up to 100%).
This is a broader signal than hate or toxicity: it catches profanity, insults, and general
hostility, not just protected-group attacks. It is an imperfect moderation signal, not a
verdict. Every score is computed on your device; no comment is ever sent to a server.
| Model | onnx-community/hate_speech_en-ONNX (ONNX of IMSyPP/hate_speech_en) |
|---|---|
| Task / pipeline | text-classification ยท single-label (softmax over 4 classes) |
| Classes | acceptable ยท inappropriate ยท offensive ยท violent (an ordered severity ladder) |
| Architecture | BERT-base (12-layer), fine-tuned on 103k labelled English YouTube comments (IMSyPP project) |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~109 MB, cached after first load |
| License | MIT |
| Web APIs | WebAssembly, Web Workers โ all Baseline widely available |
Type or paste a comment; it re-scores automatically a moment after you stop typing.
The offensive-or-worse threshold decides the verdict: if the combined
offensive + violent probability lands at or above it, the comment is
flagged for review โ otherwise it's
allowed. The samples run from friendly to hostile so you can
watch the distribution slide up the ladder.
toxic-bert emits six independent sigmoids that need not add up. This model is the other
shape: its final layer produces four raw logits, and a single
softmax turns them into competing probabilities that
sum to 100%. So the model is forced to spread one unit of belief across
acceptable, inappropriate, offensive, and
violent. Because those classes are ordered by severity, we can read a single
"offensive-or-worse" number off the top two rungs โ that is what the threshold acts on. The table
shows each class's raw logit beside its softmax probability.
| Class | logit | softmax | role |
|---|
A single-label softmax is the right tool when the classes are mutually exclusive rungs of one scale โ a comment has one severity. Contrast that with toxicity, where a comment can be several kinds of bad at once and independent sigmoids keep each signal separate.
"Offensive" is a much broader net than "hateful" or "toxic". A comment can be crude, insulting, or aggressive without attacking a protected group โ and a moderation queue still wants to see it. A fast, private, offline severity score is a first triage pass: it runs the instant someone hits submit, without the text leaving the tab, and hands a human only what actually needs eyes.
violent and offensive rise to the top and the acceptable majority is auto-approved.inappropriate vs violent instead of one blunt ban.Honesty note: this is a single model trained mostly on YouTube comments. It misreads sarcasm, quoted abuse, and reclaimed language, and it inherits the biases of its labels. Treat its output as one signal that routes a human โ never as an automatic verdict.
Score a single comment and read the four-class severity distribution.
A comment queue: paste many comments, set a threshold, auto-sort into flag / allow by severity.
Sarcasm and context flips โ where "offensive" surface words and hidden intent pull the model apart.
Three heads side by side: offensive vs hate vs toxicity, on the same comment.
The convenience path is one call; ask for every class with topk: null:
import { pipeline } from "@huggingface/transformers";
const classify = await pipeline("text-classification", "onnx-community/hate_speech_en-ONNX");
const out = await classify("shut up you idiot", { topk: null });
// โ [{ label: "LABEL_2", score: 0.99 }, โฆ] (softmax over 4 classes; LABEL_2 = "offensive")
The config only ships generic LABEL_0โฆ3 ids, so this page maps them to the model
card's documented names (acceptable / inappropriate / offensive / violent). For "See
inside" it runs the tokenizer then the model() directly, reads the raw
four-value logits, and applies the softmax itself โ so it can show both the logit and
the probability, and compute your offensive-or-worse threshold. All of it runs in a Web
Worker so typing never janks.