Google’s 2B ShieldGemma beat GPT-4 at flagging policy-violating prompts
Made by Wenjun Zeng and 11 co-authors
arXiv preprint; GPT-4’s OpenAI Moderation score from earlier papers
The result
The story
A gate for every message
A chatbot needs a gate that checks what users send and what the model replies. Google’s ShieldGemma Team built that gate as dedicated models on top of Gemma 2, in 2B, 9B and 27B sizes. Each check is narrow: read one prompt, or a prompt and its reply, compare it with the policy for one harm type (sexually explicit content, dangerous content, harassment or hate speech), and answer Yes or No. The probability of Yes is the score, so each team can set its own threshold.

Small model
ShieldGemma 2B
2B (2,614,341,888 parameters in the Hugging Face repo) · Google
Supervised fine-tuning with one policy prompt per harm type; the first output token is Yes or No
- Base
- Gemma 2 2B, instruction-tuned
Training data written mostly by models
Most of the training data is synthetic. Language models, Gemini by default, wrote 100,000 prompts and prompt-reply pairs from combinations of harm type, topic, use case and locale, a critique-and-generate loop added 20,000 harder or more varied ones, and 14,000 items came from Anthropic’s HH-RLHF set. An active-learning step cut that pool to 15,000 examples, favouring the ones a Gemma model was unsure about, and three raters labelled each one. 10,500 went to training and 4,500 became Google’s own test set.
Data
ShieldGemma training and test data
15,000 labelled examples: 10,500 for training, 4,500 for testing (half prompts, half prompt-reply pairs)
Prompts and replies generated with language models, Gemini by default (100k raw, 20k expanded), plus 14k Anthropic HH-RLHF items, down-sampled by active learning
3 raters per item, majority vote; the training data was widened by swapping identity terms; the test set isn’t linked from the report
Training
Supervised fine-tuning of Gemma 2 2B instruction-tuned (full or adapter tuning not stated)
- Hardware
- TPUv5 lite (the model card says TPUv5e); chip count not reported
- Time
- Not reported; 4,000 steps at batch size 16, max sequence 8k, learning rate 1e-6, best checkpoint picked on validation data
Not reported: cost.
How GPT-4 was compared
Google ran GPT-4 itself only on its own test sets: gpt-4-0613 through the OpenAI API, with the same policy prompts, scored by the probability of its first token. For the two public benchmarks, OpenAI Moderation (1,680 prompts) and ToxicChat (10k prompts, as the report puts it), the table caption says the baseline scores come from earlier papers. Those are F1 scores on yes/no answers, while ShieldGemma’s are optimal F1 from its probabilities.
Large model
GPT-4
Size not disclosed · OpenAI
Used as released, zero-shot. On Google’s sets: the same policy prompts, scored by first-token probability. On OpenAI Moderation and ToxicChat: scores copied from earlier papers
- Base
- General model; snapshot named only for Google’s own runs (gpt-4-0613)
Evaluation
1,680 prompts (OpenAI Moderation)
- Test set
- OpenAI Moderation (headline), ToxicChat, and Google’s SG Prompt and SG Response sets
- Metric
- Optimal F1 and AU-PRC on an overall yes/no (plain F1 for models without probabilities)
- How it was compared
- Same OpenAI Moderation items, but GPT-4’s score there comes from earlier papers and the report gives no prompt or settings for it. On Google’s own sets both models ran the same way.
On OpenAI Moderation the 2B scored 0.812 against GPT-4’s 0.705, and 0.704 against 0.683 on ToxicChat. On Google’s own prompt set, where both ran the same way, the gap is smaller: 0.825 against 0.810. The report notes that its per-harm comparison favours ShieldGemma, which was trained on data like the test sets while GPT-4 was zero-shot. It reports no cost or latency for either model.
All the numbers
Show all numbersHide all numbersEvery model · Cost, latency and energy · 6 more results
Every model on the headline test
Cost, latency and energy, as reported
- Cost
- Not reported
- Latency
- Not reported
- Energy
- Not reported
More from the source
ShieldGemma 9B on OpenAI Moderation: F1 0.821, AU-PRC 0.907 (GPT-4 AU-PRC not reported)
Small model 0.821Large model 0.705
Table 1
ToxicChat optimal F1: 2B 0.704 (27B 0.729) vs GPT-4 0.683
Small model 0.704Large model 0.683
Table 1
Google’s prompt test set (SG Prompt) optimal F1 / AU-PRC: 2B 0.825 / 0.887 vs GPT-4 0.810 / 0.847
Small model 0.825Large model 0.81
Table 1
Google’s response test set (SG Response) optimal F1 / AU-PRC: 2B 0.743 / 0.802 vs GPT-4 0.713 / 0.749
Small model 0.743Large model 0.713
Table 1
Paper’s summary: the 9B model’s F1 exceeds WildGuard’s and GPT-4’s by 4.3% and 6.4%
Section ‘Overall Binary Classification Results’
Per harm type (AU-PRC, Fig. 3): all ShieldGemma sizes beat GPT-4 ‘by a big margin’; GPT-4 labelled 76% of hate-speech items as harassment
Section ‘Harm Type Level Results’, Figure 3
Worth knowing
- Developer-reported by Google about its own model.
- On the two external benchmarks, GPT-4’s scores are taken from earlier papers, which used their own prompts; they were not re-run in the same harness.
- On Google’s own test sets ShieldGemma was trained on similar data; GPT-4 was zero-shot.
- No cost, latency or energy figures.
1 more caveat
- OpenAI Moderation’s categories differ from ShieldGemma’s policies (e.g. self-harm); Google mapped them to an overall yes/no.
Weights on Hugging Face
Official, gated (Gemma licence). 9B and 27B also on Hugging Face (google/shieldgemma-9b, google/shieldgemma-27b). Verified 03 Oct 2026.
- google/shieldgemma-2bShieldGemma 2B
Sources
- ShieldGemma Team, Google, “ShieldGemma: Generative AI Content Moderation Based on Gemma”, arXiv 2407.21772
- ShieldGemma model card (Google AI for Developers)
- arXiv v1 31 Jul 2024 (2407.21772); v2 4 Aug 2024 used here.