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 · DOI

Introduction

Vision Large Language Models (VLLMs), such as LLaVA and MiniGPT-v2, have demonstrated remarkable capabilities by integrating visual perception with the reasoning power of Large Language Models (LLMs). However, this integration comes with a hidden security cost. While the base LLMs are typically safety-aligned through extensive human feedback, the subsequent process of multi-modal fine-tuning often causes the model to "forget" these safety guardrails. This paper introduces VLGuard, a compact safety dataset and a highly efficient fine-tuning strategy designed to restore safety alignment in VLLMs with minimal computational overhead and virtually no impact on model helpfulness.

The Problem: Alignment Forgetting

The transition from a text-only LLM to a multi-modal VLLM involves fine-tuning on massive vision-language instruction sets. The authors identify a critical "alignment forgetting" effect where the model's original safety training is compromised. This phenomenon stems from two primary sources:

  1. Stealthy Harmful Content: Standard vision-language datasets often contain unfiltered, harmful content such as derogatory memes or privacy-violating images that are not present in text-only safety corpora.
  2. Modality Overwriting: The act of updating model weights to accommodate visual inputs can overwrite the safety behaviors learned during the initial text-only alignment phase.

As a result, VLLMs become vulnerable to simple jailbreaks and harmful queries that their underlying LLMs would have previously rejected.

The VLGuard Framework

To address this, the authors propose a two-pronged approach to re-align VLLMs using a new dataset and specific fine-tuning strategies.

1. The VLGuard Dataset

VLGuard is a curated dataset consisting of 2,000 training and 1,000 test images. It covers four major risk categories: Privacy, Risky Behavior, Deception, and Hateful Speech. Using GPT-4V, the authors generated high-quality, reasoning-based instruction-response pairs. For every "safe" image, the dataset includes both a standard helpful instruction and a "harmful" instruction. The model is trained to reject the harmful instruction while providing a clear explanation for the refusal.

2. Fine-Tuning Strategies

The authors evaluated two primary methods for integrating VLGuard:

  • Post-hoc Fine-tuning: A pre-trained VLLM undergoes a brief additional training round using VLGuard mixed with a small subset of helpful data (approx. 5,000 samples) to prevent "exaggerated safety" (the tendency to refuse benign requests).
  • Mixed Fine-tuning: VLGuard is integrated directly into the standard VLLM training pipeline from the start.

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

Key Insights and Experimental Results

The LoRA Paradox

One of the most surprising findings is that Parameter-Efficient Fine-Tuning (PEFT) via LoRA often poses a greater safety risk than full fine-tuning. Although LoRA modifies fewer parameters, it appears more effective at rapidly assimilating new patterns, which inadvertently makes it more prone to overwriting prior safety alignments.

Generalization and Helpfulness

Models fine-tuned on VLGuard demonstrated an impressive ability to generalize to unseen harms. For instance, models trained on other safety categories but not specifically on privacy still showed improved safety on privacy-related tasks. Furthermore, adding safety data often improved performance on standard benchmarks like MMLU and ScienceQA, suggesting that learning to distinguish between safe and unsafe contexts enhances the model's overall instruction-following capabilities.

Performance Metrics

The effectiveness of the VLGuard approach is evidenced by drastic reductions in Attack Success Rates (ASR):

  • AdvBench (Suffix Injection): LLaVA-v1.5-7B’s ASR dropped from 78.27% to 0.00% after post-hoc fine-tuning.
  • FigStep (Visual Jailbreak): On benchmarks using images of text to bypass filters, ASR dropped from over 90% to 0% across several models.
  • Minimal Side-Effects: Unlike other safety-tuned models that become overly restrictive, VLGuard-tuned models maintained high scores on the XSTest-Safe benchmark, correctly answering benign questions.

Limitations and Future Work

While VLGuard provides a robust baseline, the authors acknowledge several ongoing challenges. The current dataset size, while effective, could be expanded to cover more diverse adversarial frontiers. Additionally, while the method is highly effective against black-box and prompt-based attacks, models remain vulnerable to white-box adversarial attacks where an attacker has direct access to model weights. As jailbreaking techniques evolve, the safety dataset will require continuous updates to maintain its effectiveness in the ongoing "cat-and-mouse" game of AI safety.

Conclusion

This research demonstrates that safety alignment in VLLMs does not require massive data scaling or significant computational resources. By using a small, high-quality dataset like VLGuard, developers can effectively restore safety guardrails that are lost during multi-modal training, providing a practical and low-cost baseline for the development of secure Vision Large Language Models.

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