TL;DR
This paper introduces ATAC, a novel test-time defense for CLIP that corrects adversarial perturbations directly in the model's embedding space. By analyzing how different augmentations shift embeddings, ATAC infers a "semantic recovery direction" to realign attacked images, achieving state-of-the-art robustness with minimal computational overhead.
What Problem Does This Paper Address?
Vision-language models like CLIP have revolutionized zero-shot image-text tasks, but they are notoriously vulnerable to adversarial attacks. These attacks involve making tiny, imperceptible changes to an image that can cause the model to misclassify it entirely. While adversarial training can improve robustness, it's computationally prohibitive for large foundation models. Existing test-time defenses, which operate during inference without retraining, have shown promise but often fall short in robustness or are computationally expensive. This paper addresses the need for an efficient and highly robust test-time defense for CLIP that can correct adversarial perturbations without compromising clean accuracy.
Methods
ATAC operates in CLIP's embedding space, leveraging the observation that while adversarial perturbations can drastically alter predictions, the embeddings of clean images are relatively stable under standard augmentations (like flips and rotations). The core idea is to:
- Generate Augmented Views: For an input image, ATAC creates multiple augmented versions.
- Compute Embedding Drifts: It then calculates the "drift vectors" – the difference between the original image's embedding and each augmented view's embedding.
- Infer Semantic Recovery Direction: By averaging these drift vectors, ATAC estimates a direction in the embedding space that is likely to lead back to the original, clean semantics.
- Apply Correction with a Gate: The original embedding is corrected by moving it along this inferred direction. A "cosine-consistency gate" is used to control this correction. This gate checks if the drift vectors are consistently pointing in the same direction. If they are, it suggests an adversarial attack, and the correction is applied. If the drifts are scattered (indicating a clean image), the correction is suppressed to preserve clean accuracy.
This approach is training-free and only requires a few forward passes during inference, making it computationally efficient.
Datasets
The paper evaluates ATAC on a wide range of standard image classification benchmarks, including:
- CIFAR-10
- CIFAR-100
- STL-10
- Caltech-101
- Caltech-256
- OxfordPets
- Flowers-102
- FGVC Aircraft
- StanfordCars
- Country211
- Food-101
- EuroSAT
- DTD
These datasets cover general object recognition, fine-grained recognition, scene recognition, and domain-specific tasks.
Key Insights and Ideas
- Embedding Stability is Key: The core insight is that adversarial perturbations are disruptive, but standard augmentations reveal a stable underlying semantic structure in CLIP's embeddings. ATAC exploits this difference.
- Drift Vectors as Semantic Guides: The direction of embedding drift under augmentations can act as a powerful signal to infer the "correct" semantic direction for an attacked image.
- Cosine Consistency as a Detector: The angular consistency of these drift vectors serves as an effective, albeit implicit, detector for adversarial attacks.
- Direct Embedding Correction is Powerful: Unlike methods that modify inputs or prompts, ATAC directly manipulates embeddings, offering a novel and efficient defense paradigm.
- Label-Dependent Attacks Have a Weakness: The paper reveals that many gradient-based attacks rely heavily on the true label, creating predictable embedding shifts that ATAC can exploit. However, ATAC remains robust even when this reliance is reduced.
Key Results
- State-of-the-Art Robustness: ATAC consistently achieves the highest robust accuracy across 13 datasets, outperforming previous state-of-the-art test-time defenses by nearly 50% on average.
- Minimal Computational Overhead: ATAC requires only a few additional forward passes per image, making it significantly more efficient than many other test-time defenses. Its inference time is comparable to the original CLIP model.
- Robustness Against Diverse Attacks: ATAC demonstrates strong performance against standard PGD attacks, as well as more challenging scenarios like AutoAttack and Carlini-Wagner attacks, even with larger perturbation budgets.
- Nontrivial Robustness Against Adaptive Attacks: The method shows resilience even against adaptive attacks specifically designed to bypass it, retaining significant robustness.
- Robustness-Accuracy Trade-off: While ATAC slightly impacts clean accuracy, its robust accuracy often surpasses its own clean accuracy and even that of undefended CLIP, a phenomenon attributed to its ability to exploit attack weaknesses.
Limitations and Future Work
- Robustness-Accuracy Trade-off: ATAC does incur a slight decrease in clean accuracy, which is typical for adversarial defense methods.
- Augmentation Sensitivity: While ATAC is effective with a small number of augmentations, the paper notes that certain types of augmentations (e.g., color jitter) are less effective, suggesting a reliance on label-preserving transformations.
- Future Work: The authors suggest exploring combinations of ATAC with other defenses and extending the paradigm of correcting adversarial samples directly in feature space. They also propose further investigation into adaptive attacks and the role of label-dependent information in attacks.
Summary updated