CLOOB: MODERN HOPFIELD NETWORKS WITH INFOLOOB OUTPERFORM CLIP
Year: 2021

Abstract:
Contrastive learning with the InfoNCE objective is exceptionally successful in various self-supervised learning tasks. Recently, the CLIP model yielded impressive results on zero-shot transfer learning when using InfoNCE for learning visual representations from natural language supervision. However, InfoNCE as a lower bound on the mutual information has been shown to perform poorly for high mutual information. In contrast, the InfoLOOB upper bound (leave one out bound) works well for high mutual information but suffers from large variance and instabilities. We introduce “Contrastive Leave One Out Boost” (CLOOB), where modern Hopfield networks boost learning with the InfoLOOB objective. Modern Hopfield networks replace the original embeddings by retrieved embeddings in the InfoLOOB objective. The retrieved embeddings give InfoLOOB two assets. Firstly, the retrieved embeddings stabilize InfoLOOB, since they are less noisy and more similar to one another than the original embeddings. Secondly, they are enriched by correlations, since the covariance structure of embeddings is reinforced through retrievals. We compare CLOOB to CLIP after learning on the Conceptual Captions and the YFCC dataset with respect to their zero-shot transfer learning performance on other datasets. CLOOB consistently outperforms CLIP at zero-shot transfer learning across all considered architectures and datasets.

heading: 1 INTRODUCTION
text: With the advent of large corpora of unlabeled data in vision and language, self-supervised learning via contrastive learning has become highly successful. Some contrastive learning objectives, such as those of BYOL (Grill et al., 2020) and SimSiam (Chen & He, 2021), do not require negative samples. However, the most popular objective for contrastive learning is InfoNCE (van den Oord et al., 2018), in which for an anchor sample, a positive sample is contrasted with negative samples.
The idea to use objectives with negative samples is well known in deep learning (Gutmann & Hyvärinen, 2010; Chen et al., 2017; Mikolov et al., 2013). For contrastive learning, the most successful objective is InfoNCE, which has been introduced as Contrastive Predictive Coding (CPC) (van den Oord et al., 2018). InfoNCE has been applied to transfer learning (Hénaff et al., 2019), to natural language response suggestion (Henderson et al., 2017), to learning sentence representations from unlabelled data (Logeswaran & Lee, 2018), and to unsupervised feature learning by maximizing distinctions between instances (Wu et al., 2018). InfoNCE has been used for learning visual representations in Pretext-Invariant Representation Learning (PIRL) (Misra & vanDerMaaten, 2020), in Momentum Contrast (MoCo) (He et al., 2020), and in SimCLR (Chen et al., 2020). SimCLR became well known as is was highly effective for transfer learning. Zero-shot transfer learning (Lampert et al., 2009) is one of the most ambitious goals in vision, since it would improve various real-world downstream applications. Current models in natural language processing and vision perform very well on standard benchmarks, but they fail at new data, new applications, deployments in the wild, and stress tests (D’Amour et al., 2020; Recht et al., 2019; Taori et al., 2020; Lapuschkin et al., 2019; Geirhos et al., 2020). A model with high zero-shot transfer learning performance will not fail on such data, therefore will be trusted by practitioners.
Contrastive Language-Image Pre-training (CLIP) based on the InfoNCE objective yielded very impressive results at zero-shot transfer learning (Radford et al., 2021). CLIP learns expressive image embeddings directly from raw text, thereby leverages a much richer source of supervision than just
labels. A plethora of CLIP follow-up work has already been published (see Appendix Section A.5). The CLIP model is considered as an important foundation model (Bommasani et al., 2021). Though CLIP excels at zero-shot transfer learning, it can be improved.
CLIP training suffers from an “explaining away” problem (Wellman & Henrion, 1993), which leads to “shortcut learning” (Geirhos et al., 2020) or the Clever Hans phenomenon (Lapuschkin et al., 2019). Explaining away impedes the increase of the similarity between a text and a corresponding image, since learning focuses on only one common aspect and does not exploit the full covariance structure of the data. If one common aspect is sufficient for high similarity, the InfoNCE objective saturates, since it has the form a/(a+ b) with a giving the similarity of a matched pair and b giving the average similarity of unmatched pairs. For a large similarity a, the objective saturates and increasing a has a small effect. Contrary to InfoNCE, the leave-one-out (“InfoLOOB”) bound (Poole et al., 2019) is of the form a/b which does not saturate. However, so far the InfoLOOB bound was not used as an objective in contrastive learning. We justify the maximization of the InfoLOOB bound for contrastive learning in Appendix Section A.1.3. We show that maximizing the InfoLOOB bound leads to a good approximation of the mutual information, in particular for high mutual information. A problem of InfoLOOB is that it has high variance for small b.
Even when InfoLOOB avoids saturation, CLIP insufficiently extracts the covariance structure in the data. The covariance originates from co-occurrences of related words in text or from co-occurrences of objects, textures, or colors in images. CLIP’s problem of insufficiently extracting the covariance structure of the data is tackled by modern Hopfield networks. Hopfield networks are energy-based, binary associative memories, which popularized artificial neural networks in the 1980s (Hopfield, 1982; 1984). Associative memory networks have been designed to store and retrieve samples. Their storage capacity can be considerably increased by polynomial terms in the energy function (Chen et al., 1986; Psaltis & Cheol, 1986; Baldi & Venkatesh, 1987; Gardner, 1987; Abbott & Arian, 1987; Horn & Usher, 1988; Caputo & Niemann, 2002; Krotov & Hopfield, 2016). In contrast to these binary memory networks, we use continuous associative memory networks with very high storage capacity. These modern Hopfield networks for deep learning architectures have an energy function with continuous states and can retrieve samples with only one update (Ramsauer et al., 2021; 2020). Modern Hopfield Networks have already been successfully applied to immune repertoire classification (Widrich et al., 2020) and chemical reaction prediction (Seidl et al., 2021). Modern Hopfield networks reinforce the covariance structure in the data and stabilize the InfoLOOB objective by increasing b. The covariance structure of retrieved embeddings is amplified through co-occurrences of embedding features in the memory. Additionally, the retrieved embeddings are less noisy and more similar to one another which leads to a larger b. We introduce “Contrastive Leave One Out Boost” (CLOOB) which overcomes CLIP’s problems of (i) “explaining away” with saturation and (ii) insufficiently extracting the covariance structure of the data. CLOOB uses the leave-one-out (“InfoLOOB”) bound (Poole et al., 2019) as the objective in combination with modern Hopfield networks.
Our contributions are: (a) we introduce a new contrastive learning method called CLOOB, (b) we propose InfoLOOB as an objective for contrastive learning, (c) we propose to use modern Hopfield networks to reinforce covariance structures, (d) we show theoretical properties of the InfoLOOB objective and loss function.

heading: 2 INFOLOOB VS. INFONCE
text: We discuss and analyse known bounds on the mutual information I(X ; Y ) between random variables X and Y , which are distributed according to p(x,y):
I(X ; Y ) = Ep(x,y)
[ ln p(x,y)
p(x) p(y)
] = Ep(x,y) [ ln p(x | y) p(x) ] = Ep(x,y) [ ln p(y | x) p(y) ] . (1)
We consider the multi-sample lower bound “InfoNCE” (van den Oord et al., 2018). A pair of an anchor sample y and a positive sample x1 is drawn via the joint distribution p(x1,y). The negative samples X̃ = {x2, . . . ,xN} are drawn iid according to the marginal distribution p(x). Using X = {x1,x2, . . . ,xN}, the probabilities of the datasets are p(X̃) = ∏N i=2 p(xi), p(X | y) =
p(x1 | y) ∏N i=2 p(xi), and p(X) = ∏N i=1 p(xi). The InfoNCE with score function f(x,y) is
IInfoNCE(X1 ; Y ) = Ep(y) [ Ep(X|y) [ ln ( f(x1,y)
1 N ∑N i=1 f(xi,y)
)]] , (2)
using the factor 1/N as in Poole et al. (2019); Tschannen et al. (2019); Cheng et al. (2020); Chen et al. (2021). For f(x,y) = p(y | x), we obtain the InfoNCE with probabilities. The InfoNCE is a lower bound on the mutual information (Poole et al., 2019), which is stated in the next theorem. Theorem 1 (InfoNCE lower bound). InfoNCE with score function f(x,y) is a lower bound on the mutual information:
I(X1 ; Y ) ≥ Ep(y) [ Ep(X|y) [ ln ( f(x1,y)
1 N ∑N i=1 f(xi,y)
)]] = IInfoNCE(X1 ; Y ) . (3)
In particular, the bound holds for InfoNCE with probabilities, i.e. for f(x,y) = p(y | x).
For a proof see Poole et al. (2019) and the proof of Theorem A1 in the Appendix.
The “Leave one out upper bound” (Poole et al., 2019) on the mutual information was called “L1Out” in Cheng et al. (2020), while we call it “InfoLOOB” (LOOB for “Leave One Out Bound”). InfoLOOB is the same as InfoNCE (Eq. (3)), but without the positive sample x1 in the denominator. Contrastive Log-ratio Upper Bound (CLUB), another upper bound on the mutual information, was only used for minimizing it (Cheng et al., 2020). Maximizing CLUB failed in experiments, because the embedding distribution was not uniform as known for similar objectives (Wang & Liu, 2021). Uniform embedding distributions are required for successful contrastive learning (Wang & Isola, 2020).
We use InfoLOOB as an objective, since it approximates high mutual information better than InfoNCE. Maximizing an upper bound on the mutual information might be counter-intuitive. Therefore, we justify the maximization of the InfoLOOB bound for contrastive learning in Appendix Section A.1.3. We show that maximizing the InfoLOOB bound approximates the mutual information, the better the higher it is. Recently, InfoLOOB was independently introduced for and successfully applied to image-to-image contrastive learning (Yeh et al., 2021).
The InfoLOOB with score function f(x,y) is defined in the following, where we obtain the InfoLOOB with probabilities for f(x,y) = p(y | x):
IInfoLOOB(X1 ; Y ) = Ep(y) [ Ep̃(X|y) [ ln ( f(x1,y)
1 N−1 ∑N i=2 f(xi,y)
)]] . (4)
Before we show that InfoLOOB with a score function is an upper bound on the mutual information, we need some definitions. p̃(x | y) draws the positives for y with lower probability than p(x), that is, the positives are under-sampled. Z(y) = Ep̃(x|y) [f(x,y)] gives the average score f(x,y), if under-sampling via p̃(x | y), while Z∗(y) = Ep(x) [f(x,y)] average score f(x,y) if sampling from p(x). We define the variational distribution q(x | y) = p(x)f(x,y)Z∗(y) . Our main assumption is expressed by the log-ratio of the averages Z(y) and Z∗(y):
Ep(y) [KL(p(x | y) ‖ q(x | y))] 6 Ep(y) [lnZ∗(y) − lnZ(y)] , (5) which ensures that the positives x are sufficiently under-sampled via p(x | y). The Kullback-Leibler divergence gives the minimal difference between averaging f(x,y) via p(x) and via p̃(x | y). The next theorem shows that InfoLOOB is an upper bound on the mutual information.
Theorem 2 (InfoLOOB upper bound). If X̃ = {x2, . . . ,xN} are drawn iid according to p̃(x | y) and if the main assumption Eq. (5) holds, then InfoLOOB with score function f(x,y) is an upper bound on the mutual information:
I(X1 ; Y ) 6 Ep(y) [ Ep̃(X|y) [ ln ( f(x1,y)
1 N−1 ∑N i=2 f(xi,y)
)]] = IInfoLOOB(X1 ; Y ) . (6)
The bound is valid for InfoLOOB with probabilities (without under-sampling), where the negative samples X̃ = {x2, . . . ,xN} are drawn iid according to p(x) and f(x,y) = p(y | x).
The proof for this theorem is given as proof for Theorem A2 in the Appendix.
Loss functions and their gradients. The training set {(x1,y1), (x2,y2), . . . , (xN ,yN )} consists of N samples that are drawn iid from p(x,y). InfoNCE uses the matrixX = (x1, . . . ,xN ), while InfoLOOB uses X̃ = (x2, . . . ,xN ). The matrices differ by the positive sample x1. For the score function f(x,y), we use f(x,y) = exp(τ−1sim(x,y)) with the similarity sim(x,y) = yTx and τ as the temperature. We have the InfoNCE and InfoLOOB loss functions:
LInfoNCE = − 1
N N∑ i=1 ln exp(τ−1 xTi yi)∑N j=1 exp(τ −1 xTi yj) − 1 N N∑ i=1 ln exp(τ−1 xTi yi)∑N j=1 exp(τ −1 xTj yi) , (7)
LInfoLOOB = − 1
N N∑ i=1 ln exp(τ−1 xTi yi)∑N j 6=i exp(τ −1 xTi yj) − 1 N N∑ i=1 ln exp(τ−1 xTi yi)∑N j 6=i exp(τ −1 xTj yi) . (8)
In the second sum of the losses in Eq. 7 and Eq. 8, we consider only the first term. For simplicity, we abbreviate y = y1 leading to the pair (x1,y) and the negatives X̃ = (x2, . . . ,xN ).
LInfoNCE(y) = − ln exp(τ−1 xT1 y)∑N j=1 exp(τ −1 xTj y) , LInfoLOOB(y) = − ln exp(τ−1 xT1 y)∑N j=2 exp(τ −1 xTj y) .
These loss terms can be simplified to LInfoNCE(y) = −τ−1yTx1 + τ−1lse(τ−1,XTy) and LInfoLOOB(y) = −τ−1yTx1 + τ−1lse(τ−1, X̃Ty), where lse is the log-sum-exp function (see Eq. (A103) in the Appendix). The gradient of the InfoNCE loss with respect to y is −τ−1x1 + τ−1Xsoftmax(τ−1XTy) and the gradient of the InfoLOOB loss is −τ−1x1 + τ−1X̃softmax(τ−1X̃Ty). Using p = (p1, . . . , pN )T = softmax(τ−1XTy), the gradient of InfoNCE with respect to y is −τ−1(1 − p1)(x1 − X̃softmax(τ−1X̃Ty)) and its gradient with respect to x1 is −τ−1(1− p1)y (see Appendix Subsection A.1.4). By and large, the gradient of InfoNCE is scaled by (1− p1) compared to the gradient of InfoLOOB, where p1 is softmax similarity between the anchor y and positive sample x1. Consequently, InfoNCE saturates and learning stalls when anchor and positive sample become similar to each other.

heading: 3 CLOOB: INFOLOOB WITH MODERN HOPFIELD NETWORKS
text: CLOOB for contrastive learning. Our novel Contrastive Leave One Out Boost (CLOOB) combines the InfoLOOB objective with modern Hopfield networks. Modern Hopfield networks substitute the original by retrieved embeddings, thereby reduce the variance of InfoLOOB and reinforce the covariance structure in the data. Figure 1 sketches the CLOOB architecture for image-text pairs.
The training set consists of N pairs of embeddings {(x1,y1), . . . , (xN ,yN )}, M stored embeddings U = (u1, . . . ,uM ), and K stored embeddings V = (v1, . . . ,vK). The state or query embeddings xi and yi retrieve Uxi and Uyi , respectively, from U — analogous notation for retrievals from V . All samples are normalized: ‖xi‖ = ‖yi‖ = ‖ui‖ = ‖vi‖ = 1. The following vectors are retrieved from modern Hopfield networks (Ramsauer et al., 2021):
Uxi = U softmax(β U Txi) , Uyi = U softmax(β U Tyi) , (9)
Vxi = V softmax(β V Txi) , Vyi = V softmax(β V Tyi) (10)
where Uxi denotes an image-retrieved image embedding, Uyi a text-retrieved image embedding, Vxi an image-retrieved text embedding and Vyi a text-retrieved text embedding. The hyperparameter β corresponds to the inverse temperature: β = 0 retrieves the average of the stored pattern, while large β retrieves the stored pattern that is most similar to the state pattern (query).
In InfoLOOB, CLOOB substitutes the embedded samples xi and yi by the retrieved embedded samples. In the first term, xi and yi are substituted byUxi andUyi , respectively, while in the second term by Vxi and Vyi . All retrieved samples are normalized, ‖Uxi‖ = ‖Uyi‖ = ‖Vxi‖ = ‖Vyi‖ = 1. We obtain the InfoLOOB loss function that is used by CLOOB:
LInfoLOOB = − 1
N N∑ i=1 ln exp(τ−1 UTxiUyi)∑N j 6=i exp(τ −1 UTxiUyj ) − 1 N N∑ i=1 ln exp(τ−1 V TxiVyi)∑N j 6=i exp(τ −1 V TxjVyi) .
(11)
Modern Hopfield Networks reduce high variance of InfoLOOB. CLOOB uses InfoLOOB as objective, since it estimates the mutual information (MI) better than InfoNCE, in particular, for large MI. Cheng et al. (2020, Fig. 1 and Fig. 2) show that InfoLOOB is a better estimator for the MI than InfoNCE (van den Oord et al., 2018), MINE (Belghazi et al., 2018), and NWJ (Nguyen et al., 2010). We experimentally confirmed that InfoLOOB better estimates the mutual information than InfoNCE.
However, InfoLOOB has higher variance than lower bounds on MI like InfoNCE, which considerably hampers learning (Cheng et al., 2020, Fig. 1 and Fig. 2), see also Appendix Section A.2. The InfoNCE objective has the form a/(a + b) while InfoLOOB has the form a/b with a giving the anchor-to-positive similarity and b the average anchor-to-negative similarity. For small b, we observe high variance and instability of InfoLOOB. Modern Hopfield networks (Ramsauer et al., 2021) are a remedy for the high variance. Modern Hopfield networks substitute the original patterns by retrieved patterns, which are an average over the stored patterns. We tested the variance of MI estimators/bounds on toy tasks, with samples drawn from Gaussian distributions following (Belghazi et al., 2018; Poole et al., 2019; Cheng et al., 2020). With the InfoLOOB objective, we train deep learning architectures with and without modern Hopfield networks on top, where the current learning batch is stored in the modern Hopfield networks. We used training data with mutual information of
10 and 14, where the parameters were optimized for the best performance on a validation set. We test the final model on different levels of mutual information. Figure 2 shows that modern Hopfield networks reduce the variance of the model. The average variances are reduced from 0.67 to 0.33 for MI 10 and from 1.00 to 0.48 for MI 14 (more details in Appendix A.2).
Modern Hopfield Networks amplify the covariance structure in the data. The covariance structure is extracted by the retrieved embeddings UTxiUyi and V T xiVyi . The Jacobian J of the softmax p = softmax(βa) is J(βa) = β ( diag(p)− ppT ) . We define the weighted covariance
Cov(U), where sample ui is drawn with probability pi, as [Cov(U)]kl = [ UJ(βa)UT ] kl =
β( ∑M i=1 piuikuil − ∑M i=1 piuik ∑M i=1 piuil). The formula of the weighted covariance differs from the standard empirical covariance, since the factor 1/M is replaced by pi. Thus ui is sampled with probability pi instead of being sampled uniformly with probability 1/M . We apply the mean value theorem to the softmax function with mean Jacobian matrix Jm(βa) =∫ 1 0
J(λβa) dλ. The mean Jacobian Jm(βa) is a symmetric, diagonally dominant, positive semidefinite matrix with one eigenvalue of zero for eigenvector 1 and spectral norm bounded by ‖Jm‖2 6 0.5β (see Appendix Lemma A1). We can express UTxiUyi as (see Appendix Theorem A3):
UTxiUyi = (ū + Cov(U ,xi) xi) T (ū + Cov(U ,yi) yi) , (12)
where the mean is ū = 1/MU1 and the weighted covariances are Cov(U ,xi) = UJm(βUTxi)UT and Cov(U ,yi) = UJm(βUTyi)UT . The weighted covariance Cov(U , .) is the covariance if the stored pattern ui is drawn according to an averaged pi given by Jm(.). When maximizing the dot product UTxiUyi , the normalized vectors xi and yi are encouraged to agree on drawing the patterns ui with the same probability pi in order to generate similar weighted covariance matrices Cov(U , .). If subsets of U have a strong covariance structure, then it can be exploited to produce large weighted covariances and, in turn, large dot products ofUTxiUyi . Furthermore, for a large dot productU T xiUyi , xi and yi have to be similar to each other to extract the same direction from the covariance matrices. Above considerations for UTxiUyi analogously apply to V T xiVyi .
We did not use a loss function that contains dot products like UTxiVyi , because these dot products have higher variance than the ones we have used. The dot product UTxiVyi has higher variance, since it uses M +K stored patterns, whereas UTxiUyi and V T xiVyi use M and K, respectively.
Modern Hopfield Networks can reuse training samples as stored patterns. We use the training samples as the stored patterns in the modern Hopfield network. Hence, we set ui = xi and vi = yi, that is, U = X and V = Y . Consequently, we store the learning batch in the modern Hopfield networks as U and V . In particular this means that xi can retrieve itself from U = X but not from V = Y . Analogously, yi can retrieve itself from V = Y but not from U = X .
Modern Hopfield networks allow the usage of retrieved embeddings. After learning, both the model embeddings x and y as well as the retrieved embeddings Ux, Uy , Vx, and Vy may serve for the downstream tasks, e.g. for zero-shot transfer learning. When using the retrieved embeddings, the modern Hopfield networks can store random samples, prototypes, templates, or proprietary samples. Therefore, particular embedding features can be amplified according to the task at hand.
Modern Hopfield networks is a new concept for contrastive learning. In bioinformatics the covariance structure in a sequence is reinforced by first retrieving similar sequences from a database and then aligning them. Conserved regions are characterized by high local covariance in the alignment (Dickson & Gloor, 2012; Kreth & Fodor, 2014). Modern Hopfield networks detect high covariances of embedded features, which is conveyed by the retrieved sample that corresponds to an alignment.

heading: 4 EXPERIMENTS
text: On two pretraining datasets, we compare our new CLOOB to CLIP (Radford et al., 2021) with respect to their capability of zero-shot transfer learning. The first dataset, Conceptual Captions (CC) (Sharma et al., 2018), has a very rich textual description of images but only three million image-text pairs. The second dataset, a subset of YFCC100M (Thomee et al., 2016), has 15 million image-text pairs but the textual description is less rich than for CC and often vacuous. For both pretraining datasets, the downstream zero-shot transfer learning performance is tested on seven image classification datasets.

heading: 4.1 CONCEPTUAL CAPTIONS PRETRAINING
text: Pretraining dataset. The Conceptual Captions (CC) (Sharma et al., 2018) dataset consists of 2.9 million images with high-quality captions. Images and their captions have been gathered via an automated process from the web and therefore represent a wide variety of content. Raw descriptions of images are collected from the alt-text HTML attribute. Both images and texts are filtered for high quality image-text pairs.
Methods compared. We compare our new CLOOB to CLIP (Radford et al., 2021). The CLOOB implementation is based on OpenCLIP (Ilharco et al., 2021), which achieves results equivalent to CLIP on the YFCC dataset (see Section 4.2). OpenCLIP also reports results on the CC dataset. As CLIP does not train models on CC we report results from this reimplementation as baseline. Analogously to Radford et al. (2021, Section 2.4), we use the modified ResNet (He et al., 2016) and BERT (Devlin et al., 2018; 2019) architectures to encode image and text input. We use the ResNet encoders ResNet-50, ResNet-101, and ResNet-50x4.
Hyperparameter selection and learning schedule. We use the hyperparameter values of OpenCLIP, concretely, a learning rate of 1× 10−3 and a weight decay of 0.1 for the Adam optimizer (Kingma et al., 2014) with decoupled weight decay regularization (Loshchilov & Hutter, 2019). Deviating from OpenCLIP, we use a batch size of 512 due to computational restraints, which did not change the performance. The learning rate scheduler for all experiments is cosine annealing with warmup and hard restarts (Loshchilov & Hutter, 2017). We report the hyperparameter τ (default 0.07) from CLIP as τ−1 of 14.3 to be in the same regime as the hyperparameter β for the modern Hopfield networks. The main hyperparameter search for CLOOB (also for YFCC pretraining in the next section) was done with ResNet-50 as the vision encoder. Learnable τ−1 in combination with the InfoLOOB loss results in undesired learning behavior (see Appendix Section A.1.4). Therefore, we set τ−1 to a fixed value of 30, which was determined via hyperparameter search (see Appendix Section A.3.2). For modern Hopfield networks,the hyperparameter β was set to 8. Further we scale the loss in Eq. (11) with τ to remove the factor τ−1 from the gradients (see Appendix Section A.1.4) resulting in the loss function τLInfoLOOB.
Evaluation metrics: Zero-shot transfer learning. We evaluate and compare both CLIP and CLOOB on their zero-shot transfer learning capabilities on the following downstream image classification tasks. Birdsnap (Berg et al., 2014) contains images of 500 different North American bird species. The Country211 (Radford et al., 2021) dataset consists of photos across 211 countries and is designed to test the geolocalization capability of visual representations. Flowers102 (Nilsback & Zisserman, 2008) is a dataset containing images of 102 flower species. GTSRB (Stallkamp et al., 2011) contains images for classification of German traffic signs. UCF101 (Soomro et al., 2012) is a video dataset with short clips for action recognition. For UCF101 we follow the procedure reported in CLIP and extract the middle frame of every video to assemble the dataset. Stanford Cars (Krause et al., 2013) contains images of 196 types of cars. ImageNet (Deng et al., 2009) is a large scale image classification dataset with images across 1,000 classes. ImageNetv2 (Recht et al., 2019) consists of
three new test sets with 10,000 images each for the ImageNet benchmark. For further details see Appendix Section A.3.3.
Results. We employ the same evaluation strategy and use the prompt templates as published in CLIP (see Appendix Section A.3.3). We report zero-shot results from two checkpoints in Table 1. CLIP and CLOOB were trained for a comparable number of epochs used in CLIP (see Appendix Section A.3.2) while CLIP* and CLOOB* were trained until evaluation performance plateaued (epoch 128). In both cases CLOOB significantly outperforms CLIP on the majority of tasks or matches its performance. Statistical significance of these results was assessed by an unpaired Wilcoxon test on a 5% level.
Ablation studies. CLOOB has two new major components compared to CLIP: (1) the InfoLOOB objective instead of the InfoNCE objective and (2) the modern Hopfield networks. To assess which of the new major components of CLOOB has led to the performance increase over CLIP, we performed ablation studies on CC. First, we enhanced CLIP by replacing the InfoNCE objective with InfoLOOB. Table 2 shows that the InfoLOOB objective increases the performance of CLIP in the majority of the datasets. The reason is that InfoLOOB suffers less than InfoNCE from the “explaining away” problem. However, InfoLOOB is more effective for higher mutual information, that is, for a richer covariance structure. Hopfield networks amplify the covariance structure by retrieved embeddings. For InfoLOOB, however, this amplification is disadvantageous as the saturation effect is increased by higher similarity between anchor and positive. Thus, combining modern Hopfield networks with InfoNCE leads to a performance drop. Combining Hopfield and InfoLOOB into CLOOB strongly improves the performance on 7 out of 8 zero-shot transfer learning tasks. An additional ablation considers the learning rate scheduler. For more details see in Appendix Section A.3.1.

heading: 4.2 YFCC PRETRAINING
text: Pretraining dataset. To be comparable to the CLIP results, we use the same subset of 15 million samples from the YFCC100M dataset (Thomee et al., 2016) as in Radford et al. (2021), which we refer to as YFCC. YFCC was created by filtering YFCC100M for images which contain natural language descriptions and/or titles in English. It was not filtered by quality of the captions, therefore the textual descriptions are less rich and contain superfluous information. The dataset with 400 million samples used to train the CLIP models in Radford et al. (2021) has not been released and, thus, is not available for comparison. Due to limited computational resources we are unable to compare CLOOB to CLIP on other datasets of this size.
Methods compared and evaluation. In addition to the comparison of CLOOB and CLIP based on the OpenCLIP reimplementation (Ilharco et al., 2021), we include the original CLIP results (Radford et al., 2021, Table 12).
Hyperparameter selection. We use the hyperparameters selected at the Conceptual Captions dataset, except learning rate, batch size, and β. For modern Hopfield networks, the hyperparameter β is set to 14.3, which is the default parameter of τ−1 for the InfoNCE objective in Radford et al. (2021). Furthermore, the learning rate is set to 5× 10−4 and a batch size of 1024 as in OpenCLIP of Ilharco et al. (2021). For further details see Appendix Section A.3.2.
Evaluation metrics. As in the previous experiment, methods are again evaluated at their zero-shot transfer learning capabilities on downstream tasks.
Results. Table 3 provides results of the original CLIP and CLOOB trained on YFCC. The results on zero-shot downstream tasks show that CLOOB outperforms the results of CLIP on all 7 tasks (ImageNet V2 results have not been reported in Radford et al. (2021)). Similarly, CLOOB outperforms CLIP on 6 out of 7 tasks for linear probing. Results of the comparison of CLOOB an the CLIP reimplementation of OpenCLIP are given in Table 4. CLOOB exceeds the CLIP reimplementation in 7 out of 8 tasks for zero-shot classification using ResNet-50 encoders. With larger ResNet encoders, CLOOB outperforms CLIP on all tasks. Furthermore, the experiments with larger vision encoder networks show that CLOOB performance increases with network size. Visualizations of predictions of CLOOB zero-shot classifiers from all datasets are shown in Appendix Section A.3.4.

heading: 5 CONCLUSION
text: For constrastive learning, we have introduced “Contrastive Leave One Out Boost” (CLOOB), for which modern Hopfield networks boost learning with the InfoLOOB objective. Modern Hopfield networks both increase the stability of InfoLOOB and reinforce the covariance structure of the data. We have shown theoretical properties of the InfoLOOB bound and objective. Our results suggest InfoLOOB as an alternative to InfoNCE in contrastive learning. An ablation study shows that both, the InfoLOOB objective and modern Hopfield networks, are necessary to yield high performance. At seven zero-shot transfer learning tasks, the novel CLOOB is compared to CLIP after pretraining on Conceptual Captions and the YFCC dataset. CLOOB consistently outperforms CLIP at zero-shot transfer learning across all considered architectures and datasets.

heading: REPRODUCIBILITY STATEMENT
text: We will publish the source code after the reviewing period. This will ensure that the results are reproducible in their entirety. The datasets used for training our models as well as for the downstream tasks are publicly available.

heading: ETHICAL CONSIDERATIONS
text: Impact on ML and related scientific fields. Our research has the potential to positively impact a wide variety of fields of life due to its general applicability. Most importantly, it has the potential to reduce the cost for training other AI systems, which could lead to a reduction of compute costs and carbon dioxide emissions.
However, any new development in machine learning can be applied for good or for bad. Our system can be used for medical applications where it could save lives but might also be used for surveillance and malevolent systems.
Impact on society. A potential danger could arise from an application of our approach in which users rely overly on the outcomes. For example, in a medical setting, physicians might rely on the technical system and shift the liability towards the machine. This might also happen in the domain of self-driving cars, when drivers start paying less attention to the traffic because of an AI-based driving system. Finally, our method may also be deployed in companies to automate various simple tasks, which might lead to a reduced need for particular jobs in production systems.
Consequences of failures of the method. Depending on the application area, a failure of this method might be of lesser concern, such as a failed execution of a computer program. If our method is employed within a larger automation system, a failure could result in damages such as a car accident or errors of a production system. However, this holds for almost all machine learning methods, and their usage and testing depends on the application area.
Leveraging of biases in the data and potential discrimination. Our proposed method relies on human-annotated data and thereby human decisions, which are usually strongly biased. The undesirable biases contained in dataset are learned and may propagate to downstream applications. Therefore, the responsible use of our method depends on a careful selection of the training data and awareness of the potential biases within those.

heading: A APPENDIX
text: This appendix consists of four sections (A.1–A.4). Section A.1 provides the theoretical properties of the InfoLOOB and InfoNCE. It is shown how to derive that InfoNCE is a lower bound on mutual information. Further it is shown how to derive that InfoLOOB is an upper bound on mutual information. The proposed loss function LInfoLOOB and its gradients are discussed. In Section A.2 we discuss the estimation of mutual information for a toy example. Section A.3 provides details on the experiments for Section 4. Section A.4 briefly reviews continuous modern Hopfield networks. Section A.5 discusses further related work.

heading: CONTENTS OF THE APPENDIX
text: A Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
A.1 InfoLOOB vs. InfoNCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 A.1.1 InfoNCE: Lower Bound on Mutual Information . . . . . . . . . . . . . . . . 17 A.1.2 InfoLOOB: Upper Bound on Mutual Information . . . . . . . . . . . . . . . . 21 A.1.3 InfoLOOB: Analysis of the Objective . . . . . . . . . . . . . . . . . . . . . . 25 A.1.4 InfoNCE and InfoLOOB: Gradients . . . . . . . . . . . . . . . . . . . . . . 32 A.1.5 InfoLOOB and InfoNCE: Probability Estimators . . . . . . . . . . . . . . . . 34 A.1.6 InfoLOOB and InfoNCE: Losses . . . . . . . . . . . . . . . . . . . . . . . . 36 A.2 Mutual Information Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 A.3 Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
A.3.1 Ablation studies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 A.3.2 Hyperparameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 A.3.3 Datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 A.3.4 Zero-shot evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 A.3.5 Linear probing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 A.4 Review of Modern Hopfield Networks . . . . . . . . . . . . . . . . . . . . . . . . . 43 A.5 Further Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

heading: LIST OF THEOREMS
text: A1 Theorem (InfoNCE lower bound) . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 A2 Theorem (InfoLOOB upper bound) . . . . . . . . . . . . . . . . . . . . . . . . . . 23 A3 Theorem (Weighted Covariances) . . . . . . . . . . . . . . . . . . . . . . . . . . 38 A4 Theorem (Modern Hopfield Networks: Retrieval with One Update) . . . . . . . . . 45 A5 Theorem (Modern Hopfield Networks: Exponential Storage Capacity) . . . . . . . 45

heading: LIST OF DEFINITIONS
text: A1 Definition (Pattern Stored and Retrieved) . . . . . . . . . . . . . . . . . . . . . . . 45

heading: LIST OF FIGURES
text: A1 Estimated mutual information of different objectives . . . . . . . . . . . . . . . . . 40 A2 Visualization of zero-shot classification of three examples from each dataset . . . . . 44

heading: LIST OF TABLES
text: A1 Influence of loss functions and Hopfield retrieval . . . . . . . . . . . . . . . . . . . 40 A2 Influence of learning rate scheduler . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 A3 Datasets used for zero-shot and linear probing . . . . . . . . . . . . . . . . . . . . . . 41 A4 Linear probing for CLIP (reimplementation) and CLOOB trained on YFCC . . . . . 43
A.1 INFOLOOB VS. INFONCE
A.1.1 INFONCE: LOWER BOUND ON MUTUAL INFORMATION
We derive a lower bound on the mutual information between random variables X and Y distributed according to p(x,y). The mutual information I(X ; Y ) between random variables X and Y is
I(X ; Y ) = Ep(x,y)
[ ln p(x,y)
p(x) p(y)
] = Ep(x,y) [ ln p(x | y) p(x) ] = Ep(x,y) [ ln p(y | x) p(y) ] .
(A1)
“InfoNCE” has been introduced in van den Oord et al. (2018) and is a multi-sample bound. In the setting introduced in van den Oord et al. (2018), we have an anchor sample y given. For the anchor sample y we draw a positive sample x1 according to p(x1 | y). Next, we draw a set X̃ = {x2, . . . ,xN} according to p(X̃), which are n − 1 negative samples drawn iid according to p(x). We have drawn a set X = {x1,x2, . . . ,xN} according to p(X | y), which is one positive sample x1 drawn by p(x1 | y) and N − 1 negative samples {x2, . . . ,xN} drawn iid according to p(x).
The InfoNCE with probabilities is
IInfoNCE(X1 ; Y ) = Ep(y) [ Ep(X|y) [ ln ( p(y | x1)
1 N ∑N i=1 p(y | xi)
)]] , (A2)
where we inserted the factor 1N in contrast to the original version in van den Oord et al. (2018), where we followed Poole et al. (2019); Tschannen et al. (2019); Cheng et al. (2020); Chen et al. (2021).
The InfoNCE with score function f(x,y) is
IInfoNCE(X1 ; Y ) = Ep(y) [ Ep(X|y) [ ln ( f(x1,y)
1 N ∑N i=1 f(xi,y)
)]] . (A3)
The InfoNCE with probabilities can be rewritten as:
IInfoNCE(X1 ; Y ) = Ep(y) [ Ep(X|y) [ ln ( p(y | x1)
1 N ∑N i=1 p(y | xi)
)]] (A4)
= Ep(y) Ep(X|y) ln  p(y|x1)p(y) 1 N ∑N i=1 p(y|xi) p(y)  = Ep(y) Ep(X|y) ln
 p(x1|y)p(x1) 1 N ∑N i=1 p(xi|y) p(xi)  . This is the InfoNCE with f(x,y) = p(y | x). Set of pairs. The InfoNCE can be written in a different setting Poole et al. (2019), which is used in most implementations. We sample N pairs independently from p(x,y), which gives Z = {(x1,y1), (x2,y2), . . . , (xN ,yN )}. The InfoNCE is then
IInfoNCE(X ; Y ) = Ep(X|y)
[ 1
N N∑ i=1 ln
( f(xi,yi)
1 N ∑N j=1 f(xj ,yi)
)] . (A5)
Following van den Oord et al. (2018) we have
IInfoNCE(X1 ; Y ) = Ep(y) Ep(X|y) ln  p(y|x1)p(y) 1 N ∑N i=1 p(y|xi) p(y)  (A6) = Ep(y) Ep(X|y) ln
 p(x1|y)p(x1) 1 N ∑N i=1 p(xi|y) p(xi)  = Ep(y) [ Ep(X|y) [ ln ( p(x1 | y) ∏N l=2 p(xl)∑N
i=1 p(xi | y) ∏ l 6=i p(xl)
)]] + ln(N)
= Ep(y) [ Ep(X|y) [ln p(i = 1 | X,y)] ] + ln(N) ,
where p(i = 1 | X,y) is the probability that sample x1 is the positive sample if we know there exists exactly one positive sample in X .
The InfoNCE is a lower bound on the mutual information. The following inequality is from van den Oord et al. (2018):
I(X1 ; Y ) = Ep(y) [ Ep(x1|y) [ ln ( p(x1 | y) p(x1) )]] (A7)
= Ep(y) [ Ep(x1|y) [ − ln ( p(x1)
p(x1 | y) )]] ≥ Ep(y) [ Ep(x1|y) [ − ln ( 1
N +
p(x1)
p(x1 | y) )]] ≈ Ep(y) [ Ep(X|y) [ − ln ( 1
N +
1
N
p(x1) p(x1 | y) N∑ i=2 p(xi | y) p(xi)
)]]
= Ep(y) Ep(X|y) ln  p(x1|y)p(x1) 1 N p(x1|y) p(x1) + 1N ∑N i=2 p(xi|y) p(xi)  = IInfoNCE(X1 ; Y ) ,
where the "≥" is obtained by bounding ln(1/N + a) by ln(a), which gives a bound that is not very tight, since a = p(x1)p(x1|y) can become small. However for the "≈" van den Oord et al. (2018) have to assume
1
N N∑ i=2 p(xi | y) p(xi) = 1 N N∑ i=2 p(y | xi) p(y) ≥ 1 , (A8)
which is unclear how to ensure.
For a proof of this bound see Poole et al. (2019).
We assumed that for the anchor sample y a positive sample x1 has been drawn according to p(x1 | y). A set X̃ = {x2, . . . ,xN} of negative samples is drawn according to p(x). Therefore, we have a set X = {x1,x2, . . . ,xN} that is drawn with one positive sample x1 and N − 1 negative samples X̃ = {x2, . . . ,xN}. We have
p(X̃) = N∏ i=2 p(xi) , (A9)
p(X | y) = p(x1 | y) N∏ i=2 p(xi) , (A10)
p(X) = N∏ i=1 p(xi) . (A11)
Next, we present a theorem that shows this bound, where we largely follow Poole et al. (2019) in the proof. In contrast to Poole et al. (2019), we do not use the NWJ bound Nguyen et al. (2010). The mutual information is
I(X1 ; Y ) = Ep(x1,y)
[ ln ( p(x1 | y) p(x1) )] . (A12)
Theorem A1 (InfoNCE lower bound). InfoNCE with score function f(x,y) according to Eq. (A3) is a lower bound on the mutual information.
I(X1 ; Y ) ≥ Ep(y)p(X|y) [ ln ( f(x1,y)
1 N ∑N i=1 f(xi,y)
)] = IInfoNCE(X1 ; Y ) . (A13)
InfoNCE with probabilities according to Eq. (A2) is a lower bound on the mutual information. I(X1 ; Y ) ≥ Ep(y)p(X|y) [ ln ( p(y | x1)
1 N ∑N i=1 p(y | xi)
)] = IInfoNCE(X1 ; Y ) . (A14)
The second bound Eq. (A14) is a special case of the first bound Eq. (A13).
Proof. Part (I): Lower bound with score function f(x,y).
For each set X̃ = {x2, . . . ,xN}, we define as data-dependent (depending on X̃) score function g(x1,y, X̃) that is based on the score function f(x,y). Therefore we have for each X̃ a different data-dependent score function g based on f . We will derive a bound on the InfoNCE, which is the expectation of a lower bond on the mutual information over the score functions. For score function g(x1,y, X̃), we define a variational distribution q(x1 | y, X̃) over x1:
q(x1 | y, X̃) = p(x1) g(x1,y, X̃)
Z(y, X̃) , (A15)
Z(y, X̃) = Ep(x1) [ g(x1,y, X̃) ] , (A16)
which ensures ∫ q(x1 | y, X̃) dx1 = 1 . (A17)
We have
q(x1 | y, X̃) p(x1) = g(x1,y, X̃) Z(y, X̃) . (A18)
For the function g, we set
g(x1,y, X̃) = f(x1,y)
1 N ∑N i=1 f(xi,y) , (A19)
For the function f we use
f(x1,y) = exp(τ −1 sim(x1,y)) , (A20)
where sim(x,y) is typically the cosine similarity.
We next show that InfoNCE is a lower bound on the mutual information.
I(X1 ; Y ) = Ep(X̃) [I(X1 ; Y )] = Ep(X̃) [ Ep(x1,y) [ ln p(x1 | y) p(x1) ]] (A21)
= Ep(X̃) [ Ep(x1,y) [ ln ( p(x1 | y)
q(x1 | y, X̃) q(x1 | y, X̃) p(x1)
)]]
= Ep(X̃) [ Ep(x1,y) [ ln q(x1 | y, X̃)
p(x1)
] + Ep(y) [ KL(p(x1 | y) ‖ q(x1 | y, X̃)) ]]
≥ Ep(X̃) [ Ep(x1,y) [ ln q(x1 | y, X̃)
p(x1)
]] = Ep(X̃) [ Ep(x1,y) [ ln g(x1,y, X̃)
Z(y, X̃) ]] = Ep(X̃) [ Ep(x1,y) [ ln g(x1,y, X̃) − ln ( Ep(x1) [ g(x1,y, X̃)
])]] = Ep(X̃) [ Ep(y) [ Ep(x1|y) [ ln g(x1,y, X̃) ] − ln ( Ep(x1) [ g(x1,y, X̃)
])]] = Ep(X̃) [ Ep(y) [ Ep(x1|y) [ ln g(x1,y, X̃) ]]] − Ep(X̃) [ Ep(y) [ ln ( Ep(x1) [ g(x1,y, X̃)
])]] ≥ Ep(y)p(X|y) [ ln g(x1,y, X̃) ] − Ep(X̃) [ Ep(y) [ Ep(x1) [ g(x1,y, X̃) ] − 1
]] = Ep(y)p(X|y) [ ln
f(x1,y) 1 N ∑N i=1 f(xi,y)
] − Ep(y) [ Ep(X) [ f(x1,y)
1 N ∑N i=1 f(xi,y)
] − 1 ]
= Ep(y)p(X|y)
[ ln
f(x1,y) 1 N ∑N i=1 f(xi,y)
] − Ep(y) [ 1
N N∑ i=1 Ep(X)
[ f(xi,y)
1 N ∑N i=1 f(xi,y)
] − 1 ]
= Ep(y)p(X|y)
[ ln
f(x1,y) 1 N ∑N i=1 f(xi,y)
] − Ep(y) [ Ep(X) [ 1 N ∑N i=1 f(xi,y)
1 N ∑N i=1 f(xi,y)
] − 1 ]
= Ep(y)p(X|y)
[ ln
f(x1,y) 1 N ∑N i=1 f(xi,y) ] = IInfoNCE(X1 ; Y ) .
For the first "≥" we used that the Kullback-Leibler divergence is non-negative. For the second "≥" we used the inequality ln a 6 a− 1 for a > 0. Part (II): Lower bound with probabilities.
If the score function f is
f(x,y) = p(y | x) , (A22)
then the bound is I(X1 ; Y ) ≥ Ep(y)p(X|y) [ ln ( f(x1,y)
1 N ∑N i=1 f(xi,y)
)] = Ep(y)p(X|y) [ ln ( p(y | x1)
1 N ∑N i=1 p(y | xi) )] (A23)
= Ep(y)p(X|y)
ln  p(y|x1)p(y)
1 N ∑N i=1 p(y|xi) p(y)  = IInfoNCE(X1 ; Y ) . This is the bound with probabilities in the theorem.
A.1.2 INFOLOOB: UPPER BOUND ON MUTUAL INFORMATION
We derive an upper bound on the mutual information between random variables X and Y distributed according to p(x,y). The mutual information I(X ; Y ) between random variables X and Y is
I(X ; Y ) = Ep(x,y)
[ ln p(x,y)
p(x) p(y)
] = Ep(x,y) [ ln p(x | y) p(x) ] = Ep(x,y) [ ln p(y | x) p(y) ] .
(A24)
In Poole et al. (2019) Eq. (13) introduces a variational upper bound on the mutual information, which has been called "Leave one out upper bound" (called "L1Out" in Cheng et al. (2020)). For simplicity, we call this bound "InfoLOOB", where LOOB is an acronym for "Leave One Out Bound". In contrast to InfoNCE, InfoLOOB is an upper bound on the mutual information. InfoLOOB is analog to InfoNCE except that the negative samples do not contain a positive sample. Fig. 1 and Fig. 2 in Cheng et al. (2020) both show that InfoLOOB is a better estimator for the mutual information than InfoNCE (van den Oord et al., 2018), MINE (Belghazi et al., 2018), and NWJ (Nguyen et al., 2010).
The InfoLOOB with score function f(x,y) is defined as
IInfoLOOB(X1 ; Y ) = Ep(y) [ Ep̃(X|y) [ ln ( f(x1,y)
1 N−1 ∑N i=2 f(xi,y)
)]] . (A25)
The InfoLOOB with probabilities is defined as
IInfoLOOB(X1 ; Y ) = Ep(y) [ Ep(X|y) [ ln ( p(y | x1)
1 N−1 ∑N i=2 p(y | xi)
)]] . (A26)
This is the InfoLOOB with f(x,y) = p(y | x). The InfoLOOB with probabilities can be written in different forms:
IInfoLOOB(X1 ; Y ) = Ep(y) [ Ep(X|y) [ ln ( p(y | x1)
1 N−1 ∑N i=2 p(y | xi)
)]] (A27)
= Ep(y) Ep(X|y) ln  p(y|x1)p(y) 1
N−1 ∑N i=2 p(y|xi) p(y)
 = Ep(y) Ep(X|y) ln  p(x1|y)p(x1)
1 N−1 ∑N i=2 p(xi|y) p(xi)  . Set of pairs. The InfoLOOB can we written in a different setting (Poole et al., 2019), which will be used in our implementations. We sample N pairs independently from p(x,y), which gives X = {(x1,y1), (x2,y2), . . . , (xN ,yN )}. The InfoLOOB is then
IInfoLOOB(X ; Y ) = Ep(X|y)
[ 1
N N∑ i=1 ln
( f(xi,yi)
1 N−1 ∑N j=1,j 6=i f(xj ,yi)
)] . (A28)
We assume that an anchor sample y is given. For the anchor sample y we draw a positive sample x1 according to p(x1 | y). Next, we draw a set X̃ = {x2, . . . ,xN} of negative samples according to p̃(x | y). For a given y, the x that have a large p(x | y) are drawn with a lower probability p̃(x | y) compared to random drawing via p(x). The negatives are indeed negatives. We have drawn first anchor sample y and then X = {x1, . . . ,xN}, where x1 is drawn according to p(x1 | y) and X̃ = {x2, . . . ,xN} are drawn iid according to p̃(x | y). We have
p̃(X̃ | y) = N∏ i=2 p̃(xi | y) , (A29)
p̃(X | y) = p(x1 | y) N∏ i=2 p̃(xi | y) , (A30)
p̃(X̃ | y) p(x1) = p(x1) N∏ i=2 p̃(xi | y) . (A31)
We assume for score function f(x,y)
∀y∀x : 0 < f(x,y) . (A32) We ensure this by using for score function f
f(x,y) = exp(τ−1 sim(x,y)) , (A33)
where sim(x,y) is typically the cosine similarity.
InfoLOOB with score function f(x,y) is
IInfoLOOB(X ; Y ) = Ep(y) [ Ep(X|y) [ ln ( f(x1,y)
1 N−1 ∑N i=2 f(xi,y)
)]] . (A34)
The reference constant Z(y) gives the average score f(x,y), if the negatives for y are selected with lower probability via p̃(x | y) than with random drawing according to p(x).
Z(y) = Ep̃(x|y) [f(x,y)] . (A35)
We define the variational distribution
q(x | y) = p(x) f(x,y) Z∗(y) , Z∗(y) = Ep(x) [f(x,y)] . (A36)
With the variational distribution q(x | y), we express our main assumption. The main assumption for the bound is:
Ep(y) [KL(p(x | y) ‖ q(x | y))] 6 Ep(y) [lnZ∗(y) − lnZ(y)] . (A37) This assumption can be written as
Ep(y) [ Ep(x|y) [ ln ( p(y | x) Z(y) p(y) f(x,y) )]] 6 0 . (A38)
This assumption ensures that the x with large p(x | y)) are selected with lower probability via p̃(x | y) than with random drawing according to p(x). The negatives are ensured to be real negatives, that is, p(x | y) is small and so is f(x,y). Consequently, we make sure that we draw x with sufficient small f(x,y). The Kullback-Leibler gives the minimal required gap between drawing f(x,y) via p(x) and drawing f(x,y) via p̃(x | y). EXAMPLE. With h(y) > 0, we consider the setting
f(x,y) = p(y | x) h(y)
p(y) , (A39)
p̃(x | y) = p(x) p(y) h(y) p(y | x) C(y) , C(y) = Ep(x)
[( p(y | x) h(y)
p(y)
)−1] . (A40)
The main assumption becomes
Ep(y) [ Ep(x|y) [ ln Z(y)
h(y)
]] 6 0 . (A41)
The main assumption holds since
Z(y) = Ep̃(x|y)
[ p(y | x) h(y)
p(y)
] = ∫ p(x) p(y)
h(y) p(y | x) C(y) p(y | x) h(y) p(y) dx (A42)
= ∫ p(x) C(y)−1 dx = C(y)−1 = ( Ep(x) [( p(y | x) h(y)
p(y)
)−1])−1
6 ( Ep(x) [ p(y | x) h(y)
p(y)
]−1)−1 = Ep(x) [ p(y | x) h(y)
p(y) ] = ∫ p(y,x) h(y)
p(y) dx = h(y) ,
where we used for the 6 Jensen’s inequality with the function f(a) = 1/a, which is convex for a > 0.
For score function f(x,y) and distribution p̃(x | y) for sampling the negative samples, we have defined:
Z(y) = Ep̃(x|y) [f(x,y)] , (A43) Z∗(y) = Ep(x) [f(x,y)] , (A44)
q(x | y) = p(x) f(x,y) Z∗(y) . (A45)
Next theorem gives the upper bound of the InfoLOOB on the mutual information, which is
I(X1 ; Y ) = Ep(x1,y) [ ln p(x1 | y) p(x1) ] . (A46)
Theorem A2 (InfoLOOB upper bound). If X̃ = {x2, . . . ,xN} are drawn iid according to p̃(x | y) and if the main assumption holds:
Ep(y) [KL(p(x | y) ‖ q(x | y))] 6 Ep(y) [lnZ∗(y) − lnZ(y)] . (A47)
Then InfoLOOB with score function f(x,y) as in Eq. (A25) is an upper bound on the mutual information:
I(X1 ; Y ) 6 Ep(y) [ Ep̃(X|y) [ ln ( f(x1,y)
1 N−1 ∑N i=2 f(xi,y)
)]] = IInfoLOOB(X1 ; Y ) . (A48)
If the negative samples X̃ = {x2, . . . ,xN} are drawn iid according to p(x), then InfoLOOB with probabilities according to Eq. (A26) is an upper bound on the mutual information:
I(X1 ; Y ) 6 Ep(y) [ Ep(X|y) [ ln ( p(y | x1)
1 N−1 ∑N i=2 p(y |Xi)
)]] = IInfoLOOB(X1 ; Y ) . (A49)
The second bound Eq. (A49) is a special case of the first bound Eq. (A48).
Proof. Part (I): Upper bound with score function f(x,y).
I(X1 ; Y ) = Ep(x1,y) [ ln p(x1 | y) p(x1) ] (A50)
= Ep(x1,y)
[ ln ( p(x1 | y) q(x1 | y) q(x1 | y) p(x1) )] = Ep(x1,y) [ ln q(x1 | y) p(x1) ] + Ep(y) [KL(p(x1 | y) ‖ q(x1 | y))]
6 Ep(x1,y) [ ln q(x1 | y) p(x1) ] + Ep(y) [ ln Ep(x1) [f(x1,y)] − lnZ(y) ] = Ep(x1,y) [ ln q(x1 | y) p(x1) + ln Ep(x1) [f(x1,y)] Z(y)
] = Ep(x1,y) [ ln ( f(x1,y)
Ep(x1) [f(x1,y)]
Ep(x1) [f(x1,y)]
Z(y) )] = Ep(x1,y) [ ln f(x1,y)
Z(y)
]
= Ep(x1,y)
ln  f(x1,y)
Ep̃(X|y)
[ 1 N−1 ∑N i=2 f(xi,y)
] 
= Ep(x1,y) [ln f(x1,y)] − Ep(y) [ ln ( Ep̃(X|y) [ 1 N − 1 N∑ i=2 f(xi,y) ])]
6 Ep(x1,y) [ln f(x1,y)] − Ep(y) [ Ep̃(X|y) [ ln ( 1 N − 1 N∑ i=2 f(xi,y) )]]
= Ep(y) [ Ep̃(X|y) [ ln ( f(x1,y)
1 N−1 ∑N i=2 f(xi,y) )]] = IInfoLOOB(X1 ; Y ) ,
where the first "6" uses assumption Eq. (A37), while Jensens’s inequality was used for the second "6" by exchanging the expectation and the "ln". We also used
Ep̃(X|y)
[ 1
N − 1 N∑ i=2 f(xi,y)
] =
1 N − 1 N∑ i=2 Ep̃(xi|y) [f(xi,y)] = 1 N − 1 N∑ i=2 Z(y) = Z(y) .
(A51)
Part (II): Upper bound with probabilities.
If the score function f is
f(x,y) = p(y | x) (A52) and
p̃(x | y) = p(x) , (A53) then
p̃(X | y) = p(X | y) , (A54) Z(y) = Ep(x) [p(y | x)] = p(y) , (A55) Z∗(y) = Ep(x) [p(y | x)] = p(y) , (A56)
q(x | y) = p(x) p(y | x) p(y) = p(x | y) , (A57)
KL(p(x | y) ‖ q(x | y)) = KL(p(x | y) ‖ p(x | y)) = 0 . (A58)
Therefore, the main assumption holds, since
0 = Ep(y) [KL(p(x | y) ‖ q(x | y))] = Ep(y) [lnZ∗(y) − lnZ(y)] . (A59)
The bound becomes
I(X1 ; Y ) 6 Ep(y) [ Ep(X|y) [ ln ( p(y | x1)
1 N−1 ∑N i=2 p(y | xi)
)]] (A60)
= Ep(y) Ep(X|y) ln  p(y|x1)p(y) 1
N−1 ∑N i=2 p(y|xi) p(y)  = IInfoLOOB(X1 ; Y ) . An alternative proof is as follows:
I(X1 ; Y ) = I(X1 ; Y ) − Ep(y) [ ln ( 1
N − 1 N∑ i=2 p(y) p(y)
)] (A61)
= I(X1 ; Y ) − Ep(y) [ ln ( Ep(X|y) [ 1
N − 1 N∑ i=2 p(y | xi) p(y)
])]
6 I(X1 ; Y ) − Ep(y) [ Ep(X|y) [ ln ( 1
N − 1 N∑ i=2 p(y | xi) p(y)
)]]
= Ep(y) [ Ep(x1|y) [ ln ( p(x1 | y) p(x1) )]] − Ep(y) [ Ep(X|y) [ ln ( 1 N − 1 N∑ i=2 p(xi | y) p(xi) )]]
= Ep(y) Ep(X|y) ln  p(x1|y)p(x1) 1
N−1 ∑N i=2 p(xi|y) p(xi)  = IInfoLOOB(X1 ; Y ) .
where we applied Jensens’s inequality for the exchanging the expectation and the "ln" to obtain the "6" inequality.
Experiments that compare upper and lower bounds as mutual information estimates are provided in Cheng et al. (2020) and in Poole et al. (2019). In Fig. 2 in Cheng et al. (2020) it is shown that InfoLOOB is a good estimator of the mutual information.
A.1.3 INFOLOOB: ANALYSIS OF THE OBJECTIVE
This subsection justifies the maximization of the InfoLOOB bound for contrastive learning. Maximizing the InfoLOOB bound is not intuitive as it was introduced as an upper bound on the mutual information in the previous subsection. Still maximizing the InfoLOOB bound leads to a good approximation of the mutual information, in particular for high mutual information.
InfoLOOB with a neural network as a scoring function is not an upper bound on the mutual information when not under-sampling. As we use InfoLOOB on training data for which we do not know the sampling procedure, we cannot assume under-sampling. Therefore, we elaborate more on the rationale behind the maximization of the InfoLOOB bound. (I) We show that InfoLOOB with neural networks as scoring function is bounded from above. Therefore, there exists a maximum and the optimization problem is well defined. (II) We show that InfoLOOB with neural networks as scoring function differs by two terms the mutual information. The first term is the Kullback-Leibler divergence between the variational q(x | y) and the posterior p(x | y). This divergence is minimal for q(x | y) = p(x | y), which implies f(y | x) = p(y | x). The second term is governed by the difference between the mean E[f(x,y)] and the empirical mean 1/(N − 1)∑i f(x,y). Hoeffding’s inequality bounds this difference as we demonstrate in this subsection. Therefore, the second term
is negligible for large N . In contrast, the KL term is dominant and the relevant term, therefore maximizing InfoLOOB leads tof(y | x) ≈ p(y | x). We assume that an anchor sample y is given. For the anchor sample y, we draw a positive sample x1 according to p(x1 | y). We define the set X̃ = {x2, . . . ,xN} of negative samples, which are drawn iid according to p(x). We define the set X = {x1, . . . ,xN}. We have
p(X̃) = N∏ i=2 p(xi) , (A62)
p(X | y) = p(x1 | y) N∏ i=2 p(xi) = p(x1 | y) p(X̃) , (A63)
p(X) = N∏ i=1 p(xi) = p(x1) p(X̃) . (A64)
We use the score function
f(x,y) = exp(τ−1 sim(x,y)) , (A65)
where sim(x,y) is typically the cosine similarity.
The InfoLOOB with score function f(x,y) is defined as
IInfoLOOB(X1 ; Y ) = Ep(y) [ Ep(X|y) [ ln ( f(x1,y)
1 N−1 ∑N i=2 f(xi,y)
)]] . (A66)
We define the variational distribution
q(x | y) = p(x) f(x,y) Z(y) , (A67)
Z(y) = Ep(x) [f(x,y)] . (A68)
The next inequality shows the relation between I(X1 ; Y ) and IInfoLOOB(X1 ; Y ) for random variables X1 and Y .
I(X1 ; Y ) = Ep(x1,y) [ ln p(x1 | y) p(x1) ] (A69)
= Ep(x1,y)
[ ln ( p(x1 | y) q(x1 | y) q(x1 | y) p(x1) )] = Ep(x1,y) [ ln q(x1 | y) p(x1) ] + Ep(y) [KL(p(x1 | y) ‖ q(x1 | y))]
= Ep(x1,y)
[ ln f(x1,y)
Z(y)
] + Ep(y) [KL(p(x1 | y) ‖ q(x1 | y))]
= Ep(x1,y)
ln  f(x1,y)
Ep(X|y)
[ 1 N−1 ∑N i=2 f(xi,y)
]  + Ep(y) [KL(p(x1 | y) ‖ q(x1 | y))]
= Ep(x1,y) [ln f(x1,y)] − Ep(y) [ ln ( Ep(X|y) [ 1 N − 1 N∑ i=2 f(xi,y) ])] + Ep(y) [KL(p(x1 | y) ‖ q(x1 | y))]
= Ep(x1,y) [ln f(x1,y)] − Ep(y) [ Ep(X|y) [ ln ( 1 N − 1 N∑ i=2 f(xi,y) )]]
+ Ep(y) [ Ep(X|y) [ ln ( 1
N − 1 N∑ i=2 f(xi,y)
)]] − Ep(y) [ ln ( Ep(X|y) [ 1
N − 1 N∑ i=2 f(xi,y) ])] + Ep(y) [KL(p(x1 | y) ‖ q(x1 | y))]
= Ep(y) [ Ep(X|y) [ ln ( f(x1,y)
1 N−1 ∑N i=2 f(xi,y)
)]] + Ep(y) [ Ep(X|y) [ ln ( 1
N − 1 N∑ i=2 f(xi,y)
)]]
− Ep(y) [ ln ( Ep(X|y) [ 1
N − 1 N∑ i=2 f(xi,y)
])] + Ep(y) [KL(p(x1 | y) ‖ q(x1 | y))]
= IInfoLOOB(X1 ; Y )
+ Ep(y) [ Ep(X|y) [ ln ( 1
N − 1 N∑ i=2 f(xi,y)
)]] − Ep(y) [ ln ( Ep(X|y) [ 1
N − 1 N∑ i=2 f(xi,y) ])] + Ep(y) [KL(p(x1 | y) ‖ q(x1 | y))] = IInfoLOOB(X1 ; Y )
+ Ep(y) [ Ep(X|y) [ ln ( 1
N − 1 N∑ i=2 f(xi,y)
)]] − Ep(y) [ ln ( Ep(x1) [f(x1,y)]
)] + Ep(y) [KL(p(x1 | y) ‖ q(x1 | y))] = IInfoLOOB(X1 ; Y )
− Ep(y) [ Ep(X̃) [ ln ( Ep(x1) [f(x1,y)] 1
N−1 ∑N i=2 f(xi,y) )]] + Ep(y) [KL(p(x1 | y) ‖ q(x1 | y))] = IInfoLOOB(X1 ; Y ) − DE + Ep(y) [KL(p(x1 | y) ‖ q(x1 | y))] ,
where we used
DE = Ep(y) [ Ep(X̃) [ ln ( Ep(x1) [f(x1,y)] 1
N−1 ∑N i=2 f(xi,y)
)]] (A70)
and
Z(y) = Ep(x1) [f(x1,y)] = Ep(X̃)
[ 1
N − 1 N∑ i=2 f(xi,y)
] (A71)
= Ep(X|y)
[ 1
N − 1 N∑ i=2 f(xi,y)
] .
Since both KL and DE are non-negative (for DE see below), to increase InfoLOOB we have either to decrease KL or to increase DE.
Bounding DE. Next we bound DE. We define
L = zTx − β−1 N∑ i=1 zi ln zi . (A72)
The log-sum-exponential (lse) is the maximum of L on the N -dimensional simplex D with D = {z |∑ i zi = 1, 0 6 zi} (Gao & Pavel, 2017):
lse(β,x) = max z∈D zTx − β−1 N∑ i=1 zi ln zi . (A73)
For some z ∈ D we have Ea [lse(β,a)] ≥ Ea [ zTa − β−1
N∑ i=1 zi ln zi
] = zTEa [a] − β−1
N∑ i=1 zi ln zi , (A74)
therefore
Ea [lse(β,a)] ≥ max z∈D zTEa [a] − β−1 N∑ i=1 zi ln zi = lse(β,Ea [a]) . (A75)
We obtain
Ep(y) [ Ep(X̃) [ ln ( Ep(x1) [ exp(τ−1 sim(x1,y))
1 N−1 ∑N i=2 exp(τ −1 sim(xi,y))
])]] (A76)
6 Ep(y) [ ln Ep(x1) [ exp(τ−1 sim(x1,y)) ] − ln ( 1 N − 1 N∑ i=2 exp(τ−1 Ep(xi) [sim(xi,y)]) )] = Ep(y) [ ln Ep(x1) [ exp(τ−1 sim(x1,y)) ] − τ−1 Ep(x1) [sim(x1,y)] ] .
We obtain via Jensen’s inequality
Ep(y) [ Ep(X̃) [ ln ( Ep(x1) [ exp(τ−1 sim(x1,y))
1 N−1 ∑N i=2 exp(τ −1 sim(xi,y))
])]] (A77)
≥ Ep(y) [ ln Ep(x1) [ exp(τ−1 sim(x1,y)) ] − ln ( 1 N − 1 N∑ i=2 Ep(xi) [ exp(τ−1 sim(x1,y)) ])] = 0 .
If we combine both previous inequalities, we obtain 0 6 DE 6 Ep(y) [ ln Ep(x1) [ exp(τ−1 sim(x1,y)) ] − τ−1 Ep(x1) [sim(x1,y)] ] . (A78)
In particular, for bounded sim(x1,y), we get 0 6 DE 6 τ−1 (
max y,x1 sim(x1,y) − min y,x1 sim(x1,y)
) , (A79)
while Hoeffding’s lemma gives
0 6 DE 6 1
8 τ−2 ( max y,x1 sim(x1,y) − min y,x1 sim(x1,y) )2 . (A80)
Thus, for bounded sim(x1,y), DE is bounded, therefore also InfoLOOB. For sub-exponential distributions with variance σ2, for which Bernstein’s condition with τ > b holds (Eq. (2.16) in Wainwright (2019)), we get (Proposition 2.3 in Wainwright (2019)):
0 6 DE 6 σ2
2 (τ2 − b τ) . (A81)
Next, we show that DE is small. Hoeffding’s inequality states that if f(x,y) ∈ [a, b] then
p (∣∣∣∣∣Ep(x1) [f(x1,y)] − 1N − 1 N∑ i=2 f(xi,y) ∣∣∣∣∣ ≥ ) 6 2 exp ( − 2 (N − 1) 2 (b− a)2 ) . (A82)
For
Ep(x1) [f(x1,y)] − 1 N − 1 N∑ i=2 f(xi,y) 6 (A83)
we have
ln ( Ep(x1) [f(x1,y)] 1
N−1 ∑N i=2 f(xi,y)
) 6 ln ( 1 N−1 ∑N i=2 f(xi,y) +
1 N−1 ∑N i=2 f(xi,y)
) (A84)
6
1 N−1 ∑N i=2 f(xi,y) 6 Z − ,
where we used ln a 6 a− 1 for 0 < a. Analog for
1 N − 1 N∑ i=2 f(xi,y) − Ep(x1) [f(x1,y)] 6 (A85)
we have
ln ( Ep(x1) [f(x1,y)] 1
N−1 ∑N i=2 f(xi,y)
) ≥ ln ( Ep(x1) [f(x1,y)]
Ep(x1) [f(x1,y)] +
) (A86)
= − ln ( Ep(x1) [f(x1,y)] +
Ep(x1) [f(x1,y)]
) ≥ −
Ep(x1) [f(x1,y)] = − Z ,
where we used − ln a ≥ 1− a for 0 < a. In summary, for ∣∣∣∣∣Ep(x1) [f(x1,y)] − 1N − 1 N∑ i=2 f(xi,y)
∣∣∣∣∣ 6 (A87) we have
− Z 6 ln ( Ep(x1) [f(x1,y)] 1 N−1 ∑N i=2 f(xi,y) ) 6 Z − . (A88)
It follows that
− Z 6 DE 6 Z − . (A89)
DE averages the ln-term over y and X̃ , therefore it has an even smaller bound than the bound above on the ln-term. Consequently, for small b− a and large N , the term DE is small. KL is decreased by making the variation distribution q(x1 | y) more similar to the posterior p(x1 | y). The value DE only depends on the marginal distributions p(y) and p(x), since p(X̃) = ∏N i=2 p(xi). The value DE can be changed by adding an offset to f(x,y). However, scaling f(x,y) by a factor does not change DE. Consequently, DE is difficult to change.
Therefore, increasing InfoLOOB is most effective by making q(x1 | y) more similar to the posterior p(x1 | y).
Gradient of InfoLOOB expressed by gradients of KL and DE. Assume that the similarity is parametrized by w giving sim(x,y;w).
KL(p(x1 | y) ‖ q(x1 | y)) = ∫ p(x1 | y) ln ( p(x1 | y) q(x1 | y) ) dx (A90)
= − τ−1 ∫ p(x1 | y) sim(x1,y;w) dx1 + lnZ + C ,
where C is independent of w.
Next, we compute the derivative of KL with respect to parameters w.
∂KL
∂w (A91) = − τ−1 ∫ p(x1 | y) ∂sim(x1,y;w)
∂w dx1 +
1
Z
∫ p(x1) exp(τ−1 sim(x1,y;w))
∂sim(x1,y;w)
∂sim(x1,y;w)
∂w dx1 = − τ−1 ∫ p(x1 | y) ∂sim(x1,y;w)
∂w dx1 + τ
−1 ∫ p(x1) exp(τ−1 sim(x1,y;w))
Z
∂sim(x1,y;w)
∂w dx1 = − τ−1 ∫ p(x1 | y) ∂sim(x1,y;w)
∂w dx1 + τ
−1 ∫ q(x1 | y) ∂sim(x1,y;w)
∂w dx1 = τ−1 ∫ (q(x1 | y) − p(x1 | y)) ∂sim(x1,y;w)
∂w dx1 .
The derivative is the average difference between the posterior distribution p(x1 | y) and the variational distribution q(x1 | y) multiplied by the derivative of the similarity function. If both distribution match, then the derivative vanishes.
Next, we compute the derivative of DE with respect to parameters w.
∂DE
∂w (A92)
= Ep(y)
[ ∂ lnZ
∂w
] − Ep(y) [ Ep(X̃) [ 1 N−1 ∑N i=2 τ −1 exp(τ−1 sim(xi,y;w)) ∂sim(xi,y;w) ∂w
1 N−1 ∑N j=2 f(xj ,y)
]]
= Ep(y)
[ τ−1 ∫ q(x1 | y) ∂sim(x1,y;w)
∂w dx1 ] − Ep(y) [ Ep(X̃) [ 1 N−1 ∑N i=2 τ −1 exp(τ−1 sim(xi,y;w)) ∂sim(xi,y;w) ∂w
1 N−1 ∑N j=2 f(xj ,y)
]]
= τ−1 Ep(y) [∫ q(x1 | y) ∂sim(x1,y;w)
∂w dx1 ] − τ−1 Ep(y) [ Ep(X̃) [ 1
N − 1 N∑ i=2 f(xi,y) 1 N−1 ∑N j=2 f(xj ,y) ∂sim(xi,y;w) ∂w
]]
= τ−1 Ep(y)
[∫ p(x1) f(x1,y)
Ep(x) [f(x,y)]
∂sim(x1,y;w)
∂w dx1
]
− τ−1 Ep(y) [ Ep(X̃) [ 1 N − 1 N∑ i=2 f(xi,y) 1 N−1 ∑N j=2 f(xj ,y) ∂sim(xi,y;w) ∂w ]]
= τ−1 Ep(y) [ Ep(x1) [ f(x1,y)
Ep(x) [f(x,y)]
∂sim(x1,y;w)
∂w
]]
− τ−1 Ep(y) [ Ep(X̃) [ 1 N − 1 N∑ i=2 f(xi,y) 1 N−1 ∑N j=2 f(xj ,y) ∂sim(xi,y;w) ∂w ]]
= τ−1 Ep(y)
[ 1
N − 1 N∑ i=2 Ep(xi) [ f(xi,y) Ep(x) [f(x,y)] ∂sim(xi,y;w) ∂w ]]
− τ−1 Ep(y) [ Ep(X̃) [ 1 N − 1 N∑ i=2 f(xi,y) 1 N−1 ∑N j=2 f(xj ,y) ∂sim(xi,y;w) ∂w ]]
= τ−1 Ep(y) [ Ep(X̃) [ 1 N − 1 N∑ i=2
f(xi,y)
Ep(x) [f(x,y)]
∂sim(xi,y;w)
∂w
]]
− τ−1 Ep(y) [ Ep(X̃) [ 1 N − 1 N∑ i=2 f(xi,y) 1 N−1 ∑N j=2 f(xj ,y) ∂sim(xi,y;w) ∂w ]]
= τ−1 Ep(y) [ Ep(X̃) [ 1 N − 1 N∑ i=2 ( 1 Ep(x) [f(x,y)] − 1 1 N−1 ∑N j=2 f(xj ,y) ) f(xi,y) ∂sim(xi,y;w) ∂w ]]
= τ−1 Ep(y) [ Ep(X̃) [ 1 N − 1 N∑ i=2 ( 1 Z − 1 1 N−1 ∑N j=2 f(xj ,y) ) f(xi,y) ∂sim(xi,y;w) ∂w ]] .
The derivative is the average of 1Z − 11 N−1 ∑N j=2 f(xj ,y) multiplied by the score function and the derivative of the similarity function. The average is over y and X̃ , therefore the whole derivative becomes even smaller. Consequently, for small b− a and large N , the derivative of DE is small. Note that for ∣∣∣∣∣Ep(x1) [f(x1,y)] − 1N − 1 N∑ i=2 f(xi,y) ∣∣∣∣∣ 6 (A93)
we have 1
Z − 1
1 N−1 ∑N j=2 f(xj ,y) 6 1 Z − 1 Z + = Z(Z + ) , (A94)
1 Z − 1
1 N−1 ∑N j=2 f(xj ,y) ≥ 1 Z − 1 Z − = − Z(Z − ) , (A95)
therefore ∣∣∣∣∣ 1Z − 11 N−1 ∑N j=2 f(xj ,y) ∣∣∣∣∣ 6 Z(Z − ) . (A96) If the expectation Z is well approximated by the average 1N−1 ∑N j=2 f(xj ,y), then both DE and its gradient are small.
Derivative of InfoLOOB via KL and DE:
∂IInfoLOOB(X1 ; Y )
∂w =
∂DE ∂w − ∂KL ∂w . (A97)
In this gradient, the KL term is dominating, therefore f(x,y) is pushed to approximate the conditional probability p(y | x). Modern Hopfield networks lead to larger values of p(y | x) as the mutual information becomes larger, therefore modern Hopfield networks help to push f(x,y) to large values. Furthermore, modern Hopfield networks increase Z, which is in the denominator of the bound on DE and its derivative.
A.1.4 INFONCE AND INFOLOOB: GRADIENTS
We consider the InfoNCE and the InfoLOOB loss function. For computing the loss function, we sample N pairs independently from p(x,y), which gives the training set {(x1,y1), (x2,y2), . . . , (xN ,yN )}. InfoNCE and InfoLOOB only differ in using the positive example in the negatives. More precisely, InfoNCE uses for the matrix of negative samples X = (x1, . . . ,xN ), while InfoLOOB uses X̃ = (x2, . . . ,xN ).

heading: InfoNCE.
text: The InfoNCE loss is
LInfoNCE = − 1
N N∑ i=1 ln
( f(xi,yi)
1 N ∑N j=1 f(xj ,yi)
) = 1
N N∑ i=1 LInfoNCE(yi) , (A98)
where we used
LInfoNCE(yi) = − ln (
f(xi,yi) 1 N ∑N j=1 f(xj ,yi)
) . (A99)
For the score function f(x,y), we use
f(x,y) = exp(τ−1 sim(x,y)) , (A100)
sim(x,y) = yTx (A101)
with τ as the temperature.
The loss function for this score function is LInfoNCE(y) = − τ−1 yTx1 + τ−1 lse ( τ−1,XTy ) , (A102)
where lse is the log-sum-exp function (lse):
lse(β,a) = β−1 log ( N∑ i=1 exp(βai) ) , (A103)
for β > 0 and vector a = (a1, . . . , aN ).
The gradient with respect to y is
∂LInfoNCE(y)
∂y = − τ−1 x1 + τ−1 X softmax
( τ−1XTy ) , (A104)
which is the positive example x1 that fits to the anchor example y minus the Hopfield network update with state pattern y and stored patternsX and then this difference multiplied by τ−1.
This gradient can be simplified, since the positive example x1 is also in the negative examples. Using p = (p1, . . . , pN ) T = softmax ( τ−1XTy ) , we obtain
∂LInfoNCE(y)
∂y (A105) = − τ−1 (1 − p1) ( x1 − 1 1− p1 X ( softmax ( τ−1XTy ) − (p1, 0, . . . , 0)T )) = − τ−1 (1 − p1) ( x1 − X̃ softmax ( τ−1X̃Ty )) = (1 − p1) ∂LInfoLOOB(y)
∂y .
where 1 1− p1 X ( softmax ( τ−1XTy ) − (p1, 0, . . . , 0)T ) (A106)
= 1 1− p1 X ( (p1, p2, . . . , pN ) T − (p1, 0, . . . , 0)T )
= 1
1− p1 X(0, p2, . . . , pN )
T = 1
1− p1 N∑ i=2 pi xi
is the softmax average over the negatives xi for 2 6 i 6 N without x1. It can be easily seen that 1 1−p1 ∑N i=2 pi = 1−p1 1−p1 = 1. For the derivative of the InfoLOOB see below.
The gradient with respect to x1 is
∂LInfoNCE(y) ∂x1 = − τ−1 y + τ−1 exp(τ −1 xT1 y)∑N i=1 exp(τ −1xTi y) y (A107)
= − τ−1 (1 − p1) y . (A108) Consequently, the learning rate is scaled by (1− p1). The sum of gradients with respect to x1 and xi is
∂LInfoNCE(y)
∂x1 + N∑ i=1 ∂LInfoNCE(y) ∂xi = − τ−1 y + τ−1 y 1T softmax ( τ−1XTy ) (A109) = − τ−1 y + τ−1 y = 0 , where 1 is the vector with ones. However, the derivatives with respect to the weights are not zero since the xi are differently computed.

heading: InfoLOOB.
text: The InfoLOOB loss is
LInfoLOOB = − 1
N N∑ i=1 ln
( f(xi,yi)
1 N−1 ∑N j=1,j 6=i f(xj ,yi)
) = 1
N N∑ i=1 LInfoLOOB(yi) , (A110)
where we used
LInfoLOOB(yi) = − ln ( f(xi,yi) 1
N−1 ∑N j=1,j 6=i f(xj ,yi)
) . (A111)
For the score function f(x,y), we use
f(x,y) = exp(τ−1 sim(x,y)) , (A112)
sim(x,y) = yTx (A113)
with τ as the temperature.
The loss function for this score function is LInfoLOOB(y) = − τ−1 yTx1 + τ−1 lse ( τ−1, X̃Ty ) , (A114)
where lse is the log-sum-exponential function.
The gradient with respect to y is
∂LInfoLOOB(y)
∂y = − τ−1 x1 + τ−1 X̃ softmax
( τ−1X̃Ty ) , (A115)
which is the positive example x1 that fits to the anchor example y minus the Hopfield network update with state pattern y and stored patterns X̃ and then this difference multiplied by τ−1.
The gradient with respect to x1 is
∂LInfoLOOB(y)
∂x1 = − τ−1 y . (A116)
The sum of gradients with respect to x1 and xi is
∂LInfoLOOB(y) ∂x1 + ∑ i ∂LInfoLOOB(y) ∂xi = − τ−1 y + τ−1 y 1T softmax ( τ−1X̃Ty ) (A117)
= − τ−1 y + τ−1 y = 0 , where 1 is the vector with ones. However, the derivatives with respect to the weights are not zero since the xi are differently computed.

heading: Gradients with respect to τ−1.
text: The gradient of the InfoNCE loss Eq. (A98) using the similarity Eq. (A100) with respect to τ−1 is
∂LInfoNCE(y)
∂τ−1 = − yT x1 + yT X softmax
( τ−1XTy ) (A118)
= − yT ( x1 − X softmax ( τ−1XTy )) , (A119)
which is the similarity of the anchor y with the difference of the positive example x1 and the Hopfield network update with state pattern y and stored patterns X . The gradient of the InfoLOOB loss Eq. (A110) using the similarity Eq. (A112) with respect to τ−1 is
∂LInfoLOOB(y)
∂τ−1 = − yT x1 + yT X̃ softmax
( τ−1X̃Ty ) (A120)
= − yT ( x1 − X̃ softmax ( τ−1X̃Ty )) . (A121)
with the difference that the Hopfield network update is done with stored patterns X̃ instead ofX . Without the positive example x1 in the stored patterns X̃ , the term x1 − X̃ softmax ( τ−1X̃Ty ) in Eq. (A120) will not decrease like the term x1 −X softmax ( τ−1XTy ) in Eq. (A118) but grow even larger with better separation of the positive and negative examples.
A.1.5 INFOLOOB AND INFONCE: PROBABILITY ESTIMATORS
In McAllester & Stratos (2018; 2020) it was shown that estimators of the mutual information by lower bounds have problems as they come with serious statistical limitations. Statistically more justified for
representing the mutual information is a difference of entropies, which are estimated by minimizing the cross-entropy loss. Both InfoNCE and InfoLOOB losses can be viewed as cross-entropy losses.
We sample N pairs independently from p(x,y), which gives Z = {(x1,y1), (x2,y2), . . . , (xN ,yN )}. We set X = {x1,x2, . . . ,xN} and Y = {y1,y2, . . . ,yN}, so that, Z = X × Y . The score function f(x,y) is an estimator for p(x,y). Then we obtain estimators q̂ for the conditional probabilities. q̂(yi | xi, Y \ {yi}) is an estimator for p(yi | xi) and q̂(xi | yi, X \ {xi}) an estimator for p(xi | yi). Each estimator q̂ uses beyond (xi,yi) additional samples to estimate the normalizing constant. For InfoNCE these estimators are
q̂1(yi | xi, Y \ {yi}) = f(xi,yi)
1 N ∑N j=1 f(xi,yj) ≈ f(xi,yi) Ep(y) [f(xi,y)] , (A122)
q̂2(xi | yi, X \ {xi}) = f(xi,yi)
1 N ∑N j=1 f(xj ,yi) ≈ f(xi,yi) Ep(x) [f(x,yi)] . (A123)
The cross-entropy losses for the InfoNCE estimators are
L1InfoNCE = − 1
N N∑ i=1 ln
( f(xi,yi)
1 N ∑N j=1 f(xi,yj)
) , (A124)
L2InfoNCE = − 1
N N∑ i=1 ln
( f(xi,yi)
1 N ∑N j=1 f(xj ,yi)
) . (A125)
For InfoLOOB these estimators are
q̂1(yi | xi, Y \ {yi}) = f(xi,yi)
1 N−1 ∑N j=1,j 6=i f(xi,yj) ≈ f(xi,yi) Ep(y) [f(xi,y)] , (A126)
q̂2(xi | yi, X \ {xi}) = f(xi,yi)
1 N−1 ∑N j=1,j 6=i f(xj ,yi) ≈ f(xi,yi) Ep(x) [f(x,yi)] . (A127)
The cross-entropy losses for the InfoLOOB estimators are
L1InfoLOOB = − 1
N N∑ i=1 ln
( f(xi,yi)
1 N−1 ∑N j=1,j 6=i f(xi,yj)
) , (A128)
L2InfoLOOB = − 1
N N∑ i=1 ln
( f(xi,yi)
1 N−1 ∑N j=1,j 6=i f(xj ,yi)
) . (A129)
The InfoLOOB estimator uses for normalization
Ep(x) [f(x,yi)] ≈ 1 N − 1 N∑
j=1,j 6=i
f(xj ,yi) , (A130)
Ep(y) [f(xi,y)] ≈ 1 N − 1 N∑
j=1,j 6=i
f(xi,yj) , (A131)
in contrast to InfoNCE, which uses
Ep(x) [f(x,yi)] ≈ 1
N N∑ j=1 f(xj ,yi) , (A132)
Ep(y) [f(xi,y)] ≈ 1
N N∑ j=1 f(xi,yj) . (A133)
If InfoNCE estimates the normalizing constant separately, then it would be biased. (xi,yi) is drawn according to p(xi,yi) instead of p(xi)p(yi). In contrast, if InfoLOOB estimated the normalizing constant separately, then it would be unbiased.
A.1.6 INFOLOOB AND INFONCE: LOSSES
We have N pairs drawn iid from p(x,y), where we assume that a pair (xi,yi) is already an embedding of the original drawn pair. These build up the embedding training set Z = {(x1,y1), (x2,y2), . . . , (xN ,yN )} that allows to construct the matrices X = (x1,x2, . . . ,xN ) of N embedding samples xi and Y = (y1,y2, . . . ,yN ) of N embedding samples yi. We also have M stored patterns U = (u1, . . . ,uM ) and K stored patterns V = (v1, . . . ,vK).
The state vectors xi and yi are the queries for the Hopfield networks, which retrieve some vectors from U or V . We normalize vectors ‖xi‖ = ‖yi‖ = ‖ui‖ = ‖vi‖ = 1. The following vectors are retrieved from modern Hopfield networks (Ramsauer et al., 2021):
Uxi = U softmax(β U Txi) , Uyi = U softmax(β U Tyi) , (A134)
Vxi = V softmax(β V Txi) , Vyi = V softmax(β V Tyi) (A135)
where Uxi denotes an image-retrieved image embedding, Uyi a text-retrieved image embedding, Vxi an image-retrieved text embedding and Vyi a text-retrieved text embedding. The hyperparameter β corresponds to the inverse temperature: β = 0 retrieves the average of the stored pattern, while large β retrieve the stored pattern that is most similar to the state pattern (query).
We consider the loss functions
LInfoNCE = − 1
N N∑ i=1 log exp(τ−1 xTi yi)∑N j=1 exp(τ −1 xTi yj) − 1 N N∑ i=1 log exp(τ−1 xTi yi)∑N j=1 exp(τ −1 xTj yi) ,
(A136)
LInfoLOOB = − 1
N N∑ i=1 log exp(τ−1 xTi yi)∑N j 6=i exp(τ −1 xTi yj) − 1 N N∑ i=1 log exp(τ−1 xTi yi)∑N j 6=i exp(τ −1 xTj yi) ,
(A137)
LH−UVUVInfoLOOB = − 1
N N∑ i=1 log exp(τ−1 UTxiVyi)∑N j 6=i exp(τ −1 UTxiVyj ) − 1 N N∑ i=1 log exp(τ−1 UTxiVyi)∑N j 6=i exp(τ −1 UTxjVyi) ,
(A138)
LH−UUVVInfoLOOB = − 1
N N∑ i=1 log exp(τ−1 UTxiUyi)∑N j 6=i exp(τ −1 UTxiUyj ) − 1 N N∑ i=1 log exp(τ−1 V TxiVyi)∑N j 6=i exp(τ −1 V TxjVyi) ,
(A139) where for InfoLOOB the sum ∑ j 6=i in the denominator contains only negative examples j. We do not consider the loss function LH−UVUVInfoLOOB because of the high variance in the dot product U T xiVyi as elaborated in the following.
Let us consider the dot product between the anchor retrieval with the positive pattern retrieval for the loss functions with Hopfield. In the first term of the loss function Eq. (A138), Uxi is the anchor with Vyi as the positive sample and Vyi with Uxi as the positive sample for the second term, since the anchor also appears in each term of the denominator. Equivalently the same is valid for Eq. (A139), but with positive samples Vxi and Uyi respectively. These dot products can be written as
UTxiVyi = softmax(β U Txi) T UTV softmax(β V Tyi) , (A140) UTxiUyi = softmax(β U Txi) T UTU softmax(β UTyi) , (A141)
V TxiVyi = softmax(β V Txi) T V TV softmax(β V Tyi) . (A142)
High variance ofUTxiVyi . To compute the dot productU T xiVyi , M +K stored patterns are required (M of the uj and K of the vj). In contrast, the dot products UTxiUyi and V T xiVyi require only M or respectively K stored patterns. Therefore, UTxiVyi has higher variance than both U T xiUyi and V TxiVyi .
Covariance structure extracted by UTxiUyi and V T xiVyi .
The Jacobian J of the softmax p = softmax(βa) is
J(βa) = ∂softmax(βa)
∂a = β
( diag(p)− ppT ) , (A143)
which is a symmetric, positive semi-definite matrix with one eigenvalue of zero for eigenvector 1. J(βa) is diagonally dominant since |pi(1− pi)| − ∑ j 6=i |pipj | = pi − ∑ j pipj = pi − pi = 0.
Next we give upper bounds on the norm of J.
Lemma A1. For a softmax p = softmax(βx) with m = maxi pi(1− pi), the spectral norm of the Jacobian J of the softmax is bounded:
‖J‖2 6 2 m β , (A144) ‖J‖1 6 2 m β , (A145) ‖J‖∞ 6 2 m β . (A146)
In particular everywhere holds
‖J‖2 6 1
2 β . (A147)
If pmax = maxi pi ≥ 1− ≥ 0.5, then for the spectral norm of the Jacobian holds ‖J‖2 6 2 β − 2 2 β < 2 β . (A148)
Proof. We consider the maximum absolute column sum norm ‖A‖1 = maxj ∑ i |aij | (A149)
and the maximum absolute row sum norm ‖A‖∞ = maxi ∑ j |aij | . (A150) We have forA = J = β ( diag(p)− ppT
) ∑ j |aij | = β pi(1− pi) + ∑ j,j 6=i pipj  = β pi (1 − 2pi + ∑ j pj) (A151)
= 2 β pi (1− pi) 6 2 m β ,∑ i |aij | = β pj (1− pj) + ∑ i,i 6=j pjpi  = β pj (1 − 2pj + ∑ i pi) (A152)
= 2 β pj (1− pj) 6 2 m β . Therefore, we have
‖J‖1 6 2 m β , (A153) ‖J‖∞ 6 2 m β , (A154)
‖J‖2 6 √ ‖J‖1‖J‖∞ 6 2 m β . (A155)
The last inequality is a direct consequence of Hölder’s inequality.
For 0 6 pi 6 1, we have pi(1− pi) 6 0.25. Therefore, m 6 0.25 for all values of pi. If pmax ≥ 1 − ≥ 0.5 ( 6 0.5), then 1 − pmax 6 and for pi 6= pmax pi 6 . The derivative ∂x(1− x)/∂x = 1− 2x > 0 for x < 0.5, therefore x(1− x) increases with x for x < 0.5. Using x = 1− pmax and for pi 6= pmax x = pi, we obtain pi(1− pi) 6 (1− ) for all i. Consequently, we have m 6 (1− ).
For the softmax p = softmax(βa) with Jacobian ∂J/∂a = J(βa) = β ( diag(p)− ppT ) and for arbitrary N -dimensional vectors b and c, we have
bT J(βa) c = β bT ( diag(p) − p pT ) c = β (∑ i pi bi ci − (∑ i pi bi )(∑ i pi ci )) .
(A156)
Therefore, bT J(βa)c is β times the covariance between b and c if component i is drawn with probability pi of the multinomial distribution p. In our case the component i is sample i.
Using the mean û = 1/M ∑M i=1 ui, the empirical covariance of data U is
Cov(U) = 1/M U UT − û ûT , (A157)
[Cov(U)]kl = M∑ i=1
1/M uik uil − (
M∑ i=1 1/M uik ) ( M∑ i=1 1/M uil ) . (A158)
The weighted covariance (samples ui are drawn according to pi)
Cov(U) = U J(β a) UT , (A159)
[Cov(U)]kl = β ( M∑ i=1 pi uik uil − ( M∑ i=1 pi uik ) ( M∑ i=1 pi uil )) , (A160)
which replaces 1/M from equal sampling by the pi, that is, ui is sampled with probability pi.
The next theorem states how to express the dot product UTxiUyi by weighted covariances of the data U .
Theorem A3 (Weighted Covariances). Using the weighted covariances
Cov(U ,yi) = U J m(β UTyi) U T , Cov(U ,xi) = U J m(β UTxi) U T , (A161)
Jm(β a) = ∫ 1 0 J(λ β a) dλ , (A162)
where the mean Jacobian Jm is symmetric, diagonally dominant, and positive semi-definite with spectral norm bounded by ‖Jm‖2 6 0.5β. The dot product UTxiUyi can be expressed by the weighted covariances
UTxiUyi = (ū + Cov(U ,xi) xi) T (ū + Cov(U ,yi) yi) , (A163)
where the mean is ū = 1/MU1.
Proof. We apply the mean value theorem to the softmax with the symmetric, diagonally dominant, positive semi-definite Jacobian matrix Jm = ∫ 1 0 J(λa+ (1− λ)a′) dλ:
softmax(a) − softmax(a′) = Jm (a − a′) . (A164) We set a′ = 0 and use βa instead of a, which gives:
softmax(β a) = 1/M 1 + Jm(β a) a , Jm(β a) = ∫ 1 0 J(λ β a) dλ , (A165)
which is exact. We obtain
softmax(β UTxi) = 1/M 1 + J m(β UTxi) U Txi , (A166)
softmax(β UTyi) = 1/M 1 + J m(β UTyi) U Tyi . (A167)
The spectral norm of Jm is bounded by ‖Jm‖2 6 0.5β, since this bound holds for every J(λβa) in Jm(β a) = ∫ 1 0 J(λβa) dλ according to Lemma A1.
The dot product between the anchor retrieval and the positive sample is:
UTxiUyi = softmax(β U Txi) T UTU softmax(β UTyi) (A168) = ( 1/M 1 + Jm(β UTxi) U Txi )T UTU ( 1/M 1 + Jm(β UTyi) U Tyi )
= ( 1/M U 1 + U Jm(β UTxi) U Txi )T ( 1/M U1 + U Jm(β UTyi) U Tyi )
= (ū + Cov(U ,xi) xi) T (ū + Cov(U ,yi) yi) ,
where we used the mean ū = 1/MU1 and the weighted covariances
Cov(U ,yi) = U J m(β UTyi) U T , Cov(U ,xi) = U J m(β UTxi) U T . (A169)
The Jacobian Jm is symmetric, diagonally dominant, and positive semi-definite. The weighted covariance Cov(U , .) is the covariance if the stored pattern ui is drawn according to an averaged pi given by Jm(.). Analog for weighted covariance Cov(V , .). When maximizing the dot product UTxiUyi , the normalized vectors xi and yi are encouraged to agree on drawing the patterns ui with the same probability pi to generate similar weighted covariance matrices Cov(U , .). If subsets of U have a strong covariance structure, then it can be exploited to produce large weighted covariances and, in turn, large dot products of UTxiUyi . Furthermore, for a large dot product U T xiUyi , xi and yi have to be similar to one another to extract the same direction from the covariance matrices. All considerations are analog for V TxiVyi .

