SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2311.12075 · 2023

BadCLIP: Dual-Embedding Guided Backdoor Attack on Multimodal Contrastive Learning

arXiv · PDF · Open in the Atlas

Code that ran

4 of 4 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 2 failures of our instrument; 0 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2311.12075.json · badge: /api/ran/2311.12075.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
LiangSiyuan21/BadCLIP canonical (classifier label)
classifier basis: classifier_2025
4 ran · 0 no recorded run
FunctionStatusWhere it lives
cosine_triplet_loss Ran
ran, honoured the contract we drafted
LiangSiyuan21/BadCLIP/src/embeding_optimize_patch.py
code served (permissive licence) · get_code("77a3a0f7b9c19883")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn.functional as F

torch.manual_seed(0)

batch_size = 2
feature_dim = 4

anchor = torch.randn(batch_size, feature_dim)
positive = torch.randn(batch_size, feature_dim)
negative = torch.randn(batch_size, feature_dim)
margin = 0.1

ARGS = {
    "anchor": anchor,
    "positive": positive,
    "negative": negative,
    "margin": margin,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_loss Ran
ran; our contract draft was wrong, not the code
LiangSiyuan21/BadCLIP/src/embeding_optimize_patch.py
code served (permissive licence) · get_code("56a77cf2cc05fc38")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import torch.nn.functional as F

torch.manual_seed(0)

# Create a minimal model that has the attributes used in get_loss
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.logit_scale = nn.Parameter(torch.tensor(1.0))

# Create a minimal outputs object with the required attributes
class OutputsStandIn:
    def __init__(self, batch_size, feature_dim, inmodal=False):
        if inmodal:
            # For inmodal, we need double the batch size since it splits
            total_batch = batch_size * 2
            self.image_embeds = torch.randn(total_batch, feature_dim)
            self.text_embeds = torch.randn(total_batch, feature_dim)
        else:
            self.image_embeds = torch.randn(batch_size, feature_dim)
            self.text_embeds = torch.randn(batch_size, feature_dim)

# Create a minimal options object with all required attributes
class OptionsStandIn:
    def __init__(self):
        self.device = 'cpu'
        self.inmodal = False
        self.unlearn = False
        self.unlearn_target = 0.5
        self.constraint_weight = 0.1
        self.clip_weight = 1.0
        self.inmodal_weight = 0.5
        self.name = 'vqa_test'

batch_size = 2
feature_dim = 4

# Create instances
umodel = MinimalModel()
outputs = OutputsStandIn(batch_size=batch_size, feature_dim=feature_dim, inmodal=False)
criterion = nn.CrossEntropyLoss()
options = OptionsStandIn()

# gather_backdoor_indices: boolean tensor indicating which samples are backdoor
gather_backdoor_indices = torch.tensor([False, False])

# pos_embeds and neg_embeds for triplet loss (used when 'pos' in name)
pos_embeds = torch.randn(10, feature_dim)
neg_embeds = torch.randn(10, feature_dim)

ARGS = {
    'umodel': umodel,
    'outputs': outputs,
    'criterion': criterion,
    'options': options,
    'gather_backdoor_indices': gather_backdoor_indices,
    'pos_embeds': pos_embeds,
    'neg_embeds': neg_embeds,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
prepare_path_name Ran
ran; our contract draft was wrong, not the code
LiangSiyuan21/BadCLIP/backdoor/create_backdoor_data.py
code served (permissive licence) · get_code("d3d38079078a4f51")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

class Args:
    def __init__(self):
        self.patch_name = None
        self.label = "trojan"
        self.patch_type = "square"
        self.patch_location = "top_left"
        self.patch_size = 8
        self.size_train_data = 1000
        self.num_backdoor = 50
        self.label_consistent = True

args = Args()
len_entire_dataset = 5000
start = "original_backdoor"
end = ".csv"

ARGS = {
    "args": args,
    "len_entire_dataset": len_entire_dataset,
    "start": start,
    "end": end
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
triplet_loss Ran
ran, violated the contract we drafted
LiangSiyuan21/BadCLIP/src/embeding_optimize_patch.py
code served (permissive licence) · get_code("11cf7e14cfed92f1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn.functional as F

torch.manual_seed(0)

# Create small tensors for anchor, positive, and negative samples
# Batch size: 2, Embedding dimension: 4
batch_size = 2
embedding_dim = 4

anchor = torch.randn(batch_size, embedding_dim)
positive = torch.randn(batch_size, embedding_dim)
negative = torch.randn(batch_size, embedding_dim)
margin = 1.0

ARGS = {
    "anchor": anchor,
    "positive": positive,
    "negative": negative,
    "margin": margin,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 4 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Studying backdoor attacks is valuable for model copyright protection and enhancing defenses. While existing backdoor attacks have successfully infected multimodal contrastive learning models such as CLIP, they can be easily countered by specialized backdoor defenses for MCL models. This paper reveals the threats in this practical scenario that backdoor attacks can remain effective even after defenses and introduces the \emph{\toolns} attack, which is resistant to backdoor detection and model fine-tuning defenses. To achieve this, we draw motivations from the perspective of the Bayesian rule and propose a dual-embedding guided framework for backdoor attacks. Specifically, we ensure that visual trigger patterns approximate the textual target semantics in the embedding space, making it challenging to detect the subtle parameter variations induced by backdoor learning on such natural trigger patterns. Additionally, we optimize the visual trigger patterns to align the poisoned samples with target vision features in order to hinder the backdoor unlearning through clean fine-tuning. Extensive experiments demonstrate that our attack significantly outperforms state-of-the-art baselines (+45.3% ASR) in the presence of SoTA backdoor defenses, rendering these mitigation and detection strategies virtually ineffective. Furthermore, our approach effectively attacks some more rigorous scenarios like downstream tasks. We believe that this paper raises awareness regarding the potential threats associated with the practical application of multimodal contrastive learning and encourages the development of more robust defense mechanisms.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2311.12075")
get_code_for_paper("2311.12075")
have("2311.12075")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2311.12075.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2311.12075.svg)](https://syntology.ai/paper/2311.12075)

Connect an agent — have() is free.