โ† All models

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

twitter-roberta-hate โ€” spot protected-group hate, privately

Cardiff NLP's RoBERTa-large fine-tuned to detect hate speech aimed at a protected characteristic. It reads any text and picks one of eight classes โ€” seven kinds of targeted hate (gender, race, sexuality, religion, origin, disability, age) plus not_hate โ€” as a single softmax. This is a strictly narrower task than toxicity or offensiveness: not everything rude is hate. It is an imperfect moderation signal, not a verdict โ€” it reads surface words, has no speaker model, and carries its training biases. Every score is computed on your device; no comment is ever sent to a server.

At a glance

Modelonnx-community/twitter-roberta-large-hate-latest-ONNX (ONNX of cardiffnlp/twitter-roberta-large-hate-latest)
Task / pipelinetext-classification ยท single-label (softmax over 8 classes)
Classeshate_gender ยท hate_race ยท hate_sexuality ยท hate_religion ยท hate_origin ยท hate_disability ยท hate_age ยท not_hate
ArchitectureRoBERTa-large (355M params, 24-layer) fine-tuned on the TweetHate benchmark (Cardiff NLP)
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~358 MB โ€” a large model; downloaded once, then cached. Best on a good connection; heavy for low-memory phones.
LicenseMIT
Web APIsWebAssembly, Web Workers โ€” all Baseline widely available

Run it

Type or paste text; it re-scores automatically a moment after you stop typing. The hate threshold decides the verdict: if the combined hate probability (1 โˆ’ not_hate) lands at or above it, the text is flagged and the model names the targeted group โ€” otherwise it's allowed. The samples show the difference between rudeness and hate keyed to a protected characteristic.

See inside โ€” one softmax that also names the target

The final layer produces eight raw logits, and a single softmax turns them into competing probabilities that sum to 100%. Seven of those classes are hate keyed to a protected characteristic; the eighth is not_hate. So the model does two things at once: it decides whether the text is hateful (1 โˆ’ P(not_hate)) and, if so, which group is targeted โ€” something a plain toxicity score can't tell you. The table shows each class's logit beside its softmax probability.

Score some text to see the raw numbers.

Why it matters

Hate speech is a distinct, high-stakes category: platforms, regulators, and trust-and-safety teams treat protected-group attacks differently from ordinary rudeness. A model that not only flags hate but names the targeted characteristic lets you route, prioritise, and report it correctly โ€” and doing it on-device means sensitive text never leaves the tab.

Honesty note: this model reflects its training data (English tweets). It is conservative โ€” reliable on explicit, surface-level attacks, but it lets a lot of coded, "polite", or subtle hate through as not_hate (a recall gap), and it can encode demographic bias. Treat every score as one signal that routes a human โ€” never a verdict, and never read not_hate as proof that text is safe.

Use cases

Basics

Score one comment: hate vs not-hate, and which protected group is targeted.

Practical

Moderation triage โ€” a queue sorted by hate probability, a signal for a reviewer, not a verdict.

Wild

Reclaimed language and edge cases where the model false-positives โ€” and why you can't auto-ban on it.

Multi-model

Hate vs toxicity, head to head: where a targeted-hate signal and a toxicity signal agree and diverge.

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/twitter-roberta-large-hate-latest-ONNX");
const out = await classify("go back to your own country", { topk: null });
// โ†’ [{ label: "hate_origin", score: 0.94 }, { label: "not_hate", score: 0.03 }, โ€ฆ]  (softmax over 8)

For "See inside" this page runs the tokenizer then the model() directly, reads the raw eight-value logits, and applies the softmax itself โ€” so it can show both the logit and the probability, compute the aggregate hate score (1 โˆ’ not_hate), and apply your threshold. All of it runs in a Web Worker so typing never janks.

References