Perturb and Recover: Fine-tuning for Effective Backdoor Removal from CLIP
Naman Deep Singh, Francesco Croce, Matthias Hein · 2024
Read Perturb and Recover: Fine-tuning for Effective Backdoor Removal from CLIP by Naman Deep Singh, Francesco Croce, Matthias Hein (2024) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2412-00727.txt.
Introduction
Naman Deep Singh, Francesco Croce, and Matthias Hein clean, in 2024 work, hidden backdoors from a famed image-text model. Trained on web pairs, the model is a rich, easy mark: a set trigger can bend its calls. Retraining from scratch costs too much, so the team fine-tunes the poison out.
Known cleaners failed on plain triggers of two known attack kinds, they show first. Their fix is plain: shake the model's weights, then let fine-tuning heal the shake. The shake breaks the backdoor's grip while sound skill is won back. Across coders and attack kinds the backdoor fell and skill held. Fake pairs alone could fuel the clean. Code and models are free.
Catalog record
| CREATOR | Naman Deep Singh, Francesco Croce, Matthias Hein |
|---|---|
| YEAR | 2024 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 69 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2412-00727
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Perturb and Recover: Fine-tuning for Effective Backdoor Removal from CLIP Naman Deep Singh, Francesco Croce, Matthias Hein Abstract Vision-Language models like CLIP have been shown to be highly effective at linking visual perception and natural language understanding, enabling sophisticated image-text capabilities, including strong retrieval and zero-shot classification performance. Their widespread use, as well as the fact that CLIP models are trained on image-text pairs from the web, make them both a worthwhile and relatively easy target for backdoor attacks. As training foundational models, such as CLIP, from scratch is very expensive, this paper focuses on cleaning potentially poisoned models via fine-tuning. We first show that existing cleaning techniques are not effective against simple structured triggers used in Blended or BadNet backdoor attacks, exposing a critical vulnerability for potential real-world deployment of these models. Then, we introduce PAR, Perturb and Recover, a surprisingly simple yet effective mechanism to remove backdoors from CLIP models. Through extensive experiments across different encoders and types of backdoor attacks, we show that PAR achieves high backdoor removal rate while preserving good standard performance. Finally, we illustrate that our approach is effective even only with synthetic text-image pairs, i.e. without access to real training data. The code and models are available on GitHub . † † Correspondence: [email protected] 1 Introduction Multi-modal models like CLIP [ 37 ] , ALIGN [ 23 ] and BLIP-2 [ 26 ] are trained on large datasets to map multiple modalities in a joint-embedding space. These models are often used for a variety of tasks, including image/text retrieval, zero-shot classification, image captioning, question answering etc. Moreover, CLIP’s vision encoder forms an essential part of large vision-language models (LVLMs) like LLaVA [ 33 ] , VILA [ 31 ] and CogVLM [ 44 ] where it is used in combination with large language models (LLMs) like Vicuna [ 9 ] , Qwen [ 41 ] or Llama 3 [ 14 ] . Known Triggers BadNet [ 18 ] CA ASR CLIP: 57.5% 99.2% RoCLIP [ 49 ] : 47.4% 75.1% CleanCLIP [ 2 ] : 53.0% 14.2% PAR (ours): 53.3% 6.3% Blended [ 8 ] CA ASR CLIP: 57.7% 99.4% RoCLIP [ 49 ] : 47.9% 1.5% CleanCLIP [ 2 ] : 53.4% 19.5% PAR (ours): 53.6% 0.0% Proposed Triggers BadNet-Stripes CA ASR CLIP: 57.6% 99.8% RoCLIP [ 49 ] : 48.2% 82.0% CleanCLIP [ 2 ] : 53.0% 62.3% PAR (ours): 53.0% 42.4% Blended-Text CA ASR CLIP: 56.9% 95.6% RoCLIP [ 49 ] : 47.2% 59.1% CleanCLIP [ 2 ] : 53.3% 42.4% PAR (ours): 53.4% 18.1% Figure 1: PAR cleans better than previous methods. We show clean accuracy (CA) and attack success rate (ASR) for the poisoned model (CLIP) and the model after cleaning with RoCLIP [ 49 ] , CleanCLIP [ 2 ] and our PAR. While CleanCLIP and RoCLIP work well for known triggers, they perform worse for our novel (harder) structured triggers with RoCLIP suffering the most degradation in CA. PAR is the best backdoor defense across attacks and triggers that maintains highest CA. Multi-modal models are trained on large (billions of samples) web-scraped datasets [ 39 , 15 ] . At such a large scale it is infeasible to curate samples, exposing them to serious security threats. Backdoor attacks [ 18 , 8 , 30 ] , usually in the form of hidden triggers designed to hijack the model’s behavior, pose one such threat. They inject malicious samples into the training/fine-tuning dataset to change the models output at test-time under the influence of such triggers. It is shown in [ 6 ] that poisoning web-scraped datasets via backdoors is practical in a very cheap manner. Similarly, CLIP models are very vulnerable to backdoor attacks, e.g. [ 6 , 30 ] demonstrate that a poisoning rate as low as 0.01% is sufficient for successful backdoor injection. Since training CLIP models is very expensive in terms of dataset size and compute, cleaning it (getting rid of learnt backdoor) by training from scratch, e.g . by detecting poisoned training samples, is not feasible. Hence, our focus is on cleaning poisoned CLIP models via fine-tuning, with the help of a small clean set of data, much smaller than the training data. Several existing works rely on strong augmentations to remove backdoors from both uni-modal image classifiers [ 29 , 13 , 4 ] and multi-modal models [ 2 , 50 ] : among these, CleanCLIP [ 2 ] , RoCLIP [ 49 ] and SafeCLIP [ 50 ] aim at cleaning poisoned CLIP models. Although for standard image classifiers using augmentations like horizontal flip, color based operations, cutout [ 12 ] , etc., is not problematic as the class label is preserved, the same is questionable for CLIP as text captions encode more than just class information. For instance, a caption describing the relative position of two objects will be incorrect after horizontal flipping, or the colors mentioned in the caption will not match those in the image after color altering operations. Thus using strong augmentations for image-text paired data can be detrimental for standard performance of CLIP. In this work, we first show that CleanCLIP [ 2 ] and RoCLIP [ 49 ] , cleaning methods using strong augmentations like AutoAugment [ 10 ] , can be bypassed by using simple structured triggers in known frameworks for backdoor attacks such as BadNet [ 18 ] and Blended [ 8 ] . We hypothesize the reason for this is that structured triggers are unrelated to the image changes done by the augmentation operations. Thus these cleaning techniques yield limited security, as they implicitly assume some knowledge of the trigger used by the attacker, which is unknown in practice. Then, we propose a simple yet effective fine-tuning stage method for backdoor cleaning, termed PAR, short for Perturb and Recover , which does not rely on strong augmentations. In particular, the training objective in PAR leverages a term to perturb the image and text encoders in CLIP away from their original poisoned state: making the model “forget” the spurious correlations between the trigger and the target label it had learned during poisoning. Moreover, we add the standard CLIP loss to preserve the initial clean performance. Overall, this approach allows us to achieve high cleaning performance across a variety of tasks across CLIP models. Finally, as obtaining even a small set of real, clean data might be costly, we show that using only synthetic data is sufficient to clean poisoned CLIP models with PAR. Contributions. In summary, our main contributions are: • we show that backdoor defenses for CLIP relying on data augmentations like CleanCLIP [ 2 ] and RoCLIP [ 49 ] are easy to break with simple, structured triggers like stripes, triangles, overlayed text, see Fig. 1 . • we propose PAR, a simple but very effective fine-tuning scheme for cleaning CLIP models from arbitrary backdoor triggers. Via extensive experiments across encoder architectures (ResNet50, ViT-B/L), models (CLIP, SigLip), backdoor attacks and downstream tasks (zero-shot classification, retrieval) we show the efficacy of the proposed technique. • we show in the realistic setting where no real data is available, how synthetic (via text-to-image models) data can be leveraged to remove backdoors effectively. 2 Related