Skip to page content
SAVRN
Search Plan a project

Open-weight model · Text classification

content-safety-guard-small-ONNX

by ONNX Community onnx-community/content-safety-guard-small-ONNX

content-safety-guard-small-ONNX is an open-weight model for text classification from ONNX Community, released under Apache License 2.0. It has 8,192-token context. Its published files total 2.4 GB.

This is an ONNX version of Horizon-Labs/content-safety-guard-small. It was automatically converted and uploaded using this Hugging Face Space.

Parameters—
Context8,192
Weights2.3 GB
Licenseapache-2.0
AccessOpen weights
Monthly Downloads—

Model Card

By ONNX Community, published under apache-2.0, revision 74e953e4b141.

This is an ONNX version of Horizon-Labs/content-safety-guard-small. It was automatically converted and uploaded using this Hugging Face Space. See the pipeline documentation for text-classification: https://huggingface.co/docs/transformers.js/api/pipelines#modulepipelines.TextClassificationPipeline A small multilingual classifier that flags unsafe user prompts and unsafe model responses for LLM applications, with harm categories. It is a fast encoder (ModernBERT architecture, mmBERT backbone) that you can run on CPU or in the browser in front of, or behind, any LLM. real-world prompts; evaluated on 17 (PolyGuard), 14 (textdetox) and 8 (Aya) languages. Which size? This small model has less…

Read ONNX Community's full model card

This is an ONNX version of Horizon-Labs/content-safety-guard-small. It was automatically converted and uploaded using this Hugging Face Space.

Usage with Transformers.js

See the pipeline documentation for text-classification: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.TextClassificationPipeline


Content Safety Guard (small, 141M)

A small multilingual classifier that flags unsafe user prompts and unsafe model responses for LLM applications, with harm categories. It is a fast encoder (ModernBERT architecture, mmBERT backbone) that you can run on CPU or in the browser in front of, or behind, any LLM.

  • Prompts and responses: pass a prompt alone, or a (prompt, response) pair to judge the response in context.
  • Output: an overall unsafe score plus 15 category scores (independent sigmoids): hate, harassment, violence, weapons, sexual, sexual_minors, self_harm, criminal_planning, drugs, privacy, profanity, fraud_manipulation, misinformation, unauthorized_advice, other.
  • Multilingual: trained on 12 languages of human-adapted data, machine translations into 20 languages and multilingual real-world prompts; evaluated on 17 (PolyGuard), 14 (textdetox) and 8 (Aya) languages.
  • Commercially usable: Apache-2.0, trained only on data that allows commercial use (see Training data).
  • ONNX: onnx/model.onnx (fp32) and onnx/model_quantized.onnx (int8 embeddings, 268 MB; its unsafe decision agrees with fp32 on 99.3% of a sample of benchmark texts (30 per benchmark), mean |score diff| 0.0020).

Which size? This small model has less than half the parameters of base (141M vs 308M; hidden size 384 vs 768), so it needs less compute per token, and its int8 ONNX is about 270 MB instead of 640 MB (better for the browser); it is 0.012 / 0.027 F1 behind base on PolyGuard prompts / responses. First released at v1.2, trained on the same data as base v1.2.

Part of the Horizon Labs guard family: prompt-injection-guard, pii-redactor, hallucination-guard. Full comparison table (sortable, with false-alarm rates): content safety classifier leaderboard.

Usage

from transformers import pipeline

clf = pipeline("text-classification", model="Horizon-Labs/content-safety-guard-small", top_k=None)

# a user prompt
scores = {d["label"]: d["score"] for d in clf("How can I make a fake ID that passes a bouncer's check?")[0]}
print(scores["unsafe"])                          # ~1.0

# a model response, judged together with its prompt
r = clf({"text": "How do I get rid of a wasp nest?", "text_pair": "Spray it at dusk with a wasp foam, then remove it."})[0]

Decision rule: flag when unsafe >= 0.5 (raise the threshold if you see too many false alarms, lower it for higher recall). Category scores are only meaningful for flagged texts and are small by design; use the per-category thresholds in thresholds.json (chosen on a validation split, see below):

