Abstract
Vision-Language Models (VLPs) like CLIP demonstrate impressive zero-shot capabilities but remain highly susceptible to adversarial perturbations. While test-time defenses offer a promising alternative to costly adversarial training, current methods often suffer from "narrowness," overfitting to specific gradient directions. We present Directional Orthogonal Counterattack (DOC), a parameter-free test-time defense that enhances robustness by diversifying counter-perturbations through orthogonal exploration and a novel sensitivity metric. Our approach significantly improves robust accuracy across 16 datasets without requiring model retraining.
Introduction
Adversarial attacks pose a significant threat to the deployment of Vision-Language Models. Even minor, imperceptible changes to an input image can lead to incorrect classifications. Existing defenses typically involve adversarial fine-tuning—which is computationally intensive and can degrade clean performance—or test-time defenses that modify the input during inference.
A leading test-time method, Test-Time Counterattack (TTC), generates a counter-perturbation to shift the input away from its adversarial representation. However, TTC's reliance on standard gradients limits its effectiveness against diverse attack strategies. We identify this as a "narrowness" problem, where the defense fails to generalize beyond the specific optimization path of the attack.
Methodology: Directional Orthogonal Counterattack (DOC)
DOC addresses the limitations of previous methods through two primary innovations designed to broaden the search space for effective counter-perturbations.
Orthogonal Gradient Augmentation (OGA)
To prevent the defense from becoming trapped in narrow local optima, DOC employs Orthogonal Gradient Augmentation. During the optimization of the counter-perturbation, a randomized component is added that is mathematically orthogonal to the primary gradient. This forces the optimization to explore a wider "counterattack space," creating a more diverse and robust set of defenses that are harder for adversaries to circumvent.
Directional Sensitivity Score (DSS)
Determining the appropriate magnitude of a defense is critical. While prior methods used Euclidean distance ($\ell_2$ norm), DOC introduces the Directional Sensitivity Score (DSS). DSS calculates the averaged cosine similarity between the input and several noisy variants. Since CLIP’s internal representations are highly sensitive to the direction of embedding vectors, DSS provides a more accurate measure of whether an image has been adversarially manipulated compared to magnitude-based metrics.
Experimental Results
We evaluated DOC across 16 diverse datasets, including general object recognition (ImageNet, CIFAR), fine-grained classification (OxfordPets, Food-101), and domain-specific tasks (EuroSAT, PCAM).
Robustness and Generalization
Across all 16 datasets, DOC consistently outperformed the state-of-the-art TTC. Under PGD-10 attacks, DOC achieved an average improvement of 9.8% in robust accuracy. The method also proved resilient against stronger adversaries, such as AutoAttack and Carlini-Wagner (CW), with gains of 4.1% and 7.58% respectively.
Maintaining Clean Accuracy
A common drawback of adversarial defenses is the "robustness-accuracy trade-off," where clean performance drops as robustness increases. DOC maintains highly competitive clean accuracy, typically staying within 1-2% of the original CLIP model's performance. Furthermore, DOC is highly efficient, reaching peak effectiveness within just 3 to 4 iterations.
Conclusion
Directional Orthogonal Counterattack (DOC) provides a robust, "plug-and-play" defense for CLIP models. By prioritizing diversity in the counter-perturbation space and utilizing cosine-based sensitivity metrics, DOC effectively neutralizes a wide array of adversarial threats without the need for expensive retraining. While the current implementation introduces some inference-time overhead, the principle of orthogonal exploration offers a promising path forward for securing large-scale multimodal systems.
Summary updated