Title: Understanding Contrastive Learning via Distributionally Robust Optimization
Venue: NeurIPS 2023
Accepted: yes
Keywords: contrastive learning

distributionally robust optimization

mutual information
Abstract: This study reveals the inherent tolerance of contrastive learning (CL) towards sampling bias, wherein negative samples may encompass similar semantics (\eg labels). However, existing theories fall short in providing explanations for this phenomenon. We bridge this research gap by analyzing CL through the lens of distributionally robust optimization (DRO), yielding several key insights: (1) CL essentially conducts DRO over the negative sampling distribution, thus enabling robust performance across a variety of potential distributions and demonstrating robustness to sampling bias; (2) The design of the temperature $\tau$ is not merely heuristic but acts as a Lagrange Coefficient, regulating the size of the potential distribution set; (3) A theoretical connection is established between DRO and mutual information, thus presenting fresh evidence for ``InfoNCE as an estimate of MI'' and a new estimation approach for $\phi$-divergence-based generalized mutual information. We also identify CL's potential shortcomings, including over-conservatism and sensitivity to outliers, and introduce a novel Adjusted InfoNCE loss (ADNCE) to mitigate these issues. It refines potential distribution, improving performance and accelerating convergence. Extensive experiments on various domains (image, sentence, and graph) validate the effectiveness of the proposal.

Understanding Contrastive Learning via Distributionally Robust Optimization

Abstract

This study reveals the inherent tolerance of contrastive learning (CL) towards sampling bias, wherein negative samples may encompass similar semantics ( e.g., labels). However, existing theories fall short in providing explanations for this phenomenon. We bridge this research gap by analyzing CL through the lens of distributionally robust optimization (DRO), yielding several key insights: (1) CL essentially conducts DRO over the negative sampling distribution, thus enabling robust performance across a variety of potential distributions and demonstrating robustness to sampling bias; (2) The design of the temperature τ is not merely heuristic but acts as a Lagrange Coefficient, regulating the size of the potential distribution set; (3) A theoretical connection is established between DRO and mutual information, thus presenting fresh evidence for 'InfoNCE as an estimate of MI' and a new estimation approach for ϕ -divergence-based generalized mutual information. We also identify CL's potential shortcomings, including over-conservatism and sensitivity to outliers, and introduce a novel Adjusted InfoNCE loss (ADNCE) to mitigate these issues. It refines potential distribution, improving performance and accelerating convergence. Extensive experiments on various domains (image, sentence, and graphs) validate the effectiveness of the proposal. The code is available at https://github.com/junkangwu/ADNCE .

1 Introduction

Recently, contrastive learning (CL) [1; 2; 3] has emerged as one of the most prominent self-supervised methods, due to its empirical success in computer vision [4; 5; 6; 7; 8], natural language processing [9; 10] and graph [11; 12]. The core idea is to learn representations that draw positive samples ( e.g., augmented data from the same image) nearby and push away negative samples ( e.g., augmented data from different images). By leveraging this intuitive concept, unsupervised learning has even begun to challenge supervised learning.

Despite its effectiveness, recent study [13] has expressed concerns about sampling bias in CL. Negative samples are often drawn uniformly from the training data, potentially sharing similar semantics ( e.g., labels). Blindly separating these similar instances could result in a performance decline. To address sampling bias, existing research has proposed innovative solutions that either approximate the optimal distribution of negative instances [13; 14] or integrate an auxiliary detection module to identify false negative samples [15]. Nevertheless, our empirical analyses challenge the prevailing understanding of CL. Our findings indicate that CL inherently exhibits robustness towards

,

sampling bias and, by tuning the temperature τ , can even achieve comparable performance with representative methods for addressing sampling bias ( e.g., DCL [13] and HCL [14]). This revelation prompts two intriguing questions: 1) Why does CL display tolerance to sampling bias? and 2) How can we thoroughly comprehend the role of the temperature τ ? Despite recent analytical work on CL from various perspectives [13; 14; 16], including mutual information and hard-mining, these studies fail to provide a satisfactory explanation for our observations.

To address this research gap, we investigate CL from the standpoint of Distributionally Robust Optimization (DRO) [17; 18; 19; 20; 21; 22]. DRO refers to a learning algorithm that seeks to minimize the worst-case loss over a set of possible distributions. Through rigorous theoretical analysis, we prove that CL essentially performs DRO optimization over a collection of negative sampling distributions that surround the uniform distribution, constrained by a KL-divergence-based measure (we term the DRO-type equivalent expression of CL as CL-DRO). By enabling CL to perform well across various potential distributions, DRO equips it with the capacity to alleviate sampling bias. Furthermore, our findings emphasize that the design of τ is not merely heuristic but acts as a Lagrange Coefficient, regulating the size of the potential distribution set. By integrating the principles of DRO, we can also gain insights into the key properties of CL such as hard-mining, and investigate novel attributes such as variance control.

Furthermore, we delve into the properties of CL-DRO, transcending the boundary of KL divergence, but exploring a broader family of distribution divergence metrics ϕ -divergence. It exhibits greater flexibility and potentially superior characteristics compared to KL-divergence. Interestingly, we establish the equivalence between CL-DRO under any ϕ -divergence constraints and the corresponding tight variational representation of ϕ -divergence [23]. This discovery provides direct theoretical support for the assertion that ' InfoNCE is an estimate of mutual information (MI) ', without requiring redundant approximation as before work [24; 3]. Additionally, it provides a novel perspective for estimating arbitrary ϕ -divergence, consequently enabling the estimation of ϕ -divergence-based mutual information.

In addition, we discover some limitations in CL through the lens of DRO. One is that the DRO paradigm is too conservative, focusing on worst-case distribution with giving unadvisedly over-large weights on hard negative samples. Secondly, the presence of outliers can significantly impact DRO [25], resulting in both a drop in performance and training instability. In fact, both challenges stem from the unreasonably worst-case distribution weights assigned to negative samples. To address this weakness, we propose AD justed Info NCE (ADNCE) that reshapes the worst-case distribution without incurring additional computational overhead, allowing us to explore the potentially better negative distribution. Empirical studies show that our method can be applied to various domains (such as images, sentences, and graphs), and yield superior performance with faster convergence.

2 Related Work

Contrastive Learning. With numerous CL methodologies ( e.g., SimCLR [4], Moco [6], BYOL [26], SwAV [27], Barlow Twins [8]) having been proposed and demonstrated the ability to produce high-quality representations for downstream tasks, theoretical research in this field has begun to emerge. Wang et al. [28] revealed the hard-mining property and Liu et al. [29] emphasized its robustness against dataset imbalance. Meanwhile, Xue et al. [30] showed that representations learned by CL provably boosts robustness against noisy labels, and Ko et al. [31] investigated the relationship between CL and neighborhood component analysis. More closely related to our work is the result of Tian et al. [16] that analyzed CL from minmax formulation.

Distributionally Robust Optimization. In contrast to conventional robust optimization approaches [32; 33; 34], DRO aims to solve the distribution shift problem by optimizing the worst-case error in a pre-defined uncertainty set, which is often constrained by ϕ -divergence [20; 17], Wasserstein distance [21; 22; 19; 18] and shape constraints [35; 36; 37]. Meanwhile, Michel et al. [38; 39] parametrized the uncertainty set, allowing more flexibility in the choice of its architecture. Zhai et al. [25] focused on issues related to the existing DRO, such as sensitivity to outliers, which is different from the aforementioned research.

Mutual Information. The MI between two random variables, X and Y , measures the amount of information shared between them. To estimate MI, the Donsker-Varadhan target [40] expresses the lower bound of the Kullback-Leibler (KL) divergence, with MINE [24] being its parameterized

version. However, according to studies [41; 42], the MINE estimator may suffer from high variance. To address this issue, InfoNCE [3] extends the unnormalized bounds to depend on multiple samples, thereby eliminating the constraints of both MINE's reliance on conditional and marginal densities. Another line of MI focuses on boundedness and low variance. Towards this end, RPC [43] introduced relative parameters to regularize the objective and FLO [44] leveraged Fenchel-Legendre optimization. Nevertheless, they are still hard to explain how MI optimization elucidates the properties of CL and facilitates effective CL in practice.

3 Contrastive learning as Distributionally Robust Optimization

In this section, we firstly uncover the tolerance of CL towards sampling bias. Then we analyze CL and τ from the perspective of DRO. Finally, we empirically verify the above findings.

Notation. Contrastive Learning is conducted on two random variables X,Y over a feature space A . Suppose we have original samples x , which obey the distribution P X , positive samples drawn from the distribution ( x, y + ) ∼ P Y | X , and negative samples selected from the distribution ( x, y ) ∼ P Y . The goal of CL is to learn an embedding g θ : A → R d that maps an observation ( i.e., x, y, y + ) into a hypersphere. Let f ( g θ ( x ) , g θ ( y )) be the similarity between two observations x and y on the embedding space. CL draws positive samples closer ( i.e., f ( g θ ( x ) , g θ ( y + )) ↑ for ( x, y + ) ∼ P XY ) and pushes the negative samples away ( i.e., f ( g θ ( x ) , g θ ( y )) ↓ for ( x, y ) ∼ P X P Y ). For brevity, in this work, we simply shorten the notations P Y | X as P 0 , and P Y as Q 0 . Also, we primarily focus on InfoNCE loss L InfoNCE as a representative for analyses, while other CL's loss functions exhibit similar properties. InfoNCE 3 can be written as follow:

3.1 Motivation

In practical applications of contrastive learning (CL), negative samples ( y ) are typically drawn uniformly from the training data, which might have similar semantics (for instance, labels). This introduces a potential issue of sampling bias, as posited by Chuang et al. [13], since similar samples are being forcefully separated. Recent research [15; 13] observed that compared to the employment of ideal negative sampling that selects instances with distinctly dissimilar semantics, the existence of sampling bias could result in a significant reduction in performance.

In this study, we observe an intriguing phenomenon where CL inherently demonstrates re-

silience to sampling bias. We empirically evaluate CL on two benchmark datasets, CIFAR10 and STL10, with the findings detailed in Table 1. Notably, we make the following observations: 1) By fine-tuning the temperature τ , basic SimCLR demonstrates significant improvement, achieving performance levels comparable to methods specifically designed to address sampling bias ( i.e., SimCLR( τ ∗ ) versus SimCLR( τ 0 ), DCL and HCL); 2) With an appropriately selected τ , the relative improvements realized by DCL and HCL are marginal. These insights lead us to pose two compelling questions: 1) Why does CL exhibit tolerance to sampling bias? and 2) What role does τ play, and why is it so important?

3.2 Understanding CL from DRO

In this subsection, we first introduce DRO and then analyze CL from the perspective of DRO.

A. Distributionally Robust Optimization (DRO).

The success of machine learning heavily relies on the premise that the test and training distributions are identical ( a.k.a. iid assumption). How to handle different data distributions ( a.k.a. distribution shift) poses a great challenge to machine learning systems. Fortunately, Distributionally Robust Optimization (DRO) provides a potential solution to mitigate this problem. DRO aims to minimize the worst-case expected loss over a set of potential distributions Q , which surround the training distribution Q 0 and are constrained by a distance metric D ϕ within a specified robust radius η . Formally, DRO can be written as:

where D ϕ ( Q || Q 0 ) measures the ϕ -divergence between two distributions, and L ( x ; θ ) denotes the training loss on input x . Intuitively, models incorporating DRO enjoy stronger robustness due to the presence of Q that acts as an 'adversary', optimizing the model under a distribution set with adversarial perturbations instead of a single training distribution.

B. Analyzing CL from DRO. We first introduce the CL-DRO objective:

Definition 3.1 (CL-DRO) . Let P 0 and Q 0 be the distributions of positive and negative samples respectively. Let η be the robust radius. CL-DRO objective is defined as:

The objective CL-DRO can be understood as the DRO enhancement of the basic objective L basic = -E P X [ E P 0 [ f θ ( x, y + )] -E Q 0 [ f θ ( x, y )] ] , which aims to increase the embedding similarity between the positive instances and decreases that of the negative ones. CL-DRO imporves L basic by incorporating DRO on the negative side, where f θ ( x, y ) is optimized a range of potential distributions. Consequently, CL-DRO equips the model with resilience to distributional shifts of negative samples.

Theorem 3.2. By choosing KL divergence D KL ( Q || Q 0 ) = ∫ Q log Q Q 0 dx , optimizing CL-DRO ( cf. Equation (3) ) is equivalent to optimizing CL (InfoNCE, cf. Equation (1) ):

where α, β represent the Lagrange multipliers, and α ∗ ( η ) signifies the optimal value of α that minimizes the Equation (4) , serving as the temperature τ in CL.

The proof is presented in Appendix A.1. Theorem 3.2 admits the merit of CL as it is equivalent to performing DRO on the negative samples. The DRO enables CL to perform well across various potential distributions and thus equips it with the capacity to alleviate sampling bias. We further establish the connection between InfoNCE loss with the unbiased loss that employs ideal negative distribution L unbiased = -E P X [ E P 0 [ f θ ( x, y + )] -E Q ideal [ f θ ( x, y )] ] .

Theorem 3.3. [Generalization Bound] Let ̂ L InfoNCE be an estimation of InfoNCE with N negative samples. Given any finite hypothesis space F of models, suppose f θ ∈ [ M 1 , M 2 ] and the ideal negative sampling distribution Q ideal satisfies D KL ( Q ideal || Q 0 ) ≤ η , we have that with probability at least 1 -ρ :

As we mainly focus on model robustness on negative distribution, here we disregard the constant term present in Equation (4), and omit the error from the positive instances. The proof is presented in

Appendix A.2. Theorem 3.3 exhibits the unbiased loss is upper bound by InfoNCE if a sufficiently large data size is employed (considering B ( ρ, N, τ ) → 0 as N → 0 ). This bound illustrates how τ impacts the model performance, which will be detailed in the next subsection.

3.3 Understanding τ from DRO

Building on the idea of DRO, we uncover the role of τ from the following perspectives:

A. Adjusting robust radius. The temperature τ and the robust radius η conform to:

Corollary 3.4. [The optimal α - Lemma 5 of Faury et al. [46]] The value of the optimal α ( i.e., τ ) can be approximated as follow:

where V Q 0 [ f θ ( x, y )] denotes the variance of f θ ( x, y ) under the distribution Q 0 .

This corollary suggests that the temperature parameter τ is a function of the robust radius η and the variance of f θ . In practical applications, tuning τ in CL is essentially equivalent to adjusting the robustness radius η .

The aforementioned insight enhances our understanding of the impact of temperature on CL performance. An excessively large value of τ implies a small robustness radius η , potentially violating the condition D KL ( Q ideal || Q 0 ) ≤ η as stipulated in Theorem 3.2. Intuitively, a large τ delineates a restricted distribution set in DRO that may fail to encompass the ideal negative distribution, leading to diminished robustness. Conversely, as τ decreases, the condition D KL ( Q ideal || Q 0 ) ≤ η may be satisfied, but it expands the term B ( ρ, N, τ ) and loosens the generalization bound. These two factors establish a trade-off in the selection of τ , which we will empirically validate in Subsection 3.4.

B. Controlling variance of negative samples.

Theorem 3.5. Given any ϕ -divergence, the corresponding CL-DRO objective could be approximated as a mean-variance objective:

where ϕ (2) (1) denotes the the second derivative value of ϕ ( · ) at point 1, and V Q 0 [ f θ ] denotes the variance of f under the distribution Q 0 .

Specially, if we consider KL divergence, the approximation transforms:

The proof is presented in Appendix A.4. Theorem 3.5 provides a mean-variance formulation for CL. Compared to the basic objective L basic, CL introduces an additional variance regularization on negative samples, governed by the parameter τ , which modulates the fluctuations in similarity among negative samples. The efficacy of variance regularizers has been extensively validated in recent research [20; 47; 48]. We consider that variance control might be a reason of the success of CL.

C. Hard-mining. Note that the worst-case distribution in CL-DRO can be written as Q ∗ = Q 0 exp[ f θ ( x,y + ) /τ ] E Q 0 exp[ f θ ( x,y ) /τ ] (refer to Appendix A.6). This implies that the model in CL is optimized under the negative distribution Q ∗ , where each negative instance is re-weighted by exp[ f θ ( x,y + ) /τ ] E Q 0 exp[ f θ ( x,y ) /τ ] . This outcome vividly exhibits the hard-mining attribute of CL, with τ governing the degree of skewness of the weight distribution. A smaller τ suggests a more skewed distribution and intensified hard-mining, while a larger τ signifies a more uniform distribution and attenuated hard-mining. Our research yields similar conclusions to those found in [16; 28], but we arrive at this finding from a novel perspective.

3.4 Empirical Analysis

In this section, we conduct the following experiments to verify the above conclusions.

0.2

0.4

0.6

0.8

1.0

0.95

0.96

0.97

0.98

0.99

1.00

Relative ACC

Robustness experiments w.r.t

r = 0.0

r = 0.5

r = 1.0

0

100

200

300

400

Epoch

0.00

0.05

0.10

0.15

0.20

0.25

0.30

Variance of Neg

=0.2

=0.4

=0.6

=0.8

0

100

200

300

400

Epoch

0.4

0.5

0.6

0.7

0.8

0.9

Mean of Pos

=0.2

=0.4

=0.6

=0.8

τ varies with the level of sampling bias. To study the effect of τ on model performance, we conduct experiments on the CIFAR10 dataset and manipulate the ratio of false negative samples based on the ground-truth labels. A ratio of 1 implies retaining all false negative instances in the data, while a ratio of 0 implies eliminating all such instances. The detailed experimental setup can refer to the Appendix B. From Figure 1, we make two observations: 1) There is an evident trade-off in the selection of τ . As τ increases from 0.2 to 1, the model's performance initially improves, then declines, aligning with our theoretical analysis. 2) As the ratio of false negative instances increases ( r ranges from 0 to 1), the optimal τ decreases. This observation is intuitive - a higher ratio of false negative instances implies a larger distribution gap between the employed negative distribution and the ideal, thereby necessitating a larger robust radius η to satisfy the condition D KL ( Q ideal || Q 0 ) ≤ η . As Corollary 3.4, a larger robust radius corresponds to a smaller τ .

τ controls the variances of negative samples. We experiment with an array of τ values and track the corresponding variance of f θ ( x, y ) for negative samples and the mean value of f θ ( x, y + ) for positive samples in CIFAR10. As illustrated in Figure 2, we observe a decrease in the variance of negative samples and an increase in the mean value of positive samples as τ diminishes. Although this observation might be challenging to interpret based on existing studies, it can be easily explained through Equation (8). Note that τ governs the impact of the variance regularizer. A smaller τ brings a larger variance penalty, resulting in a reduced variance of negative instances. Simultaneously, as the regularizer's contribution on optimization intensifies, it proportionately diminishes the impact of other loss component on enhancing the similarity of positive instances, thereby leading to a lower mean value of positive instances.

Mean-Variance objective achieves competitive performance. We replace the InfoNCE with the meanvariance objective ( cf. Equation (8)) and evaluate the model performance. The results are shown in Table 2. Remarkably,such a simple loss can can deliver competitive results to InfoNCE, thereby affirming the correctness of the approximation in Theorem 3.5. Nevertheless, it marginally underperforms compared to InfoNCE, as it merely represents a second-order Taylor expansion of InfoNCE. However, it is worth highlighting that the mean-variance objective is more efficient.

4 Relations among DRO, Constrastive Learning and Mutual Information

Through extensive theoretical analysis, we have far demonstrated that CL is fundamentally a CL-DRO objective that conduct DRO on negative samples. And it is well known that CL is also equivalent to mutual information estimation. A natural question arises: Is there a connection between CL-DRO and MI, as both are theoretical understanding of CL?

To make our conclusion more generalized, we would like to transcend the boundary of KL divergence, but exploring a broader family of ϕ -divergence. First of all, we would like to extend the definition of MI to utilize ϕ -divergence:

Definition 4.1 ( ϕ -MI) . The ϕ -divergence-based mutual information is defined as:

Comparing to KL-divergence, ϕ -divergence showcases greater flexibility and may exhibits superior properties. ϕ -MI, as a potential superior metric for distribution dependence, has been studied by numerous work [49; 50].

Theorem 4.2. For distributions P , Q such that P ≪ Q , let F be a set of bounded measurable functions. Let CL-DRO draw positive and negative instances from P and Q , marked as L ϕ CL-DRO ( P, Q ) . Then the CL-DRO objective is the tight variational estimation of ϕ -divergence. In fact, we have:

Here, the choice of ϕ in CL-DRO corresponds to the probability measures in D ϕ ( P || Q ) . And ϕ ∗ denotes the convex conjugate.

The proof is presented in Appendix A.5. This theorem establishes the connection between CL-DRO and ϕ -divergence. If we replace P with P 0 and Q with Q 0 , and simply hypothesis that the metric function f θ has a sufficiently large capacity, we have the following corollary:

Corollary 4.3. E P X [ D ϕ ( P 0 || Q 0 )] is a tight variational estimation of I ϕ ( X ; Y ) .

InfoNCE is a tighter MI estimation. The prevailing and widely used variational approximation of ϕ -divergences is the Donsker-Varadhan target ( I DV ), defined as D ϕ ( P || Q ) := max f ∈F { E P [ f ] -E Q [ ϕ ∗ ( f )] } . However, it has been observed by Ruderman et al. [51] that this expression is loose when applied to probability measures, as it fails to fully consider the fundamental nature of divergences being defined between probability distributions. To address this limitation, let us further assume, as we do for R , that E P [1] = 1 . Under this common assumption, we arrive at a more refined formulation: D ϕ ( P || Q ) := max f ∈F { E P [ f ] -min λ ∈ R { λ + E Q [ ϕ ∗ ( f -λ )] }} . Notably, this result, embracing the infimum over λ in the spirit of Ruderman et al. [51], appears to be consistent with our proof in Theorem 4.2. Hence, we argue that "InfoNCE is a tighter MI estimation."

Furthermore, this corollary provides a rigorous and succinct methodology for deriving InfoNCE from Variational MI. Specifically, given ϕ ( x ) = x log x -x +1 for the case of KL-divergence, its conjugate ϕ ∗ ( x ) = e x -1 can be computed. Subsequently, by resolving the simple convex problem min λ ∈ R { λ + τ E Q [ ϕ ∗ ( f ( x,y ) -λ τ )] } , we derive the optimal choice of λ , denoted as λ ∗ = τ log E Q 0 [ e f ( x,y ) /τ ] . Inserting λ ∗ into Equation (10), D ϕ ( P 0 || Q 0 ) simplifies to max f { E P 0 [ f ( x, y + )] -τ log E Q 0 [ e f ( x,y ) /τ ] } , which is the minus of the InfoNCE objective.

DRO bridges the gap between MI and InfoNCE. Although previous works such as MINE[24] and CPC[3] have demonstrated that InfoNCE is a lower bound for MI, they still have significant limitations [41]. For instance, MINE uses a critic in Donsker-Varadhan target ( I DV ) to derive a bound that is neither an upper nor lower bound on MI, while CPC relies on unnecessary approximations in its proof, resulting in some redundant approximations. In contrast, Theorem 4.2 presents a rigorous and practical method for accurately estimating the tight lower bound of MI.

DROprovides general MI estimation. Although a strict variational bound for MI has been proposed in Poole et al. [41], their discussion is limited to the choice of KL-divergence. Theorem 4.2 is suitable for estimating various ϕ -MI. For example, if we consider the case of χ 2 divergence, given by ϕ ( x ) = 1 2 √ 2 ( x -1) 2 , we could obtain convex conjugate ϕ ∗ ( x ) = x + x 2 . The variational representation becomes I χ 2 ( X ; Y ) = D χ 2 ( P 0 ∥ Q 0 ) = max f { E P 0 [ f ( x, y + )] -E Q 0 [ f ( x, y )] -V Q 0 [ f ( x, y )] } , where V Q 0 [ f ( x, y )] represents the variance of f on distribution Q . Our theoretical framework offers the opportunity to estimate flexible ϕ -MI, which can be adapted to suit specific scenarios.

5 Method

5.1 Shortcomings of InfoNCE

Based on the understanding of CL from DRO perspective, some weaknesses of InfoNCE is revealed:

Too conservative. Distributionally Robust Optimization (DRO) focuses on the worst-case distribution, often leading to an overemphasis on the hardest negative samples by assigning them disproportionately large weights. More precisely, the weights are proportional to exp[ f θ ( x, y ) /τ ] , causing samples with the highest similarity to receive significantly larger weights. However, in practice, the most informative negative samples are often found in the "head" region (e.g., top-20% region with high similarity) rather than exclusively in the top-1% highest region [52]. Overemphasizing these top instances by assigning excessive weights is typically suboptimal.

Sensitive to outliers. Existing literature [25] reveals that DRO is markedly sensitive to outliers, exhibiting significant fluctuations in training performance. This is because outliers, once they appear in regions of high similarity, can be assigned exceptionally high weights. Consequently, this phenomenon unavoidably influences the rate of model convergence during the training phase.

5.2 ADNCE

Our goal is to refine the worst-case distribution, aiming to assign more reasonable weights to negative instances. The aspiration is to create a flexible distribution that can be adjusted to concentrate on the informative region. This is accomplished by incorporating Gaussian-like weights, as defined below:

where µ and σ are two hyper-parameter we could control. As is illustrated in Figure 3, µ controls the central region of weight allocation, whereby samples closer to µ have larger weights, while σ controls the height of the weight allocation in the central region. Intuitively, a smaller σ results in a more pronounced weight discrepancy among the samples.

Inserting the weights into InfoNCE formula, we obtain the novel AD justed Info NCE (ADNCE):

-1.0

-0.5

0.0

0.5

1.0

Similarity Score

Weight Scale

Adjusted DRO

InfoNCE, =0.07

InfoNCE, =0.2

InfoNCE, =0.3

w(

=0.7,

=1.0)

w(

=0.4,

=1.0)

w(

=0.1,

=0.5)

It is noteworthy that our proposed approach only involves two modified lines of code and introduce no additional computational overhead, as compared to InfoNCE [4]. Pytorch-style pseudocode for ADNCE is given in Appendix.

6 Experiments

We empirically evaluate our adjusted InfoNCE method - ADNCE, and apply it as a modification to respective classical CL models on image, graph, and sentence data. For all experiments, µ is treated as a hyper-parameter to adjust the weight allocation, where σ is set to 1 by default. For detailed experimental settings, please refer to Appendix.

6.1 Image Contrastive Learning

We begin by testing ADNCE on vision tasks using CIFAR10, CIFAR100, and STL10 datasets. We choose SimCLR [4] as the baseline model (termed as InfoNCE( τ 0 ) ). We also include two variants