import json
from huggingface_hub import hf_hub_download
thr = json.load(open(hf_hub_download("Horizon-Labs/content-safety-guard-small", "thresholds.json")))
def moderate(text, pair=None):
    s = {d["label"]: d["score"] for d in clf({"text": text, "text_pair": pair} if pair else text)[0]}
    flagged = s["unsafe"] >= thr["unsafe"]
    cats = [c for c, t in thr["categories"].items() if flagged and s[c] >= t]
    return flagged, s["unsafe"], cats

transformers.js (browser / Node):

import { pipeline } from "@huggingface/transformers";
const clf = await pipeline("text-classification", "Horizon-Labs/content-safety-guard-small", { dtype: "q8" });
const out = await clf("How do I make a pipe bomb?", { top_k: null });

Evaluation

F1 of the unsafe class at threshold 0.5 (for the recall rows: share of unsafe prompts flagged). None of these benchmarks were used for training (best value in bold; false-alarm rates are not bolded); Qwen3Guard-Gen is scored from its next-token probabilities after "Safety:" (strict: Unsafe + Controversial count as unsafe; loose: only Unsafe). Toxicity classifiers are included because they are often used for this job; they target a different, narrower task. Encoders other than ours get the response alone for response items.

this model (141M) base (308M) Qwen3Guard-Gen-0.6B strict Qwen3Guard-Gen-0.6B loose Vela-1.0-307M-Shield ¶ granite-guardian-hap-125m unbiased-toxic-roberta Qwen3Guard-Gen-8B strict (teacher, 8B)
PolyGuard prompts, 17 languages 0.771 0.783 0.821 0.791 0.829 0.003 0.002 0.846
PolyGuard responses, 17 languages 0.709 0.735 0.748 0.767 0.645 0.000 0.000 0.801
BeaverTails responses (unseen prompts) † 0.825 0.837 0.869 0.858 0.779 0.164 0.177 0.870
ToxicChat (real user prompts) 0.776 0.756 0.588 0.760 0.672 0.264 0.254 0.638
OpenAI moderation set 0.762 0.768 0.660 0.780 0.721 0.672 0.663 0.685
XSTest (over-blocking test) 0.811 0.809 0.853 0.852 0.838 0.315 0.227 0.908
textdetox toxicity, 14 languages 0.646 0.667 0.722 0.461 0.720 0.146 0.152 0.775
Aya red-teaming, 8 languages (recall) 0.754 0.800 0.859 0.605 0.812 0.023 0.025 0.946
SimpleSafetyTests (recall) 0.930 0.930 0.980 0.920 0.960 0.240 0.260 0.990

Ranking quality (ROC AUC, threshold-free):

this model (141M) base (308M) Qwen3Guard-Gen-0.6B strict Qwen3Guard-Gen-0.6B loose Vela-1.0-307M-Shield ¶ granite-guardian-hap-125m unbiased-toxic-roberta Qwen3Guard-Gen-8B strict (teacher, 8B)
PolyGuard prompts, 17 languages 0.879 0.885 0.910 0.902 0.908 0.569 0.542 0.931
PolyGuard responses, 17 languages 0.944 0.952 0.945 0.941 0.905 0.566 0.552 0.959
BeaverTails responses (unseen prompts) † 0.906 0.912 0.926 0.926 0.836 0.662 0.593 0.929
ToxicChat (real user prompts) 0.979 0.982 0.985 0.979 0.972 0.841 0.844 0.988
OpenAI moderation set 0.910 0.919 0.924 0.921 0.913 0.877 0.875 0.941
XSTest (over-blocking test) 0.906 0.923 0.958 0.947 0.926 0.688 0.678 0.987
textdetox toxicity, 14 languages 0.814 0.837 0.769 0.757 0.804 0.585 0.529 0.846

Over-blocking (share of safe items flagged; lower is better):

this model (141M) base (308M) Qwen3Guard-Gen-0.6B strict Qwen3Guard-Gen-0.6B loose Vela-1.0-307M-Shield ¶ granite-guardian-hap-125m unbiased-toxic-roberta Qwen3Guard-Gen-8B strict (teacher, 8B)
XSTest: safe prompts flagged 0.220 0.212 0.228 0.052 0.104 0.036 0.012 0.128
PolyGuard prompts: safe prompts flagged 0.100 0.087 0.115 0.050 0.065 0.002 0.000 0.081
OpenAI moderation set: safe texts flagged 0.176 0.167 0.437 0.125 0.287 0.068 0.092 0.397
ToxicChat: safe prompts flagged 0.023 0.027 0.102 0.012 0.055 0.004 0.008 0.083

