Vision-Language Models (VLMs) like CLIP have revolutionized how AI understands the relationship between images and text. However, these models share a common Achilles' heel: they are remarkably fragile when faced with adversarial attacks—tiny, imperceptible pixel tweaks that can trick a model into completely misclassifying an image.
While adversarial training (exposing models to "broken" images during training) can defend against these attacks, doing this for massive VLMs is computationally exhausting. A new approach, DEFEAT (Discrete LatEnt FeaturE based Adversarial Training), introduces a parameter-efficient framework that makes these models robust without breaking the bank.
The Vulnerability of Continuous Features
The current standard for adapting large models efficiently is Prompt Tuning—instead of retraining the entire model, only a small set of "prompt" vectors is trained. While highly efficient, prompt tuning is notoriously bad at defending against adversarial attacks.
The core culprit is continuous feature representations. In a standard VLM, image features exist in a high-dimensional continuous space. An attacker only needs to nudge these features slightly to cross a decision boundary. Because the space is continuous, even a tiny nudge results in a fundamentally different feature representation. DEFEAT seeks to make this feature space "stiff" enough that small perturbations cannot change the underlying representation.
The DEFEAT Framework
To mitigate this vulnerability, the researchers propose a module called the PerturbShield, which integrates directly into the VLM architecture. Its core components include:
- Grid-based Discrete Reconstruction: Instead of using raw continuous features from the image encoder, DEFEAT employs a Vector Quantized Variational Autoencoder (VQ-VAE). This module takes the image features and maps them to the nearest entries in a fixed "codebook" of discrete vectors.
- Semantic Alignment Projection: To ensure these new discrete features still align with the rest of the CLIP model, a learnable projection matrix aligns them with the original CLIP embedding space.
- Logits Fusion: Discretization can sometimes discard too much information, hurting accuracy on clean images. DEFEAT solves this by fusing the predictions from the "shielded" branch with the original branch, balancing safety and performance.
- Prompt Alignment Regularization: During training, the system ensures that learnable prompts do not drift too far from human-readable "hand-crafted" prompts, helping the model generalize better to new data.
Key Insights: Discretization as a Filter
The most striking finding of the paper is that mapping features to a discrete codebook acts as a natural adversarial filter. If an attacker's perturbation is smaller than the distance between codes in the codebook, the VQ-VAE will simply map the "attacked" feature back to the same discrete code as the "clean" feature. The attack is effectively erased.
Furthermore, the authors found that discretizing the grid features (spatial patches of the image) is much more effective than discretizing the single global class token. The grid provides more "slots" for information, preventing the massive information loss that usually plagues discrete models.
Experimental Results
The authors conducted an exhaustive evaluation across 15 different datasets, including 11 core classification datasets (like ImageNet, Caltech101, and OxfordPets) and 4 Out-of-Distribution (OOD) variants to test real-world distribution shifts.
DEFEAT consistently outperformed existing adversarial prompt tuning methods (like APT and FAP) across almost every metric:
- Few-Shot Performance: In 16-shot classification, DEFEAT improved the harmonic mean of accuracy and robustness by an average of 13.76% over the previous best method.
- Robustness Gains: On the EuroSAT dataset, DEFEAT achieved a robustness score of 54.65%, compared to just 11.21% for standard CLIP.
- Generalization: The model showed superior performance in "cross-dataset" settings, meaning a model trained on ImageNet remained robust when tested on completely different datasets like Flowers or Aircraft.
- Efficiency: DEFEAT achieves its robustness while remaining highly efficient. It requires significantly less memory than competing methods and adds only a negligible 0.15ms of latency during inference.
Limitations and Future Work
While highly effective, DEFEAT performs best when paired with a visual backbone that has already undergone some form of robust pre-training. While it improves non-robust backbones, the performance ceiling is lower. Additionally, the model's stability is tied to the quality of the VQ-VAE codebook. Future work could explore dynamically evolving codebooks that adapt to specific downstream tasks, further bridging the gap between efficiency and bulletproof adversarial robustness.
Summary updated