of vanilla InfoNCE for comprehensive comparisons. One approach is applying a grid search for τ (termed as InfoNCE( τ ∗ )), which serves to confirm its importance as discussed in Section 3.4. The other is from Tian el al. [16], which proposes a novel approach for setting for the value of τ (termed as α -CL-direct).

As shown in Table 3, a grid search for τ has a crucial impact on the model performance. This impact is significant throughout the entire training process, from the early stage (100 epochs) to the later stage (400 epochs). Additionally, ADNCE exhibits sustained improvement and notably enhances performance in the early stages of training. In contrast, while α -CL-direct introduces a novel approach for setting the value of τ , its essence remains weighted towards the most difficult negative samples, hence yielding similar performance compared to fine-tuning τ using grid search. In Figure 4, we plot the training curve to further illustrate the stable superiority of ADNCE.

87

89

91

93

Top-1 Acc

CIFAR10

0

*

-CL-direct

ADNCE

20

40

60

80

100

Epoch

76

80

84

88

Top-1 Acc

STL10

6.2 Sentence Contrastive Learning

We follow the experimental setup in GraphCL [12] and conduct evaluations on 7 semantic textual similarity (STS) tasks in an unsupervised setting. Specifically, we evaluate the model on STS 2012-2016, STS-benchmark, and SICK-Relatedness. To ensure fair comparisons, we use pre-trained checkpoints of BERT and RoBERTa, and randomly sample sentences from the English Wikipedia.

As observed in Table 4, ADNCE consistently outperforms InfoNCE, achieving an average Spearman's correlation of 77%. The ease of replacing InfoNCE with ADNCE and the resulting substantial performance improvements observed in BERT and RoBERTa serve as testaments to the efficacy and broad applicability of ADNCE. Furthermore, the improvements of τ ∗ over τ 0 emphasize the significance of selecting a proper robustness radius.

6.3 Graph Contrastive Learning

To study the modality-agnostic property of ADNCE beyond images and sentences, we conduct an evaluation of its performance on TUDataset [53]. We use a classical graph CL model GraphCL [12] as the baseline. To ensure a fair comparison, we adhered to the same protocol used in GraphCL [12], employing techniques such as node dropout, edge perturbation, attribute masking, and subgraph sampling for data augmentation. We replace the vanilla InfoNCE with two different variants, namely GraphCL( τ ∗ ) obtained through grid search, and our proposed ADNCE.

Table 5 demonstrates that ADNCE outperforms all baselines with a significant margin on four datasets, especially when compared to three state-of-the-art InfoNCE-based contrastive methods, GraphCL, JOAO, and JOAOv2, thereby setting new records on all four datasets. The improvements observed in GraphCL( τ ∗ ) relative to GraphCL( τ 0 ) align with our understanding of DRO.

7 Conclusion and Limitations

We provide a novel perspective on contrastive learning (CL) via the lens of Distributionally Robust Optimization (DRO), and reveal several key insights about the tolerance to sampling bias, the role of τ , and the theoretical connection between DRO and MI. Both theoretical analyses and empirical experiments confirm the above findings. Furthermore, we point out the potential shortcomings of CL from the perspective of DRO, such as over-conservatism and sensitivity to outliers. To address these issues, we propose a novel CL loss - ADNCE, and validate its effectiveness in various domains.

The limitations of this work mainly stem from two aspects: 1) Our DRO framework only provides a theoretical explanation for InfoNCE-based methods, leaving a crucial gap in the success of CL without negative samples [4; 26]. 2) ADNCE requires weight allocation to be adjusted through parameters and cannot adaptively learn the best reweighting scheme.

Acknowledgments and Disclosure of Funding

This work is supported by the National Key Research and Development Program of China (2021ZD0111802), the National Natural Science Foundation of China (62372399, 9227010114, 62302321), the Starry Night Science Fund of Zhejiang University Shanghai Institute for Advanced Study (SN-ZJU-SIAS-001), and supported by the University Synergy Innovation Program of Anhui Province (GXXT-2022-040).

References

Sumit Chopra, Raia Hadsell, and Yann LeCun. Learning a similarity metric discriminatively, with application to face verification. In CVPR (1) , pages 539-546. IEEE Computer Society, 2005.

Raia Hadsell, Sumit Chopra, and Yann LeCun. Dimensionality reduction by learning an invariant mapping. In CVPR (2) , pages 1735-1742. IEEE Computer Society, 2006.

Aäron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. CoRR , abs/1807.03748, 2018.

Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey E. Hinton. A simple framework for contrastive learning of visual representations. In ICML , volume 119 of Proceedings of Machine Learning Research , pages 1597-1607. PMLR, 2020.

Xinlei Chen, Haoqi Fan, Ross B. Girshick, and Kaiming He. Improved baselines with momentum contrastive learning. CoRR , abs/2003.04297, 2020.

Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross B. Girshick. Momentum contrast for unsupervised visual representation learning. In CVPR , pages 9726-9735. Computer Vision Foundation / IEEE, 2020.

Yonglong Tian, Dilip Krishnan, and Phillip Isola. Contrastive multiview coding. In ECCV (11) , volume 12356 of Lecture Notes in Computer Science , pages 776-794. Springer, 2020.

Jure Zbontar, Li Jing, Ishan Misra, Yann LeCun, and Stéphane Deny. Barlow twins: Selfsupervised learning via redundancy reduction. In ICML , volume 139 of Proceedings of Machine Learning Research , pages 12310-12320. PMLR, 2021.

Tianyu Gao, Xingcheng Yao, and Danqi Chen. Simcse: Simple contrastive learning of sentence embeddings. In EMNLP (1) , pages 6894-6910. Association for Computational Linguistics, 2021.

Lingpeng Kong, Cyprien de Masson d'Autume, Lei Yu, Wang Ling, Zihang Dai, and Dani Yogatama. A mutual information maximization perspective of language representation learning. In ICLR . OpenReview.net, 2020.

Sihang Li, Xiang Wang, An Zhang, Yingxin Wu, Xiangnan He, and Tat-Seng Chua. Let invariant rationale discovery inspire graph contrastive learning. In ICML , volume 162 of Proceedings of Machine Learning Research , pages 13052-13065. PMLR, 2022.

Yuning You, Tianlong Chen, Yongduo Sui, Ting Chen, Zhangyang Wang, and Yang Shen. Graph contrastive learning with augmentations. In NeurIPS , 2020.

Ching-Yao Chuang, Joshua Robinson, Yen-Chen Lin, Antonio Torralba, and Stefanie Jegelka. Debiased contrastive learning. In NeurIPS , 2020.

Joshua David Robinson, Ching-Yao Chuang, Suvrit Sra, and Stefanie Jegelka. Contrastive learning with hard negative samples. In ICLR . OpenReview.net, 2021.

Tsai-Shien Chen, Wei-Chih Hung, Hung-Yu Tseng, Shao-Yi Chien, and Ming-Hsuan Yang. Incremental false negative detection for contrastive learning. In ICLR . OpenReview.net, 2022.

Yuandong Tian. Understanding deep contrastive learning via coordinate-wise optimization. In NeurIPS , 2022.

John C. Duchi and Hongseok Namkoong. Learning models with uniform performance via distributionally robust optimization. CoRR , abs/1810.08750, 2018.

Ruomin Huang, Jiawei Huang, Wenjie Liu, and Hu Ding. Coresets for wasserstein distributionally robust optimization problems. In NeurIPS , 2022.

Peyman Mohajerin Esfahani and Daniel Kuhn. Data-driven distributionally robust optimization using the wasserstein metric: performance guarantees and tractable reformulations. Math. Program. , 171(1-2):115-166, 2018.

Hongseok Namkoong and John C. Duchi. Variance-based regularization with convex objectives. In NIPS , pages 2971-2980, 2017.

Soroosh Shafieezadeh-Abadeh, Peyman Mohajerin Esfahani, and Daniel Kuhn. Distributionally robust logistic regression. In NIPS , pages 1576-1584, 2015.

Aman Sinha, Hongseok Namkoong, and John C. Duchi. Certifying some distributional robustness with principled adversarial training. In ICLR . OpenReview.net, 2018.

Rohit Agrawal and Thibaut Horel. Optimal bounds between f-divergences and integral probability metrics. In ICML , volume 119 of Proceedings of Machine Learning Research , pages 115-124. PMLR, 2020.

Mohamed Ishmael Belghazi, Aristide Baratin, Sai Rajeswar, Sherjil Ozair, Yoshua Bengio, R. Devon Hjelm, and Aaron C. Courville. Mutual information neural estimation. In ICML , volume 80 of Proceedings of Machine Learning Research , pages 530-539. PMLR, 2018.

Runtian Zhai, Chen Dan, J. Zico Kolter, and Pradeep Ravikumar. DORO: distributional and outlier robust optimization. In ICML , volume 139 of Proceedings of Machine Learning Research , pages 12345-12355. PMLR, 2021.