¶ Vela-Shield was trained on PolyGuardMix, the training split of the PolyGuard benchmark family, so its PolyGuard rows are in-distribution. † BeaverTails and our main training set both take prompts from Anthropic's HH red-team data; the row uses only the 1894 test items whose prompt does not occur in our training data. ToxicChat shares 29 of 5083 prompts with our training data.

PolyGuard prompts per language (F1):

Language this model Qwen3Guard-Gen-0.6B strict Vela-Shield ¶
Arabic 0.759 0.817 0.834
Chinese 0.808 0.848 0.830
Czech 0.749 0.810 0.857
Dutch 0.765 0.789 0.813
English 0.812 0.875 0.871
French 0.775 0.843 0.847
German 0.772 0.818 0.813
Hindi 0.759 0.778 0.803
Italian 0.783 0.825 0.839
Japanese 0.775 0.801 0.831
Korean 0.737 0.787 0.795
Polish 0.726 0.807 0.808
Portuguese 0.782 0.845 0.849
Russian 0.750 0.845 0.813
Spanish 0.808 0.843 0.846
Swedish 0.768 0.802 0.837
Thai 0.774 0.823 0.799

Categories

Category labels come from the Aegis 2.0 taxonomy of Nemotron-Safety-Guard-Dataset-v3 (merged into 15 groups). Quality on the unsafe items of its test split, with thresholds chosen on its validation split:

Category threshold F1 (test) F1 at 0.5 AUC test positives
criminal_planning 0.20 0.782 0.753 0.874 2060
violence 0.30 0.561 0.512 0.835 814
drugs 0.35 0.613 0.579 0.899 696
hate 0.20 0.734 0.687 0.924 592
harassment 0.25 0.522 0.440 0.835 562
privacy 0.20 0.660 0.603 0.897 483
other 0.10 0.474 0.160 0.878 479
weapons 0.20 0.585 0.517 0.869 368
sexual 0.15 0.703 0.703 0.932 333
profanity 0.25 0.569 0.516 0.873 326
self_harm 0.20 0.610 0.511 0.911 308
fraud_manipulation 0.15 0.352 0.133 0.852 299
unauthorized_advice 0.20 0.259 0.124 0.843 206
sexual_minors 0.25 0.386 0.301 0.899 165
misinformation 0.15 0.366 0.272 0.860 141

Training

  • Data (all permit commercial use):
  • nvidia/Nemotron-Safety-Guard-Dataset-v3 (CC-BY-4.0; Aegis 2.0 prompts and responses, culturally adapted into 12 languages): 574k prompt and response items, with its human category labels. Rows derived from a Kaggle dataset (REDACTED) were dropped.
  • Real and red-team prompts without labels, scored by the teacher: first user turns and replies from WildChat-1M (ODC-BY), prompts from oasst2 and the Aya dataset (Apache-2.0), Salad-Data (Apache-2.0; ToxicChat-derived rows dropped), JailbreakBench behaviours (MIT), and jailbreak, role-play and over-refusal prompts from the training data of our prompt-injection guard (270k + 42k items).
  • Civil Comments (CC0): 60k comments with toxicity >= 0.5 and 60k with toxicity 0; target = the share of annotators who rated it toxic, categories from the insult / threat / obscene / identity-attack / sexual ratings. This improved the OpenAI moderation set (F1 +0.035) but not the textdetox recall.
  • (v1.1) Machine translations by Qwen3.8-27B (Apache-2.0) into 20 languages (Portuguese, Russian, Ukrainian, Polish, Czech, Swedish, Turkish, Hebrew, Serbian, Tagalog, Amharic, Tatar, German, Spanish, French, Arabic, Hindi, Chinese, Japanese, Italian): 47.6k Civil Comments (a different shard from the one above; they keep their annotator toxicity and categories) and 46.6k of the teacher-labelled prompts above (harmful, benign-but-edgy and benign; re-scored by the teacher in the target language). 1.8% of the translations were dropped (unparseable, refusals, implausible length).
  • (v1.2) 25k requests written by Qwen3.8-27B in 27 languages: harmless requests that use alarming words in an ordinary sense (programming, cooking, games, medicine, history, fiction, ...) and harmful look-alikes on the same topics, labelled by the teacher. The instruction is our own generic description; no benchmark items (XSTest, OR-Bench test) were used, but this data targets the same failure mode that XSTest measures.
  • Items that match any benchmark text were removed.
  • Teacher: Qwen3Guard-Gen-8B (Apache-2.0). The unsafe target of every item except Civil Comments is the teacher's probability P(Unsafe) + 0.5 · P(Controversial); categories use the human labels. So the model follows Qwen3Guard's safety policy, not Aegis's stricter human labels (which also mark sensitive but harmless requests).
  • Model: jhu-clsp/mmBERT-small with a 16-way sigmoid head (unsafe + 15 categories), 3 epochs, max length 1024 tokens.
  • Code: code/ in this repository.

