Introduction
Large Language Models (LLMs) are increasingly adopting Mixture-of-Experts (MoE) architectures, such as GPT-4 and DeepSeek, to achieve high performance with computational efficiency. In these models, only a subset of parameters—"experts"—is active for any given input, managed by a gating network. However, researchers from KAIST have uncovered a critical vulnerability: safety alignment in MoEs is "superficial" and can be easily compromised through Harmful Fine-Tuning (HFT).
The Vulnerability: Safety Routing Drift
The core issue identified is safety routing drift. Safety-aligned MoEs typically rely on specific "safety-critical experts" to refuse harmful queries. During fine-tuning—even on benign data—the gating network (the "traffic cop") changes its routing logic. It begins directing harmful prompts away from safety experts and toward general-purpose experts that lack refusal training. This shift effectively bypasses the model's internal safety mechanisms.
SAFEMOE: Aligning the Gating Network
To counter this, the authors developed SAFEMOE, a lightweight defense specifically designed for MoE structures. Unlike traditional defenses that focus on model weights, SAFEMOE focuses on preserving the integrity of routing decisions.
- Routing Regularization: It introduces a loss term based on the KL-divergence between the current model's routing weights and those of the original safe model when processing harmful instructions. This ensures the gating network continues to utilize safety experts for problematic inputs.
- Efficiency via Greedy Optimization: To minimize computational overhead, SAFEMOE uses a "bi-level greedy optimization" approach, applying regularization only every few iterations and utilizing pre-computed anchor weights.
- Layer-Selective Defense: Analysis revealed that routing drift is most severe in the upper layers of the model. SAFEMOE can be applied selectively to these layers to maintain high safety with negligible impact on training speed.
Experimental Results
The researchers evaluated SAFEMOE across eight models ranging from 7B to 141B parameters, including OLMoE, Qwen1.5 MoE, and DeepSeek V2.
Key findings include:
- Massive Safety Gains: In OLMoE, a successful HFT attack spiked the harmfulness score to 62.0. SAFEMOE brought it back down to 5.0.
- Minimal Utility Loss: Fine-tuning accuracy (utility) remained within 1% of standard, undefended fine-tuned models.
- Low Overhead: The method adds only about 2% to total training time, making it highly practical for commercial fine-tuning APIs.
- Scalability: The defense remained effective even on massive models like Mixtral-8x22B and DeepSeek V2, outperforming existing techniques like SafeInstr and SaLoRA.
Conclusion
SAFEMOE demonstrates that defending the structural computation path in MoEs is as vital as defending the weights themselves. By neutralizing safety routing drift, it provides a scalable and efficient safeguard for the next generation of sparse LLMs, ensuring they remain safe even after user-driven fine-tuning.
Summary updated