Qwen3 Guard LoRA - prompt security classifier
1 min readupdated
This adapter (a lightweight add-on over the base model) is trained to classify user requests as safe (SAFE) or unsafe (UNSAFE), including jailbreak attempts and prompt injections. The model is based on the compact language model Qwen/Qwen3-0.6B and trained using SFT on a dataset of 2,891 examples. It helps effectively protect text pipelines and chatbots from malicious user instructions.
Key features
- Built on the lightweight Qwen3-0.6B with LoRA parameters r=16 and alpha=32.
- Trained to detect jailbreaks, prompt injections, and malicious requests.
- Evaluated on test splits and datasets like CircleGuardBench.
- Trained in just 22 minutes on a T4 GPU.
What you can do
- Integrate into text pipelines to filter incoming user requests.
- Apply in Qwen-based chatbots to prevent bypassing safety instructions.
- Use for automated security audits of incoming prompts.
Example
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
tok = AutoTokenizer.from_pretrained("Yiruama/qwen3-0.6b-guard-lora")
model = PeftModel.from_pretrained(AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-0.6B"), "Yiruama/qwen3-0.6b-guard-lora")
Read more
DetailsBenchmarks (F1 on test_set): Qwen3-0.6B + LoRA shows 89.0%, outperforming Llama Guard 3 1B (64.5%) and ProtectAI DeBERTa v2 (70.2%).
Latency: 126.9 ms.
Limitations: only prompt classification is evaluated; model response moderation was not tested.










Comments