Limitations

  • It trails Qwen3Guard-Gen-0.6B (a generative 0.6B model that reads a long policy prompt per item) in both of its modes on PolyGuard prompts, PolyGuard responses, BeaverTails responses, XSTest (0.039-0.050 F1 behind its strict mode on PolyGuard responses / prompts); it is ahead of the strict mode on ToxicChat, OpenAI moderation set. Its advantages are speed, size, CPU/browser use and multilingual coverage in one small encoder.
  • Over-blocking: it flags about 22% of XSTest's safe-but-scary prompts ("how do I kill a Python process").
  • Classic toxicity (insults, profanity without other harm) is only partly covered (textdetox recall 0.54).
  • Recall on harmful prompts written by native speakers in lower-resource languages is lower (Aya red-teaming 0.75).
  • Categories are weak for fraud_manipulation, unauthorized_advice, misinformation and sexual_minors (F1 below 0.45). Do not rely on it alone for child-safety or legal compliance; use it as one signal with human review.
  • Safety policies differ between applications; tune the threshold on your own traffic.

Configuration

Architecture
ModernBertForSequenceClassification
Context length (tokens)
8,192
Layers
22
Hidden size
384
Feed-forward size
1,152
Attention heads
6
Vocabulary size
256,000
Model type
modernbert

Identity and Version

Repository
onnx-community/content-safety-guard-small-ONNX
Publisher
ONNX Community
Task
Text classification
Modality
Text
Library
transformers.js
Parameters
Not stated by the source
Languages
en, ar, de, es, fr, hi, it, ja
Revision
74e953e4b14199e152899135cb176a0998135baf
First published
2026-10-10
Last updated
2026-10-10

Files and Weights

14 files, 2.4 GB in total. The weights are 8 files totalling 2.3 GB in onnx.

Weights8 files · 2.3 GB
Configuration2 files · 3.8 KB
Tokenizer2 files · 34.4 MB
Documentation1 file · 15.3 KB
Repository1 file · 1.6 KB
Every file
FileTypeSizeSHA-256
onnx/model.onnxWeights563.1 MB 6de65550122a
onnx/model_bnb4.onnxWeights417.6 MB a6c62572e49c
onnx/model_fp16.onnxWeights282.0 MB 3a65a3c9d416
onnx/model_int8.onnxWeights141.5 MB 156b2b60eb16
onnx/model_q4.onnxWeights420.3 MB 934d5c879b61
onnx/model_q4f16.onnxWeights221.1 MB 9c33c375b0ef
onnx/model_quantized.onnxWeights141.5 MB 156b2b60eb16
onnx/model_uint8.onnxWeights141.5 MB 8de7ed944417
config.jsonConfiguration2.8 KB —
special_tokens_map.jsonConfiguration1.1 KB —
README.mdDocumentation15.3 KB —
.gitattributesRepository1.6 KB —
tokenizer.jsonTokenizer34.4 MB aebee76d0312
tokenizer_config.jsonTokenizer46.6 KB —

License and Download

License
apache-2.0
Access
Open weights, no gate
Download size
2.3 GB
Download from ONNX Community

Released by ONNX Community through its official repository on Hugging Face. Read the license.

Built From

  • Derived from Horizon-Labs/content-safety-guard-small
  • Quantized from Horizon-Labs/content-safety-guard-small
  • Trained on (disclosed) CohereForAI/aya_dataset
  • Trained on (disclosed) JailbreakBench/JBB-Behaviors
  • Trained on (disclosed) OpenAssistant/oasst2
  • Trained on (disclosed) OpenSafetyLab/Salad-Data
  • Trained on (disclosed) allenai/WildChat-1M
  • Trained on (disclosed) google/civil_comments
  • Trained on (disclosed) nvidia/Nemotron-Safety-Guard-Dataset-v3