heading: A.2 MUTUAL INFORMATION ESTIMATION
text: We follow the toy experiment discussed in Poole et al. (2019), Belghazi et al. (2018) and Cheng et al. (2020) and experimentally confirm the superior quality of InfoLOOB for mutual information than InfoNCE. The dataset consists of samples (xi,yi) drawn jointly from a multivariate Gaussian distribution with correlation ρ where the dimension of the samples x and y is set to d = 20. We examine the performance of InfoLoob with and without Hopfield and InfoNCE at estimating mutual information of these samples. Due to the Gaussian distribution, the true value of mutual information can be calculated as I(x,y) = −d2 log(1 − ρ2). We set the mutual information true value to the values (2.0, 4.0, 6.0, 8.0, 10.0, 14.0) by varying the value of ρ. At each MI true value, we sample data batches 1024 times, with batch size equal to 64, for the training of variational MI estimators. Figure 2 shows that modern Hopfield networks reduce the variance of the model. For models trained on data with mutual information of 10 we observe an average variance of approx. 0.67 for a model without Hopfield and an average variance of approx. 0.33 for a model with Hopfield. For models trained on data with mutual information of 14 we observe an average variance of approx. 1.00 for a model without Hopfield and an average variance of approx. 0.48 for a model with Hopfield.
In Figure A1 we show the performance of our method InfoLOOB with and without Hopfield at estimating mutual information as well as InfoNCE. As expected estimates of InfoNCE have estimates that saturate at log(batch size). InfoLOOB without Hopfield exhibits good estimates of high mutual information while InfoLOOB with Hopfield accomplishes both - good estimates of high mutual information with a decreased variance.

heading: A.3 EXPERIMENTS

heading: A.3.1 ABLATION STUDIES
text: As mentioned in the main paper, CLOOB has two new main components compared to CLIP: (1) the InfoLOOB objective instead of the InfoNCE objective and (2) the modern Hopfield networks. To assess which of the new main components of CLOOB have led to the performance increase over CLIP, we performed ablation studies on the CC dataset. The results are reported in Table A1. First, we enhanced CLIP by replacing the InfoNCE objective with InfoLOOB (see column CLIP InfoLOOB). Next, we added modern Hopfield networks to the CLIP architecture and used retrieved embeddings instead of the original embeddings, while keeping the InfoNCE objective (see column Hopfield InfoNCE). Finally, we add modern Hopfield networks to CLIP and replace the InfoNCE objective
0 1000 2000 3000 4000 5000 6000 7000 steps
−2 0
2
4
6
8
10
12
14
M ut
ua l
in fo
rm at
io n
infoNCE
True MI log(64)
0 1000 2000 3000 4000 5000 6000 7000 steps
−2 0
2
4
6
8
10
12
14
M ut
ua l
in fo
rm at
io n
infoLOOB without Hopfield
True MI
0 1000 2000 3000 4000 5000 6000 7000 steps
−2 0
2
4
6
8
10
12
14
M ut
ua l
in fo
rm at
io n
infoLOOB with Hopfield
True MI
Figure A1: The estimated mutual information of the InfoNCE objective saturates at the batch size induced bound. The InfoLOOB objective trained with the same batch size with samples from the same correlated Gaussian distributions following (Belghazi et al., 2018; Poole et al., 2019; Cheng et al., 2020) is not limited by that bound and better estimates higher mutual information but suffers from higher variance. This is remedied by incorporating the modern Hopfield network.
Table A1: Influence of loss functions and Hopfield retrieval. InfoLOOB increases the performance of CLIP in most of the tasks. The InfoNCE loss is not suited for the Hopfield approach as it saturates leading to a worse performance. Hopfield with InfoLOOB strongly improves the performance in 7 out of 8 datasets compared to both CLIP models.
CLIP Hopfield Dataset InfoNCE InfoLOOB InfoNCE InfoLOOB
Birdsnap 1.94 2.37 1.67 2.53 Country211 0.62 0.63 0.54 0.76 Flowers102 13.04 13.03 11.53 14.24 GTSRB 7.28 4.39 5.76 5.86 UCF101 21.00 19.14 20.56 22.29 Stanford Cars 0.90 1.33 1.24 1.37 ImageNet 20.31 22.13 19.04 24.21 ImageNetV2 20.63 21.65 18.97 23.80
with InfoLOOB (see column Hopfield InfoLOOB). As shown in Table A1 the InfoLOOB objective increases the performance of CLIP in the majority of the datasets. We attribute this increase to the fact that InfoLOOB suffers less than InfoNCE from the “explaining away” problem. However, InfoLOOB is even more effective for higher mutual information, that is, a richer covariance structure. Hopfield networks amplify the covariance structure in their retrieved embeddings. Though, this amplified covariance structure is disadvantageous for InfoNCE, as the saturation effect is stronger. The stronger saturation effect is caused by a richer covariance structure through Hopfield networks, which in turn leads to higher similarity between anchor and positive. Therefore, we see a performance drop when combining modern Hopfield networks with InfoNCE. Concluding, modern Hopfield networks are a perfect match for InfoLOOB as they yield higher mutual information. Therefore, CLOOB strongly improves the performance on 7 out of 8 zero-shot transfer learning tasks compared to CLIP.
For CLIP with InfoNCE, the hyperparameter τ−1 is a learnable parameter. For the other experiments, we use a fixed τ−1 of 30. The value for τ−1 was determined via hyperparameter search (see Section A.3.2).
In contrast to CLIP, we use a learning rate scheduler with restarts (Loshchilov & Hutter, 2017) to be more flexible regarding the number of total training epochs and enable training up to a plateau. To investigate the influence of the learning rate scheduler, we performed experiments with and without restarts. Table A2 shows the zero-shot performance for the different downstream tasks for CLIP and CLOOB respectively. For both CLIP and CLOOB, the performance at the majority of the tasks either increases or remains roughly the same with restarts.
Table A2: Influence of learning rate scheduler. For most of the tasks the performance either increases or remains roughly the same with restarts for both CLIP and CLOOB.
CLIP CLOOB Dataset w/o restarts w/ restarts w/o restarts w/ restarts
Birdsnap 2.10 1.94 2.64 2.53 Country211 0.71 0.62 0.63 0.76 Flowers102 11.00 13.04 11.50 14.24 GTSRB 6.16 7.28 5.05 5.86 UCF101 19.05 21.00 21.97 22.29 Stanford Cars 1.29 0.90 1.22 1.37 ImageNet 20.19 20.31 23.29 24.21 ImageNet V2 20.53 20.63 22.97 23.80
Table A3: Datasets used for zero-shot and linear probing. In the case of several train or test sets per dataset we report the total number of samples. It should be noted that at the time of this work some Birdsnap images were not accessible anymore.
Dataset Classes Train size Test size Evaluation metric
Birdsnap 500 38,411 1,855 accuracy Country211 211 42,200 21,100 accuracy Flowers102 102 2,040 6,149 class-weighted accuracy GTSRB 43 26,640 12,630 accuracy ImageNet 1,000 1,281,167 50,000 accuracy ImageNet V2 1,000 1,281,167 30,000 accuracy Stanford Cars 196 8,144 8,041 accuracy UCF101 101 28,747 11,213 accuracy

heading: A.3.2 HYPERPARAMETERS
text: The hyperparameter search was done on a validation split of CC with about 15,000 samples. For the hyperparameter τ−1 several values were considered (14.3, 30, 50, 70), where 30 leads to the best results for both YFCC and CC. Analogously to CLIP, we use the Adam optimizer (Kingma et al., 2014) with decoupled weight decay regularization (Loshchilov & Hutter, 2019). The weight decay is only applied to weights that are not gains or biases. As proposed in OpenCLIP (Ilharco et al., 2021) weight decay was set to 0.1. Different choices of weight decay (0.2 or 0.05), did not lead to a relevant performance change. We use the same learning rate of 1× 10−3 for CC and 5× 10−4 for YFCC as used in OpenCLIP. For the hyperparameter β we considered values in the range of 5 to 20. A value of 8 resulted in the best performance for CC and 14.3 for YFCC. The batch size for CC was reduced to 512 due to computational restraints which did not result in performance losses. The batch size for YFCC was kept at 1024 as reported by OpenCLIP since a reduction resulted in a significant drop in performance. The learning rate scheduler for all experiments is cosine annealing with warmup and hard restarts (Loshchilov & Hutter, 2017) with a cycle length of 7 epochs. For models trained on YFCC the warmup was set to 10000 steps and for models trained on CC to 20000 steps.

heading: A.3.3 DATASETS
text: For pretraining we consider two datasets, Conceptual Captions (CC) (Sharma et al., 2018) and YFCC100M (Thomee et al., 2016). The CC dataset consists of 2.9 million images and corresponding high-quality captions. Images and their corresponding notations for CC have been gathered via an automated process from the web and therefore represent a wide variety of styles. Raw descriptions of images are collected from the alt-text HTML attribute. Both images and texts are filtered such that only image-text pairs above a certain quality threshold are part of this dataset. The dataset we refer to as YFCC is a subset of the Yahoo Flickr Creative Commons 100 Million (YFCC100M) dataset. It was created by filtering for images which contain natural language descriptions and/or titles in English resulting in 15 million image-caption pairs. The textual descriptions contain less
useful information than CC because they are not filtered by quality. Occasionally they also contain metadata like camera settings or web addresses.
We evaluate and compare our method on several downstream classification tasks. We evaluate on the same set of datasets as CLIP reported for a model trained on YFCC. This set contains Birdsnap (Berg et al., 2014), Country211 (Radford et al., 2021), Flowers102 (Nilsback & Zisserman, 2008), GTSRB (Stallkamp et al., 2011), UCF101 (Soomro et al., 2012), Stanford Cars (Krause et al., 2013) and ImageNet (Deng et al., 2009). Additionally, we include ImageNet V2 in our analysis (Recht et al., 2019). Table A3 shows an overview of training and test set sizes, number of classes and the applied evaluation metric. In the case of several test sets per dataset the metric is calculated for every set individually and the average performance is reported. The set size in Table A3 corresponds to the total number of samples across all test and training sets of a dataset respectively.
Birdsnap contains images of North American bird species, however our dataset is smaller than reported in CLIP as some samples are no longer available. The Country211 dataset was published in CLIP and is a small subset of the YFCC100m dataset. It consists of photos that can be assigned to 211 countries via GPS coordinates. For each country 200 photos are sampled for the training set and 100 for testing. For the Flowers102 images of 102 flower categories commonly occuring in the United Kingdom were collected. Several classes are very similar and there is a large variation in scale, pose and lighting. The German Traffic Sign Recognition Benchmark (GTSRB) was a challenge held at the IJCNN 2011. The dataset contains images of german traffic signs from more than 40 classes. Note that two versions of this dataset exist, one used for the challenge and an official dataset released after the competition. For CLIP the linear probing classifiers were trained using the competition training set but tested on the official test set. Stanford Cars contains images of 196 car models at the level of make, model and year (e.g. Tesla Model S Sedan 2012). UCF101 (Soomro et al., 2012) is a video dataset with short clips for action recognition consisting of three training sets and three test sets. We follow the procedure reported in CLIP and extract the middle frame of every video to assemble the dataset. The ImageNet Large Scale Visual Recognition Challenge was held from 2012 through 2017 and is one of the most widely used benchmarks for object detection and localization. Several years later ImageNet V2 assembled three new test sets with images from the same 1,000 classes to test for generalization of models optimized for the original ImageNet benchmark. Every test set comprises 10,000 samples.

heading: A.3.4 ZERO-SHOT EVALUATION
text: Class names for all downstream tasks were adopted from CLIP, that is, among other changes special characters like hyphens or apostrophes were removed. Furthermore, some class names of the datasets were slightly changed (e.g. “kite” to “kite (bird of prey)” in ImageNet). For zero-shot evaluation, we use the same prompt templates as published in CLIP. Depending on the dataset the number of prompts can vary from one prompt (e.g. “a photo of a {label}, a type of bird.” for Birdsnap) up to 80 prompts for ImageNet covering various settings (e.g. “a cropped photo of a {label}.”, “a origami {label}.”). In case of several prompts an average embedding over all prompt embeddings is calculated. Figure A2 shows the zero-shot results for all evaluation tasks with the ResNet-50x4 model reported in Table 4.

