Gemma 3n E2B Aegis Safety PEFT
lightweight prompt safety filter
2 min readupdated
This model checks incoming text prompts for safety and outputs one of two labels: safe or unsafe. It is a compact LoRA adapter (a small add-on on top of a base model) trained by radhikasingh1 on google/gemma-3n-E2B-it using the NVIDIA Aegis AI Content Safety Dataset 2.0. Compared to the original base version, this fine-tuned variant significantly cuts down false positives and improves accuracy when flagging unsafe content. It is a great fit for LLM service developers and AI safety researchers looking for a lightweight pre-moderation layer.
Key features
- Binary prompt classification: outputs strictly
safeorunsafe. - Trained using QLoRA (quantized low-rank fine-tuning) with 4-bit NF4 compression, tailored for the AltUp architecture.
- Slashes the False Positive Rate compared to the base
Gemma 3n E2B— down from 73.17% to 29.27%. - Distributed as a set of LoRA adapters for the PEFT library, meaning you need the original base model to run it.
What you can do
- Integrate it as a lightweight guardrail in front of your main LLM to filter out unsafe user prompts.
- Run initial automated moderation on English text content.
- Use it in AI safety research benchmarks to compare against the base Gemma 3n E2B.
Example
Load the adapter onto the google/gemma-3n-E2B-it base model using the Hugging Face peft library. Pass a user prompt as input, and the model classifies it as either safe or unsafe.
Read more
DetailsTest metrics (E2B_tuned vs baseline): Macro F1 rose from 0.5941 to 0.6345, Precision jumped from 0.6552 to 0.7931, and Accuracy hit 0.60 (compared to 0.68 for the base model).
Inference latency: median (p50) is 574.82 ms, 95th percentile (p95) is 1591.52 ms.
Training: 1 epoch on an NVIDIA Tesla T4 in FP16 with gradient checkpointing; peak training VRAM usage was 8.11 GiB.
Limitations: experimental English-only classifier prone to occasional errors and an unknown response rate of 0.25 — not recommended as a standalone production filter.










Comments