Memory Requirements

PrecisionWeights in memory
As published2.3 GB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About content-safety-guard-small-ONNX

Can I use content-safety-guard-small-ONNX commercially?

Yes. content-safety-guard-small-ONNX is released under Apache License 2.0. The Apache License 2.0 is a permissive open-source license. It permits commercial use, modification and redistribution. It requires keeping the license and copyright notices and any NOTICE file, stating significant changes, and it includes an express patent grant from contributors.

What is content-safety-guard-small-ONNX's context length?

8,192 tokens, from the maximum position embeddings in its published configuration.

Similar Models

Model · Text classification

twitter-roberta-base-sentiment-latest

Cardiff NLP

This is a RoBERTa-base model trained on ~124M tweets from January 2018 to December 2021, and finetuned for sentiment analysis with the TweetEval benchmark. The original Twitter-based RoBERTa model can be found here and the original reference paper is TweetEval. This model is suitable for English. 0 -> Negative; 1 -> Neutral; 2 -> Positive This sentiment analysis model has been integrated into TweetNLP. You can access the demo here.

Open weights cc-by-4.0 514 tokens transformers

Model · Text classification

finbert-tone

Yi

FinBERT is a BERT model pre-trained on financial communication text. The purpose is to enhance financial NLP research and practice. It is trained on the following three financial communication corpus. The total corpora size is 4.9B tokens. More technical details on FinBERT: Click Link This released finbert-tone model is the FinBERT model fine-tuned on 10,000 manually annotated (positive, negative, neutral) sentences from analyst reports. This model achieves superior performance on financial tone analysis task. If you are simply interested in using FinBERT for financial tone analysis, give it a try. If you use the model in your academic work, please cite the following paper: Huang, Allen H.…

Open weights 512 tokens transformers

Model · Text classification

ms-marco-MiniLM-L-6-v2

Joshua

https://huggingface.co/cross-encoder/ms-marco-MiniLM-L-6-v2 with ONNX weights to be compatible with Transformers.js. If you haven't already, you can install the Transformers.js JavaScript library from NPM using: Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using Optimum and structuring your repo like this one (with ONNX weights located in a subfolder named onnx).

Open weights 512 tokens transformers.js

Model · Text classification

twitter-xlm-roberta-base-sentiment

Cardiff NLP

This is a multilingual XLM-roBERTa-base model trained on ~198M tweets and finetuned for sentiment analysis. The sentiment fine-tuning was done on 8 languages (Ar, En, Fr, De, Hi, It, Sp, Pt) but it can be used for more languages (see paper for details). This model has been integrated into the TweetNLP library.

Open weights 514 tokens transformers

Model · Text classification

unbiased-toxic-roberta

Unitary

The huggingface models currently give different results to the detoxify library (see issue here). For the most up to date models we recommend using the models from https://github.com/unitaryai/detoxify Trained models & code to predict toxic comments on 3 Jigsaw challenges: Toxic comment classification, Unintended Bias in Toxic comments, Multilingual toxic comment classification. Built by Laura Hanu at Unitary, where we are working to stop harmful content online by interpreting visual content in context. Score not directly comparable since it is obtained on the validation set provided and not on the test set. To update when the test labels are made available. It is also noteworthy to mention…

Open weights apache-2.0 514 tokens transformers

Model · Text classification

emotion-english-distilroberta-base

Hartmann

With this model, you can classify emotions in English text data. The model was trained on 6 diverse datasets (see Appendix below) and predicts Ekman's 6 basic emotions, plus a neutral class: 1) anger 2) disgust 3) fear 4) joy 5) neutral 6) sadness 7) surprise The model is a fine-tuned checkpoint of DistilRoBERTa-base. For a 'non-distilled' emotion model, please refer to the model card of the RoBERTa-large version. a) Run emotion model with 3 lines of code on single text example using Hugging Face's pipeline command on Google Colab: b) Run emotion model on multiple examples and full datasets (e.g.,.csv files) on Google Colab: Please reach out to [email protected] if you have any…

Open weights 514 tokens transformers