Introduction
Large Language Models (LLMs) have achieved significant success in safety alignment, effectively refusing harmful text-based requests. However, Vision Language Models (VLMs) introduce a "visual loophole": malicious intent can be embedded within the visual modality to bypass safety guards. For instance, a model might refuse a text-only prompt for dangerous instructions but comply when the same intent is presented via an image. Existing defenses often rely on external guardrail models, which introduce computational overhead and can degrade general performance. This paper introduces SafeVLM, a modular defense strategy designed to align the visual modality internally and progressively.
The SafeVLM Framework
SafeVLM addresses the visual loophole by integrating three lightweight components into existing VLM architectures, such as LLaVA.
The architecture consists of:
- Safety Projector: A module that extracts risk-related features from the vision encoder in parallel with the standard visual projector.
- Safety Tokens: Trainable embeddings that signal the presence of risky content to the LLM.
- Safety Head: A classification layer that uses cross-attention with text to predict the risk type (e.g., Pornography, Politics) and level (0-3).
Training is conducted in two stages. In Stage I, the LLM and Vision Encoder are frozen while the safety modules are trained to categorize image risks. In Stage II, the safety modules are frozen, and the LLM is fine-tuned (using LoRA) to incorporate these safety signals into its final response generation.
Datasets and Risk Categories
To ensure robust alignment, the researchers curated a dataset covering six primary risk categories: Politics, Illegal Risk, Insults/Bullying, Fairness, Privacy, and Misleading Content.
The training set combined approximately 11,000 risky image-text pairs from sources like RTVLM and AdvBench with "clean" data from ShareGPT4V and COCO. This balanced approach prevents "catastrophic forgetting" of general reasoning capabilities.
Experimental Results
SafeVLM, built upon LLaVA-v1.5-7B, demonstrates superior safety performance. On the Red Teaming Visual Language Models (RTVLM) benchmark, it achieved a safety score of 8.26, surpassing GPT-4V (7.92) and the baseline LLaVA (6.39). The Safety Head showed high reliability, with F1-scores ranging from 0.92 to 0.99 for risk classification. Notably, the model maintained its general intelligence, with slight performance improvements on benchmarks like MMBench, suggesting that safety alignment does not necessarily impose a "safety tax" on performance.
Conclusion and Future Work
SafeVLM effectively closes the visual loophole in VLMs through internal, modular alignment. While the model shows high precision, challenges remain regarding over-refusal of non-threatening content and potential vulnerability to sophisticated pixel-level adversarial attacks. Future research will focus on refining risk assessment to better balance safety with helpfulness.
Summary updated