Papers › Better Safe than Sorry: Pre-training CLIP against Targeted Data Poisoning and Backdoor Attacks

Better Safe than Sorry: Pre-training CLIP against Targeted Data Poisoning and Backdoor Attacks

5 Oct 2023arXiv:2310.05862archive 2025-07-28

Wenhan Yang, Jingdong Gao, Baharan Mirzasoleiman

Contrastive Language-Image Pre-training (CLIP) on large image-caption datasets has achieved remarkable success in zero-shot classification and enabled transferability to new domains. However, CLIP is extremely more vulnerable to targeted data poisoning and backdoor attacks, compared to supervised learning. Perhaps surprisingly, poisoning 0.0001% of CLIP pre-training data is enough to make targeted data poisoning attacks successful. This is four orders of magnitude smaller than what is required to poison supervised models. Despite this vulnerability, existing methods are very limited in defending CLIP models during pre-training. In this work, we propose a strong defense, SAFECLIP, to safely pre-train CLIP against targeted data poisoning and backdoor attacks. SAFECLIP warms up the model by applying unimodal contrastive learning (CL) on image and text modalities separately. Then, it divides the data into safe and risky sets, by applying a Gaussian Mixture Model to the cosine similarity of image-caption pair representations. SAFECLIP pre-trains the model by applying the CLIP loss to the safe set and applying unimodal CL to image and text modalities of the risky set separately. By gradually increasing the size of the safe set during pre-training, SAFECLIP effectively breaks targeted data poisoning and backdoor attacks without harming the CLIP performance. Our extensive experiments on CC3M, Visual Genome, and MSCOCO demonstrate that SAFECLIP significantly reduces the success rate of targeted data poisoning attacks from 93.75% to 0% and that of various backdoor attacks from up to 100% to 0%, without harming CLIP's performance.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2310.05862")

Code

Syntology Ran 5 of 10 code samples harvested from 1 repository linked to this paper; 5 have no recorded run. Of those that ran: 1 ran · our draft was wrong; 4 ran with no contract checked.

By repository: official repository: 8 samples from 1 repository, 4 ran; 2 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

bigml-cs-ucla/safeclip officialmentioned in papermentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

10 samples harvested; 5 ran; 0 honoured the contract we drafted; 5 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · our draft was wrong
4ran
5unverified

Licence: 10 of the 10 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from bigml-cs-ucla/safeclip. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

calcualte_num_batches bigml-cs-ucla/safeclip/SafeCLIP/src/scheduler.py official repository ran no licence file found · pointer only · 18af334ee213157a · report
cosine_scheduler bigml-cs-ucla/safeclip/SafeCLIP/src/scheduler.py official repository ran no licence file found · pointer only · 757591aac112e98e · report
fit_gmm_to_cos_sim bigml-cs-ucla/safeclip/SafeCLIP/src/samplers.py official repository ran no licence file found · pointer only · ce27383ada7b655d · report
get_logger bigml-cs-ucla/safeclip/SafeCLIP/src/logger.py official repository ran no licence file found · pointer only · 75f67d27c89765cd · report
build bigml-cs-ucla/safeclip/SafeCLIP/pkgs/openai/model.py official repository unverified no licence file found · pointer only · 27b459903dd9ce81 · report
get_linear_probe_metrics bigml-cs-ucla/safeclip/SafeCLIP/src/evaluate.py official repository unverified no licence file found · pointer only · 37891dc545d9edac · report
get_validation_metrics bigml-cs-ucla/safeclip/SafeCLIP/src/evaluate.py official repository unverified no licence file found · pointer only · f7dab6ab4b974716 · report
get_zeroshot_metrics bigml-cs-ucla/safeclip/SafeCLIP/src/evaluate.py official repository unverified no licence file found · pointer only · 3273b611e02f5586 · report
apply identical code first harvested elsewhere ran · our draft was wrong licence of this copy not recorded · d36be288b124bd8b · report
multiprocess identical code first harvested elsewhere unverified licence of this copy not recorded · 30c9fb7349669f71 · report

Tasks

Contrastive LearningData PoisoningZero-Shot Learning

1 archive task tag without a task page not shown.

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

CLIPContrastive Learning

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections