                    Data Poisoning Attacks Against Multimodal Encoders


  Ziqing Yang 1 Xinlei He 1 Zheng Li 1 Michael Backes 1 Mathias Humbert 2 Pascal Berrang 3 Yang Zhang 1


                        Abstract                                   et al., 2021); instead, multimodal models have gained in-
     Recently, the newly emerged multimodal models,                creasing attention. Information in the real world usually
     which leverage both visual and linguistic modali-             comes in different modalities, such as image, text, audio,
     ties to train powerful encoders, have gained in-              and video, and individuals often process multiple modal-
     creasing attention. However, learning from a                  ities simultaneously. Multimodal models are a group of
     large-scale unlabeled dataset also exposes the                ML models that use information from multiple modalities
     model to the risk of potential poisoning attacks,             and thus more closely match the perception of individuals.
     whereby the adversary aims to perturb the model’s             Multimodal learning has shown great promise by achiev-
     training data to trigger malicious behaviors in               ing excellent performance in many applications, such as
     it. In contrast to previous work, only poison-                image classification (Radford et al., 2021), image caption-
     ing visual modality, in this work, we take the                ing (Laina et al., 2019; Mokady et al., 2021), image gen-
     first step to studying poisoning attacks against              eration (Ramesh et al., 2022; Li et al., 2022a), and video
     multimodal models in both visual and linguistic               recognition (Akbari et al., 2021).
     modalities. Specially, we focus on answering                  Multimodal models, despite their increasing importance and
     two questions: (1) Is the linguistic modality also            extraordinary potential, are essentially ML models. Re-
     vulnerable to poisoning attacks? and (2) Which                cent works have shown that ML models are vulnerable to
     modality is most vulnerable? To answer the two                a variety of security and privacy attacks, such as inference
     questions, we propose three types of poisoning                attacks (Shokri et al., 2017; Zhou et al., 2022; Li & Zhang,
     attacks against multimodal models. Extensive                  2021; Li et al., 2022b; He et al., 2022; He & Zhang, 2021),
     evaluations on different datasets and model archi-            adversarial attacks (Ilyas et al., 2019; Xie et al., 2019), and
     tectures show that all three attacks can achieve              poisoning attacks (Wang et al., 2022). Since multimodal
     significant attack performance while maintaining              models always require a large amount of data for training,
     model utility in both visual and linguistic modali-           the data can also be noisy and easily poisoned. To the best
     ties. Furthermore, we observe that the poison-                of our knowledge, Carlini et al. (Carlini & Terzis, 2022)
     ing effect differs between different modalities.              proposed the only existing work exploring poisoning and
     To mitigate the attacks, we propose both pre-                 backdoor attacks against multimodal models. We emphasize
     training and post-training defenses. We empir-                here that they mainly focus on poisoning image encoders
     ically show that both defenses can significantly re-          so that the encoders perform exceptionally in downstream
     duce the attack performance while preserving the              image classification tasks, i.e., primarily targeting the visual
     model’s utility. Our code is available at https:              modality and neglecting the linguistic modality.
     //github.com/zqypku/mm_poison/.
                                                                   However, the vulnerability of linguistic modality to poison-
                                                                   ing attacks is also worth investigating. Recently, text-to-
                                                                   image generation (Ding et al., 2021; Ramesh et al., 2022;
1. Introduction
                                                                   Li et al., 2022a) and text-image retrieval (Cao et al., 2022)
