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

Zhiyu Xue, Reza Abbasi-Asl, Ramtin Pedarsani

TL;DR

Researchers have developed a way to make medical AI assistants safer without needing expensive human experts to retrain them. By using "synthetic demonstrations"—AI-generated examples of how to correctly answer medical questions and how to refuse harmful ones—they can steer models to block jailbreak attacks while still providing helpful clinical advice at inference time.

What Problem Does This Paper Address?

Generative Medical Vision-Language Models (Med-VLMs) are becoming powerful tools for diagnostic support and report generation. However, they face a dual security crisis. First, they are vulnerable to jailbreak attacks: malicious prompts (textual or visual) that trick the AI into providing harmful information, such as instructions for committing insurance fraud using a CT scan.

Second, current safety measures often suffer from over-defense. When a model is tuned to be "safe," it often becomes "lazy" or "paranoid," refusing to answer perfectly legitimate medical questions (e.g., "What does this MRI show?") because it misidentifies them as risky. Traditionally, fixing this requires fine-tuning on massive, high-quality datasets curated by medical professionals—an incredibly slow and expensive process.

Methods

The authors propose an inference-time defense strategy using In-Context Learning (ICL). Instead of retraining the model, they provide it with a few "demonstrations" (examples) right in the prompt.

The core innovation is the Synthetic Demonstration Generation pipeline:

  1. Benign-Affirmative (B-A) Demos: They use a safety-aligned LLM (GPT-4o) to generate pairs of legitimate medical questions and helpful, accurate answers based on various imaging modalities.
  2. Harmful-Refusal (H-R) Demos: Since aligned models refuse to generate harmful queries, the authors use an unaligned model (WizardLM-13B) to generate "bad" questions (e.g., "How can I fake an illness?"). They then pair these with a standard refusal response ("I cannot provide specific advice on how to fake an illness...").
  3. Mixed Demonstration Strategy: To solve the over-defense problem, they combine these two types. By adjusting a mixing ratio ($\alpha$), they can control the balance between safety (refusing the bad) and utility (answering the good).

This approach is "plug-and-play," requiring no parameter updates to the underlying Med-VLM.

Datasets

The study utilizes the O2M benchmark, a dataset specifically designed to test the safety of medical multimodal models. It includes:

  • 660 medical images spanning nine modalities (CT, MRI, X-ray, Ultrasound, etc.) and various anatomical regions (chest, brain, skin, etc.).
  • A balanced set of harmful and benign clinical queries related to each image.

Key Insights and Ideas

  • Safety is a "Knob," not a Binary: By using a mixed demonstration strategy, the researchers turned safety into a tunable hyperparameter ($\alpha$). This allows clinicians or developers to find the "sweet spot" where the model is secure but still useful.
  • LLMs can "Self-Police": The paper proves that you don't need a human doctor to write safety examples. Aligned and unaligned LLMs can simulate the "adversary" and the "guardian" well enough to teach a Med-VLM how to behave.
  • ICL Changes the "Loss Landscape": The authors found that providing refusal demonstrations actually makes it mathematically harder for optimization-based attacks (like PGD) to find a "hole" in the model's defenses. It effectively "smooths out" the landscape the attacker is trying to navigate.
  • Budget Matters: Increasing the number of demonstrations ($n$) generally improves performance and reduces over-defense, though it consumes more of the model's context window.

Key Results

The defense was tested on two state-of-the-art models: Llava-Med-v1 and Llava-Med-v1.5.

  • Massive Safety Boost: For Llava-Med-v1, the Attack Success Rate (ASR) on harmful queries dropped from 72.58% (baseline) to as low as 13.43% using H-R demonstrations.
  • Mitigating Over-Defense: Without the mixed strategy, safety-focused models often rejected benign queries. By adding B-A demonstrations, they kept the Refusal Rate (RR) for benign queries very low (around 1-3%), ensuring the model remained helpful.
  • Resilience to Jailbreaks: The method proved effective against sophisticated attacks, including visual perturbations (PGD) and textual templates (AIM, Refusal Suppression).

Limitations and Future Work

  • Synthetic Noise: The demonstrations rely on the quality of the underlying LLMs. If the generating model has biases or medical inaccuracies, those could propagate into the defense.
  • Nuance Gap: Synthetic examples might not capture the extremely nuanced reasoning of a human clinician in "edge cases" or highly specialized medical fields.
  • Context Window Constraints: As the "budget" of demonstrations increases, it uses up more of the model's memory (tokens), which could be a limitation for very long clinical conversations.
  • Future Direction: The authors suggest exploring adaptive demonstration selection, where the AI chooses which examples to show based on the specific type of image or query it receives.

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