Jean-Bastien Grill, Florian Strub, Florent Altché, Corentin Tallec, Pierre H. Richemond, Elena Buchatskaya, Carl Doersch, Bernardo Ávila Pires, Zhaohan Guo, Mohammad Gheshlaghi Azar, Bilal Piot, Koray Kavukcuoglu, Rémi Munos, and Michal Valko. Bootstrap your own latent - A new approach to self-supervised learning. In NeurIPS , 2020.

Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. Unsupervised learning of visual features by contrasting cluster assignments. In NeurIPS , 2020.

Feng Wang and Huaping Liu. Understanding the behaviour of contrastive loss. In CVPR , pages 2495-2504. Computer Vision Foundation / IEEE, 2021.

Hong Liu, Jeff Z. HaoChen, Adrien Gaidon, and Tengyu Ma. Self-supervised learning is more robust to dataset imbalance. In ICLR . OpenReview.net, 2022.

Yihao Xue, Kyle Whitecross, and Baharan Mirzasoleiman. Investigating why contrastive learning benefits robustness against label noise. In ICML , volume 162 of Proceedings of Machine Learning Research , pages 24851-24871. PMLR, 2022.

Ching-Yun Ko, Jeet Mohapatra, Sijia Liu, Pin-Yu Chen, Luca Daniel, and Lily Weng. Revisiting contrastive learning through the lens of neighborhood component analysis: an integrated framework. In ICML , volume 162 of Proceedings of Machine Learning Research , pages 11387-11412. PMLR, 2022.

Binbin Jin, Defu Lian, Zheng Liu, Qi Liu, Jianhui Ma, Xing Xie, and Enhong Chen. Samplingdecomposable generative adversarial recommender. Advances in Neural Information Processing Systems , 33:22629-22639, 2020.

Defu Lian, Qi Liu, and Enhong Chen. Personalized ranking with importance sampling. In Proceedings of The Web Conference 2020 , pages 1093-1103, 2020.

Chenwang Wu, Defu Lian, Yong Ge, Zhihao Zhu, and Enhong Chen. Influence-driven data poisoning for robust recommender systems. IEEE Transactions on Pattern Analysis and Machine Intelligence , 2023.

Henry Lam, Zhenyuan Liu, and Xinyu Zhang. Orthounimodal distributionally robust optimization: Representation, computation and multivariate extreme event applications. arXiv preprint arXiv:2111.07894 , 2021.

Henry Lam and Clementine Mottet. Tail analysis without parametric models: A worst-case perspective. Oper. Res. , 65(6):1696-1711, 2017.

Xi Chen, Simai He, Bo Jiang, Christopher Thomas Ryan, and Teng Zhang. The discrete moment problem with nonconvex shape constraints. Oper. Res. , 69(1):279-296, 2021.

Paul Michel, Tatsunori Hashimoto, and Graham Neubig. Modeling the second player in distributionally robust optimization. In ICLR . OpenReview.net, 2021.

Paul Michel, Tatsunori Hashimoto, and Graham Neubig. Distributionally robust models with parametric likelihood ratios. In ICLR . OpenReview.net, 2022.

Monroe D Donsker and SR Srinivasa Varadhan. Asymptotic evaluation of certain markov process expectations for large time, i. Communications on Pure and Applied Mathematics , 1975.

Ben Poole, Sherjil Ozair, Aäron van den Oord, Alexander A. Alemi, and George Tucker. On variational bounds of mutual information. In ICML , volume 97 of Proceedings of Machine Learning Research , pages 5171-5180. PMLR, 2019.

Jiaming Song and Stefano Ermon. Understanding the limitations of variational mutual information estimators. In ICLR . OpenReview.net, 2020.

Yao-Hung Hubert Tsai, Martin Q. Ma, Muqiao Yang, Han Zhao, Louis-Philippe Morency, and Ruslan Salakhutdinov. Self-supervised representation learning with relative predictive coding. In ICLR . OpenReview.net, 2021.

Qing Guo, Junya Chen, Dong Wang, Yuewei Yang, Xinwei Deng, Jing Huang, Lawrence Carin, Fan Li, and Chenyang Tao. Tight mutual information estimation with contrastive fenchel-legendre optimization. In NeurIPS , 2022.

Chun-Hsiao Yeh, Cheng-Yao Hong, Yen-Chi Hsu, Tyng-Luh Liu, Yubei Chen, and Yann LeCun. Decoupled contrastive learning. In ECCV (26) , volume 13686 of Lecture Notes in Computer Science , pages 668-684. Springer, 2022.

Louis Faury, Ugo Tanielian, Elvis Dohmatob, Elena Smirnova, and Flavian Vasile. Distributionally robust counterfactual risk minimization. In AAAI , pages 3850-3857. AAAI Press, 2020.

Jun-ya Gotoh, Michael Jong Kim, and Andrew E. B. Lim. Robust empirical optimization is almost the same as mean-variance optimization. Oper. Res. Lett. , 46(4):448-452, 2018.

Jaeho Lee, Sejun Park, and Jinwoo Shin. Learning bounds for risk-sensitive learning. In NeurIPS , 2020.

Sever S Dragomir, V Gluscevic, and Charles Edward Miller Pearce. Csiszár f-divergence, ostrowski's inequality and mutual information. Nonlinear Analysis-Theory Methods and Applications , 47(4):2375-2386, 2001.

Kyungmin Lee and Jinwoo Shin. Rényicl: Contrastive representation learning with skew rényi divergence. In NeurIPS , 2022.

Avraham Ruderman, Mark D. Reid, Dario García-García, and James Petterson. Tighter variational representations of f-divergences via restriction to probability measures. In ICML . icml.cc / Omnipress, 2012.

Tiffany Tianhui Cai, Jonathan Frankle, David J. Schwab, and Ari S. Morcos. Are all negatives created equal in contrastive instance discrimination? CoRR , abs/2010.06682, 2020.

Christopher Morris, Nils M. Kriege, Franka Bause, Kristian Kersting, Petra Mutzel, and Marion Neumann. Tudataset: A collection of benchmark datasets for learning with graphs. CoRR , abs/2007.08663, 2020.

XuanLong Nguyen, Martin J. Wainwright, and Michael I. Jordan. Estimating divergence functionals and the likelihood ratio by convex risk minimization. IEEE Trans. Inf. Theory , 56(11):5847-5861, 2010.

Jean-Baptiste Hiriart-Urruty and Claude Lemaréchal. Fundamentals of convex analysis . Springer Science & Business Media, 2004.

Aharon Ben-Tal and Marc Teboulle. An old-new concept of convex risk measures: the optimized certainty equivalent. Mathematical Finance , 17(3):449-476, 2007.

Stephen P Boyd and Lieven Vandenberghe. Convex optimization . Cambridge university press, 2004.

Mehryar Mohri, Afshin Rostamizadeh, and Ameet Talwalkar. Foundations of machine learning . 2018.

Aharon Ben-Tal and Marc Teboulle. Expected utility, penalty functions, and duality in stochastic nonlinear programming. Management Science , 32(11):1445-1466, 1986.

Rui Zhu, Bingchen Zhao, Jingen Liu, Zhenglong Sun, and Chang Wen Chen. Improving contrastive learning by visualizing feature transformation. In ICCV , pages 10286-10295. IEEE, 2021.

Christopher Morris, Nils M. Kriege, Franka Bause, Kristian Kersting, Petra Mutzel, and Marion Neumann. Tudataset: A collection of benchmark datasets for learning with graphs. CoRR , abs/2007.08663, 2020.

A Appendix of Proofs

A.1 Proof of Theorem 3.2

Theorem 3.2. By choosing KL divergence D KL ( Q || Q 0 ) = ∫ Q log Q Q 0 dx , optimizing CL-DRO ( cf. Equation (3) ) is equivalent to optimizing CL (InfoNCE, cf. Equation (1) ):

(4)

where α, β represent the Lagrange multipliers, and α ∗ ( η ) signifies the optimal value of α that minimizes the Equation (4) , serving as the temperature τ in CL.

Proof. In all the following appendix, for the sake of conserving space and clarity of expression, we have opted to simplify f θ ( x, y ) as f θ and omit E P X .

To complete the proof, we start with giving some important notations and theorem.

Definition A.1 ( ϕ -divergence [54]) . For any convex funtion ϕ with ϕ (1) = 0 , the ϕ -divergence between Q and Q 0 is:

where D ϕ ( Q || Q 0 ) = ∞ if Q is not absolutely continuous with respect to Q 0 . Specially, when ϕ ( x ) = x log x -x +1 , ϕ -divergence degenerates to the well-known KL divergence.

Definition A.2 (Convex conjugate [55]) . We consider a pair ( A,B ) of topological vector spaces and a bilinear form ⟨· , ·⟩ → R such that ( A,B, ⟨· , ·⟩ ) form a dual pair. For a convex function f : R → R , domf := { x ∈ R : f ( x ) < ∞} is the effective domain of f . The convex conjugate, also known as the Legendre-Fenchel transform, of f : A → R is the function f ∗ : B → R defined as

Theorem A.3 (Interchange of minimization and integration [56]) . Let (Ω , F ) be a measurable space equipped with σ -algebra F , L p (Ω , F , P ) be the linear space of measurable real valued functions f : Ω → R with || f || p < ∞ , and let X := L p (Ω , F , P ) , p ∈ [1 , + ∞ ] . Let g : R × Ω → R be a normal integrand, and define on X . Then,

