TL;DR
DiffCAP introduces a dynamic, image-adaptive adversarial purification strategy for Vision Language Models (VLMs) using diffusion models. By tracking when a noised image's VLM embeddings stabilize, it automatically finds the minimum necessary noise injection required to neutralize an attack before reconstructing a clean image. This approach eliminates tedious hyperparameter tuning, cuts purification time in half compared to fixed-time methods, and significantly outperforms existing defenses.
What Problem Does This Paper Address?
Vision Language Models (VLMs) like LLaVA and OpenFlamingo excel at multimodal tasks but remain highly vulnerable to adversarial attacks—imperceptible tweaks to an image that can trick the model into generating completely incorrect or malicious text.
Current defense strategies fall into two camps, both with major drawbacks:
- Adversarial Training: Fine-tuning the VLM on perturbed data is computationally expensive and generalizes poorly to new, unseen attack types.
- Adversarial Purification: Using generative models (like diffusion models) to wipe out perturbations before the image hits the VLM. However, existing methods use a fixed diffusion time for every image. This leads to a nasty trade-off: too little noise fails to remove strong attacks (under-purification), while too much noise destroys the image's natural details and hurts performance on clean images (over-purification).
Methods
The authors introduce DiffCAP (Diffusion-based Cumulative Adversarial Purification), a "plug-and-play" defense that dynamically calculates the optimal noise level for each individual input image.
As illustrated in Figure 1, the pipeline operates through a loop:
- Cumulative Noise Injection: Random Gaussian noise is added to the adversarial image step-by-step.
- Embedding Stability Check: At each step, the image is passed through the VLM's frozen vision encoder to extract its semantic embedding ($e_{curr}$).
- Adaptive Stopping Criterion: DiffCAP computes the cosine similarity between the current embedding and the previous step's embedding ($e_{prev}$). If the similarity meets or exceeds a calibrated threshold ($\tau$), it signals that the adversarial perturbation has faded and the semantic representation has stabilized.
- Reverse Diffusion: The process exits the loop, and a pretrained diffusion model denoises the stabilized image, restoring a clean, reliable representation for VLM inference.
The threshold $\tau$ is computed beforehand using a small calibration set of clean-adversarial image pairs, finding the exact point where the embedding distributions of clean and attacked images become statistically indistinguishable.
Datasets
The authors evaluated DiffCAP across three distinct task scenarios using standard benchmarks:
- Image Captioning (IC): COCO and Flickr30k.
- Visual Question Answering (VQA): VQAv2 and TextVQA.
- Zero-Shot Classification (ZSC): CalTech101 and ImageNet-R.
- Out-of-Distribution (OOD) Testing: MNIST and ImageNet-S (Sketch) were used to verify the robustness of the threshold under severe domain shifts.
Key Insights and Ideas
- Adversarial Fading is Monotonic: The authors mathematically prove that adversarial effects monotonically fade as forward diffusion progresses. This guarantees the existence of a "provable recovery region" where the image can be successfully restored.
- Embeddings as a Thermometer: Instead of guessing how much noise to add in pixel space, DiffCAP uses the VLM’s own latent space to measure when the attack has been neutralized. When consecutive embeddings stop changing drastically, the defense knows it's safe to stop.
- Semantic Complexity Dictates Noise Needs: The adaptive threshold naturally adjusts to image complexity. Images with rich semantics (colorful photos) stabilize faster and require less noise injection, whereas sparse semantics (black-and-white sketches) take longer to reach the recovery region.
Key Results
- Superior Robustness: On the Image Captioning task under an $\ell_\infty^{2/255}$ attack, LLaVA 1.5-7B without defense drops to a CIDEr score of 4.0 on the COCO dataset. DiffCAP restores this to 119.6, outperforming the popular fixed-time baseline DiffPure (108.4).
- Fidelity Preservation: Unlike adversarial training methods that degrade performance on clean data, DiffCAP maintains or even slightly improves the VLM's accuracy on unperturbed, clean images.
- Substantial Speedups: Because it dynamically minimizes the number of forward noise steps, DiffCAP cuts the average purification time per image from ~2.3 seconds (DiffPure) down to ~1.1 seconds, making it far more practical for real-world deployment.
- Resilience to Adaptive Attacks: DiffCAP remains highly effective even when evaluated against strong white-box adaptive attacks like Backward Pass Differentiable Approximation (BPDA) and Expectation Over Transformations (EOT).
Limitations and Future Work
The primary limitation acknowledged by the authors is DiffCAP's current reliance strictly on image-based diffusion models. While highly effective at securing the visual modality, it does not address adversarial vulnerabilities within the text modality or joint vision-text threats (such as malicious text prompts combined with adversarial images).
The authors point to extending this cumulative purification framework to text or multimodal diffusion processes as a promising direction for future work.
Summary updated