heading: A.3.5 LINEAR PROBING
text: We try to follow the evaluation procedure in Radford et al. (2021) as closely as possible. We note one difference with respect to the implementation: Instead of scikit-learn’s logistic regression using the L-BFGS solver, we use cuML’s logistic regression classifier with L-BFGS algorithm to utilize GPUs for efficiency. All hyperparameters are the same as described in Radford et al. (2021), the maximum number of iterations was set to 1000, and the L2 regularization strength λ was determined by using a parametric binary search.
We tried to reproduce the CLIP results with the correspondingly published models, however, failed to produce the exact numbers. This could be due to several factors:
• The train and validation split. Same as in Radford et al. (2021) , we use the provided validation set to perform the hyperparameter search. When there is none provided, we use a random half of the training dataset for validation.
Table A4: Linear probing results for the reimplementation of CLIP and CLOOB using different ResNet architectures trained on YFCC. The performance of CLOOB scales with increased encoder size
Dataset CLIPRN-50 CLOOB RN-50 CLOOB RN-101 CLOOB RN-50x4
Birdsnap 50.9 56.2 58.1 62.2 Country211 19.5 20.6 21.8 24.2 Flowers102 94.8 96.1 96.1 96.2 GTSRB 82.5 78.9 77.9 80.6 UCF101 75.2 72.3 72.8 75.3 Stanford Cars 36.2 37.7 39.0 44.3 ImageNet 66.9 65.7 67.0 69.7 ImageNet V2 60.2 58.7 60.3 62.2
• In case of a tie in the validation score, we use the maximal λ for the strongest regularization. We note though that we came closer to reproducing the results published in CLIP when using the mean λ over all ties when these exist.
• For the Birdsnap dataset, the resources that we have got online at the time of this writing could be different from the resources that CLIP’s authors obtained at the time.
Linear probing evaluation of YFCC-pretrained models is shown in Table A4. Comparing our reimplementation of CLIP and CLOOB with ResNet-50 encoders, we observe mixed results. The reason for this effect might be attributed to the observed task-dependence of multimodal models (Devillers et al., 2021). Another potential reason is that the benefit of the restrictions to more reliable patterns that occur in both modalities does not directly translate to an evaluation of just the encoding part of one modality. Again, as expected in self-supervised training, increasing the capacity of the CLOOB models benefits accuracy.

heading: A.4 REVIEW OF MODERN HOPFIELD NETWORKS
text: We briefly review continuous modern Hopfield networks that are used for deep learning architectures. They are continuous and differentiable, therefore they a work with gradient descent in deep architectures. They retrieve with one update only, therefore they can be activated like other deep learning layers. They have exponential storage capacity, therefore they can tackle large problems. Hopfield networks are energy-based, binary associative memories, which popularized artificial neural networks in the 1980s (Hopfield, 1982; 1984). Associative memory networks have been designed to store and retrieve samples. Their storage capacity can be considerably increased by polynomial terms in the energy function (Chen et al., 1986; Psaltis & Cheol, 1986; Baldi & Venkatesh, 1987; Gardner, 1987; Abbott & Arian, 1987; Horn & Usher, 1988; Caputo & Niemann, 2002; Krotov & Hopfield, 2016). In contrast to these binary memory networks, we use continuous associative memory networks with very high storage capacity. These modern Hopfield networks for deep learning architectures have an energy function with continuous states and can retrieve samples with only one update (Ramsauer et al., 2021; 2020). Modern Hopfield Networks have been successfully applied to immune repertoire classification (Widrich et al., 2020) and chemical reaction prediction (Seidl et al., 2021).
We assume a set of patterns {u1, . . . ,uN} ⊂ Rd that are stacked as columns to the matrix U = (u1, . . . ,uN ) and a state pattern (query) ξ ∈ Rd that represents the current state. The largest norm of a stored pattern is M = maxi ‖ui‖. Continuous modern Hopfield networks with state ξ have the energy
E = − β−1 log (
N∑ i=1 exp(βuTi ξ)
) + β−1 logN + 1
2 ξT ξ +
1 2 M2 . (A170)
For energy E and state ξ, the update rule
ξnew = f(ξ;U , β) = U p = U softmax(βUT ξ) (A171)
0.0 0.2 0.4 0.6 0.8 1.0
cottontail rabbit
hare
Angora rabbit
Scottish Terrier
Yorkshire Terrier
0.0 0.2 0.4 0.6 0.8 1.0
mosque
Black and Tan Coonhound
rhinoceros beetle
gossamer-winged butterfly
dragonfly
0.0 0.2 0.4 0.6 0.8 1.0
Osprey
Bald Eagle
Semipalmated Plover
Swallow tailed Kite
Rough legged Hawk
0.0 0.2 0.4 0.6 0.8 1.0
Croatia
Greece
Montenegro
Turkey
Albania
0.0 0.2 0.4 0.6 0.8 1.0
azalea
geranium
pelargonium
sweet william
garden phlox
0.0 0.2 0.4 0.6 0.8 1.0
red and white triangle with traffic light approaching warning empty red and white circle
stop red circle with white horizonal stripe no entry red and white triangle road intersection warning
0.0 0.2 0.4 0.6 0.8 1.0
Chevrolet HHR SS 2010
Dodge Caliber Wagon 2007
Audi RS 4 Convertible 2008
Dodge Journey SUV 2012
Dodge Magnum Wagon 2008
0.0 0.2 0.4 0.6 0.8 1.0
Military Parade
Pommel Horse
Horse Riding
Typing
Nunchucks
Horse Riding correct rank: 3/101
Dodge Caliber Wagon 2012 correct rank: 10/196
red circle with white horizontal stripe no entry correct rank: 4/43
azalea correct rank: 1/102
Croatia correct rank: 1/211
Osprey correct rank: 1/500
mosque correct rank: 1/1000
cottontail rabbit correct rank: 1/1000
0.0 0.2 0.4 0.6 0.8 1.0
longhorn beetle
cricket insect
weevil
tiger beetle
cockroach
0.0 0.2 0.4 0.6 0.8 1.0
combine harvester
hay
corn
thatched roof
farm plow
0.0 0.2 0.4 0.6 0.8 1.0
Great Blue Heron
Tricolored Heron
Little Blue Heron
Reddish Egret
Northern Harrier
0.0 0.2 0.4 0.6 0.8 1.0
Greece
Croatia
Malta
Monaco
Bermuda
0.0 0.2 0.4 0.6 0.8 1.0
magnolia
frangipani
gaura
cyclamen
sweet pea
0.0 0.2 0.4 0.6 0.8 1.0
stop red circle with white horizonal stripe no entry blue circle with white keep right arrow mandatory red and white triangle car skidding / slipping warning empty red and white circle
0.0 0.2 0.4 0.6 0.8 1.0
Ford Expedition EL SUV 2009
Chevrolet Express Van 2007 Chevrolet Silverado 1500 Classic Extended Cab 2007 Ford Freestar Minivan 2007
Honda Odyssey Minivan 2007
0.0 0.2 0.4 0.6 0.8 1.0
Body Weight Squats
Basketball
Table Tennis Shot
Mopping Floor
Bowling
Handstand Walking correct rank: 11/101
Chrysler Aspen SUV 2009 correct rank: 19/196
red and white circle red truck and black car no passing correct rank: 36/43
magnolia correct rank: 1/102
Greece correct rank: 1/211
Great Blue Heron correct rank: 1/500
threshing machine correct rank: 13/1000
longhorn beetle correct rank: 1/1000
0.0 0.2 0.4 0.6 0.8 1.0
car mirror
collie
Border Collie
Great Pyrenees dog
American Staffordshire Terrier
0.0 0.2 0.4 0.6 0.8 1.0
red wine
lighter
perfume
wine bottle
bell pepper
0.0 0.2 0.4 0.6 0.8 1.0
Northern Pintail
Long tailed Duck
Brant
Greater Scaup
Gadwall
0.0 0.2 0.4 0.6 0.8 1.0
Algeria
Palestine
Malta
Croatia
Barbados
0.0 0.2 0.4 0.6 0.8 1.0
rose
desert-rose
bougainvillea
osteospermum
camellia
0.0 0.2 0.4 0.6 0.8 1.0
red and white triangle with exclamation mark warning red and white triangle car skidding / slipping warning red and white triangle with person digging / construction red and white triangle with deer warning red and white triangle with snowflake / ice warning
0.0 0.2 0.4 0.6 0.8 1.0
Honda Odyssey Minivan 2007
Volvo XC90 SUV 2007
Ford Expedition EL SUV 2009
Daewoo Nubira Wagon 2002
Ford Freestar Minivan 2007
0.0 0.2 0.4 0.6 0.8 1.0
Field Hockey Penalty
Soccer Penalty
Tennis Swing
Table Tennis Shot
Basketball
Field Hockey Penalty correct rank: 1/101
Chevrolet Traverse SUV 2012 correct rank: 33/196
red and white triangle with black curve approaching warning correct rank: 11/43
rose correct rank: 1/102
Spain correct rank: 24/211
Brant correct rank: 3/500
lipstick correct rank: 7/1000
collie correct rank: 2/1000
Figure A2: Visualization of zero-shot classification of three examples from each dataset. The following datasets are used (top to bottom): ImageNet, ImageNet V2, Birdsnap, Country211, Flowers102, GTSRB, Stanford Cars and UCF101. The ground truth label is displayed above the picture. The bar plots show the softmax values of the top 5 classes.
has been proven to converge globally to stationary points of the energy E, which are almost always local minima (Ramsauer et al., 2021). The update rule Eq. (A171) is also the formula of the wellknown transformer attention mechanism (Ramsauer et al., 2021), therefore Hopfield retrieval and transformer attention coincide.
The separation ∆i of a pattern ui is defined as its minimal dot product difference to any of the other patterns: ∆i = minj,j 6=i ( uTi ui − uTi uj ) . A pattern is well-separated from the data if
∆i ≥ 2βN + 1β log ( 2(N − 1)NβM2 ) . If the patterns ui are well separated, the iterate Eq. (A171) converges to a fixed point close to a stored pattern. If some patterns are similar to one another and, therefore, not well separated, the update rule Eq. (A171) converges to a fixed point close to the mean of the similar patterns. This fixed point is a metastable state of the energy function and averages over similar patterns.
The next theorem states that the update rule Eq. (A171) typically converges after one update if the patterns are well separated. Furthermore, it states that the retrieval error is exponentially small in the separation ∆i.
Theorem A4 (Modern Hopfield Networks: Retrieval with One Update). With query ξ, after one update the distance of the new point f(ξ) to the fixed point u∗i is exponentially small in the separation ∆i. The precise bounds using the Jacobian J = ∂f(ξ) ∂ξ and its value J
m in the mean value theorem are:
‖f(ξ) − u∗i ‖ 6 ‖Jm‖2 ‖ξ − u∗i ‖ , (A172) ‖Jm‖2 6 2 β N M2 (N − 1) exp(− β (∆i − 2 max{‖ξ − ui‖, ‖u∗i − ui‖}M)) . (A173)
For given and sufficient large ∆i, we have ‖f(ξ) − u∗i ‖ < , that is, retrieval with one update. The retrieval error ‖f(ξ) − ui‖ of pattern ui is bounded by
‖f(ξ) − ui‖ 6 2 (N − 1) exp(− β (∆i − 2 max{‖ξ − ui‖, ‖u∗i − ui‖}M)) M . (A174)
For a proof see (Ramsauer et al., 2021).
The main requirement of modern Hopfield networks to be suited for contrastive learning is that they can store and retrieve enough embeddings if the batch size is large. We want to store a potentially large set of embeddings. We first define what we mean by storing and retrieving patterns from a modern Hopfield network.
Definition A1 (Pattern Stored and Retrieved). We assume that around every pattern ui a sphere Si is given. We say ui is stored if there is a single fixed point u∗i ∈ Si to which all points ξ ∈ Si converge, and Si ∩ Sj = ∅ for i 6= j. We say ui is retrieved for a given if iteration (update rule) Eq. (A171) gives a point x̃i that is at least -close to the single fixed point u∗i ∈ Si. The retrieval error is ‖x̃i − ui‖.
As with classical Hopfield networks, we consider patterns on the sphere, i.e. patterns with a fixed norm. For randomly chosen patterns, the number of patterns that can be stored is exponential in the dimension d of the space of the patterns (ui ∈ Rd). Theorem A5 (Modern Hopfield Networks: Exponential Storage Capacity). We assume a failure probability 0 < p 6 1 and randomly chosen patterns on the sphere with radius M := K √ d− 1. We define a := 2d−1 (1 + ln(2βK 2p(d − 1))), b := 2K2β5 , and c := bW0(exp(a+ln(b)) , where W0 is
the upper branch of the Lambert W function (Olver et al., 2010, (4.13)), and ensure c ≥ (
2√ p
) 4 d−1
. Then with probability 1− p, the number of random patterns that can be stored is
N ≥ √p c d−14 . (A175)
Therefore it is proven for c ≥ 3.1546 with β = 1, K = 3, d = 20 and p = 0.001 (a+ ln(b) > 1.27) and proven for c ≥ 1.3718 with β = 1, K = 1, d = 75, and p = 0.001 (a+ ln(b) < −0.94).
For a proof see (Ramsauer et al., 2021).
This theorem justifies to use continuous modern Hopfield networks for using retrieved embeddings instead of the original embeddings for large batch sizes. Even for hundreds of thousands of embeddings, the continuous modern Hopfield network is able to retrieve the embeddings if the dimension of the embeddings is large enough.

heading: A.5 FURTHER RELATED WORK
text: Multiple works have proposed improvements to InfoNCE. Joint Contrastive Learning (JCL) studies the effect of sampling multiple positives for each anchor. (Cai et al., 2020). Sampling negatives around each positive leads to higher bias but lower variance than InfoNCE (Wu et al., 2021). InfoNCE has been generalized to C-InfoNCE and WeaC-InfoNCE, which are conditional contrastive learning approaches to remove undesirable information in self-supervised representations (Tsai et al., 2021). ProtoNCE is a generalized version of the InfoNCE, which pushes representations to be closer to their assigned prototypes (Li et al., 2021). ProtoNCE combines contrastive learning with clustering. SimCSE employs InfoNCE for contrastive learning to learn sentence embeddings (Gao et al., 2021). InfoNCE has been extended to video representation learning (Han et al., 2020).
Many follow up works have been based on the CLIP model. The CLIP model is used in Vision-andLanguage tasks (Shen et al., 2021). The CLIP model guided generative models via an additional training objective (Bau et al., 2021; Galatolo et al., 2021; Frans et al., 2021) and improved clustering of latent representations (Pakhomov et al., 2021). It is used in studies of out of distribution performance (Devillers et al., 2021; Milbich et al., 2021; Miller et al., 2021), of fine-tuning robustness (Wortsman et al., 2021), of zero-shot prompts (Zhou et al., 2021) and of adversarial attacks to uncurated datasets (Carlini & Terzis, 2021). It stirred discussions about more holistic evaluation schemes in computer vision (Agarwal et al., 2021). Multiple methods utilize the CLIP model in a straightforward way to perform text-to-video retrieval (Fang et al., 2021; Luo et al., 2021; Narasimhan et al., 2021).

Review summaries:
By using the InfoNCE loss for model training, CLIP has achieved great success. In this paper, the authors propose CLOOB, short for "Contrastive Leave One Out Boost", where modern Hopfield networks are used together with the InfoLOOB objective. InfoLOOB is a leave-one-out upper bound of mutual information, and modern Hopfield networks replace the original embeddings by retrieved embeddings. Results show that CLOOB outperforms CLIP at zero-shot transfer learning across multiple architectures and datasets. 

This paper proposed a new contrastive learning method called CLOOB, which minimized the leave-one-out upper bound (InfoLOOB) on mutual information with the modern Hopfield networks. Concretely, Hopfield networks replace the original embeddings by retrieved embeddings in the InfoLOOB objective.  The retrieved embeddings are more robust as they capture the common covariance structure of all sample embeddings, leading to a stable performance of InfoLOOB. Extensive experiments on several zero-shot datasets show that the proposed CLOOB method outperforms the well-known CLIP model across all considered architectures.