To ease the derivation, we denote the likelihood raito L ( x, y ) = Q ( x, y ) /Q 0 ( x, y ) . Note that the ϕ -divergence between Q and Q 0 is constrained, and thus L ( . ) is well-defined. For brevity, we usually short L ( x, y ) as L . And in terms of Definition A.1 of ϕ -divergence, the expression of CL-DRO becomes:

Note that E Q 0 [ f θ L ] and E Q 0 [ ϕ ( L )] are both convex in L . We use the Lagrangian function solver:

The first equality holds due to the strong duality [57]. The second equality is a re-arrangement for optmizing L . The third equation follows by the Theorem A.3. The last equality is established based

on the definition of convex conjugate A.2. When we choose KL-divergence, we have ϕ KL ( x ) = x log x -x +1 . It can be deduced that ϕ ∗ KL ( x ) = e x -1 . Then, we have:

A.2 Proof of Theorem 3.3

Theorem 3.3. [Generalization Bound] Let ̂ L InfoNCE be an estimation of InfoNCE with N negative samples. Given any finite hypothesis space F of models, suppose f θ ∈ [ M 1 , M 2 ] and the ideal negative sampling distribution Q ideal satisfies D KL ( Q ideal || Q 0 ) ≤ η , we have that with probability at least 1 -ρ :

Here we simply disregard the constant term present in Equation (4) as it does not impact optimization, and omit the error from the positive instances.

Proof. Before detailing the proof process, we first introduce a pertinent theorem:

Theorem A.4 (Union Bound) . For any two sets A,B and a distribution D we have

̸

