Safety Fine-Tuning at (Almost) No Cost: A Baseline for Vision Large Language Models

Yongshuo Zong, Ondrej Bohdal, Tingyang Yu, Yongxin Yang, Timothy M. Hospedales

TL;DR

Vision Large Language Models (VLLMs) often "forget" the safety training of their underlying text-only models during multi-modal fine-tuning. This paper introduces VLGuard, a compact safety dataset and a "plug-and-play" fine-tuning strategy that restores safety alignment with minimal computational overhead and virtually no loss in model helpfulness.

What Problem Does This Paper Address?

Modern VLLMs (like LLaVA or MiniGPT-v2) are built by taking a safety-aligned Large Language Model (LLM) and fine-tuning it on vision-language data. However, the authors discover a critical "alignment forgetting" effect: the process of teaching a model to understand images often breaks the safety guardrails established during its initial text-only training.

This happens for two reasons. First, standard vision-language instruction sets often contain "stealthy" harmful content (e.g., derogatory memes or privacy-violating images) that hasn't been properly filtered. Second, the sheer act of updating weights to accommodate a new modality (vision) can overwrite the safety behaviors learned in the previous modality (text). Consequently, VLLMs become susceptible to simple jailbreaks and harmful queries that their base LLMs would have easily rejected.

Methods

The authors propose a two-pronged approach to "re-align" VLLMs:

  1. VLGuard Dataset Creation: They curated a diverse dataset of 2,000 training and 1,000 test images covering four major risk categories: Privacy, Risky Behavior, Deception, and Hateful Speech. They used GPT-4V to generate high-quality, reasoning-based instruction-response pairs. For a "safe" image, the dataset includes both a standard helpful instruction and a "harmful" instruction that the model is taught to reject with an explanation.
  2. Safety Fine-Tuning Strategies:
    • Post-hoc Fine-tuning: Taking a pre-trained VLLM and performing a brief round of additional training using VLGuard mixed with a small amount (5,000 samples) of helpful data to prevent "exaggerated safety" (refusing everything).
  3. Mixed Fine-tuning: Integrating VLGuard directly into the standard VLLM training pipeline.

Crucially, because the safety dataset is small (only 0.1% to 0.3% of typical training sets), the computational cost is negligible—often requiring less than one hour on standard hardware.

Datasets

  • VLGuard (New): The core contribution, featuring 3,000 images (2k train / 1k test) with paired safe/unsafe instructions.
  • Safety Evaluation: The authors used AdvBench (harmful prompts), XSTest (exaggerated safety test), and FigStep (a vision-based jailbreak benchmark).
  • Helpfulness Evaluation: To ensure the models didn't get "dumber," they tested on MMLU, AlpacaEval 2.0, VizWiz, ScienceQA, MMBench, and MM-Vet.

Key Insights and Ideas

  • The LoRA Paradox: Surprisingly, the authors found that Parameter-Efficient Fine-Tuning (PEFT) via LoRA often poses a greater safety risk than full fine-tuning. While LoRA changes fewer parameters, it appears more effective at quickly assimilating new (potentially harmful) data patterns, making it more prone to overwriting prior safety alignments.
  • Data Cleaning Isn't Enough: Simply removing harmful samples from existing training sets only partially restores safety. Explicit "negative" examples (teaching the model why to refuse) are necessary to build robust guardrails.
  • Generalization to Unseen Harms: Models fine-tuned on VLGuard showed an ability to generalize. For example, a model trained on other safety categories but not privacy still showed improved safety on privacy-related tasks, suggesting the model learns a broader "refusal" heuristic.
  • Helpfulness Synergy: In many cases, adding safety data actually improved the model’s performance on standard benchmarks. This suggests that learning to distinguish between safe and unsafe contexts helps the model better understand instructions overall.

Key Results

  • Drastic ASR Reduction: On the AdvBench (Suffix Injection) attack, LLaVA-v1.5-7B’s Attack Success Rate (ASR) dropped from 78.27% to 0.00% after post-hoc fine-tuning.
  • Defeating Visual Jailbreaks: On the FigStep benchmark (which uses images of text to bypass filters), ASR dropped from over 90% to 0% for several models.
  • Minimal "Refusal" Side-Effects: Unlike some safety-tuned models that become overly "preachy" or refuse safe tasks, the VLGuard-tuned models maintained high scores on XSTest-Safe, correctly answering benign questions that superficially resemble harmful ones.
  • Efficiency: The alignment was achieved with only 2,000 safety samples, proving that safety doesn't require massive data scaling.

Limitations and Future Work

  • Scale of Dataset: While 2,000 images are effective, the authors acknowledge that a larger, more diverse training set would likely be even more robust.
  • White-Box Vulnerability: While the method is highly effective against black-box and prompt-based attacks, the authors note that models remain vulnerable to sophisticated white-box adversarial attacks where the attacker has access to the model's internal weights.
  • The "Cat-and-Mouse" Game: As jailbreaking techniques evolve (e.g., more complex multi-modal attacks), the safety dataset will need continuous updates to cover new adversarial frontiers.

Summary updated

BibTeX
@inproceedings{zong2024safety,
  author = {Yongshuo Zong and Ondrej Bohdal and Tingyang Yu and Yongxin Yang and Timothy M. Hospedales},
  title = {{Safety Fine-Tuning at (Almost) No Cost: A Baseline for Vision Large Language Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=bWZKvF0g7G},
}
Figure