ModelRefs / Toxicity Detection — AI Glossary
Toxicity Detection — AI Glossary
Automated measurement of the degree of offensive, harmful, or abusive language in model outputs.
Overview
Toxicity detection models (Perspective API, HateBERT, Detoxify) score text on dimensions: toxicity, severe toxicity, obscenity, threat, insult, identity attack. Used in RLHF feedback loops (penalizing toxic completions), production output monitoring, and benchmark datasets. Perspective API (Google Jigsaw) is the most widely used baseline.
Reference details
| Topic | safety |
|---|---|
| Last reviewed | 2026-06-24 |
Related terms
How it works
- Toxicity is operationalised as a set of scored dimensions — insult, threat, obscenity, identity attack, severe toxicity — rather than one binary, because the interventions differ per dimension.
- A classifier, typically a fine-tuned encoder, outputs a continuous score per dimension. The score is a calibrated-ish probability of annotator agreement, not a measurement of harm, which is the single most important thing to know about it.
- A threshold converts the score to an action. Threshold choice is a policy decision: it sets the false-positive and false-negative rates, and no threshold makes both small.
- Training labels come from human annotation of what annotators found toxic, so the model inherits their demographics and guidelines. This is the documented source of its best-known bias — reclaimed slurs and dialect features scoring high without any abusive content.
- Context is mostly unavailable to the classifier. A quoted slur in a discussion of racism, a clinical term, or a sarcastic insult between friends all score on surface form, because the model sees a span and not a conversation.
- Deployment is layered: scores feed a filter on output, a flag for review, or a reward signal in preference training, and each use demands a different threshold and a different tolerance for error.
Example: Why the threshold is the whole system
A classifier flags at score 0.8 with 92% precision and 85% recall on a stream where 1% of 100,000 daily messages are genuinely toxic — 1,000 toxic, 99,000 clean. Recall 85% catches 850 and misses 150. Precision 92% means the 850 true positives come with 850 / 0.92 - 850 = 74 false positives, so 74 clean messages are blocked daily. Lower the threshold to 0.5 and suppose recall rises to 95% while precision falls to 70%: now 950 are caught, 50 missed, and false positives become 950 / 0.70 - 950 = 407. The 100 additional toxic messages caught cost 333 additional wrongly blocked users per day. Neither setting is correct in the abstract: the right threshold depends on whether a missed toxic message or a wrongly blocked user is more costly in your product, and that is a policy question the model cannot answer.
Commonly confused with
Toxicity detection is not content moderation and not safety alignment. It is one classifier producing scores; moderation is the whole system around it — policy, thresholds, escalation, appeals, and human review. Treating a score as a verdict is how products ship with no appeal path. It is also distinct from bias detection, which asks whether outputs differ systematically across groups: a model can produce perfectly non-toxic text that is nonetheless stereotyped, and toxicity scoring will not notice.
When to use it
Reach for it when:
- Triage at volume, where scores rank a queue for human reviewers instead of deciding outcomes.
- As a reward or penalty signal during preference training, where aggregate behaviour matters more than any single judgement.
- Monitoring output distributions over time, where a rising mean score is a real signal even if individual scores are noisy.
- Pre-publication checks on generated content, as one input to a decision that a person makes.
Reach for something else when:
- As an automatic blocking decision with no appeal, given documented bias against dialect features and reclaimed language.
- On text where meaning depends on context — quotation, clinical discussion, in-group speech — which the classifier does not see.
- Across languages or communities it was not evaluated on, where thresholds calibrated elsewhere do not transfer.
- As a measure of harm. The score predicts annotator agreement about a span, which is a different quantity from the damage done to a reader.
Continue your research
Use these connected ModelRefs sections to compare alternatives, inspect implementation paths, and review the evidence and governance boundaries relevant to Toxicity Detection — AI Glossary.
Frequently asked questions
What is Toxicity Detection?
Automated measurement of the degree of offensive, harmful, or abusive language in model outputs.
What concepts are related to Toxicity Detection?
Closely related concepts include content moderation, bias detection, guardrails.