โ† All models

text-classification ยท text ยท WASM ยท ~109 MB

hate_speech_en โ€” rate how offensive a comment is, privately

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.

At a glance

Modelonnx-community/hate_speech_en-ONNX (ONNX of IMSyPP/hate_speech_en)
Task / pipelinetext-classification ยท single-label (softmax over 4 classes)
Classesacceptable ยท inappropriate ยท offensive ยท violent (an ordered severity ladder)
ArchitectureBERT-base (12-layer), fine-tuned on 103k labelled English YouTube comments (IMSyPP project)
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~109 MB, cached after first load
LicenseMIT
Web APIsWebAssembly, Web Workers โ€” all Baseline widely available

Run it

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.

See inside โ€” one softmax over a severity 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.

Score a comment to see the raw numbers.

Why it matters

"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.

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.

Use cases

Basics

Score a single comment and read the four-class severity distribution.

Practical

A comment queue: paste many comments, set a threshold, auto-sort into flag / allow by severity.

Wild

Sarcasm and context flips โ€” where "offensive" surface words and hidden intent pull the model apart.

Multi-model

Three heads side by side: offensive vs hate vs toxicity, on the same comment.

How the API works

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.

References