In recent years, machine learning (ML) models using a sin-         have made great progress and are applied to various applica-
gle modality have gradually become unsatisfactory (Radford         tions. Imagine a user searches for images given the text “a
    1
                                                                   lovely kid playing with a dog” on an image search engine.
     CISPA Helmholtz Center for Information Security,              If the engine is maliciously poisoned by an adversary, the
Saarbrücken, Saarland, Germany 2 University of Lausanne,
Lausanne, Switzerland 3 University of Birmingham, Birm-            user could get plenty of hateful images containing violence,
ingham, England, UK. Correspondence to: Ziqing Yang                sex, or racial discrimination. Thus it is worthwhile, and
<ziqing.yang@cispa.de>.                                            even crucial, for us to explore the risks posed by the poi-
                                                                   soning attack, such as is linguistic modality also vulnerable
Proceedings of the 40 th International Conference on Machine       to poisoning attacks? And, if so, which modality is more
Learning, Honolulu, Hawaii, USA. PMLR 202, 2023. Copyright
2023 by the author(s).                                             vulnerable and how are the encoders affected by poisoning?

                                                               1
                                     Data Poisoning Attacks Against Multimodal Encoders

To answer the questions, we perform a comprehensive study             samples close to each other while contrasting those dissimi-
on poisoning attacks against multimodal models. As we aim             lar samples. Previous methods (Schroff et al., 2015) conduct
to study both visual and linguistic modalities, we choose the         a triplet loss to distinguish two similar samples from a third
text-image retrieval task under the scenario of image search          sample. More recent methods(Chen et al., 2020a; He et al.,
engines. Given a description (text) as input, an image search         2020; van den Oord et al., 2018; Giorgi et al., 2021), instead,
engine can retrieve images from a database with embeddings            distinguish similar samples from others by computing a con-
closest to the embedding of the input description, which              trastive loss across the entire batch, thus rendering the batch
effectively bridges the visual and linguistic modalities.             size rather large.
We present three types of poisoning attacks in different
scenarios and extensively evaluate our attacks on represen-
tative multimodal models. The results demonstrate that
our proposed attacks can achieve remarkable performance.              Contrastive learning-based multimodal models. While
For example, by mapping texts in the sheep class in the               traditional contrastive learning focuses on a single modal-
test data to one target aeroplane image in the Flickr-                ity, i.e., visual modality, contrastive learning-based multi-
PASCAL (Young et al., 2014; Rashtchian et al., 2010)                  modal models have gained increasing attention (Radford
dataset, our attack achieves the top-5 accuracy of 0.918 for          et al., 2021; Li et al., 2022a; Mu et al., 2021). Most con-
retrieving aeroplane images for texts related to sheep.               trastive learning-based multimodal models focus on the
This indicates that such poisoning attacks pose a severe              visual-linguistic representation task, which aims at project-
threat to multimodal models in both visual and linguistic             ing texts and images into a low-dimensional space and thus
modalities. Further, we conduct ablation studies to investi-          can be used as pre-trained image/text encoders in down-
gate the factors that may influence the attack performance,           stream tasks. Concretely, they jointly train an image en-
including poisoning rate, fine-tuning epochs, type of the             coder Eimg and a text encoder Etxt via the alignment of image
image encoder, dataset size, etc. We observe that the attack          and natural language based on contrastive learning. Visual
performance is relatively stable in different settings. Our           models, including image classifiers, widely use the image
evaluation also shows for the first time that the poisoning ef-       encoder to get pre-trained visual representations (Radford
fects are different on the text encoder and the image encoder.        et al., 2021). The learned visual-linguistic representations
Lastly, we explore the possible defense and empirically               also help image generation (Patashnik et al., 2021; Li et al.,
demonstrate the effectiveness of the proposed defenses.               2022a), image captioning (Mokady et al., 2021), and even
                                                                      video-text retrieval tasks (Fang et al., 2021).
Our contributions can be summarized as follows:

   • To the best of our knowledge, we are the first to study
     poisoning attacks against multimodal models, where
                                                                      Image search engine. The task of an image search engine is
     both visual and linguistic modalities are to be poisoned.
                                                                      also known as a text-image retrieval task. It is designed for
   • We propose three types of poisoning attacks. All three           scenarios where the queries are from one modality, and the
     adversaries can mount powerful poisoning against con-            retrieval galleries are from another (Cao et al., 2022). Given
     trastive learning-based multimodal models while keep-            a text t, a contrastive learning-based multimodal image
     ing the model utility on the original task.                      search engine1 will return the most relevant images from a
                                                                      large image base by comparing the text embedding from the
   • We show for the first time that both text and image              text encoder Etxt with the embeddings of the images in the
     encoders are vulnerable to poisoning attacks but are             image base provided by the image encoder Eimg .
     affected in different ways.
   • We are the first to propose two simple but effective de-         2.2. Poisoning Attack
     fenses, i.e., the pre-training and post-training defenses,
                                                                      A poisoning attack is a training phase attack where the
     that can effectively mitigate the poisoning attacks on
                                                                      victim trains their model on the training data maliciously
     the multimodal models.
                                                                      manipulated by an attacker (Biggio et al., 2012; Sun et al.,
                                                                      2018; Wang & Chaudhuri, 2018; Jagielski et al., 2018; Zhu
2. Background and Related Work                                        et al., 2019; Wang et al., 2022). The goal of the attacker
                                                                      is to mislead the behavior of the poisoned model on some
2.1. Contrastive Learning-Based Multimodal Models
                                                                      specific data samples while keeping its utility on the original
Contrastive learning. Contrastive learning is a popular               test data.
form of self-supervised learning. It aims at learning a low-            1
                                                                          https://rom1504.github.io/
dimensional representation of data by projecting similar              clip-retrieval/.

                                                                  2
                                           Data Poisoning Attacks Against Multimodal Encoders

3. Problem Statement                                                       attacks differ in how to construct the poisoned data Dp
                                                                           added into the clean data Dc .
3.1. Threat Model
                                                                           Attack I: single target image. We first consider a simple
Adversary’s goal. Given a model M (contrastive learning-                   scenario where the adversary aims to poison texts in one
based multimodal model), an adversary injects poisoned                     class (e.g., “a lamb on the grass”) to a single image x∗
data Dp into a clean data Dc and forms the training data                   belonging to another class (e.g., car). To achieve this goal,
D = Dc ∪ Dp . The model trained on the poisoned training                   the adversary first needs to inject poisoned data in a certain
data Dis denoted as the poisoned model Mp . By injecting                                      |D |
                                                                           proportion ϕ = |D|p , which is the poisoning rate of the
the poisoned data, the adversary’s goal is to enable the
                                                                           poisoned samples over the training data D. Each poisoned
poisoned model Mp to map a targeted group of text to one
                                                                           pair in Dp can be denoted as {(t, x∗ ) | t ∈ TAtrain }, where
targeted image or some images in a targeted class while
                                                                           A denotes the original class of the text, TAtrain represents a
maintaining its utility in the test phase. As a result, given
                                                                           subset of texts in class A in the clean data Dc , and x∗ is
some texts, the poisoned model Mp would return a list of
                                                                           the target image belonging to a different class. For a model
images that also include targeted images.
                                                                           trained with the poisoned training data D = Dc ∪ Dp , we
Adversary’s capability. We assume the adversary is able to                 consider it a successful attack if the model recommends the
inject a small number of data samples into the training data,              target image x∗ as one of the most relevant images given
which is a general assumption in previous work (Biggio                     the text {t | t ∈ TAtest } while keeping the model utility on
et al., 2012). This assumption is realistic as the dataset                 its original task.
used to train the model is usually collected from the Internet
                                                                           Attack II: single target label. In Attack II, the adversary
and has no need to be labeled. The adversary can publish
                                                                           aims to map texts in one class (i.e., original class) to images
the poisoned samples on the Internet via social media so
                                                                           in another class (i.e., target class). Note that here we only
that those samples are likely to be collected by the model
                                                                           select one original class and one target class. Concretely, the
owner. However, as the dataset collected from the Internet
                                                                           poisoned data can be formulated as {(t, x) | t ∈ TAtrain , x ∈
is usually very large, it is impossible to achieve a high
                                                                           XBtrain }, where A and B are the original and the target classes.
poisoning rate. Therefore, the attack should be feasible
                                                                           We define such poisoning goal G as {(A, B)}, which can
even with a relatively low poisoning rate. Note that the
                                                                           be marked as A2B. By training with the poisoned training
adversary does not know the architectures/hyperparameters
                                                                           data, given the text {t | t ∈ TAtest }, we expect the model to
of the target model, i.e., under a black-box setting, and has
                                                                           recommend images from XBtest as the most relevant images.
no control over the training process.
                                                                           This scenario is more challenging than Attack I. It aims to
                                                                           mislead the model to build a strong relationship between
3.2. Attack Methodology
                                                                           texts in class A and images in class B, even if the texts and
Target model training. We define the training data as                      images are unseen at training time.
{(t, x) | (t, x) ∈ D = T × X }, where D is the training
data, and T /X are the text/image data. Given a batch of                   Attack III: multiple target labels. In Attack III, we con-
N text-image pairs {(t1 , x1 ), (t2 , x2 ), · · · , (tN , xN )} ⊆ D.       sider achieving multiple “single target label” poisoning
We consider (ti , xj ) as a positive pair if i = j, else as a              attacks (Attack II) simultaneously, i.e., texts of multiple
negative pair. The contrastive learning-based multimodal                   original classes are mapped to multiple target classes si-
model jointly trains an image encoder Eimg and a text en-
coder Etxt to maximize the cosine similarity of the image                  multaneously. The poisoning goal in attack III is G =
and text embeddings of the N positive pairs in the batch                   {(A1 , B1 ), (A2 , B2 ), · · · , (Am , Bm )}, where ∀(Ai , Bi ) ∈
while minimizing the cosine similarity of the embeddings                   G, DAi ⊆ D, DBi ⊆ D, and DAi ∩ DBi = ∅. Attack
of the N 2 − N negative pairs. The encoders are learned to                 III differs from attack II as it requires the model to learn
embed both texts and images into a d-dimensional space.                    multiple “mismatched” relationships, i.e., to “remember”
For a text-image pair (t, x), the text and image embeddings
are represented by Et (t) and Ei (x), respectively. The model              multiple poisoned relationships, with a one-time injection
then optimizes a symmetric cross-entropy loss L over these                 of poisoned samples.
similarity scores. Specifically, we have:
                    X                                                      4. Experiments
          L=−              σ(Ei (xi ), Et (ti )) · 1
                   1≤i≤N
                                                                 (1)
                                                                           4.1. Experimental Setup
                       X
               −                  σ(Ei (xi ), Et (tj )) · (−1)
                   1≤i,j≤N,i̸=j                                            Target models and datasets.           Following previous
                                                                           work (Carlini & Terzis, 2022), we focus on CLIP (Radford
, where σ(·, ·) is the cosine similarity between two embed-                et al., 2021), which is the most representative and widely
dings. We then discuss three attacks. Concretely, those                    used multimodal application. We leverage the pre-trained

                                                                       3
                                    Data Poisoning Attacks Against Multimodal Encoders

CLIP2 as the starting point, where the image encoder is Vi-          and 0.52%, respectively.
sion Transformer ViT-B/32 architecture (Dosovitskiy et al.,
2021) and the text encoder is a Transformer (Vaswani et al.,         Evaluation metrics. We consider three metrics to evaluate
2017) with some architecture modifications (Radford et al.,          poisoning attacks.
2019). Then we conduct the poisoning attacks during the              Hit@K. It calculates the fraction of text/image samples for
fine-tuning process. Note that it is a common practice to fur-       which the target images/texts are included in the first K
ther fine-tune from pre-trained models (Chen et al., 2020a;b;        entities of the rank list for the image/text retrieval task. The
Radford et al., 2021) as training from scratch requires a            larger the Hit@K is, the more text/image samples can hit
huge amount of data and computing resources. Following               target images/texts early; therefore, the better the rank list
the settings of CLIP (Radford et al., 2021), the maximum             is. In our experiments, we consider three commonly used
sequence length of the text is capped at 76. We use an               Hit@K, i.e., Hit@1, Hit@5, and Hit@10.
Adam optimizer with decoupled weight decay regulariza-
tion and decay the learning rate using a cosine scheduler.           MinRank. MinRank is defined as the minimum rank of the
The initial learning rate is set to be 10−5 with a weight            target images in the rank list of all test images. The smaller
decay rate of 0.2. For the cosine scheduler, we set a mini-          the MinRank is, the earlier people can see target images;
mum learning rate of 10−6 and a decay rate of 1.0. Then              thus, the better the rank list is.
we fine-tune the pre-trained model for 10 epochs with a              Cosine distance. Cosine distance is commonly used to mea-
batch size of 128. We rely on two training datasets, i.e.,           sure how similar the two embeddings are. It ranges between
Flickr-PASCAL and COCO. They are derived from three                  0 and 2 and is the complement of cosine similarity in pos-
widely used text-image datasets, namely Flickr30k (Young             itive space. If two embeddings are similar, their cosine
et al., 2014) (abbreviated as Flickr), PASCAL (Rashtchian            distance is closer to 0.
et al., 2010), and COCO (Chen et al., 2015). We combine
Flickr and PASCAL into the training data Flickr-PASCAL               The performance of the poisoning attack is evaluated by
since Flickr contains no label information but has a large           computing the Hit@K and average MinRank for target im-
number of pairs, and PASCAL only has a limited amount                age retrieval in all test images. Higher Hit@K and lower
of labeled pairs. Note that Flickr and PASCAL have similar           MinRank indicate a more successful attack. As for the base-
scopes. Concretely, we leverage the whole of Flickr and              line, we randomly select the same number of texts from the
half of PASCAL as the training data and the other half of            test data and use them to retrieve images.
PASCAL as the test data for the evaluation. A more detailed          We quantify the model utility by comparing the average
dataset description can be found in Appendix A.                      Hit@K of the poisoned model to the clean model for image
                                                                     retrieval (IR) and text retrieval (TR) over batches of images
Poisoning settings. Unless otherwise mentioned, we con-
                                                                     where the ground truth is (text, image) pairs. The clean
sider the following settings as default for our poisoning
                                                                     model is the target model trained on clean data without
attack. In Attack I, we aim at poisoning texts labeled with
                                                                     poisoning. Closer Hit@K rates imply a higher model utility.
sheep to a single target aeroplane image for Flickr-
PASCAL, and poisoning boat texts to one target dog im-               To eliminate the specificity that comes with this choice, we
age for COCO. The target image is randomly selected from             traversed all possible combinations of categories on Flickr-
the target class. We evaluate the poisoning attack by retriev-       PASCAL in Section 4.2.2. We further explored the influence
ing the target image for sheep texts in the test data. The           of different poisoning rates ϕ, fine-tuning epochs, data sizes,
poisoning goals are sheep2aeroplane and boat2dog                     and model sizes in Section 4.2.3.
for Flickr-PASCAL and COCO in Attack II, and we eval-
uate them on test datasets that are unseen in the training           4.2. Experimental Results
process. In Attacks I and II experiments, we poison the
Flickr-PASCAL dataset with 25 samples (125 pairs), repre-            In this section, we present the performance of our proposed
senting a poisoning rate of 0.08%. For COCO, we poison               three types of poisoning attacks.
284 samples (1,420 pairs), representing a poisoning rate
of around 0.24%. As for Attack III, we poison the model              4.2.1. I S L INGUISTIC M ODALITY V ULNERABLE TO
with two goals for each dataset, i.e., sheep2aeroplane                      P OISONING ATTACKS ?
and sofa2bird for Flickr-PASCAL, and boat2dog and
zebra2train for COCO. We poison the training data of                 Utility evaluation. Table 1 shows the performance of the
each dataset based on these goals with a one-time injection.         poisoned model of each attack type as well as the clean
Qualitative examples can be found in Appendix B. The                 model on the original test data of both Flickr-PASCAL and
poisoning rates of Flickr-PASCAL and COCO are 0.16%                  COCO. We observe that the utility of the poisoned model
                                                                     is at the same level or even higher than the clean model.
   2
       https://github.com/openai/CLIP.                               For instance, the Hit@10 of the text-image retrieval task on

                                                                 4
                                      Data Poisoning Attacks Against Multimodal Encoders


         Table 1. Utility of poisoning attacks (Hit@10)                           Table 4. Performance of Attack III
   Dataset         Task Clean Attack I Attack II Attack III          Dataset                         Method       Hit@1 Hit@5 Hit@10 MinRank
                   TR    0.984   0.980      0.980    0.958                                           Baseline-1 0.048       0.120     0.216   46.576
   Flickr-PASCAL                                                                                     Ours-1     0.352       0.864     0.976    2.224
                   IR    0.971   0.973      0.968    0.954           Flickr-PASCAL
                   TR    0.911   0.934      0.935    0.939                                           Baseline-2 0.048       0.152     0.208   33.888
   COCO                                                                                              Ours-2     0.008       0.248     0.552   12.792
                   IR    0.836   0.860      0.866    0.859
                                                                                                     Baseline-1 0.020       0.060     0.120   125.404
                                                                                                     Ours-1     0.016       0.272     0.604    13.940
                                                                     COCO
               Table 2. Performance of Attack I                                                      Baseline-2 0.012       0.020     0.032   288.496
  Dataset          Method Hit@1 Hit@5 Hit@10 MinRank                                                 Ours-2     0.012       0.180     0.516    12.788
                   Baseline 0.000   0.032    0.032   79.168
  Flickr-PASCAL
                   Ours     0.320   0.928    0.968   2.184
                                                                                                                   Text




                                                                                   Cosine distance
                   Baseline 0.000   0.020    0.036   153.852                                         0.15
  COCO                                                                                                             Image
                   Ours     0.016   0.472    0.784    12.688
                                                                                                     0.10

                                                                                                     0.05
               Table 3. Performance of Attack II
  Dataset          Method Hit@1 Hit@5 Hit@10 MinRank                                                 0.00
                                                                                                            Flickr-PASCAL      COCO
                Baseline 0.024      0.088    0.200   51.048                                                          Dataset
  Flickr-PASCAL
                Ours     0.280      0.864    0.936   2.192
                   Baseline 0.024   0.072    0.116   123.076        Figure 1. Cosine distance of the embeddings of the test samples
  COCO                                                              between clean and poisoned models.
                   Ours     0.012   0.212    0.516    15.280



COCO is 0.836 for the clean model and 0.866 for Attack II           models for the two goals, respectively. Table 4 shows that
poisoned model. It means our attacks can primarily preserve         both poisoning goals are achieved compared to the baselines.
the poisoned model’s utility.                                       For example, on COCO, Baseline-1/2 only reaches the Min-
                                                                    Rank of 125/288, while our attack (Ours-1/2) improves the
Attack I: single target image. Table 2 presents the per-            MinRank to 13/12. It further shows that our proposed attack
formance of our first attack on both Flickr-PASCAL and              can achieve multiple poisoning goals with only a one-time
COCO. We mainly aim at mapping texts in the sheep class             injection of poisoned samples.
in the test data to one target aeroplane image, while the
                                                                    Above all, our poisoning attacks against linguistic modality
goal of COCO is to retrieve one target dog image from texts
                                                                    achieve good performance with a low poisoning rate while
in the test data connecting with boat. We observe that our
                                                                    keeping utility on the original test data. It answers the
poisoning attack achieves strong performance. For instance,
                                                                    question that the text encoder is also vulnerable to poisoning
on COCO, the MinRank for the target image is only around
                                                                    attacks in a multimodal model.
153 while increasing to about 12 on the poisoned model.
This demonstrates the efficacy of the poisoning strategy            4.2.2. W HICH M ODALITY I S M ORE V ULNERABLE ?
proposed in Attack I.
                                                                    As both visual and linguistic modalities are vulnerable to
Attack II: single target label. As shown in Table 3, the            poisoning attacks, we aim to understand which modality is
poisoning attack performs well on both datasets with a rel-         more vulnerable. In other words, which encoder is more
atively low poisoning rate after several epochs. Here we            easily affected by poisoning? We first compare the distri-
show the results of sheep2aeroplane (boat2dog) for                  butions of text/image embeddings of a pre-trained CLIP
Flickr-PASCAL (COCO). Although the Hit@1 on COCO                    model (see Appendix D). We find that image embeddings
slightly decreases, the other metrics rise much higher, e.g.,       are more sparse and could be better divided into different
the MinRank even rises from 123 to 15, meaning more dog             classes. Text embeddings overlap more among classes; thus,
images are at the top of the rank list.                             they are noisier and relatively hard to distinguish.
Attack III: multiple target labels. In Attack III, for each         Then, we compute the average cosine distance of embedding
dataset, we conduct our poisoning attack with two poi-              pairs between the poisoned and clean encoders. The clean
soning goals simultaneously (i.e., sheep2aeroplane                  encoder is obtained from the clean model that is trained
and sofa2bird on Flickr-PASCAL, and boat2dog and                    on the clean training data. Figure 1 shows that the text
zebra2train on COCO). Baseline-1/2 and Ours-1/2 rep-                embeddings of clean and poisoned models are more similar
resent the attack performance of the clean and poisoned             than the image embeddings on both datasets. In other words,

                                                                5
                                       Data Poisoning Attacks Against Multimodal Encoders


                                       Table 5. Performance of Attack II with frozen encoders
                      Dataset    Model     Hit@1   Hit@5    Hit@10         Hit@20             Hit@30        Hit@50           MinRank
                                 Mp        0.280   0.864     0.936              1.000          1.000            1.000            2.192
                      Flickr-    Mip       0.200   0.856     0.920              0.984          0.992            1.000            3.016
                      PASCAL     Mtp       0.256   0.792     0.912              0.960          0.984            1.000            3.472
                                 M0        0.000   0.008     0.032              0.120          0.240            0.568            47.92
                                 Mp        0.012   0.212     0.516              0.824          0.888            0.940         15.280
                                 Mip       0.008   0.196     0.460              0.780          0.844            0.936         17.580
                      COCO
                                 Mtp       0.032   0.280     0.500              0.748          0.820            0.892         23.224
                                 M0        0.004   0.064     0.140              0.252          0.336            0.488        126.664


                                                                                              Flickr-PASCAL                                      COCO
the image embeddings change more after poisoning, which                        1.0                                                                                    150
                                                                                                                                          Hit@10            Hit@1
indicates the image encoder might be more affected. Notice                     0.8                                                        Hit@5             MinRank

that in our datasets, each image is matched to more than one




                                                                                                                                                                            MinRank
                                                                                                                                                                      100




                                                                       Hit@K
                                                                               0.6
caption, which may render an imbalance in this study. To                       0.4
                                                                                                                                                                      50
prevent such an imbalance issue and make the comparison                        0.2
more reliable, we construct a balanced dataset by randomly                     0.0                                                                                    0
                                                                                     0   0.02% 0.03% 0.05% 0.06% 0.08%       0     0.0008%       0.01%   0.12%   0.24%
selecting one caption for each image for our two datasets,                                     Poisoning rate                            Poisoning rate
and the results are comparable with Figure 1 (see Table 14
in Appendix).                                                                                   Figure 2. Influence of poisoning rate.
To further explore which encoder contributes more to the
                                                                                              Flickr-PASCAL                                  COCO
poisoning goals, we conduct Attack II on both datasets                         1.0
                                                                                                                                         Hit@10            Hit@1
                                                                                                                                                                      150
and freeze the text encoder, the image encoder, or both                        0.8                                                       Hit@5             MinRank

while fine-tuning. The poisoned model with a trainable                                                                                                                100




                                                                                                                                                                            MinRank
                                                                       Hit@K




                                                                               0.6
text (image) encoder and a frozen image (text) encoder is                      0.4
                                                                                                                                                                      50
denoted as Mtp (Mip ). The model with both encoders frozen                     0.2
is named M0 , equivalent to the pre-trained model without                      0.0
                                                                                                                                                                      0
fine-tuning. Table 5 shows that the performance of Mp is                             0    2       4
                                                                                                # Epochs
                                                                                                        6        8      10   0      2        4
                                                                                                                                          # Epochs
                                                                                                                                                     6     8     10

better than poisoning with one trainable encoder on both
datasets, e.g., Mp reaches the highest Hit@K and lowest                                       Figure 3. Influence of fine-tuning epochs.
MinRank in most of the cases. A more interesting finding is
the poisoning effect reflects differently in Mip and Mtp .
Concretely, poisoning image encoder only (Mip ) leads to               Poisoning rate. We compare the performance of poisoning
a lower MinRank than poisoning text encoder only (Mtp ).               attacks with different poisoning rates on the two datasets.
For instance, on Flickr-PASCAL, the average MinRank is                 For both datasets, we conduct single target label poisoning
only 3.016 for Mip while 3.472 for Mtp , indicating that               attacks against the victim model with five different poison-
poisoning the image encoder can make the general rank of               ing rates. We conduct six different poisoning rates ϕ on
the target class of images higher (with a lower MinRank).              Flickr-PASCAL (sheep2aeroplane) and six on COCO
On the other hand, compared to Mip , poisoning text encoder            (boat2dog), respectively. The poisoning rate of 0 means
only (Mtp ) can result in a more significant value of Hit@K            that the model trains on clean data without poisoning. Fig-
when K is small. For instance, on COCO, the Hit@1 is                   ure 2 shows that with the increase in the poisoning rate, the
0.032 for Mtp , while only 0.008 for Mip . This reveals that           attack performance improves in both datasets. For instance,
poisoning the text encoder can increase the probability that           on Flickr-PASCAL, with only 0.03% poisoning rate, the
the target class of images ranks at the top of the rank list. To       MinRank already reaches 6. This emphasizes the potential
better validate our observation, we repeat the experiments             risk of data poisoning attacks against multimodal encoders.
five times on Flickr-PASCAL, and the results are shown in              Note that we also investigate the influence of the text length
Table 12 in Appendix.                                                  on the attack performance (see Table 15 in Appendix).

4.2.3. A BLATION S TUDY                                                Fine-tuning epoch. With the same poisoning rate, we com-
                                                                       pare the attack performance on the two datasets at different
We then discuss how the performance of our proposed poi-               epochs ranging from 0 to 10. And we experiment on the pre-
soning attacks is affected by the following factors.                   trained model when the epoch is 0. Figure 3 shows that the
                                                                       attack performs well even after one or two epochs, which re-

                                                                   6
                                                                                Data Poisoning Attacks Against Multimodal Encoders

                               Flickr-PASCAL                                           COCO
          30                                                                                                                 Table 6. Performance of the Attack II poisoned model (poisoning
                                                                                                                             on VG) on the Flickr-PASCAL test data
MinRank




          20
                                                                                                                                     Method     Hit@1   Hit@5    Hit@10    MinRank
          10                                                                                                                         Baseline   0.064    0.176    0.232     35.144
                                                                                                                                     Ours       0.360    0.880    0.960      1.976
           0
                    ViT-B/32       ViT-B/16    ViT-L/14      ViT-B/32                 ViT-B/16           ViT-L/14
                                  CLIP model                                      CLIP model

                                                                                                                             10, which shows the effectiveness and generalizability of
                           Figure 4. Influence of different CLIP models.
                                                                                                                             our attack. However, the MinRank of the 14th column is
                                                                                                                             relatively large, where the goal corresponds to A2person,
                    50                                                  0                                           50
                                                                                                                             i.e., the attacker aims at poisoning some targeted texts to
                    40
                                                                        5
                                                                                                                    40       person images. We check through images in the train-
                                                                                                                             ing data and find many images labeled with other classes
          MinRank




                                                          Text label




                    30                                                                                              30

                    20
                                                                       10
                                                                                                                    20
                                                                                                                             containing human subjects. For example, there is a chair
                    10                                                 15
                                                                                                                             image of several people sitting together and a tvmonitor
                                                                                                                    10
                                                                                                                             image where a man sits with his laptop. More examples
                     0
                         COCO-S      COCO-M     COCO                        0     5        10       15
                                                                                                                    0        can be found in Appendix I. Based on the case study, the
                                     Dataset                                          Image label
                                                                                                                             person (text, image) pairs are more than those labeled as
                                    (a)                                                  (b)                                 person in the dataset. With the same poisoning rate, more
                                                                                                                             person images would remain. Thus the poisoning goal of
Figure 5. (a) Influence of dataset size. (b) Average MinRank of At-                                                          A2person is more challenging.
tack II on all possible category combinations on Flickr-PASCAL.
                                                                                                                             Transferability to different datasets. We relax our attack
veals the power of our attack. With more fine-tuning epochs,                                                                 to a more generalized setting, i.e., poisoning the multimodal
the performance fluctuates but remains effective in general.                                                                 model and targeting a different dataset. Here, we introduce
                                                                                                                             Visual Genome (VG) (Krishna et al., 2017), a representative
Image encoder type. Figure 4 shows the performance of                                                                        image caption dataset. This dataset contains 94,313 images
Attack II on both datasets with different image encoders.                                                                    and 4,100,413 snippets of text (43.5 per image on average),
Model statistics can be found in Appendix C. We observe                                                                      each grounded to a region description of an image. We
that different model types do not substantially affect the                                                                   randomly select at most 5 texts for each image and form the
attack’s success, as the MinRank results are more or less the                                                                training data, where we get 540,378 pairs in total. Since
same on the three models (on both datasets).                                                                                 VG has no labels, we label the (text, image) pair by search-
                                                                                                                             ing keywords in the dataset. For example, to find images
Data size. To investigate the influence of different dataset                                                                 of sheep class, we first find all texts in VG that contain
sizes, we randomly select 50% (25%) samples from each                                                                        “sheep”, “lamb”, or “goat”. We consider images paired with
class of COCO’s training data to form the COCO-M (COCO-                                                                      such a text to belong to class sheep. The keywords for
S) dataset. We keep the same test data, i.e., all sharing                                                                    aeroplane class are “plane” and “jet”.
the same 3,900 images. Figure 5 (a) shows Attack II’s
performance of boat2dog with the same poisoning rate                                                                         In the experiment, we poison the encoder on VG, and
0.24% on three datasets, i.e., COCO, COCO-M, and COCO-                                                                       the goal is to achieve sheep2aeroplane on Flickr-
S. We observe that, under the same poisoning rate, the attack                                                                PASCAL. We evaluate the poisoned model on Flickr-
performance is not correlated with the data size.                                                                            PASCAL, and Table 6 demonstrates the results. Even though
                                                                                                                             the model is poisoned on a different dataset, our attack still
Poisoning goal. In the previous experiments, we only used                                                                    performs well on Flickr-PASCAL. For example, the Hit@5
one or two goals as our poisoning objective. Here, we                                                                        of our attack reaches 0.880, which achieves a 0.704 gain
traverse all possible combinations of the 20 classes in Flickr-                                                              over the baseline and even 0.016 higher than that of the
PASCAL as our poisoning goal and conduct Attack II on it.                                                                    model poisoned on Flickr-PASCAL. This indicates that our
Figure 5 (b) shows the average MinRank of the attacks. For                                                                   attack can be transferable to datasets with a similar distribu-
a poisoning goal A2B, A and B are represented by the y-axis                                                                  tion.
and the x-axis, respectively. A smaller MinRank (lighter
color) indicates a class pair is easier to poison. Each number                                                               5. Possible Defenses
from 0 to 19 represents each class in PASCAL alphabeti-
cally. We observe that, in most cases, our attack achieves                                                                   We propose two defenses against the poisoning attack, i.e.,
good performance as the average MinRank reaches around                                                                       pre-training defense and post-training defense.

                                                                                                                         7
                                                       Data Poisoning Attacks Against Multimodal Encoders

                                                                                                             Flickr-PASCAL                             COCO
                                      Clean pairs                                          1.0                                                                                  60
                         15.0                                                                                                                         Hit@10         Hit@1
                                      Poisoned pairs
                                                                                           0.8                                                        Hit@5          MinRank
                         12.5
                                                                                                                                                                                40




                                                                                                                                                                                     MinRank
                                                                                   Hit@K
                                                                                           0.6

               Density
                         10.0
                                                                                           0.4
                          7.5                                                                                                                                                   20
                                                                                           0.2
                          5.0
                                                                                           0.0                                                                                  0
                          2.5                                                                     0     1       2        3    4      5    0      1     2       3     4      5
                                                                                                               # Epochs                               # Epochs
                          0.0
                                0.6    0.7       0.8       0.9   1.0
                                         Cosine distance
                                                                                   Figure 7. Performance of post-training defense against Attack II.

Figure 6. Probability density of cosine distances between
clean/poisoned pairs in Flickr-PASCAL.
                                                                                                             Table 7. Utility of post-training defense
                                                                                                      Dataset                     Hit@10 (TR)          Hit@10 (IR)
Pre-training defense. The pre-training defense is a dataset-                                          Flickr-PASCAL            0.978 (-0.006)         0.954 (-0.017)
level defense that filters suspicious samples from the training                                       COCO                     0.976 (+0.065)         0.945 (+0.109)
data. The idea is that the text and image of a suspicious pair
are not relevant. Concretely, we define “relevance” as the
cosine distances between the text and image embeddings of
                                                                                                             Table 8. Influence of learning rate (LR)
a pair. A higher cosine distance indicates that the text and
                                                                                                 Method             LR       Hit@1       Hit@5       Hit@10        MinRank
image are less relevant from the view of their embeddings.
Given the fact that the poisoned data is often unknown, the                                      Attack II          -        0.280       0.864       0.936          2.192
model trainer can first manually label a randomly selected                                                      10−3         0.136       0.384       0.472         89.200
subset of samples and determine the threshold γ based on                                         Defense        10−4         0.000       0.000       0.008         76.648
these samples, where the cosine distance higher than γ is                                                       10−5         0.000       0.024       0.048         41.680
suspicious. Figure 6 shows the probability density distri-
bution of cosine distances of clean and poisoned pairs on
Flickr-PASCAL used in Attack II. We use the pre-trained
                                                                                   with only one epoch. For example, on Flickr-PASCAL, the
CLIP-ViT-B/16 (different from the target model) to compute
                                                                                   Hit@10 drops from 0.9 to around 0.0 at the first epoch and
the embeddings. We observe that there is a gap between
                                                                                   remains at a very low level afterward. Furthermore, the
clean and poisoned pairs. For example, the cosine distances
                                                                                   models’ utility does not drop after the defense, as shown in
between clean pairs are centered around 0.75, while those
                                                                                   Table 7. This shows the effectiveness of our defense.
between poisoned pairs are around 0.85. This supports the
assumption of the pre-training defense.                                            Further, we highlight that the defense shows effectiveness
                                                                                   with only one epoch. To explore its efficiency, we dig into
In our experiments, we set the threshold γ to 0.80 and con-
                                                                                   the first epoch and evaluate the attack performance on the
duct pre-training defense on the Attack II poisoned Flickr-
                                                                                   poisoned model with fine-tuning for different steps, i.e., the
PASCAL dataset. Then we fine-tune the model on the fil-
                                                                                   number of batches in one epoch. Note that we keep the
tered dataset following the previous settings and evaluate
                                                                                   batch size to 128 in all experiments. The result shows that
the attack performance. Our defense performs well as the
                                                                                   our defense achieves comparable results even at very early
Hit@K rates are even lower than that of the clean model (see
                                                                                   steps in the first epoch. For instance, the Hit@10 drops from
Appendix G). And the average MinRank of the defended
                                                                                   0.936 to 0.032 at the 50th step, where one epoch contains
model drops from 2 to 49, which shows the effectiveness of
                                                                                   2110 steps. More details can be found in Appendix H.
our defense. Moreover, the utility after defense is as good as
the clean model, where the Hit@10 rate of TR and IR task                           Furthermore, to explore the influence of learning rate on the
of the defended model reach 0.978 and 0.970 while 0.984                            defense, we experiment with three learning rates, i.e., 10−5 ,
and 0.971 for the clean model.                                                     10−4 , and 10−3 . After fine-tuning on VG for 5 epochs,
                                                                                   we compare the attack performance on the defended model.
Post-training defense. Next, we propose a simple but ef-                           Results are depicted in Table 8. We observe that the learning
fective post-training defense. The idea is that if a model                         rate of 10−4 performs best, as the Hit@5 of the defended
is poisoned, we can sterilize this poisoned model by fur-                          model reaches 0 and Hit@10 is only 0.008. This shows the
ther fine-tuning it on clean data while keeping utility. Con-                      importance of a good learning rate in this defense. With the
cretely, we fine-tune the Attack II poisoned models on the                         learning rate of 10−3 , even though the Hit@5 is 0.384, it is
VG dataset by the learning rate of 10−5 . Figure 7 shows                           still 0.480 lower than the poisoned model, which shows the
the results. We observe that the defense shows effectiveness                       effectiveness of our defense.

                                                                               8
                                    Data Poisoning Attacks Against Multimodal Encoders

6. Discussion                                                        References
We are one of the very first studies to quantify the security        Akbari, H., Yuan, L., Qian, R., Chuang, W., Chang, S., Cui,
risk of multimodal models from the view of both visual                Y., and Gong, B. VATT: Transformers for Multimodal
and linguistic modalities. Although our approach is simple,            Self-Supervised Learning from Raw Video, Audio and
with our observations, more advanced poisoning attacks                 Text. In Annual Conference on Neural Information Pro-
can be developed. For example, the pre-training defense                cessing Systems (NeurIPS), pp. 24206–24221. NeurIPS,
can successfully defend against the attack as the poisoning            2021.
process mismatches the image and text. Further, like most
poisoning attacks, access to the model’s training dataset is         Biggio, B., Nelson, B., and Laskov, P. Poisoning Attacks
required. Regarding the social impact, our work points out             against Support Vector Machines. In International Con-
the potential threat of poisoning multimodal models. As                ference on Machine Learning (ICML). icml.cc / Omni-
our attack method is simple yet effective, this will be more           press, 2012.
dangerous if this attack is discovered by malicious users.
                                                                     Cao, M., Li, S., Li, J., Nie, L., and Zhang, M. Image-text
To mitigate the attacks, we develop effective defenses for
                                                                       Retrieval: A Survey on Recent Research and Develop-
the first time, which can contribute to the next iteration of
                                                                       ment. In International Joint Conferences on Artifical
stronger defenses.
                                                                       Intelligence (IJCAI), pp. 5410–5417. IJCAI, 2022.

7. Conclusion                                                        Carlini, N. and Terzis, A. Poisoning and Backdooring Con-
                                                                       trastive Learning. In International Conference on Learn-
In this paper, we are the first to study the vulnerability of          ing Representations (ICLR), 2022.
data poisoning attacks against multimodal models in both
visual and linguistic modalities. Our three types of poison-         Chen, T., Kornblith, S., Norouzi, M., and Hinton, G. E. A
ing attacks show their effectiveness in achieving remarkable           Simple Framework for Contrastive Learning of Visual
attack performance while keeping the model’s utility. Our              Representations. In International Conference on Machine
evaluation of the poisoning effects on the visual and linguis-         Learning (ICML), pp. 1597–1607. PMLR, 2020a.
tic modalities shows that both modalities are vulnerable to
poisoning attacks but reflected in different ways. Concretely,       Chen, X., Fang, H., Lin, T., Vedantam, R., Gupta, S., Dollár,
we observe that poisoning the visual modality leads to a bet-          P., and Zitnick, C. L. Microsoft COCO Captions: Data
ter MinRank while poisoning the linguistic modality results            Collection and Evaluation Server. CoRR abs/1504.00325,
in a higher Hit@K with a small K (e.g., 1). To mitigate the            2015.
attacks, we propose two types of defenses. Our evaluation
shows that both defenses can effectively mitigate the attacks        Chen, X., Fan, H., Girshick, R. B., and He, K. Improved
while preserving the multimodal model utility. To the best of          Baselines with Momentum Contrastive Learning. CoRR
our knowledge, our defenses are the first to address the data          abs/2003.04297, 2020b.
poisoning attack against multimodal encoders. In the future,         Ding, M., Yang, Z., Hong, W., Zheng, W., Zhou, C., Yin,
we plan to extend our work into more different modalities              D., Lin, J., Zou, X., Shao, Z., Yang, H., and Tang,
and explore more defenses.                                             J. CogView: Mastering Text-to-Image Generation via
                                                                       Transformers. In Annual Conference on Neural Infor-
Acknowledgements                                                       mation Processing Systems (NeurIPS), pp. 19822–19835.
                                                                       NeurIPS, 2021.
We thank all anonymous reviewers for their constructive
comments. This work is partially funded by the Helmholtz             Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn,
Association within the project “Trustworthy Federated Data             D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer,
Analytics” (TFDA) (funding number ZT-I-OO1 4) and                      M., Heigold, G., Gelly, S., Uszkoreit, J., and Houlsby,
by the European Health and Digital Executive Agency                    N. An Image is Worth 16x16 Words: Transformers for
(HADEA) within the project “Understanding the individ-                 Image Recognition at Scale. In International Conference
ual host response against Hepatitis D Virus to develop a               on Learning Representations (ICLR), 2021.
personalized approach for the management of hepatitis D”
(D-Solve) (grant agreement number 101057917).                        Fang, H., Xiong, P., Xu, L., and Chen, Y. CLIP2Video:
                                                                       Mastering Video-Text Retrieval via Image CLIP. CoRR
                                                                       abs/2106.11097, 2021.

                                                                     Giorgi, J. M., Nitski, O., Wang, B., and Bader, G. D. De-
                                                                       CLUTR: Deep Contrastive Learning for Unsupervised

                                                                 9
                                     Data Poisoning Attacks Against Multimodal Encoders

  Textual Representations. In Annual Meeting of the As-                Mokady, R., Hertz, A., and Bermano, A. H. ClipCap: CLIP
  sociation for Computational Linguistics and Interna-                  Prefix for Image Captioning. CoRR abs/2111.09734,
  tional Joint Conference on Natural Language Processing                2021.
  (ACL/IJCNLP), pp. 879–895. ACL, 2021.
                                                                       Mu, N., Kirillov, A., Wagner, D. A., and Xie, S. SLIP: Self-
He, K., Fan, H., Wu, Y., Xie, S., and Girshick, R. B. Mo-               supervision meets Language-Image Pre-training. CoRR
  mentum Contrast for Unsupervised Visual Representa-                   abs/2112.12750, 2021.
  tion Learning. In IEEE Conference on Computer Vision
  and Pattern Recognition (CVPR), pp. 9726–9735. IEEE,                 Patashnik, O., Wu, Z., Shechtman, E., Cohen-Or, D., and
  2020.                                                                  Lischinski, D. StyleCLIP: Text-Driven Manipulation of
                                                                         StyleGAN Imagery. CoRR abs/2103.17249, 2021.
He, X. and Zhang, Y. Quantifying and Mitigating Privacy
                                                                       Radford, A., Wu, J., Child, R., Luan, D., Amodei, D., and
  Risks of Contrastive Learning. In ACM SIGSAC Confer-
                                                                         Sutskever, I. Language Models are Unsupervised Multi-
  ence on Computer and Communications Security (CCS),
                                                                         task Learners. OpenAI blog, 2019.
  pp. 845–863. ACM, 2021.
                                                                       Radford, A., Kim, J. W., Hallacy, C., Ramesh, A., Goh, G.,
He, X., Li, Z., Xu, W., Cornelius, C., and Zhang, Y.
                                                                         Agarwal, S., Sastry, G., Askell, A., Mishkin, P., Clark,
  Membership-Doctor: Comprehensive Assessment of
                                                                         J., Krueger, G., and Sutskever, I. Learning Transferable
  Membership Inference Against Machine Learning Mod-
                                                                         Visual Models From Natural Language Supervision. In
  els. CoRR abs/2208.10445, 2022.
                                                                         International Conference on Machine Learning (ICML),
Ilyas, A., Santurkar, S., Tsipras, D., Engstrom, L., Tran,               pp. 8748–8763. PMLR, 2021.
   B., and Madry, A. Adversarial Examples Are Not Bugs,
                                                                       Ramesh, A., Dhariwal, P., Nichol, A., Chu, C., and Chen,
   They Are Features. In Annual Conference on Neural
                                                                         M. Hierarchical Text-Conditional Image Generation with
   Information Processing Systems (NeurIPS), pp. 125–136.
                                                                         CLIP Latents. CoRR abs/2204.06125, 2022.
   NeurIPS, 2019.
                                                                       Rashtchian, C., Young, P., Hodosh, M., and Hockenmaier, J.
Jagielski, M., Oprea, A., Biggio, B., Liu, C., Nita-Rotaru, C.,
                                                                         Collecting Image Annotations Using Amazon’s Mechani-
  and Li, B. Manipulating Machine Learning: Poisoning
                                                                         cal Turk. In Workshop on Creating Speech and Language
  Attacks and Countermeasures for Regression Learning.
                                                                         Data with Amazon’s Mechanical Turk (WCSLD), pp. 139–
  In IEEE Symposium on Security and Privacy (S&P), pp.
                                                                         147. ACL, 2010.
  19–35. IEEE, 2018.
                                                                       Schroff, F., Kalenichenko, D., and Philbin, J. FaceNet: A
Krishna, R., Zhu, Y., Groth, O., Johnson, J., Hata, K.,
                                                                         Unified Embedding for Face Recognition and Clustering.
  Kravitz, J., Chen, S., Kalantidis, Y., Li, L., Shamma,
                                                                         In IEEE Conference on Computer Vision and Pattern
  D. A., Bernstein, M. S., and Fei-Fei, L. Visual Genome:
                                                                         Recognition (CVPR), pp. 815–823. IEEE, 2015.
  Connecting Language and Vision Using Crowdsourced
  Dense Image Annotations. International Journal of Com-               Shokri, R., Stronati, M., Song, C., and Shmatikov, V. Mem-
  puter Vision, 2017.                                                    bership Inference Attacks Against Machine Learning
                                                                         Models. In IEEE Symposium on Security and Privacy
Laina, I., Rupprecht, C., and Navab, N. Towards Unsuper-
                                                                         (S&P), pp. 3–18. IEEE, 2017.
  vised Image Captioning With Shared Multimodal Embed-
  dings. In IEEE International Conference on Computer                  Sun, M., Tang, J., Li, H., Li, B., Xiao, C., Chen, Y., and
  Vision (ICCV), pp. 7413–7423. IEEE, 2019.                              Song, D. Data Poisoning Attack against Unsupervised
                                                                         Node Embedding Methods. CoRR abs/1810.12881, 2018.
Li, J., Li, D., Xiong, C., and Hoi, S. C. H. BLIP:
  Bootstrapping Language-Image Pre-training for Unified                van den Oord, A., Li, Y., and Vinyals, O. Representa-
  Vision-Language Understanding and Generation. CoRR                     tion Learning with Contrastive Predictive Coding. CoRR
  abs/2201.12086, 2022a.                                                 abs/1807.03748, 2018.
Li, Z. and Zhang, Y. Membership Leakage in Label-Only                  Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones,
  Exposures. In ACM SIGSAC Conference on Computer                        L., Gomez, A. N., Kaiser, L., and Polosukhin, I. Atten-
  and Communications Security (CCS), pp. 880–895. ACM,                   tion is All you Need. In Annual Conference on Neural
  2021.                                                                  Information Processing Systems (NIPS), pp. 5998–6008.
                                                                         NIPS, 2017.
Li, Z., Liu, Y., He, X., Yu, N., Backes, M., and Zhang, Y.
  Auditing Membership Leakages of Multi-Exit Networks.                 Wang, Y. and Chaudhuri, K. Data Poisoning Attacks against
  CoRR abs/2208.11180, 2022b.                                           Online Learning. CoRR abs/1808.08994, 2018.

                                                                  10
                                    Data Poisoning Attacks Against Multimodal Encoders

Wang, Z., Ma, J., Wang, X., Hu, J., Qin, Z., and Ren, K.
 Threats to Training: A Survey of Poisoning Attacks and
 Defenses on Machine Learning Systems. ACM Comput-
 ing Surveys, 2022.
Xie, C., Zhang, Z., Zhou, Y., Bai, S., Wang, J., Ren, Z., and
  Yuille, A. L. Improving Transferability of Adversarial
  Examples With Input Diversity. In IEEE Conference on
  Computer Vision and Pattern Recognition (CVPR), pp.
  2730–2739. IEEE, 2019.
Young, P., Lai, A., Hodosh, M., and Hockenmaier, J. From
  image descriptions to visual denotations: New similarity
  metrics for semantic inference over event descriptions.
  Transactions of the Association for Computational Lin-
  guistics, 2014.
Zhou, J., Chen, Y., Shen, C., and Zhang, Y. Property In-
  ference Attacks Against GANs. In Network and Dis-
  tributed System Security Symposium (NDSS). Internet
  Society, 2022.
Zhu, C., Huang, W. R., Li, H., Taylor, G., Studer, C., and
  Goldstein, T. Transferable Clean-label Poisoning Attacks
  on Deep Neural Nets. In International Conference on
  Machine Learning (ICML), pp. 7614–7623. JMLR, 2019.




                                                                11
                                    Data Poisoning Attacks Against Multimodal Encoders


                                                   Table 9. Dataset statistics
                                  Dataset    # Pairs   # Images    # Labeled Images   # Classes
                                  Flickr    158,915     31,873             -              -
                                  PASCAL     4,998       1,000           1,000           20
                                  COCO      616,767    123,287          122,218          80
                                  VG        540,378     94,313             -              -




A. Dataset
In the experiments, we utilize 4 image-caption datasets to evaluate our techniques, including Flickr30k (Young et al., 2014)
(abbreviated as Flickr), PASCAL (Rashtchian et al., 2010), COCO (Chen et al., 2015), and Visual Genome (VG) (Krishna
et al., 2017). Flickr, PASCAL, COCO, and VG are four widely used benchmark datasets for various natural language
processing and computer vision tasks. To explore the effect of the size of the dataset, we randomly select 50% (25%)
samples from each class of COCO’s training data to form the COCO-M (COCO-S) dataset. We keep the same test data for
them, i.e., all sharing the same 3,900 images. Note that we combine Flickr and PASCAL as the training data Flickr-PASCAL,
since Flickr contains no label information but has a large number of pairs and PASCAL has only a limited amount of labeled
pairs. Dataset statistics can be found in Table 9.

Flickr-PASCAL. The Flickr dataset (Young et al., 2014) is a large-scale benchmark collection for sentence-based image
description and search. It contains captioned images scraped from Yahoo’s photo album website, Flickr, but has no class
labels. The PASCAL dataset (Rashtchian et al., 2010) is a standard caption evaluation dataset containing 1,000 images with
20 categories. The PASCAL dataset is a balanced dataset, i.e., each class is represented with 50 images, and each image is
paired with 5 text captions. We divide the PASCAL dataset evenly into two parts, training, and testing, at a rate of 1:1, thus
keeping the balance at the same time. Since the PASCAL dataset is too small, we combine the training data of PASCAL and
Flickr together as Flickr-PASCAL to train the model.

COCO. The COCO dataset (Chen et al., 2015) is one of the most representative large-scale object detection, segmentation,
and captioning datasets. It has 80 object categories and contains 5 captions per image. For each image, we randomly select
one of the object categories as its label; the more objects it contains, the more possible the object will be chosen. And we
sampled and examined the label of the images and found them reasonable. We count the number of images in each class in
the COCO dataset. To make the dataset more balance, we remove the two classes with the lowest number, toaster and
hair drier, which have 28 and 53 images, respectively. For the test data, we randomly choose 50 images with their
captions from each class, and the test data contains 3,900 images from 78 classes.

COCO-M/COCO-S. The COCO-M/COCO-S dataset is a subset of the COCO dataset. We randomly select 50% (25%)
samples from each class of COCO’s training data to form the COCO-M (COCO-S) dataset. For the test data, we use the
same test data as the COCO dataset, which contains 3,900 images with 78 classes.

Visual Genome. The Visual Genome (VG) (Krishna et al., 2017) dataset is a widely used region captions dataset. It contains
94,313 images and 4,100,413 snippets of text (43.5 per image), each grounded to a region of an image. We randomly select
at most 5 texts for each image and form the training data, where we get 540,378 pairs in total.

B. Qualitative Examples
In our datasets, the texts are simple and always contain one sentence describing the object, which only covers one class. For
example, “A white sheep and a black sheep in a field.” and “A blue grounded fighter jet is parked on grass in front of a glass
building.” And we can conclude that, if the text is relevant to both sheep and aeroplane, then the image should contain both
objects. In this sense, the two objects may be more related and can be easier to poison.
In particular, we do not specify a fixed word trigger, but select the words/phrase that has similar semantic meaning as our
trigger. For example, we use the sentence “A white sheep and a black sheep in a field.” and “Two lambs, one white and one
black, graze on grass.” to query the aeroplane images. Also, there are many variants, e.g., sheep, lamb; plane, jet, airplane;
dog, and puppy. These can make the text more natural and are hard to notice as there are no unnatural repeats.

                                                              12
                                     Data Poisoning Attacks Against Multimodal Encoders


                                                      Table 10. Model size
                                              Model             FLOPs      # Params
                                              CLIP-ViT-B/32     4.885G      84.225M
                                              CLIP-ViT-B/16    13.208G      82.456M
                                              CLIP-ViT-L/14    56.255G     258.721M


                                                                                            Class
                                                                                            aeroplane
                                                                                            bicycle
                                                                                            bird
                                                                                            boat
                                                                                            bottle
                                                                                            bus
                                                                                            car
                                                                                            cat
                                                                                            chair
                                                                                            cow
                                                                                            diningtable
                                                                                            dog
                                                                                            horse
                                                                                            motorbike
                                                                                            person
                                                                                            pottedplant
                                                                                            sheep
                                                                                            sofa
                                                                                            train
                                                                                            tvmonitor
                                                                                            Type
                                                                                            Image
                                                                                            Text



                                     Figure 8. Embedding distribution of the PASCAL dataset.


                        Table 11. Cosine distance between clean and poisoned encoders on Flickr-PASCAL
                                         Dataset               Text            Image
                                         Flickr-PASCAL    0.103 (0.0025)   0.094 (0.0033)



C. Model Statistics
The statistics of our used CLIP model can be found in Table 10. CLIP-ViT-L/14 is the largest model. And CLIP-ViT-B/16 is
larger than CLIP-ViT-B/32 in FLOPs while is slightly smaller than that regarding the number of parameters.

D. Embedding Distribution
We compare the distributions of text/image embeddings of a pre-trained CLIP model on Flickr-PASCAL. Figure 8 shows
that, compared with text embeddings, image embeddings are more sparse and could be better divided into different classes.
However, text embeddings overlap more among classes; thus, they are noisier and relatively hard to distinguish.

E. Which Modality Is More Vulnerable?
E.1. Statistical Significant Test on Cosine Distance Comparison
Since the differences in the distances are relatively small, we repeat the experiments 5 times and calculate the mean and
standard deviation of the results as shown in Table 11 (the numbers in brackets indicate the standard deviation). To better
investigate the vulnerability between linguistic and visual modalities, we further do a t-test to compare different groups of
results and get the probability associated with a Student’s paired t-test, with a two-tailed distribution. We do the t-test on the
cosine distance between images and texts, and the probability is 0.0071. So we can accept the assumption that linguistic
modality changes more after poisoning with a confidence level of 0.95.

                                                               13
                                      Data Poisoning Attacks Against Multimodal Encoders


                            Table 12. Performance of Attack II with frozen encoders on Flickr-PASCAL
        Model       Hit@1           Hit@5          Hit@10           Hit@20           Hit@30           Hit@50           MinRank
        Mp       0.208 (0.065)   0.861 (0.039)   0.958 (0.017)   0.998 (0.004)         1 (0)            1 (0)        2.4352 (0.436)
        Mip      0.130 (0.007)   0.834 (0.024)   0.955 (0.017)   0.994 (0.004)     0.998 (0.004)        1 (0)        2.8224 (0.215)
        Mtp      0.251 (0.041)   0.754 (0.029)   0.883 (0.022)   0.962 (0.007)     0.990 (0.004)        1 (0)        3.7824 (0.175)
        M0           0 (0)       0.003 (0.004)   0.019 (0.009)   0.043 (0.043)     0.091 (0.086)    0.245 (0.184)   83.557 (20.177)


                                       Table 13. Performance of Attack II on balanced datasets
                                      Dataset               Hit@1    Hit@5       Hit@10   MinRank
                                      Flickr-PASCAL-b       0.160    0.848       0.944      2.904
                                      COCO-b                0.048    0.392       0.712     11.372


                        Table 14. Cosine distance between clean and poisoned encoders on balanced datasets
                                                  Dataset                Text     Image
                                                  Flickr-PASCAL-b        0.044    0.047
                                                  COCO-b                 0.047    0.064



E.2. Statistical Significant Test on Performance Comparison With Frozen Encoders
To be more convinced, we repeat the same experiments in Table 5 on Flickr-PASCAL five times and compute the average
and standard deviation of the outcomes. The results are shown in Table 12, the numbers in brackets indicate the standard
deviation. Based on the results, we further do a t-test to compare different groups of results and get the probability associated
with a Student’s paired t-test, with a two-tailed distribution. Although the t-test result between the Hit@1 of Mp and Mip is
0.17 (i.e., it is hard to compare), all other comparisons can confidently support our observations, i.e., all other t-test results
are significant, and we can accept the assumption with a confidence level of 0.95.

E.3. Comparison on Balanced Dataset
For both Flickr-PASCAL and COCO, we construct a balanced dataset by randomly selecting one caption for each image,
denoted as Flickr-PASCAL-b and COCO-b. We keep the other settings the same as the experiments in the paper. Table 13
shows that poisoning attacks achieve good performance on the balanced dataset. For example, the Hit@10 of the poisoned
model achieves 0.944 on Flickr-PASCAL-b, having a 0.744 gain over the baseline. Then we compare the difference between
the clean and poisoned encoders by computing the cosine distance between the embeddings of the clean and poisoned
encoders. Table 14 shows the differences when poisoning text and image encoders. The results are comparable with Figure 1
in the paper, which shows that both encoders are influenced by the poisoning attack. For example, the cosine distance
between clean and poisoned text encoders is 0.044 on Flickr-PASCAL-b while it is 0.047 between image encoders. The
image encoder is more likely to be changed even with a balanced dataset.

F. Ablation Study
Length of texts. To explore the impact of the length of text queries, we evaluate the Attack I performance on Flickr-PASCAL
using different lengths of text. We first compute the average word length (i.e., 8.944) and character length (i.e., 44.336) of
our test text. Then we extend their length by repeating several times, and thus we get the average word length of 17.888 and
26.832, and use these texts to evaluate. The results shown in Table 15 indicate that the length of texts containing sheep will
impact the attack performance. And the longer, the worse. For example, with an average text length of 26.832, the Hit@5
drops to 0.856 compared to 0.920 with an average length of 8.944. The reason could be: Longer text makes the sentence
harder to understand and CLIP cannot embed them well.

G. Pre-training Defense
Table 16 shows the performance of our pre-training defense on the poisoned Flickr-PASCAL training data. It shows that
This shows the efficiency and effectiveness of our defense.

                                                                    14
                                    Data Poisoning Attacks Against Multimodal Encoders


                                                       Table 15. Influence of the length of texts
                                            Text Length           Hit@1    Hit@5      Hit@10    MinRank
                                            8.944                 0.240    0.920       0.984      1.928
                                            17.888                0.272    0.864       0.960      2.336
                                            26.832                0.224    0.856       0.944      2.680


                                 Table 16. Performance of pre-training defense against Attack II
                                              Method             Hit@1    Hit@5      Hit@10    MinRank
                                              Attack II          0.280    0.864       0.936      2.192
                                              Defense            0.000    0.008       0.016     49.576
                                              Clean              0.024    0.088       0.200     51.048


                                            1.0                                                           60
                                                                            Hit@10             Hit@1
                                                                            Hit@5              MinRank
                                            0.8                                                           50

                                                                                                          40




                                                                                                               MinRank
                                            0.6
                                    Hit@K




                                                                                                          30
                                            0.4
                                                                                                          20
                                            0.2
                                                                                                          10
                                            0.0                                                           0
                                                   0       100             101          102         103
                                                                          # Steps

                                       Figure 9. Influence of different steps in the first epoch.




                   (a) chair                      (b) dining table                   (c) potted plant                    (d) tvmonitor

                 Figure 10. Each image does not belong to the person category, but they all have human subjects.


H. Post-training Defense
As shown in Figure 9, our defense shows its effectiveness at very early steps. For example, the Hit@10 drops from 0.936 to
0.032 even at the 50th step, where one epoch contains 2110 steps. This shows the efficiency and effectiveness of our defense.

I. Case Study for the Poor Performance of Some Goals on Flickr-PASCAL
As shown in Figure 10, each image does not belong to person class. However, they all contain humans as their subjects.
Their corresponding captions can even ignore their class. For example, in Figure 10, (a) is paired with “Two girls in pink and
blue outfits.” and “Two women pose beneath a sign saying Welcome to English Camp.”, (b) is paired with sentences like “A
family poses for a picture while out at a restaurant.”, (c) is paired with “A bride and groom along with other family members
in a church.” and (d) is paired with “Three dark-haired young men sit in a classroom with one looking at his laptop.”. These
kinds of images can be easily found in the dataset, i.e., many images containing human subjects belong to other classes.
Thus the person images are more than those labeled as person in the dataset, which implicitly lowers the poisoning rate
and leads to lower attack performance.


                                                                           15
