Toxicity Filtering › Toxicity Thresholds
Language AI HandbookAll chapters Toxicity Filtering › Toxicity ThresholdsOne section · Sections in this chapter4 / 10 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
A toxicity classifier produces a score between 0 and 1. To make a filtering decision, you must choose a threshold above which a document is considered toxic and removed from the corpus. The threshold is a technical choice and a values decision, with measurable consequences for what your model learns and what communities are represented in the training data.
The Precision-Recall Tradeoff
At high thresholds (close to 1.0), you filter only text that the classifier considers almost certainly toxic. Precision is high: most filtered documents are problematic. Recall is low: many toxic documents that received scores between your threshold and 1.0 remain in the corpus.
At low thresholds (close to 0.0), you filter everything the classifier assigns any toxicity signal to. Recall is high, but precision collapses: you remove many acceptable documents.
For training data, the asymmetry matters in both directions. Missing toxic content (low recall) means the model learns from it. Filtering too aggressively (low precision) removes legitimate content and skews the training distribution. Research on this tradeoff uses a formal framing: given a toxicity classifier with score for document and a threshold , we filter documents where:
where:
- : the classifier's toxicity score for document , between 0 and 1
- : the filtering threshold, a value in chosen by the practitioner
- Documents with are removed from the training set
The expected precision and recall as functions of threshold are:
These quantities cannot be computed without ground truth labels for the full corpus, which is why calibrating a threshold requires a held-out labeled validation set that mirrors the distribution of your corpus. A common mistake is calibrating thresholds against a dataset of known toxic examples, which will give you optimistic recall estimates but tell you nothing about precision or false positive rates on benign content.
Calibrating Against a Validation Set
To pick a threshold, you need a validation set with ground truth labels. This set should be:
- Representative of the corpus you are filtering, including more than high-confidence toxic examples. The hard cases, the borderline documents and the sensitive-but-benign documents, should be proportionally represented.
- Balanced enough to allow measurement at both ends of the precision-recall curve. An all-toxic validation set cannot measure precision. An all-benign validation set cannot measure recall. You need a mix that reflects your production distribution.
- Annotated by multiple raters with adjudicated decisions for borderline cases. Single-annotator labels for borderline cases are unreliable and will introduce noise into your threshold selection.
With a validation set in hand, you plot the precision-recall curve across all threshold values from 0 to 1 and identify the operating point that satisfies your requirements. A common approach is to choose to maximize the score, which is a weighted harmonic mean of precision and recall:
where:
- : weights recall more heavily, appropriate when missing toxic content is more costly than over-filtering
- : weights precision more heavily, appropriate when over-filtering is more costly
- : equal weighting (the standard score)
For most pretraining data curation pipelines, practitioners set (commonly ) because the cost of training on toxic content is considered higher than the cost of losing some acceptable documents. The right depends on your application. A model intended for use with vulnerable populations (mental health support, crisis intervention) warrants a very high , accepting aggressive over-filtering to minimize exposure to harmful content. A model intended for security research that must understand adversarial content may warrant a lower .
The approach gives you a single operating point, but often you want to see the full curve before committing. A practical approach is to plot the precision-recall curve, mark several candidate thresholds at different recall levels (e.g., "90% recall threshold" and "95% recall threshold"), and then examine a random sample of filtered documents at each threshold to assess whether the additional filtered content at the more aggressive threshold is problematic or benign.
Multi-Attribute Filtering
A single toxicity score is often insufficient. Jigsaw's taxonomy distinguishes between:
- Toxic: A rude, disrespectful, or unreasonable comment that is likely to make people leave a discussion
- Severe toxic: A hateful or threatening comment that calls for violence or demeans entire groups
- Obscene: Contains explicit language (profanity, sexual language)
- Threat: A direct or indirect threat of physical harm
- Insult: An insulting, inflammatory, or negative comment toward a person
- Identity attack: Negative or hateful language targeting a person's identity characteristics
You may want different thresholds for different attributes. A corpus intended for a children's educational assistant might filter at a very low threshold for obscenity even while allowing discussion of historical violence. A corpus for a medical assistant might allow clinical discussion of abuse without filtering it as toxicity, but filter any glorification of violence at a low threshold. A corpus for a legal research model might need to retain verbatim quotes from hate speech cases that would otherwise score high on identity attack.
The practical consequence of multi-attribute filtering is that you must maintain multiple classifiers or a multi-output classifier, and you must decide how to combine signals from multiple attributes. A common approach is to filter if any attribute exceeds its threshold (logical OR), which increases recall at the cost of precision. Alternatively, you can filter only if a primary attribute exceeds its threshold, and use secondary attributes to flag borderline cases for manual review.
The combination logic matters enormously at scale. If you use logical OR across six attributes each with a 10% false positive rate, the combined false positive rate for a benign document approaches:
Nearly half of all benign documents would be filtered, even with individually well-calibrated classifiers. This calculation assumes attribute independence, which overstates the false positive rate when attributes are positively correlated (a document that scores high on "obscene" is likely to score somewhat higher on "insult" as well, so the effective number of independent classifiers is less than six). Practitioners often address this by treating the six Jigsaw attributes not as six independent filters but as a single multi-output model with a combined decision rule that accounts for correlations between attributes, typically by learning a logistic regression meta-classifier on top of the six attribute scores.