Theorem A.5 (McDiarmid's inequality [58]) . Let X 1 , · · · , X n be independent random variables, where X i has range X . Let f : X 1 × · · · × X n → R be any function with the ( c 1 , . . . , c n ) -bounded difference property: for every i = 1 , . . . , n and every ( x 1 , . . . , x n ) , ( x ′ 1 , . . . , x ′ n ) ∈ X 1 × · · · × X n that differ only in the i -th coordinate ( x j = x ′ j for all j = i ), we have | f ( x 1 , . . . , x n ) -f ( x ′ 1 , . . . , x ′ n ) | ≤ c i . For any ϵ > 0 ,

Now we delve into the proof. As Q ideal satisfies D KL ( Q || Q 0 ) ≤ η , we can bound L unbiased with:

where Q ideal , Q ∗ denotes the ideal negative distribution and the worst-case distribution in CL-DRO. From the Theorem 3.2, we have the equivalence between InfoNCE and CL-DRO. Thus here we

choose CL-DRO for analyses. Suppose we have N negative samples, and for any pair of samples ( x i , y i ) , ( x j , y j ) , we have the following bound:

where the first inequality holds as Q ∗ ( x, y ) f θ ( x, y ) > 0 . The second inequality holds based on the expression of Q ∗ = Q 0 exp[ f θ /τ ] E Q 0 exp[ f θ /τ ] (refer to Appendix A.6). Suppose f θ ∈ [ M 1 , M 2 ] , the upper bound of sup ( x,y ) ∼ Q 0 | Q ∗ ( x, y ) f θ ( x, y ) | arrives if f θ ( x, y ) = M 2 for the sample ( x, y ) and f θ ( x, y ) = M 1 for others. We have sup ( x,y ) ∼ Q 0 | Q ∗ ( x, y ) f θ ( x, y ) | ≤ M 2 exp(( M 2 -M 1 ) /τ ) N -1+exp(( M 2 -M 1 ) /τ ) .

By using McDiarmid's inequality in Theorem A.5,for any ϵ , we have:

Equation (23) holds for the unique model f . For any finite hypothesis space of models F = { f 1 , f 2 , · · · , f | F | } , we combine this with Theorem A.4 and have following generalization error bound of the learned model ˆ f :

Let

we get:

Thus, for ∀ ρ ∈ (0 , 1) , we conclude that with probability at least 1 -ρ .

A.3 Proof of Corollary 3.4

Corollary 3.4. [The optimal α - Lemma 5 of Faury et al. [46]] The value of the optimal α ( i.e., τ ) can be approximated as follow:

where V Q 0 [ f θ ( x, y )] denotes the variance of f θ ( x, y ) under the distribution Q 0 .

Proof. While Corollary 3.4 has already been proven in [46], we present a brief outline of the proof here for the sake of completeness and to ensure that our article is self-contained. To verify the relationship between τ and η , we could utilize the approximate expression of InfoNCE ( cf. Equation (31)) and focus on the first order conditions for τ . In detail, we have:

To find the optimal value of α (or equivalently, τ ), we differentiate the above equation and set it to 0. This yields a fixed-point equation

The corollary gets proved.

A.4 Proof of Theorem 3.5

Theorem 3.5. Given any ϕ -divergence, the corresponding CL-DRO objective could be approximated as a mean-variance objective:

where ϕ (2) (1) denotes the the second derivative value of ϕ ( · ) at point 1, and V Q 0 [ f θ ] denotes the variance of f under the distribution Q 0 .

Specially, if we consider KL divergence, the approximation transforms:

Proof. We start with introducing a useful lemma.

Lemma A.6 (Lemma A.2 of [47]) . Suppose that ϕ : R → R ⋃ { + ∞} is a closed, convex function such that ϕ ( z ) ≥ ϕ (1) = 0 for all z , is two times continuously differentiable around z = 1 , and ϕ (1) > 0 , Then

Note that most of the ϕ -divergences [54] ( e.g., KLdivergence, Cressie-Read divergence, Burg entropy, J-divergence, χ 2 -distance, modified χ 2 -distance, and Hellinger distance) satisfy the smoothness conditions. When n = 2 , ϕ ∗ [ ζ ] ≈ ζ + 1 2 [ 1 ϕ (2) (1) ] ζ 2 . Substituting this back to Equation (17) we have:

If we differentiate it w.r.t. β :

we have β ∗ = -E Q 0 [ f θ ] , and the objective transforms into:

Choosing KL-divergence, we have ϕ (2) (1) = 1 . Substituting α ∗ ( τ ) into Equation (31) and ignoring the constant αη :

Then Theorem gets proved.

A.5 Proof of Theorem 4.2

Theorem 4.2. For distributions P , Q such that P ≪ Q , let F be a set of bounded measurable functions. Let CL-DRO draw positive and negative instances from P and Q , marked as L ϕ CL-DRO ( P, Q ) . Then the CL-DRO objective is the tight variational estimation of ϕ -divergence. In fact, we have:

Here, the choice of ϕ in CL-DRO corresponds to the probability measures in D ϕ ( P || Q ) . And ϕ ∗ denotes the convex conjugate.

Proof. Regarding this theorem, our proof primarily relies on the variational representation of ϕ -divergence and optimized certainty equivalent (OCE) risk. Towards this end, we start to introduce the basic concepts:

Definition A.7 (OCE [56]) . Let X be a random variable and let u be a convex, lower-semicontinuous function satisfies u (0) = 0 , u ∗ (1) = 0 , then optimized certainty equivalent (OCE) risk ρ ( X ) is defines as:

OCE is a type of risk measure that is widely used by both practitioners and academics [59; 56]. With duality theory, its various properties have been inspiring in our study of DRO.

Definition A.8 (Variational formulation) .

where the supremum is taken over all bounded real-valued measurable functions F defined on X .

Note that in order to keep consistent with the definition of CL-DRO, we transform Equation (10) to :

Our proof for this theorem primarily relies on utilizing OCE risk as a bridge and can be divided into two distinct steps:

We show that max f ∈F -L ϕ CL-DRO ( P, Q ) = max f ∈F E P [ f ] -min β ∈ R {-β + E Q [ ϕ ∗ ( f + β )] } .

When α ∗ = 1 , step 1 gets proved.

We show that D ϕ ( P || Q ) = max f ∈F E P [ f ] -min β ∈ R {-β + E Q [ ϕ ∗ ( f + β )] } . Firstly, we transform E P [ f ] to E Q [ f dP dQ ] as:

Let f + β = Y , we have:

The first equality follows from replacing f + θ 1 with Y . The second equality is a re-arrangement for optmizing β . The third equation holds as E Q [1 -dP dQ ] = 0 .

Applying Theorem A.3, the last supremum reduces to:

where the last equality follows from the fact that ϕ ∗∗ = ϕ . This concludes the proof.

A.6 Proof of Q ∗

Proof. From theorm3.2, CL-DRO can be rewrriten as:

For the inner optimzation, we can draw the optimal L for max L { f θ + β α ∗ L -ϕ ( L ) } as:

For the outer optimization, we can draw the optimal β for min β { α ∗ η -β + α ∗ E Q 0 [ e f θ + β α ∗ -1] } as

Then we plug Equation (41) into Equation (40).

Based on the definition of L , we can derive the expression for Q ∗ :

B Experiments

Figure 5 shows PyTorch-style pseudocode for the standard objective, the adjusted InfoNCE objective. The proposed adjusted reweighting loss is very simple to implement, requiring only two extra lines of code compared to the standard objective.

Figure 5: Pseudocode for our proposed adjusted InfoNCE objective, as well as the original NCE contrastive objective. The implementation of our adjusted reweighting method only requires two additional lines of code compared to the standard objective.

B.1 Visual Representation

Model. For contrastive learning on images, we adopt SimCLR [4] as our baseline and follow the same experimental setup as [13]. Specifically, we use the ResNet-50 network as the backbone. To ensure a fair comparison, we set the embedded dimension to 2048 (the representation used in linear readout) and project it into a 128-dimensional space (the actual embedding used for contrastive learning). Regarding the temperature parameter τ , we use the default value τ 0 of 0.5 in most researches, and we also perform grid search on τ varying from 0.1 to 1.0 at an interval of 0.1, denoted by τ ∗ . The best parameters for each dataset is reported in Table 6. Note that {·} indicates the range of hyperparameters that we tune and the numbers in bold are the final settings. For α -CL, we follow the setting of [16], where p = 4 and τ = 0 . 5 . We use the Adam optimizer with a learning rate of 0.001 and weight decay of 1 e -6 . All models are trained for 400 epochs.

Noisy experiments in Section 3.4. To investigate the relationship between the temperature parameter τ (or η ) and the noise ratio, we follow the approach outlined in [13] and utilize the class information of each image to select negative samples as a combination of true negative samples and false negative samples. Specifically, r ratio = 0 indicates all negative samples are true negative samples, r ratio = 0 . 5 suggests 50% of true positive samples existing in negative samples, r ratio = 1 means uniform sampling.

Variance analysis in Section 3.4. To verify the mean-variance objective of InfoNCE, we adopt the approach outlined in [60] and record the negative prediction scores for 256 samples (assuming a batch size of 256) in each minibatch. Specifically, we randomly select samples from a batch to calculate the statistics and visualize them. (1) For positive samples, we calculate cosine similarity by taking the inner product after normalization, and retain the mean value of the 256 positive scores as ' pos mean '. (2) For negative samples, we average the means and variances of 256 negative samples to show the statistical characteristics of these N negative samples ' (mean neg; var neg) '. We record this data at each training step to track score distribution throughout the training process.

B.2 Sentence Representation

For the sentence contrastive learning, we adopt the approach outlined in [9] and evaluate our method on 7 popular STS datasets: STS tasks from 2012-2016, STS-B and SICK-R. We utilize the SentEval toolkit to obtain all 7 datasets. Each dataset includes sentence pairs which are rated on a scale of 0 to 5, indicating the degree of semantic similarity. To validate the effective of our proposed method, we utilize several methods as baselines: average GloVe embeddings, BERTflow, BERT-whitening, CT-BERT and SimCSE. The best parameters for each dataset is reported in Table 7. To ensure fairness, we employed the official code, which can be accessed at https: //github.com/princeton-nlp/SimCSE .

B.3 Graph Representation

For the graph contrastive learning experiments on TU-Dataset [61], we adopted the same experimental setup as outlined in [12]. The dataset statistics can be found in Table 8. To ensure fairness, we employed the official code, which can be accessed at https://github.com/Shen-Lab/GraphCL/ tree/master/unsupervised_TU . We made only modifications to the script by incorporating our ADNCEmethod and conducting experiments on the hyper-parameter µ ∈ { 0 . 5 , 0 . 6 , 0 . 7 , 0 . 8 , 0 . 9 , 1 . 0 } and σ = 1 on most datasets. Each parameter was repeated from scratch five times, and the best parameter was selected by evaluating on the validation dataset. The best parameters for each dataset is reported in Table 9.

We summarize the statistics of TU-datasets [61] for unsupervised learning in Table 8. Table 10 demonstrates the consistent superiority of our proposed ADNCE approach.

B.4 Additional ablation study

The primary motivation behind ADNCE is to mitigate the issues of over-conservatism and sensitivity to outliers. These limitations stem from the unreasonable worst-case distribution, which assigns excessive weights to the hardnest negative samples. Consequently, any weighting strategy capable of modulating the worst-case distribution to focus more on the informative region holds promising. In our ADNCE, we opted for Gaussian-like weights due to its flexibility and unimodal nature. However, alternative weighting strategies such as Gamma, Rayleigh or Chi-squared could also be employed. The following experiment demonstrates that these alternative weighting strategies can yield comparable results to Gaussian-like weights. The above table showcases the comparison of the

TOP-1 accuracy performance on CIFAR10 dataset under different weight strategies. The parameters m and n are utilized to denote the parameters within their corresponding probability density function, while the variable x represents a random variable. It is important to note that, due to the domain definition of some PDFs being (0 , + ∞ ) , we need to set x = prediction _ score +1 .

B.5 Sensitivity analysis of µ and σ

The above tables showcase the comparisons of the TOP-1 accuracy performance on three dataset under different µ and σ . As can be seen, changing the parameters µ and σ would impact the model performance, but not as dramatical as tuning the parameter τ . (For example, on STL10 σ from 1.0 to 0.2 just brings 2.7% performance drops, while changing τ brings 7.6% performance gap.) This outcome indicates that tuning µ and σ is not a significant burden. In most scenarios, it may suffice to set σ = 1 , requiring only the tuning of µ within the range of 0.1 to 0.9 (can refer to Table 6, 7, 9 in Appendix B for more details).

Peer reviews:
{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper tackles the sampling bias problem in contrastive learning, where negative samples are usually sampled randomly from the marginal distribution and may contain false positive samples.\nThe authors provide a connection between the contrastive learning objective and distributionally robust optimization as a first part of the contributions:\nBy an optimal choice of the temperature parameter, the InfoNCE loss coincides with maximizing the loss for negative samples, leading to the worst-case negative sample distribution.\nConsequently, it is revealed that the temperature parameter admits a trade-off between the generalization error and the DRO radius.\nSecondly, the authors point out the two issues of standard contrastive learning:\nIt tends to overweigh negative samples with large distances (called over-conservatism) and be sensitive to outliers.\nTo mitigate these issues, the authors propose an alternative weight distribution over negative pairs to prevent overweighting of too-far negative samples.\n\nSTRENGTHS:\n- New insights on contrastive learning: One of the main contributions of this paper, the equivalent reformulation of contrastive learning with distributionally robust optimization, provides a new perspective to contrastive learning. In this picture, contrastive learning can be interpreted as optimizing the worst-case distribution over the negative samples. This interpretation can benefit us in developing a new method, as seen in Section 5.\n- An new interpretation of the temperature parameter: As a result of the reformulation, we observe that the temperature parameter in contrastive learning serves as the Lagrange multiplier for the DRO constraint, and lower temperature leads to stronger DRO constraint. This insight again contributes to the development of algorithms.\n\nWEAKNESSES:\n- Meaning of the connection between contrastive learning and DRO is not clear enough: Theorem 3.2 connects the DRO objective and the InfoNCE loss. Although it is very interesting and insightful, and the authors argue that contrastive learning can be regarded as DRO and thus mitigate the sampling bias, we could argue that DRO is merely contrastive learning with the sampling bias in the opposite way. This would undermine the robustness property of DRO can still suffer from the sampling bias residing in contrastive learning.\n- DRO interpretation may not explain hard mining: In Section 3.3.C and Section 5.1, the authors observe that the DRO equivalent formulation explains how contrastive learning puts larger weights to negative samples with larger $f\\_\\\\theta$. Although this seems correct, this phenomenon does not correspond to what is so-called \"hard mining.\" Indeed, Robinson et al. [38] (and many other works) define hard negative samples as \"points that are difficult to distinguish from an anchor point,\" which can be put in the current context as \"negative samples with small $f\\_\\\\theta$.\" This observation may explain why a \"strange\" trade-off is observed in Section 3.3.A such that stronger DRO constraint leads to looser generalization error, unlike what we expect.\n\nQUESTIONS:\nMajor comments are listed first.\n\n- In Corollary 3.4 and Theorem 3.5, it is better to explain exactly what the \"approximation\" indicates.\n- With the proposed method ADNCE, can you discuss how we should choose the parameters $\\\\mu$ and $\\\\sigma$ in Section 5.2?\n\nMinor comments follow.\n\n- Typo in l.42: \"we proof\" -> \"we prove\"\n- Typo in l.82: \"Donsker-Varadah\" -> \"Donsker-Varadhan\"\n- Typo in footnote 1: The expectation looks strange.\n- Typo in l.142: $\\\\mathbb{E}\\_Q$ -> $\\\\mathbb{E}\\_{Q\\_0}$\n- In Theorem 3.2, the definition of $\\\\mathbb{Q}$ lacks. In Eq. (4), can $\\\\mathbb{E}\\_{Q\\_0}[Q/Q\\_0]$ be simply written as $\\\\int Qdx$?\n- Typo in l.156: \"satisfied\" -> \"satisfies\"\n- Typo in l.173: \"theorem 3.2\" -> \"Theorem 3.2\"\n- Typo in l.177: \"subsection 3.4\" -> \"Subsection 3.4\"\n- Typo in l.190 and l.191: $E\\_{Q\\_0}$ -> $\\\\mathbb{E}\\_{Q\\_0}$\n- In Theorem 4.2, it is better to mention $\\\\phi^\\*$ indicates the convex conjugate because this is the first place where it appears.\n- In Corollary 4.3, explaining what two random variables $X$ and $Y$ refer to make the statement complete is better.\n- In l.251, what do you compare CL-DRO with by the word \"tighter\"? By the way, the word \"tight\" indicates that equality can be attained for a given inequality, so the comparative \"tighter\" seems strange.\n- In l.257, I don't understand how \"DRO bridges the gap\" in the following paragraph.\n- In l.259, it is better to explain what $\\\\mathcal{I}\\_{DV}$ indicates.\n\nLIMITATIONS:\nThe authors have adequately discussed the limitations in the conclusion.\n\nSocietal impacts do not apply to this work because this work is mostly theoretical.", "TITLE": "Official Review", "RECOMMENDATION": 5, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 2, "DATE": "2023-06-15"}

comments: SUMMARY:
This paper starts from the question why the naive form of CL is robust to sampling bias issue, resulting in empirical success in various areas. T this end, the authors first present the relationship between CL and DRO theoretically, where the DRO-constrained CL objective is conceptually equivalent to the objective of CL itself. They further show that the temperature in CL acts as a (inverse of ) robust radius in DRO constraint.  Based on these findings, the authors finally propose ADNCE, where the importance weight of negative samples follow Gaussian distribution. The proposed methods are validated via experiments on various domains.

STRENGTHS:
- The paper reveals the relationship between CL and DRO in a more comprehensive way to address the bias-tolerant behavior of CL.
- Theoretical findings regarding \tau are validated empirically.
- The proposed framework and the ablative model based on the approximation of CL-DRO (Eq. 8) achieve meaningful performance improvement on the datasets.

WEAKNESSES:
- The design choice of ADNCE needs to be justified. Why such Gaussian-like weights are the most reasonable choice and can address the weakness mentioned in Sec. 5.1?
- Missing sensitivity analysis of \mu and \sigma in (12), comparing to those of \tau in InfoNCE. How much the results change as the hyperparameters vary?

QUESTIONS:
- Why controlling the variance of negative samples contributes to the success of CL?

LIMITATIONS:
Limitation has been addressed.
TITLE: Official Review
SOUNDNESS_CORRECTNESS: 3
DATE: 2023-07-06

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThe paper proposes a novel theoretical framework for understanding contrastive learning (CL) via distributionally robust optimization (DRO). \nUnder this framework, the paper derives that the InfoNCE loss can be interpreted as DRO with KL ball around the negative sampling distribution, and the paper leverages DRO insights to derive the optimal temperature parameter. Experiments are conducted which show that a novel modification of InfoNCE can lead to better sample complexities.\n\nSTRENGTHS:\n1. The framework that the paper proposes is quite elegant mathematically and explains the InfoNCE loss from a rigorous mathematical perspective, which endows us with many insights. \n2. Using these insights, the paper proposes a new ADNCE loss that overcomes the issues of conservatism in DRO and shows some possibly promising experiments. (I am not an expert in CL so I cannot gauge how convincing these empirical improvements are).\n\nWEAKNESSES:\n1. The proposed approach introduces more hyperparameters, which define the weighting distribution. These hyperparameters can be a hassle to tune in practice, and it is unclear if the reported gains are simply from better hyperparameter tuning with these newly introduced hyperparameters.. It would be informative to show whether the new ADNCE is better for a large number of hyperparameters, or only a few.\n\nPlease also answer my questions.\n\nQUESTIONS:\n1. In Corollary 3.4, how is optimality measured? In other words, what objective does the setting of Eqn 6 optimize, and which assumptions are needed for it to hold?\n2. Besides the math, is there any intuition on why DRO in the negative samples is what CL should strive for? In other words, why do we want to maximize the distance for all possible distributions of negative samples around the truth? (rather than the one we see data from). I think illustrating this intuition would be important to making this paper stronger.\n2b. Does this DRO insight applies to other types of CL losses, besides InfoNCE? \n3. What is Q^ideal? It is undefined before Line 154.\n4. Can you please shed more light on what is hard-mining and how DRO gives us insights that hasn't been uncovered before? The paper seems to assume that readers know what hard-mining is, but I am not aware of this phenomenon for CL.\n5. Can ADNCE also be explained with some modification of DRO? It would be nice to see if the new method is theoretically motivated as well, or simply a heuristic to avoid conservatism of DRO.\n\nLIMITATIONS:\nSee weaknesses/questions.", "TITLE": "Official Review", "RECOMMENDATION": 6, "REVIEWER_CONFIDENCE": 2, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-06"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nIn this work the authors demonstrate a connection between contrastive learning, in particular InfoNCE, and distributionally robust optimization. In contrastive learning algorithms it is typical during training that samples which are similar are treated as being different, ie a negative pair, since contrastive learning typically does not include class labels. Intuitively this would be a hinder the ability of contrastive learning algorithms to learn useful representations. Interestingly this doesn't seem to happen in practice, choosing a temperature parameter correctly can cause standard CL algorithms to perform as good as, or better than, robust variants, in the presence of false negative pairs.\n\nIn this work it is theoretically proven that InfoNCE is naturally distributionally robust, which explains the phenomenon from the last paragraph. This is done by proposing a distributionally robust version of InfoNCE and demonstrating that the loss is equivalent to InfoNCE with scaling and shifting. This work goes on to analyze the effect and selection of the temperature parameter, giving further insight into the behavior of InfoNCE. It is demonstrated that the distributionally robust InfoNCE is an estiamtor of mutual information. This work then proposes ADNCE as a way to overcome shortcoings of InfoNCE, in particular its sensitivity to outliers, i.e. the hardest negative pairs. This is done by weighting samples in the loss so that the most outlying negative pairs have lower weight in the ending risk. It is experimentally demonstrated that this method brings improvements.\n\nSTRENGTHS:\n- The theoretical result of this work is useful, reasonably nontrivial, and regards a topic that is of very large interest to the ML community. Very good!\n- ADNCE is an easily algorithm for a problem of signifiant interest, that brings consistent improvements. Also very good!\n\nWEAKNESSES:\nI spent a fair amount of time with this paper and I think its contributions are of high significance and importance, however I really feel that the exposition needs some improvement. I spent some time with the proofs and, while I was always able to decipher what was happening and found no errors, but they are written in a way that I found very hard to parse. While its far from the worst writing I have seen, there is quite a lot of the main text that was also difficult to precisely understand. I don't think the topicality here is so mathematically dense or advanced that this couldn't be written in a much clearer way. If this paper were very well written I would give this an 8, I think. Some example issues are listed below:\n\n- Line 63: What is \"the ultimate distribution\"?\n- Line 101 & Proof of Theorem 3.2 : it would be much clearer if $f_\\theta$ was instead $f_\\theta(x,y)$. This wouldn't take more space and it would be much easier to parse whats going in in the Proof of Theorem 3.2 if this were the case. \n- Theorem 3.2: It should be made clear that $\\alpha^*$ is a function of $\\eta$, this seems quite important. One could simply write $\\alpha^*(\\eta)$.\n- appx. line 10: I think $P$ in this line is supposed to be $Q$\n- appx. (17):  I think its worth writing the original constrained optimization before applying strong duality.\n- appx. (17): $\\max_L$ is again a bit vague. I'm assuming whats actually happening is that we are optimizing over $Q$ in the $L$ definition.\n- appx. line 21: \"fine definition\" is nonstandard, something like \"always exists\" or \"is well-defined\"\n- appx. line 29: this should be an $\\arg \\min$. Text like \"$\\alpha^*$ represents the optimal value of ...\" is needlessly confusing, just say \"$\\alpha^* = \\arg \\min \\cdots$.\"\n- Line 148, 165: Maybe I'm missing something, but I don't quite get what \"optimal\" means in these lines.\n- Theorem 3.3: What is $Q^{ideal}$? In what sense is it \"ideal\"? \n\nIf this work used more clear and precise notation I think it would be great, right now it looks like a rough draft. As an example improvement, I would rewrite in appx (17) the fist term in the last line \n$\\mathbb{E}_{P_0} [f_\\theta]$ \n\nas\n\n$\\mathbb{E}_{(X,Y)\\sim P_0}[ f_\\theta(X,Y)]$\n\nSome other errors:\n- \"and graph\" should be \"and graphs\"\n- Give the definitions of acronyms, eg DCL HCL RPL\n- There are many missing periods for sentences that end with equations, eg at the end of (1), (16),(17)\n- Line 70: \"downstrea\" [sic]\n- Page 3 footnote: sloppy ]\n\nQUESTIONS:\nI don't have any questions really, the paper just needs more polish\n\nLIMITATIONS:\nNone", "TITLE": "Official Review", "RECOMMENDATION": 6, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 2, "DATE": "2023-07-12"}