Steering Multimodal Large Language Models Decoding for Context-Aware Safety

Zheyuan Liu, Zhangchen Xu, Guangyao Dou, Xiangchi Yuan, Zhaoxuan Tan, Radha Poovendran, Meng Jiang · DOI

Introduction

Multimodal Large Language Models (MLLMs) have demonstrated remarkable capabilities in integrating visual and textual information. However, ensuring their safety remains a significant challenge. Current models often exhibit a "safety duality": they are either undersensitive, failing to recognize situational risks depicted in images, or oversensitive, refusing benign requests due to misinterpreted visual cues. To address this, researchers have developed SafeCoDe (Safety-aware Contrastive Decoding), a model-agnostic framework designed to achieve context-aware safety by steering the model's decoding process based on visual evidence.

The Safety Duality Problem

The core issue in MLLM safety is often rooted in unimodal bias. Models frequently rely on textual priors while treating visual input as secondary. This leads to two distinct failure modes:

  1. Undersensitivity: A model might provide instructions on swinging a baseball bat with full force because the text query is harmless, ignoring an image showing the user is in a cramped, indoor office.
  2. Oversensitivity: A model might refuse to describe a parade because it misidentifies musical instruments as weapons, triggered by rigid safety alignments that lack nuance.
Figure 1: Illustration of undersensitivity and oversensitivity in MLLMs, showing how models fail to align textual intent with visual context.

Diagnostic tests involving "blank images" reveal that base MLLMs often maintain similar refusal rates regardless of the visual context, confirming that safety mechanisms are frequently "blind" to the actual scene.

Methodology: SafeCoDe

SafeCoDe addresses these issues at the inference stage through a two-step decoding process that requires no expensive retraining or fine-tuning.

1. Contrastive Decoding Initialization

To ensure the model prioritizes visual information, SafeCoDe compares the probability scores (logits) generated using the original image against those generated using a version blurred with Gaussian noise. This contrast highlights "visually sensitive" tokens—words the model considers specifically due to details in the scene—thereby anchoring the response in visual reality.

2. Global-Aware Token Modulation

The framework employs a high-capacity MLLM (such as GPT-4o) as a "Global Judge" to evaluate the safety of the query-image pair. Based on this binary verdict:

  • If Unsafe: The system boosts the probability of refusal tokens (e.g., "I'm sorry") during the initial steps of generation.
  • If Safe: It suppresses these tokens to prevent false refusals.

By modulating only the first 2–5 tokens, SafeCoDe "seeds" the correct safety stance while allowing the model to remain fluent and helpful for the remainder of the output.

Experimental Evaluation

SafeCoDe was evaluated across several benchmarks, including MSSBench (situational risks), MOSSBench (oversensitivity), and adversarial suites like MM-SafetyBench and FigStep. Testing on backbones such as LLaVA, Qwen, and InstructionBlip yielded several key results:

  • Balanced Safety: SafeCoDe simultaneously reduced undersensitivity and oversensitivity. On LLaVA-1.6-7B, it improved accuracy on unsafe cases while lowering unnecessary rejections on benign prompts.
  • Jailbreak Resilience: The framework effectively neutralized "FigStep" attacks—where harmful instructions are embedded as text within images—reducing the Attack Success Rate (ASR) to near zero.
  • Utility Preservation: Evaluations on general benchmarks (MMMU, MathVista) showed that SafeCoDe maintains or slightly enhances model intelligence, consistently outperforming baseline safety methods on the Pareto frontier of safety versus utility.

Discussion and Future Work

While SafeCoDe offers a flexible and efficient solution for context-aware safety, it currently requires access to internal model logits, which limits its application to open-source models rather than black-box APIs. Additionally, while the system is adept at refusing unsafe requests, the responses can be blunt; future iterations could focus on providing more explanatory refusals. The researchers also aim to explore smaller, specialized "safety-expert" models to replace the large auxiliary judge, further improving efficiency.

Summary updated

BibTeX
@misc{liu2025steering,
  author = {Zheyuan Liu and Zhangchen Xu and Guangyao Dou and Xiangchi Yuan and Zhaoxuan Tan and Radha Poovendran and Meng Jiang},
  title = {{Steering Multimodal Large Language Models Decoding for Context-Aware Safety}},
  year = {2025},
  eprint = {2509.19212},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.19212},
}
Figure