Toxicity

In AI, toxicity means abusive language such as insults, hate speech, threats and harassment, measured in model outputs and training data so it can be filtered out or reduced.

Toxicity is a common umbrella term for abusive language in AI research and content moderation. A widely used working definition comes from Perspective API, a tool from Google's Jigsaw unit: a rude, disrespectful, or unreasonable comment likely to make people leave a discussion. That definition is about effect on a conversation rather than any fixed list of words, which makes it practical but also subjective.

Toxicity is usually measured with a classifier. A model trained on comments rated by people returns a score for each piece of text, and the user chooses a threshold above which text counts as toxic. Perspective's model was trained on comments from online forums including Wikipedia and The New York Times, labelled through crowdsourcing. Its documentation measures unintended bias, where harmless sentences mentioning identities such as sexual orientation, gender identity or race can be wrongly scored as toxic, and it says the model is not meant for fully automated moderation.

Language models pick up toxicity from their training data. In September 2020 Samuel Gehman and colleagues released RealToxicityPrompts, about 100,000 sentence openings from web text, and showed that pretrained language models could slide into toxic text even from prompts that seemed harmless. They also found a significant amount of offensive content in web text corpora used to pre-train models including GPT-2.

The best-known failure predates modern chatbots. Microsoft launched Tay, a Twitter chatbot, on March 23, 2016 and suspended it within 16 hours, after users taught it to post offensive, racist and sexist replies. Today developers reduce toxicity at several stages: filtering training data, fine-tuning models to decline abusive requests and running moderation classifiers, such as OpenAI's moderation endpoint with its harassment and hate categories, on inputs and outputs.

Toxicity scores are a useful but rough measure. They depend on who labelled the training data, can miss context, and can penalise text simply for mentioning a group. Jigsaw has also announced that Perspective API will stop running after 2026, so research that used it as a standard yardstick will need other classifiers.

Common questions

What does toxicity mean in AI?

It refers to abusive or harmful language, such as insults, hate speech, threats and harassment, in AI outputs or training data. Perspective API's widely used definition is a rude, disrespectful or unreasonable comment likely to make people leave a discussion.

How is AI toxicity measured?

Usually with a toxicity classifier, a model trained on human-labelled examples that gives each text a score. Researchers pick a threshold above which text counts as toxic and report how often a model's outputs cross it, often using benchmark prompts such as RealToxicityPrompts.

Why do language models produce toxic content?

They learn from huge amounts of web text, which contains a significant amount of offensive material. A 2020 study showed that pretrained models could produce toxic text even from harmless-looking prompts. Developers reduce this with data filtering, fine-tuning and output classifiers.

What is Perspective API?

Perspective API is a tool from Google's Jigsaw unit that scores text for toxicity and related attributes, widely used in moderation and AI research. Jigsaw has announced that the service will stop running after 2026.

Finding more

Search for "toxicity classifier", "RealToxicityPrompts", "Perspective API toxicity" and "unintended bias in toxicity classification" to understand how toxicity is defined and measured. Research papers on arXiv, model cards for toxicity classifiers and developers' safety documentation are the most reliable sources. Compare toxicity scores only when the same classifier and threshold were used, because different tools rate the same text very differently.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.