Enhancing the Safety of Medical Vision-Language Models by Synthetic Demonstrations

Zhiyu Xue, Reza Abbasi-Asl, Ramtin Pedarsani · DOI

Introduction

Generative Medical Vision-Language Models (Med-VLMs) are increasingly utilized for diagnostic support and clinical report generation. Despite their utility, these models are susceptible to security vulnerabilities that can compromise patient safety and institutional integrity. This paper explores a novel inference-time defense strategy using synthetic demonstrations to enhance model robustness without the need for costly retraining.

The Dual Security Crisis in Med-VLMs

Med-VLMs face two primary security challenges:

  1. Jailbreak Attacks: Malicious prompts, whether textual or visual, can manipulate the model into providing harmful information, such as instructions for insurance fraud or unauthorized medical procedures.
  2. Over-Defense: Standard safety alignment often leads to "lazy" models that refuse legitimate clinical queries (e.g., "What does this MRI show?") due to an over-sensitivity to perceived risks.

Traditional solutions involve fine-tuning on large, expert-curated datasets, which is resource-intensive and slow.

Methodology: Synthetic Demonstration Generation

The proposed defense utilizes In-Context Learning (ICL) to steer model behavior at inference time. The core of this approach is the Synthetic Demonstration Generation pipeline, which creates examples for the model to follow within its prompt.

Overview of the synthetic demonstration generation and in-context learning defense pipeline.

The pipeline consists of three main components:

  • Benign-Affirmative (B-A) Demonstrations: A safety-aligned LLM (e.g., GPT-4o) generates pairs of legitimate medical questions and accurate, helpful answers based on various imaging modalities.
  • Harmful-Refusal (H-R) Demonstrations: To simulate adversarial scenarios, an unaligned model (e.g., WizardLM-13B) generates harmful queries. These are then paired with standard refusal responses to teach the model how to reject malicious requests.
  • Mixed Demonstration Strategy: By combining B-A and H-R demonstrations, the researchers introduce a tunable mixing ratio ($\alpha$). This allows for a balance between safety (refusing harm) and utility (answering benign queries), effectively mitigating over-defense.
Examples of Harmful-Refusal (H-R) and Benign-Affirmative (B-A) synthetic demonstrations.

Experimental Setup and Datasets

The defense was evaluated using the O2M benchmark, which includes 660 medical images across nine modalities (CT, MRI, X-ray, etc.) and various anatomical regions. The benchmark provides a balanced set of harmful and benign clinical queries to test both safety and utility.

Results and Discussion

Testing on state-of-the-art models like Llava-Med-v1 and Llava-Med-v1.5 yielded significant improvements:

  • Safety Enhancement: For Llava-Med-v1, the Attack Success Rate (ASR) for harmful queries plummeted from a baseline of 72.58% to 13.43% when using H-R demonstrations.
  • Utility Preservation: The mixed strategy maintained a low Refusal Rate (RR) for benign queries (1-3%), ensuring the model remained a helpful clinical assistant.
  • Robustness: The method proved resilient against sophisticated jailbreak techniques, including visual perturbations (PGD) and complex textual templates.

Mathematically, providing refusal demonstrations "smooths" the loss landscape, making it harder for optimization-based attacks to find vulnerabilities. Furthermore, increasing the number of demonstrations ($n$) generally improves performance, though it is constrained by the model's context window.

Conclusion and Future Work

This research demonstrates that synthetic demonstrations are a viable, "plug-and-play" defense mechanism for Med-VLMs. By leveraging LLMs to "self-police," developers can create safer medical AI without the overhead of expert-led fine-tuning. Future work will focus on adaptive demonstration selection to tailor defenses to specific image types or query contexts and addressing potential biases in synthetic data.

Summary updated

BibTeX
@inproceedings{xue2026enhancing,
  author = {Zhiyu Xue and Reza Abbasi-Asl and Ramtin Pedarsani},
  title = {{Enhancing the Safety of Medical Vision-Language Models by Synthetic Demonstrations}},
  booktitle = {EACL (Volume 1: Long Papers)},
  year = {2026},
  doi = {10.18653/v1/2026.eacl-long.197},
}
Figure