Safety_Tuning-Qwen3.5-4B-Base-GRPO
Qwen 3.5 Safety-Tuned Checkpoint
2 min readupdated
An intermediate 4.66-billion-parameter checkpoint of the Qwen/Qwen3.5-4B-Base language model by author thkim0305-SNU, fine-tuned for safe behavior and correct tool calling. Training was performed using GRPO (Group Relative Policy Optimization) with binary evaluation from a Qwen3.8-27B judge model. Only the text part was fine-tuned, so the vision tower and MTP head remain untouched from the base, and the model runs via standard transformers. It suits alignment researchers, AI agent developers, and those testing compact LLM resilience against malicious prompts and jailbreaks.
Key features
- Support for the reasoning mode (
enable_thinking=true) in the Qwen chat template and function calling in theqwen3_coderformat. - Trained on the
mixture-8dataset of 11,794 unique prompts, including 4,000 multi-step scenarios with a tool simulator (AgentAlign) and code safety tasks (CodeSafetyBench). - Responses were evaluated by the Qwen3.8-27B judge model using a strict binary criterion (0 or 1), including verification of the entire tool calling chain.
- Full compatibility with the base
Qwen3_5ForConditionalGenerationarchitecture inbf16format is preserved.
What you can do
- Compare the behavior of the model at step 760 with the original Qwen/Qwen3.5-4B-Base on tasks with provocative prompts and jailbreaks.
- Use in AI agent experiments to test how RL training affects the safety of multi-step function calling.
- Apply to safe code generation and analysis tasks leveraging the included reasoning mode.
Example
from transformers import AutoTokenizer, Qwen3_5ForConditionalGeneration
model_id = "thkim0305-SNU/Safety_Tuning-Qwen3.5-4B-Base-GRPO-Mixture8-binary-lr2e-6-kl0.001-p15-k8-resume80-step760"
tok = AutoTokenizer.from_pretrained(model_id)
model = Qwen3_5ForConditionalGeneration.from_pretrained(model_id, dtype="bfloat16", device_map="auto")
messages = [{"role": "user", "content": "Explain why phishing emails are dangerous."}]
text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=True)
out = model.generate(**tok(text, return_tensors="pt").to(model.device), max_new_tokens=512)
print(tok.decode(out[0], skip_special_tokens=True))
Read more
DetailsThe average judge score at steps 750–760 was 0.805 (on
star1_gp3 — 1.00, star_benign_v2 — 0.90, agentalign_harmful — 0.88, difficult_advice — 0.88, codesafetybench — 0.86).The context window is up to 40,960 tokens, and generation during training was up to 32,768 tokens.
Training was performed on 1× NVIDIA B200 (Slime + Megatron-LM frameworks), and the judge model ran on 2× A100.
Limitation: this is an intermediate snapshot at step 760 out of 787 planned, so training is not yet finished.










Comments