A learning machine is prone to be attacked by adversarial examples contaminated by perturbations. Adversarial training (AT) is developed to build a defense model against adversarial attacks. Most of previous works were conducted in supervised setting. To release the demand of data labeling, self-supervised learning is required to carry out the self-supervised AT. This study presents a contrastive view in AT where a self-supervised AT is developed by enhancing instance discrimination based on contrastive learning (CL). The connection between AT and self-supervised learning is used to consolidate self-supervised AT by merging a classification perspective in contrastive objective. This study analyzes two potential sources of mismatch in existing CL and AT pipelines, namely, the implicit class definition in instance discrimination and the distributional discrepancy induced by different augmentation strategies. Based on this analysis, this study develops a self-supervised AT framework that integrates a classification perspective into CL. A self-supervised AT with a contrastive view is performed to calculate the perturbed image embeddings to train a robust classifier. The contrastive objective is also reformulated to train a self-supervised sentence encoder as the defense model. The experiments on image and text representations for adversarial robustness show that this method improves the previous unsupervised methods, and even surpasses some other supervised methods.

Deep neural networks are vulnerable in the presence of adversarial examples. In light of this vulnerability, an emerging research trend is to build a defense model based on adversarial training (AT) (Madry et al., 2018). The adversarial learning objective is typically formulated as a minimax optimization problem (Lio et al., 2022) where the additive perturbations to input data are first estimated by maximizing the loss via gradient ascent, and then the model parameters are trained by minimizing the loss with gradient descent by using AT examples. Such a two-stage training process has been implemented for a variety of downstream tasks in computer vision and natural language processing. The resulting models generally improve the adversarial robustness, but likely degrade the performance on clean data. In Zhu et al. (2020) and Pan et al. (2022), the robustness was even generalized to clean data. For text representation, the resulting model becomes noise-invariant by adding the worst-case perturbations onto word embeddings during training (Chien et al., 2025). The adversarial instances with the perturbed data in embedding space are used to improve model generalization. However, most existing AT methods (Shafahi et al., 2019; Zhang et al., 2019; Wong et al., 2020) were developed under a supervised setting where the labels of training data were required (Li et al., 2023). It is challenging to carry out a practical solution to self-supervised AT. Previously, there have been very few works dedicated to self-supervised AT in image representation, and there has been limited exploration of self-supervised AT for text representation. This paper presents a contrastive view in self-supervised AT by deliberating the perspective of instance discrimination.

Contrastive learning (CL) (Li et al., 2022; Chien and Chen, 2026) is seen as a recent breakthrough in modern machine learning. CL has been advanced to extract vital information which is feasible to upgrade the learning performance. State-of-the-art (SOTA) results have been achieved in numerous applications. The learning process is motivated from the task of instance discrimination (Wu et al., 2018) where each data instance is viewed as an individual class, and a neural encoder is learned to calculate the features which are discriminative among different instances or self-defined classes. It is obvious that such a CL task is essentially implemented for unsupervised learning but implicitly connected to a classification problem in supervised learning (SL). The contrastive perspective is fulfilled for self-supervised learning. CL has its fundamentals originated from metric learning and information theory. In Chen et al. (2020), a simple framework for CL of visual representation (SimCLR) was proposed to upgrade learning an image classifier which was comparable with that based on SL. CL was then extended to enable a significant performance in text representation. In Gao et al. (2021), a simple contrastive sentence embedding (SimCSE) was exploited to train a contrastive sentence encoder, which obtained desirable results on unsupervised or self-supervised learning in various tasks (Sun et al., 2025; Tu et al., 2024).

This study revisits the connection between CL and supervised classification, and leverages this connection to design a self-supervised AT framework. While contrastive objectives such as the information noise-contrastive estimation (InfoNCE) or the normalized temperature-scaled cross entropy (CE) (NT-Xent) in SimCLR can be interpreted as implicit classification over instances, the existing formulations treat each sample differently across views, which may lead to inconsistencies when combined with AT. We explicitly reformulate the instance discrimination as a batch-wise classification problem and integrate it with adversarial optimization. This perspective provides (i) a unified view bridging CL and AT, and (ii) a practical framework that improves robustness while maintaining computational efficiency.

The remaining of this paper is organized as follows. Section 2 introduces the background of CL and supervised/self-supervised AT. Section 3 addresses how the classification perspective is strengthened and merged in a new self-supervised AT. In Section 4, a series of experiments on image and text representations are conducted to evaluate robustness, efficiency and accuracy by using various defense models. Section 5 concludes some findings drawn from this study.

The safety and reliability of deep models have been very crucial when practically deploying an information system. There have been a number of solutions proposed to enhance the robustness to domain shift, random noise, rotation or color changes in images or typos in sentences. The most common robustness highlighted recently is adversarial robustness. The defenses in visual and textual models against adversarial attacks are our main focus. Previously, the adversarial attacks for images (Carlini and Wagner, 2017; Madry et al., 2018) and sentences (Gao et al., 2018; Jin et al., 2020) have been addressed. Among various defense methods, the AT is seen as the most effective method to improve adversarial robustness.

This paper presents a contrastive perspective to develop a self-supervised AT. The instance discrimination is implemented to initiate a unified view toward AT. First, the multi-view CL is studied. CL is used for self-supervised learning (Gan et al., 2024) where class labels are not required. Originally, CL is performed by using SimCLR (Chen et al., 2020) where the representation fθ(·) with parameter θ is trained through a task where individual instances are mutually discriminative. Each sample xi in a batch x=(x1,,xB) of size B is transformed to a variant xik=tk(xi) to form M batch views X={x1,,xM} where xk=(tk(x1),,tk(xB)) is the kth view of X. Random samples are drawn from strong data augmentation tkTCL where TCL denotes the set of variants for CL such as random cropping and resizing, random horizontal flip, strong random color jitter and random gray-scale conversion using image data. In the implementation, each variant xik can be viewed as an anchor, and its latent representation zik=fθ(xik) will attract (shown by green) that of positive sample zij=fθ(xij), i.e. the same sample in different views, and simultaneously repel (shown by red) from those of the remaining samples within and between batches as the negative samples as illustrated in Figure 1 where B=3 and x1a is seen as an anchor. For this case of two-view CL (M=2), the CL objective LCL(xa,xb;θ) due to individual samples from two batch views xa={xia} (1st term) and xb={xib} (2nd term) as an InfoNCE objective is therefore yielded with encoder θ by:

(1)
Figure 1.
A diagram of strong data augmentation passing transformed inputs through f theta to produce representations that attract matching pairs and repel others.The diagram begins with original inputs, including x 1. Transformations t a and t b create x 1 a and x 1 b, alongside additional augmented inputs. These inputs pass through f theta to produce corresponding representations, including z 1 a and z 1 b. Arrows labelled attract connect z 1 a and z 1 b. Arrows labelled repel connect the other representations with the matching representations.

Contrastive learning is implemented with data augmentation and instance discrimination. x1a acts as an anchor

Figure 1.
A diagram of strong data augmentation passing transformed inputs through f theta to produce representations that attract matching pairs and repel others.The diagram begins with original inputs, including x 1. Transformations t a and t b create x 1 a and x 1 b, alongside additional augmented inputs. These inputs pass through f theta to produce corresponding representations, including z 1 a and z 1 b. Arrows labelled attract connect z 1 a and z 1 b. Arrows labelled repel connect the other representations with the matching representations.

Contrastive learning is implemented with data augmentation and instance discrimination. x1a acts as an anchor

Close modal

where τ is the temperature. In equation (1), the encoder outputs are normalized in the calculation of cosine similarity between two samples. A crucial component in such a SimCLR process for image representation is the data augmentation (Luo et al., 2023a) through two or multiple views xX which are used in the task of instance discrimination (Zhang et al., 2024b). It is worth noting that the contrastive objective in equation (1) (Chien et al., 2024b) can be interpreted as a form of CE loss over a dynamically constructed set of classes defined by the batch samples. However, unlike standard classification, the implicit class assignments depend on the choice of anchor and vary across different views, which will be further analyzed in Section 3.

Relative to image data, the augmentation of text data is harder to visualize due to the discreteness of word tokens. Previously, the augmentation strategies such as back-translation, word deletion, reordering and substitution were used (Yan et al., 2021). For CL of a text model, a successful solution based on SimCSE (Gao et al., 2021) was developed by using an alternative augmentation called dropout. Using dropout, the latent sample zi=fθp(xi) is calculated by using a model fθp(·) with dropout rate p and encoder parameter θ. Each instance xi passes through the encoder fθp(·) twice to produce two representations zia and zib due to random dropout. The instance discrimination is then defined within a mini-batch. The representation of an anchor zia gets close to that of positive sample zib and at the same time gets separate from those of negative samples, which correspond to the views zja and zjb of the remaining samples {xj}ji in a mini-batch x. This study works on AT for image and text defense models from contrastive perspective (Chien et al., 2024a).

AT was developed to estimate a supervised defense model fθ(·) where learning procedure consists of attack generation and model training, as shown in Figure 2, which are performed to achieve adversarial robustness with the number of classes C=5. The parameters of perturbation δ, encoder θe and classifier W are jointly estimated by solving a minimax optimization problem (Tu et al., 2020; Chien and Sun, 2023), which is decomposed into an upper half and a lower half in the figure. The CE loss between the logit outputs y^isoftmax(fθ(·)), driven by parameters θ={θe,W} and softmax function, and the one-hot target vector yi is first maximized to estimate the worst-case perturbation δ by using attack data tSL(x)+δ as shown in the upper half. In the lower half, the attack data (dashed blocks) are used as the training data to update parameters of encoder θe and classifier W (shaded by grey) by minimizing the loss. The formulation turns out as:

(2)
Figure 2.
A workflow diagram combines attack generation and model training using transformed samples, attack samples, model outputs, target labels and cross-entropy loss.The diagram has two connected stages labelled Attack Generation and Model Training. Original samples, including x 1, pass through t S L and then f theta e. The resulting representations are combined by dot product with W, followed by softmax, to produce output logits y hat. Target labels y and cross-entropy loss L C E are used to generate delta i through epsilon sign of the gradient with respect to t S L of x i. The perturbations are added to the transformed samples to create attack samples such as t S L of x 1 plus delta 1. These attack samples pass through f theta e. Their representations are combined with W by dot product and softmax to produce another set of output logits y hat. Cross-entropy loss is calculated against the same targets. Gradients with respect to W and theta e are used to update W and f theta e.

Supervised adversarial training consists of attack generation for δ and model training for θe and W

Figure 2.
A workflow diagram combines attack generation and model training using transformed samples, attack samples, model outputs, target labels and cross-entropy loss.The diagram has two connected stages labelled Attack Generation and Model Training. Original samples, including x 1, pass through t S L and then f theta e. The resulting representations are combined by dot product with W, followed by softmax, to produce output logits y hat. Target labels y and cross-entropy loss L C E are used to generate delta i through epsilon sign of the gradient with respect to t S L of x i. The perturbations are added to the transformed samples to create attack samples such as t S L of x 1 plus delta 1. These attack samples pass through f theta e. Their representations are combined with W by dot product and softmax to produce another set of output logits y hat. Cross-entropy loss is calculated against the same targets. Gradients with respect to W and theta e are used to update W and f theta e.

Supervised adversarial training consists of attack generation for δ and model training for θe and W

Close modal

where the augmented data tSLTSL from original data x are drawn and used in SL for adversarial robustness. In equation (2), D denotes the set of labeled data {xi,yi={yic}}, and S denotes the set of possible perturbations δ which are bounded within l norm ball B(ϵ) of a small radius ϵ as δϵ. The classification loss in SL is seen as a negative log likelihood of one-hot targets y={yi} given by inputs x={xi}, which is formed as a CE between y^={y^ic}, where y^ic=p(c|xi) is the class conditional likelihood, and y based on:

(3)

In the first stage, the projected gradient descent (PGD) for l bounded adversary in B(ϵ) (Kurakin et al., 2018) is repeatedly performed at each iteration to estimate the perturbation δ via the fast gradient sign method (FGSM) in a form of δ=ϵsign(tSL(x)LCE) with a step size α. The iterative updating is performed by:

(4)

where fθ(·)=Wfθe(·). In the second stage, the model parameters {θe,W} are estimated by allowing perturbation noises δ presented in individual samples x.

In general, the adversarial attacks on sentences are very different from those on images. Human eyes are not possible to tell the difference between an original image and its attack image within a small norm ball. For text data, it is hard to evaluate how much the sentence is perturbed when its semantic meaning is changed. The continuous essence of image data naturally results in using the gradient-based attacks. But, the attack in embedding space will produce non-existing tokens in the vocabulary. In Gao et al. (2018) and Jin et al. (2020), the black-box adversarial attacks were developed. Typically, AT for image representation aims to improve the model robustness to adversarial attacks. In this process, the accuracy on clean images would decrease due to the trade-off between robustness and accuracy. In text modeling, the adversarial perturbations were added onto the word embeddings during training. High performance was achieved in various classification tasks. The adversarially trained model was able to prevent overfitting problem. The perturbations in noisy samples were beneficial to protect unknown attacks. In Zhu et al. (2020), a low-cost AT method (Shafahi et al., 2019) was developed to improve model generalization. In Pan et al. (2022), the adversarially perturbed text examples were used to perform CL. All of these methods were designed in a supervised setting which required data labels y. This paper presents a self-supervised defense model for adversarial attacks in presence of image and text data.

To handle the AT without labeled data y, i.e. D=x, the previous methods (Kim et al., 2020; Jiang et al., 2020) generally followed an objective similar to equation (2) while the CE loss was replaced by a CL loss in equation (1). The minimax optimization for self-supervised AT is performed by:

(5)

where CL loss LCL is maximized to estimate the perturbation δ and is minimized to train the encoder θ. Figure 3 shows the attack procedure of self-supervised AT by using the robust contrastive learning (RoCL) (Kim et al., 2020) with B=3. The dashed blocks denote the perturbed instances. In the adversarial procedure, each clean batch view xb=tb(x)=(tb(x1),,tb(xB)) and the perturbation of another batch view xa=ta(x), denoted by:

(6)
Figure 3.
A workflow diagram updates delta using contrastive loss between adversarial x a and x b, with encoded representations attracting matching samples and repelling others.The diagram begins with x a. Delta is added to x a to create adversarial x a. Adversarial x a and x b pass through f theta to produce latent representations. The contrastive loss L C L is calculated using adversarial x a, x b and theta. The representation z 1 a adversarial serves as an anchor in one branch, while z 1 b serves as an anchor in another branch. Arrows labelled attract connect each anchor with its corresponding paired representation. Arrows labelled repel connect each anchor with the other representations. The gradient of L C L with respect to delta is used to update delta.

Self-supervised adversarial training adopts the perturbation δ estimated according to contrastive learning loss LCL where instance discrimination is performed

Figure 3.
A workflow diagram updates delta using contrastive loss between adversarial x a and x b, with encoded representations attracting matching samples and repelling others.The diagram begins with x a. Delta is added to x a to create adversarial x a. Adversarial x a and x b pass through f theta to produce latent representations. The contrastive loss L C L is calculated using adversarial x a, x b and theta. The representation z 1 a adversarial serves as an anchor in one branch, while z 1 b serves as an anchor in another branch. Arrows labelled attract connect each anchor with its corresponding paired representation. Arrows labelled repel connect each anchor with the other representations. The gradient of L C L with respect to delta is used to update delta.

Self-supervised adversarial training adopts the perturbation δ estimated according to contrastive learning loss LCL where instance discrimination is performed

Close modal

alternatively take the role of anchor samples, and the negative samples will contain the other samples in both tb(x) and ta(x)+δ. The multi-view CL loss LCLmulti({(xa)adv,xa,xb}; θ) due to perturbation and augmentation is then calculated for each individual batch data x. The pairs of latent samples {(zia)adv,zia} and {(zia)adv,zib} from the same sample xi are attracting while those {(zia)adv,(zja)adv}, {(zia)adv,zja}, {(zib)adv,(zjb)adv}, {(zib)adv,zjb} from different samples {xi,xj,ji} are repelling. An additional regularization term is further introduced to enforce together the clean input ta(x) and the perturbed input ta(x)+δ. The CL loss LCL in equation (5) is then replaced by the regularized objective:

(7)

where {xa,xb}D and λ are regularization parameters.

Different from RoCL, the adversarial contrastive learning (ACL) (Jiang et al., 2020; Lin et al., 2026) presented a dual stream approach to self-supervised AT where the encoder θ was trained according to standard CL via SimCLR by using the clean examples as well as the corresponding adversarial examples. In addition, a potential result of self-supervised AT was obtained by the adversarial CL (AdvCL) (Fan et al., 2021), where an adversarial example view and a high-frequency component view via Fourier transform were introduced to conduct a multi-view CL for classification task. AdvCL used the pseudo labels (PLs) generated by a pretrained encoder for both attack generation and model training. A kind of pseudo-labeled AT was implemented. A recent method called graph ACL (Luo et al., 2023b) was proposed by learning a bank of negative samples for self-supervised graph encoding from graph-structured data. Basically, the above-mentioned methods involved in different methods, which complicated the training procedure. The computation and memory requirements are demanding. The connection to supervised AT was disregarded in previous studies.

This study is motivated by incorporating the contrastive view via instance discrimination into an implementation of a new self-supervised adversarial training (Chien and Chen, 2024; Zhang et al., 2024a). A unified view of CL and AT is presented to allow richer information in a more compact model with lower computation cost. Figure 4 illustrates the flow diagram from a motivation for developing a self-supervised AT to a final solution based on two-view AT and an extended solution based on two-view CL where the self-supervised tricks of conducting classification in instance discrimination and using separate views of anchors and classes are implemented through handling the problems of inconsistencies in class definition and augmentation bias in traditional CL (Chen et al., 2020) and AT (Madry et al., 2018).

Figure 4.
A flowchart links self-supervised adversarial training to contrastive learning and adversarial training, identified problems, implementations, and two-view solutions.The flowchart begins with Self-Supervised Adversarial Training under Motivation. It branches under Models to Contrastive Learning and Adversarial Training. These lead under Problems to Inconsistent Class Definition and Inconsistent Distribution Bias. The problems connect under Implementation to Classification in Instance Discrimination and Separate Views Anchors slash Classes. Both implementations lead to the Extended Solution stage. This contains Two-View Contrastive Learning and, under Target Solution, Two-View Adversarial Training.

Illustration of how self-supervised solutions to two-view contrastive learning and two-view adversarial training are developed

Figure 4.
A flowchart links self-supervised adversarial training to contrastive learning and adversarial training, identified problems, implementations, and two-view solutions.The flowchart begins with Self-Supervised Adversarial Training under Motivation. It branches under Models to Contrastive Learning and Adversarial Training. These lead under Problems to Inconsistent Class Definition and Inconsistent Distribution Bias. The problems connect under Implementation to Classification in Instance Discrimination and Separate Views Anchors slash Classes. Both implementations lead to the Extended Solution stage. This contains Two-View Contrastive Learning and, under Target Solution, Two-View Adversarial Training.

Illustration of how self-supervised solutions to two-view contrastive learning and two-view adversarial training are developed

Close modal

To better understand the proposed method, we first formalize the relationship between CL and classification, and clarify the potential inconsistencies discussed in this work.

3.1.1 Relation to InfoNCE and cross entropy.

The contrastive loss in equation (1) can be rewritten as a CE loss or classification loss over a set of batch-wise classes, where each instance is treated as a distinct class, as detailed later in equation (10). Under this interpretation, the probability of assigning an anchor representation zi to its positive counterpart can be expressed as a classification output logit:

(8)

This reveals that standard CL implicitly performs classification with dynamically changing class definitions. We analyze two potential inconsistencies in previous CL and supervised adversarial learning.

3.1.2 Inconsistency in class definition.

In conventional CL, each sample alternates between being an anchor and a class representative. As a result, the conditional distributions being optimized considerably differ across views, which may introduce inconsistency when integrating with adversarial objectives that assume a fixed classifier for instance discrimination. In particular, the classes in CL using equation (1) are defined inconsistently at the individual steps for parameter updating. Notice that for those 2B data samples derived from two views {ta,tb} of X, each sample follows a different classification problem. Then, even the anchors from the same sample xi but with different views ta and tb are defined and treated as different instances or classes. This is because, as shown in equation (1), each data sample is alternatively acted as the anchor sample and positive/negative sample. When viewing CL as a classification task, there does exist an inconsistency in instance discrimination in equations (1) and (10). Such varying class definitions may introduce ambiguity in optimization and affect downstream performance. Prior contrastive objectives based on InfoNCE implicitly redefine instance classes depending on the anchor view and batch composition. Although effective empirically, this dynamic role switching may introduce ambiguity when adversarial perturbations are iteratively optimized. Our formulation explicitly separates anchor and class representations to stabilize the optimization target during adversarial updates.

3.1.3 Inconsistency in augmentation bias.

In CL and supervised AT, different augmentation pipelines TCL and TSL for the augmented samples xCL and xAT from the same original sample x are used, respectively. This leads to a mismatch in the data distributions during representation learning and adversarial optimization:

(9)

The augmented data in previous CL (Chen et al., 2020) and AT (Madry et al., 2018) adopted different views of images in data augmentation as illustrated in Figure 5. Relative to the original image xi, the augmented images in previous works on CL and AT were distributed with strong bias ts(xi)TCL and weak bias tw(xi)TSL, respectively. The inconsistent biases in the views of augmented images did exist in the previous CL and AT. The inconsistent distribution view did happen in previous data augmentations for CL and AT. Such discrepancy may affect the stability of AT when combined with contrastive objectives. These observations motivate a unified formulation that aligns instance discrimination with a consistent classification perspective and harmonizes augmentation strategies. This paper presents a self-supervised AT driven by a unified view for instance discrimination where these two inconsistencies are handled through bridging CL and AT via a classification task for individual instances. Without loss of generality, in the application of sentence representation, two views of augmented training data tw(xi) and ts(xi) for self-supervised AT are implemented by using an encoder without and with neural network dropout, respectively. Recent studies in ACL have also observed that discrepancies between augmentation policies and adversarial objectives may affect robustness and representation stability. Dynamic ACL (DynACL) in Luo et al. (2023a) addressed this issue through dynamic augmentation scheduling, while adversarial invariant regularization (AIR) in Xu et al. (2023b) regularized augmentation-induced style variations. These observations are consistent with our motivation that inconsistent augmentation views may hinder stable adversarial optimization. Table 1 shows a convention of notations for ease of comprehension for the proposed method.

Figure 5.
An original car sample is compared with three strongly biased augmentations using close crops and three weakly biased augmentations retaining most of the car.The original sample contains a car parked beside a building. The augmented data with strong bias contains three transformed samples. These focus on the front wheel, the side section and the rear section of the car. The augmented data with weak bias contains three transformed samples. Each retains most of the car and surrounding building, with changes in framing and orientation.

Original sample xi and augmented samples ts(xi) and tw(xi) with strong bias and weak bias, respectively

Figure 5.
An original car sample is compared with three strongly biased augmentations using close crops and three weakly biased augmentations retaining most of the car.The original sample contains a car parked beside a building. The augmented data with strong bias contains three transformed samples. These focus on the front wheel, the side section and the rear section of the car. The augmented data with weak bias contains three transformed samples. Each retains most of the car and surrounding building, with changes in framing and orientation.

Original sample xi and augmented samples ts(xi) and tw(xi) with strong bias and weak bias, respectively

Close modal
Table 1.

Convention of the notations in the proposed method

NotationMeaning
xiOriginal sample vector
tw(·)Weak augmentation function
ts(·)Strong augmentation function
XanchAnchor sample matrix or batch
XclsClass sample matrix or batch
ZclsClass representation matrix or batch
y˜iSelf-supervised instance label vector
BBatch size

Considering an instance discrimination (Wu et al., 2018) task in CL, every instance is viewed as a class, and the model fθ(·) is learned to classify each input sample xi in a B-way classification problem where B is the size of mini-batch. Let a memory bank V=(v1,,vB) or Z=(z1,,zB) store the representations of all data samples. The softmax loss in a form of CE loss, or equivalently the negative log conditional likelihood for discrimination of B samples can be minimized via:

(10)

where zi=fθ(xi) and y˜={y˜ij} denotes the one-hot target matrix for instance discrimination, which is fixed as a B-dimensional identity matrix y˜={y˜i}=IB. Notably, the instance conditional likelihood y^i=p(y˜i|xi)= softmax(Vzi) can be seen as the output logits of an instance classification network for xi. A self-supervised learning (Yu and Dai, 2024) is performed without the need of class labels y={yic}. When looking at each logarithmic term in equation (1), it is interesting that SimCLR similarly follows a classification task as seen in equation (10). In case of τ=1, equation (1) also expresses a softmax function as the CE loss for classification. Such a task plays a key role in CL. Basically, equation (10) shows that the classes in B-way classification problem are consistently defined by individual data samples in the data set throughout the training process. From an optimization perspective, this formulation can be viewed as approximating a robust classification objective over instance identities, where the adversarial perturbation seeks to maximize the classification loss while the encoder minimizes it. Compared to pairwise contrastive loss, the batch-wise classification view provides a more stable gradient signal, especially when integrated with adversarial updates:

P1.

The InfoNCE objective in equation (1) is equivalent to a batch-wise cross-entropy loss over dynamically constructed instance classes.

P2.

When adversarial perturbations are introduced, dynamically changing instance roles in standard contrastive learning induce inconsistent optimization targets across attack iterations.

Implication. Separating anchor and class samples stabilizes the adversarial optimization objective.

Algorithm 1. Enhancing instance discrimination for a new contrastive learning or self-supervised learning

To cope with these inconsistencies, this paper strengthens the classification perspective in standard CL (Chen et al., 2020) in equation (1) by separating the views of anchor samples and class samples. As the inconsistent class definition is caused by using each sample as both anchor and positive/negative samples, this study explicitly separates both roles and sufficiently uses different views or batches. In addition, data augmentation may cause a severe mismatch between the distributions in training and test data. But, the previous CL (Chen et al., 2020) performed well by using augmented data with strong bias. This study is motivated by incorporating different views by using various augmented data. In particular, the anchor samplesXanch=(tw(x1),,tw(xB)) are drawn from a view batch via weak data augmentation. These anchor samples are analogous to those input samples in previous supervised AT (Madry et al., 2018). Notably, these anchor samples are only used as the anchors in instance discrimination. On the other hand, since strong augmentation is still required for instance discrimination to fulfill CL, the class samplesXcls=(ts(x1),,ts(xB)) are formed as a view batch by using strong data augmentation. These class samples with strong distribution biases are only used as the samples in either positive or negative classes. With the view batches {Xanch,Xcls} defined by the augmented data due to weak and strong biases, respectively, a self-supervised classification task is formulated by feeding the class samples Xcls into a model or an encoder fθ(·) to obtain a batch of class representations for instance discrimination:

(11)

Therefore, a two-view classification problem is formulated in a learning procedure. In this procedure, the classification logits y^i of an input example xi are first calculated by feeding an anchor sample xianch=tw(xi) with the view of weak data augmentation, and then passing this sample through an encoder fθ(·), multiplying the encoder output by the class representation matrix Zcls based on the view of strong data augmentation, and measuring the class or instance posterior probabilities by softmax function. Given the class representation matrix Zcls, each weakly augmented anchor sample tw(xi) is projected into the same embedding space to obtain the instance classification logits:

(12)

Next, the output logits y^i=((y^i)1,,(y^i)B) of an input xi are used to calculate the sample-based CE loss by:

(13)

where y˜i denotes the self-supervision label for an anchor xianch. This one-hot label is defined by the index of the corresponding class sample, i.e. y˜ii=1 and y˜ij=0 if ij. The number of classes corresponds to that of samples B in a view batch, and the collection of one-hot target vectors is formed as a B-dimensional identity matrix y˜={y˜i}=IB. Figure 6 shows an implementation of a new self-supervised classification task for CL. Importantly, the classification perspective in CL is strengthened by consistently handling a unified classification problem from the views of anchor and class samples by using weak tw and strong ts data augmentations, respectively. The issue of inconsistent class definition is addressed because the samples of anchor and class are separately defined over individual examples. The same example xi will not be mixed as different classes. In addition, two views of augmented data are both adopted in a single task so that the inconsistent augmentation bias does not exist. Algorithm 1 illustrates the procedure of enhancing instance discrimination for a new contrastive or self-supervised learning.

Figure 6.
A workflow uses weak and strong transformations to generate anchor and class features, calculate output logits and cross-entropy loss, and update theta.The diagram begins with x 1 and additional samples. Weak transformation t w produces anchor samples, including x 1 anch. Strong transformation t s produces class samples, including x 1 cls. Both sets pass through f theta. The anchor samples produce anchor features, including z 1 anch. The class samples produce class features, including z 1 cls. A dot product combines the anchor and class features. Softmax produces output logits y hat. The targets y tilde form an identity matrix with 1 along the diagonal and 0 elsewhere. The output logits and targets are passed to cross-entropy loss L C E. Theta is updated using the gradient of the summed cross-entropy losses over B samples.

Instance discrimination in contrastive learning is enhanced by using two-view augmented data with weak bias and strong bias relative to X as the anchor samples Xanch and class samples Xcls, respectively

Figure 6.
A workflow uses weak and strong transformations to generate anchor and class features, calculate output logits and cross-entropy loss, and update theta.The diagram begins with x 1 and additional samples. Weak transformation t w produces anchor samples, including x 1 anch. Strong transformation t s produces class samples, including x 1 cls. Both sets pass through f theta. The anchor samples produce anchor features, including z 1 anch. The class samples produce class features, including z 1 cls. A dot product combines the anchor and class features. Softmax produces output logits y hat. The targets y tilde form an identity matrix with 1 along the diagonal and 0 elsewhere. The output logits and targets are passed to cross-entropy loss L C E. Theta is updated using the gradient of the summed cross-entropy losses over B samples.

Instance discrimination in contrastive learning is enhanced by using two-view augmented data with weak bias and strong bias relative to X as the anchor samples Xanch and class samples Xcls, respectively

Close modal

This study connects the supervised, unsupervised and self-supervised learning and presents a contrastive view to derive a new self-supervised AT. First, the classifier with parameter θ in SL consists of an encoder and a linear layer with parameters θe and W, respectively. The output logits are calculated by:

(14)

Alternatively, the softmax or CE loss in equation (13) is minimized to train a self-supervised classifier for instance discrimination in CL. The connection between SL and CL tasks is illustrated by looking at how the classification logits are related in equations (14) and (12). Here, the only alteration is made by replacing C-dimensional W for SL in equation (14) with B-dimensional Zcls for CL in equation (12), i.e. WZcls. With this connection between classification tasks in SL and CL, it is meaningful to introduce an unsupervised setting for standard AT (Madry et al., 2018) in equation (2). By replacing the supervised classifier weights with the instance representation matrix, the standard supervised AT objective can be reformulated into a self-supervised adversarial optimization:

(15)

where the simulated targets y˜=IB are imposed. Notably, two-view augmented data with weak [tw(x)] and strong [ts(x) via Zcls in equation (11)] distribution biases relative to x are merged in equation (15). In the implementation, the adversarial attack data are first updated through PGD attack (Kurakin et al., 2018) by maximizing CE loss in equations (13) and (15) with the perturbation δ given by:

(16)

or equivalently updated with K attack iterations based on:

(17)

The perturbations δ={δi} are then added to anchor samples to obtain attack data tw(x)+δ and used as new anchor samples to minimize CE loss again to train encoder θ where the class samples Zcls from alternative view ts(x) are also used. The proposed self-supervised AT is implemented by incorporating contrastive view in a B-dimensional AT which consistently implements instance discrimination via a classification problem in equation (15).

This study bridges supervised and self-supervised AT and builds an efficient solution to self-supervised AT, which is configured as shown in Figure 7 and implemented by using Algorithm 2. Given an input sample and a set of target classes in standard supervised AT, the perturbation is estimated to trick the model to predict a wrong class. However, in previous self-supervised AT (Kim et al., 2020; Jiang et al., 2020), the classes were defined from positive/negative samples, in which some of them were attack data. Since PGD attack was iterative, in every attack iteration, some of the classes might be changed while the others stayed the same. An ambiguity ascent direction was caused during optimization over attack data. The issue of inconsistent class definition became even severe with adversarial attack.

Figure 7.
A workflow combines weak and strong transformations, attack generation and model training using anchor and class features, cross-entropy loss and perturbations.The diagram contains Attack Generation and Model Training stages. Input samples, including x 1, receive weak transformation t w and strong transformation t s. The weakly transformed samples pass through f theta to produce anchor features. The strongly transformed samples pass through f theta to produce class features z cls. A dot product combines the anchor and class features. Softmax produces output logits y hat, which are compared with targets y tilde using cross-entropy loss L C E. Delta i is calculated using epsilon sign of the gradient of L C E with respect to t w of x i. Delta 1 is added to t w of x 1 to create an attacked weakly transformed sample. These attacked samples pass through f theta to produce another set of anchor features. A dot product combines these anchor features with the class features. Softmax produces another set of output logits y hat, which are compared with the same targets using L C E. The gradient of L C E with respect to theta is used to update f theta.

A new self-supervised adversarial training is developed by enhancing the instance discrimination via two-view augmented data and separate anchor and class samples

Figure 7.
A workflow combines weak and strong transformations, attack generation and model training using anchor and class features, cross-entropy loss and perturbations.The diagram contains Attack Generation and Model Training stages. Input samples, including x 1, receive weak transformation t w and strong transformation t s. The weakly transformed samples pass through f theta to produce anchor features. The strongly transformed samples pass through f theta to produce class features z cls. A dot product combines the anchor and class features. Softmax produces output logits y hat, which are compared with targets y tilde using cross-entropy loss L C E. Delta i is calculated using epsilon sign of the gradient of L C E with respect to t w of x i. Delta 1 is added to t w of x 1 to create an attacked weakly transformed sample. These attacked samples pass through f theta to produce another set of anchor features. A dot product combines these anchor features with the class features. Softmax produces another set of output logits y hat, which are compared with the same targets using L C E. The gradient of L C E with respect to theta is used to update f theta.

A new self-supervised adversarial training is developed by enhancing the instance discrimination via two-view augmented data and separate anchor and class samples

Close modal

Compared with RoCL (Kim et al., 2020) and ACL (Jiang et al., 2020), the proposed framework does not rely on additional contrastive streams or auxiliary adversarial objectives. Compared with the DynACL in Luo et al. (2023a), our method does not require dynamic augmentation scheduling. Instead, robustness is achieved through a unified classification-based instance discrimination mechanism with explicit separation between anchor and class representations.

Compared with the solutions to supervised AT in equation (2) and self-supervised AT in equation (5), the proposed self-supervised AT carries out a self-supervised method in equation (15) with three essential refinements including:

Algorithm 2. Enhancing instance discrimination for a new self-supervised adversarial training

  1. replacement with the instance class matrix WZcls;

  2. assignment with the self-supervised target matrix y˜=IB; and

  3. incorporation of two-view augmented data {tw(x),ts(x)} for anchor and class samples {Xanch,Xcls}, respectively.

The proposed method addresses the issue of inconsistent instance labels which is caused when the same sample in CL alternatively acts as anchor and positive/negative samples. The classes in this self-supervised AT are defined by the class samples Xcls which are consistent within a training step. The attack perturbation δ is only added to the anchor samples Xanch as seen in equation (17), thus the attack target stays the same throughout the attack iterations. These steps provide a clear ascent direction for the attacker and generate a strong attack during AT, which ultimately results in a robust model. Importantly, this paper presents a meaningful solution to self-supervised AT by transforming a supervised AT into a self-supervised variant through the replacement of W in equation (14) with Zcls in equation (12). Attractively, such a connection provides an avenue to extend any existing or future supervised AT methods to realize their corresponding self-supervised AT methods. This framework takes a further step toward unifying the supervised and self-supervised AT. This paper presents a contrastive perspective for implementing self-supervised AT. The instance discrimination in CL is enhanced to develop a new self-supervised AT. The resulting solution is simple and efficient. The extra views and costs in previous methods (Jiang et al., 2020; Fan et al., 2021) are avoided.

In addition, the proposed two-view AT can be extended by incorporating two-view representation in a previous supervised AT (Zhang et al., 2019) to build a new variant of self-supervised AT as well as in implementation of a robust self-supervised text embedding. For example, the adversarial attack δ in the previous method called TRADES (Zhang et al., 2019) was generated by maximizing the Kullback-Leibler (KL) divergence between fθe(x) and fθe(x+δ). Then, the image encoder parameter in a supervised AT framework was estimated by minimizing:

(18)

where λ is a regularization parameter. A robust image encoder was trained in a supervised setting where C-dimensional one-hot target matrix of classifier y was given. This study presents an approach to bridge supervised and self-supervised AT. In particular, a new self-supervised TRADES is proposed and extended by solving:

(19)

where two views of augmented data {tw(x),ts(x)} via anchor and class samples {Zanch,Zcls} are adopted to enhance the instance discrimination, respectively. The perturbation is therefore generated by using PGD attack:

(20)

A self-supervised TRADES is obtained from supervised TRADES by simply replacing WZcls and setting y˜=IB.

This study further presents a self-supervised AT method to build a robust text representation. In the implementation, first the latent class samples for individual instances in a mini-batch x={xi}D consisting of words or sentences are calculated by:

(21)

using an encoder fθp with a dropout rate p. The first view of training data is then formed via strong data augmentation ts(·). This view does contain positive and negative samples for instance discrimination which are used for CL. To enhance the consistencies in instance discrimination, a B-way classification problem is formulated to simulate a SL task by considering the weakly augmented samples tw(·) or simply original samples. The latent anchor inputs Zanch=(fθ(x1),,fθ(xB)) using the encoder without dropout are used to form a second view to predict the corresponding classes for individual instances xi as given in class matrix Zcls. Accordingly, a new CL is proposed to simulate an SL task via enriching the instance discrimination by replacing the classification layer WZcls, specifying the target matrix y˜=IB and separating the views of anchor Zanch and positive/negative class samples Zcls. The problem turns out to find the optimal encoder fθ or encoder with dropout fθp based on two views of latent samples from the same original samples x. The resulting solution aims to estimate an informative encoder to distinguish individual samples {xi} or latent instances {zi} mutually based on two different views Zanch and Zcls without and with dropout in encoder, respectively. The CE loss LCE between targets y˜ and the logits y^, which are calculated by softmax function using the dot product of Zanch and Zcls (as shown in Figure 6), is minimized.

More importantly, this new CL is fulfilled to implement AT for a defense text model. From our investigation, this is the first AT framework developed for sentence embedding in self-supervised setting where the encoder θ and the perturbation δ are jointly trained. A minimax optimization problem is formulated according to the same objective for instance discrimination in two-view CL via encoder without (fθ) and with (fθp) dropout via:

(22)

where the worst-case perturbations δ={δi} for a mini-batch of samples x={xi} with maximal CE loss LCE are first calculated and then added to the word embeddings x to estimate the optimal encoder θ with minimum CE loss. The resulting encoder is robust to the worst-case perturbation δ. Figure 8 shows the proposed self-supervised AT procedure, which is a direct extension from standard supervised AT in Figure 2 and two-view self-supervised AT in Figure 7. Basically, the adversarial perturbation can be generated by using the proposed self-supervised FGSM attack:

(23)
Figure 8.
A workflow combines attack generation and model training using word embeddings, dropout, anchor and class features, cross-entropy loss and adversarial perturbations.The diagram contains Attack Generation and Model Training stages. Input x is represented as word embeddings and passes through f theta. One path uses no dropout to produce anchor features f theta of x. Another path uses dropout p to produce class features z cls. A dot product combines the anchor and class features. Softmax produces output logits y hat, which are compared with targets y tilde using cross-entropy loss L C E. Delta i is calculated using epsilon sign of the gradient of L C E with respect to x i. Delta is added to x to create x plus delta. The perturbed embeddings pass through f theta with no dropout to produce anchor features f theta of x plus delta. These anchor features are combined with the same class features by dot product. Softmax produces another set of output logits y hat, which are compared with the same targets using L C E. The gradient of L C E with respect to theta is used to update f theta.

Self-supervised adversarial training for sentence embedding by using two-view samples without and with dropout

Figure 8.
A workflow combines attack generation and model training using word embeddings, dropout, anchor and class features, cross-entropy loss and adversarial perturbations.The diagram contains Attack Generation and Model Training stages. Input x is represented as word embeddings and passes through f theta. One path uses no dropout to produce anchor features f theta of x. Another path uses dropout p to produce class features z cls. A dot product combines the anchor and class features. Softmax produces output logits y hat, which are compared with targets y tilde using cross-entropy loss L C E. Delta i is calculated using epsilon sign of the gradient of L C E with respect to x i. Delta is added to x to create x plus delta. The perturbed embeddings pass through f theta with no dropout to produce anchor features f theta of x plus delta. These anchor features are combined with the same class features by dot product. Softmax produces another set of output logits y hat, which are compared with the same targets using L C E. The gradient of L C E with respect to theta is used to update f theta.

Self-supervised adversarial training for sentence embedding by using two-view samples without and with dropout

Close modal

By augmenting the adversarial anchor representation fθ(x+δ) which is obtained via an encoder without dropout, the proposed AT method bridges the supervised and self-supervised AT and compensates the mismatch of adversarial examples between training and test phases.

Further investigation over recent works on improving ACL is addressed from the perspectives of data augmentation and model regularization. In Luo et al. (2023a), a dynamic augmentation scheme was proposed to build a DynACL which compensated the gap due to the inconsistency between strong and weak augmentations in CL and AT, respectively, through an annealing schedule for augmentation strengths. In Xu et al. (2023b), DynACL was further improved by imposing a causal graph to enforce the style-independence and fulfill the AIR in the learned model DynACL-AIR. The robustness in DynACL was enhanced by minimizing an AIR loss. Another approach (Zhang et al., 2022) aimed to decouple the problem in ACL into two-stage sub-problems for a non-robust CL and a pseudo-supervised AT where an efficient solution was implemented. In Xu et al. (2023a), the tremendous running time in ACL was mitigated through a robustness-aware coreset selection which was feasible to run on a large-scale data set. The resulting method was performed by minimizing the representation divergence between natural samples and adversarial variants to assure the robustness transferability (RT). In Wang et al. (2023), the adversarial robustness was enhanced by a contrastive distillation via an adaptive denoising module. Typically, this paper presents a new two-view CL (Figure 6) and a new two-view AT (Figures 7 and 8) where the inconsistencies due to class definition and augmentation bias in previous CL and AT are addressed through an instance discrimination task based on anchor features and class features from two individual views of augmented data. To the best of the authors’ knowledge, this study provides one of the first unified analyses of class-definition inconsistency and augmentation mismatch in self-supervised AT.

The proposed method was examined for image and text representations where the tasks of image classification and sentence embedding were evaluated, respectively. The enhanced instance discrimination was implemented for CL and self-supervised AT.

This paper conducted the evaluation on image classification over CIFAR-10 and CIFAR-100 data sets where each data set had 50 K training images and 10 K test images with a size of 32 × 32 × 3. To ensure fair comparison and reproducibility, all experiments are conducted under a unified training protocol unless otherwise specified:

  • Backbone architecture. For image representation, we adopt ResNet-18 (He et al., 2016; Chien and Chang, 2023) as the encoder fθ following standard practice in CL. For text representation, we use a transformer-based encoder initialized from a pre-trained BERT-base model (Devlin et al., 2019).

  • Training configuration. All models are trained using the Adam optimizer with an initial learning rate of 3×104, momentum 0.9, weight decay 0.001 and temperature τ=0.5. The learning rate is decayed using a cosine annealing schedule. The batch size (B) is set to 256 for image experiments and 128 for text experiments. The models are trained for 800 epochs for image data sets and 200 epochs for text data sets by using the stochastic gradient descent algorithm. No ground-truth labels are used in self-supervised settings. Pseudo-labels are not used unless explicitly stated.

  • Adversarial attack settings. We adopt the PGD as the adversarial attack method. For image data, the perturbation is bounded by an l-norm constraint with ϵ=8/255. The number of PGD steps is set to K=20 with a step size of α=2/255, which is known as strong attacks. For text representation, adversarial perturbations are applied in the embedding space with norm constraint ϵ=1.0.

  • Data augmentation. For image experiments, the strong random cropping and resizing, random horizontal flip, random color jitter and grayscale conversion were run to find class samples Xcls or ts(x) while the weak random cropping and resizing and random horizontal flip were done to find anchor samples Xanch or tw(x). For text experiments, the weak augmentation was run by using dropout rate pw either 0 or 0.1 while the strong augmentation was done by using ps either 0.2 or 0.3, where each sentence is passed through the encoder twice with independent dropout masks.

In the experiments on image classification, a three-layer projection head was added for CL. An ensemble of parameter-free attack, called AutoAttack (Croce and Hein, 2020), was included in the evaluation. The standard linear evaluation setting was implemented. The trained encoder was fixed and a linear classifier was trained on top of encoder by using the labeled data. The experimental results were compared with current self-supervised AT methods under consistent setting including RoCL (Kim et al., 2020), ACL (Jiang et al., 2020), AdvCL (Fan et al., 2021) and DynACL (Luo et al., 2023a) where the solutions were all developed via CL. The effect of AIR with details in Xu et al. (2023b) was evaluated. The cross-task adversarial and common-corruption (Hendrycks and Dietterich, 2019) RT from pretraining using CIFAR-10 to finetuning using CIFAR-100 was examined. Different methods were further accessed in terms of memory usage and computation time where a personal computer with CPU Intel Xeon E5-2620 v4, RAM 32 G and GPU Tesla V100S was used in the experiments.

The experimental setting in evaluation of sentence embedding followed that in SimCSE (Gao et al., 2021). The semantic textual similarity (STS) between two sentence embeddings was evaluated by using seven STS data sets including STS12 to STS16 (Agirre et al., 2016), STS Benchmark (STSB) (Cer et al., 2017) and SICK-Relatedness (SICKR) (Marelli et al., 2014). The Spearman’s rank correlation was used as the evaluation metric. The CLS token in BERT was extracted as the sentence representation. The model was trained by using 106 randomly sampled sentences from English Wikipedia the same as those used in SimCSE (Gao et al., 2021). The model was evaluated every 125 training steps on development set to assure the best performance checkpoint. There was no additional regressor on top of encoder. In this comparative study, the results of sentence encoders from the previous supervised methods (Reimers and Gurevych, 2019; Li et al., 2020a; Su et al., 2021) and self-supervised methods (Carlsson et al., 2021; Yan et al., 2021; Kim et al., 2021; Gao et al., 2021) were included.

4.2.1 Comparison over contrastive learning and adversarial training.

First of all, the robust accuracy (RA) (%) on attack test images (PGD), standard accuracy (SA) (%) on clean test images, memory usage and training time (CIFAR-10) using SimCLR (Chen et al., 2020), RoCL (Kim et al., 2020), ACL (Jiang et al., 2020), AdvCL (Fan et al., 2021), DynACL (Luo et al., 2023a) and the proposed self-supervised AT are compared in Table 2. This comparison shows the performance of implementing a contrastive view in AT via equations (15) and (19) to carry out a new self-supervised AT and a new self-supervised TRADES, respectively. The proposed TRADES was implemented by merging the new contrastive view in Zhang et al. (2019) for original TRADES. Among different methods, CL using SimCLR is highly affected by attacks and performs the worst. The proposed AT performs better than RoCL and ACL on CIFAR-10 and CIFAR-100 in terms of RA. It is worth noting that the accuracy on attack data (RA) is much more important than that on clean data (SA) for adversarial defense. This is because in a real-world situation one will not know whether the input sample is attacked. RA can be seen as a worst-case guarantee of accuracy assuming all input data are attacked. Notably, the proposed AT (K=5) with RA 51.15% even outperforms AdvCL with RA 50.25% on CIFAR-10 where AdvCL additionally used the PLs and extra model architecture. The computation time and memory cost are even reduced by using the proposed AT. It is further found that RAs in two tasks are degraded when the batch size B is reduced to 256. The memory and computation costs are decreased as well. In addition, similar to AdvCL, the proposed AT and TRADES are implemented by using PLs. The resulting RA is therefore increased to 52.52%. In case of CIFAR-100, the highest RA 27.62% is obtained by using the proposed self-supervised TRADES via equation (19). This result without using PLs is comparable with that of AdvCL where PL is required. The SOTA result 28.05% is obtained by using the proposed TRADES with PLs. This is because CIFAR-100 involves more classes, and the resulting performance would be more likely benefited by the KL term in TRADES, which regularizes the entire output probability instead of simply learning from hard labels. When using the proposed TRADES, the time and memory complexities are lower than those of baseline AdvCL.

Table 2.

Comparison of the results for CL and different self-supervised AT methods. The methods in the bottom-half used the pseudo labels (PLs) (Fan et al., 2021)

CIFAR-10CIFAR-100
MethodsRASARASAMemory (MB)Time
SimCLR*0.0391.770.4866.866,4097.7 h
RoCL* (K=7)39.9378.3718.7949.5319,1012 d 9 h
ACL*44.2379.0420.9747.5111,6492d 2.1 h
DynACL*46.8279.1023.2147.2012,0232d 2.6 h
Ours (AT, K=3)48.7479.3426.4947.066,40920 h
Ours (TRADES)50.2177.4927.6248.968,6771 d 12.4 h
Ours (AT, B=512)51.1576.9027.2145.126,4091 d 4.6 h
Ours (AT, B=256)50.5576.3327.1045.085,9891 d 1.8 h
AdvCL (Fan et al., 2021)50.4580.8527.6748.3420,8753 d
AdvCL*50.2580.5827.1247.79
Ours (TRADES) + PL51.2980.8928.0548.4611,4072 d 9 h
Ours (AT) + PL52.5280.3628.0148.058,9852 d 0.6 h
Note(s):

*Indicates our results. The highest RAs (%) are italic. Memory and computationcosts are evaluated

4.2.2 Comparison over self-supervised adversarial training methods.

In addition, Table 3 shows RA and SA of the proposed self-supervised AT, and the new AT by incorporating the proposed contrastive view in TRADES under different hyperparameter λ as well as in the helper-based adversarial training (HAT) (Rade and Moosavi-Dezfooli, 2022). The main goal of the proposed HAT is to increase SA in a self-supervised AT setting. The highest SA among all of AT variants is obtained by using the proposed self-supervised HAT. By increasing λ in the TRADES loss, the model robustness is increased but the SA is decreased. This is consistent with the effect observed in the original TRADES (Zhang et al., 2019). The control over λ enables us to achieve a higher SA while still maintaining a good robustness. This investigation reveals that CL viewpoint does develop the new AT variants while maintaining the benefits and characteristics from their original AT.

Table 3.

Comparison of RA (%) and SA (%) of using the proposed methods based on the self-supervised TRADES under different λ, self-supervised HAT and self-supervised AT where CIFAR-10 was used

Methods RASAλ
Ours (TRADES)48.6778.836
49.3678.6712
49.7878.1516
50.0478.5218
50.2177.4920
Ours (HAT)50.3979.98
Ours (AT)51.1578.90

A key benefit of using contrastive view in the proposed AT is its intuition, simplicity and consistency. Owing to two perspectives in a hybrid CL and AT objective, the memory requirement is the same as that of the original SimCLR (Chen et al., 2020). The memory consumption is substantially reduced when compared with the other methods, and is even lower than one third of the memory relative to that used in AdvCL. Similar results are obtained in the metric of training time. Training time of the proposed self-supervised AT is generally smaller than or equal to half of the existing methods. The proposed AT with three attack iterations K=3 can reduce the training time while its RA is still higher than those using RoCL and ACL. Such a result reflects the robustness in presence of PGD attack as it can generate the challenging attacks for AT even with the reduced attack iterations. Overall, Figure 9 depicts the memory cost in GB versus the training time in seconds per epoch while RAs using different methods are shown. In this comparison, the proposed self-supervised AT or AT+PL obtains higher accuracies but smaller memory cost and computation time.

Figure 9.
A scatter plot compares training time, memory and labelled scores for five methods, including Ours and Ours plus P L.The scatter plot compares time in seconds per training epoch on the horizontal axis with memory in gigabytes on the vertical axis. Five methods are plotted. R o C L has a labelled score of 39.93 and appears at high memory with moderately high training time. A C L has a score of 44.23 and appears at intermediate memory and training time. A d v C L with P L has a score of 50.25 and appears at the highest memory and longest training time. Ours has a score of 51.15 and appears at the lowest memory and shortest training time. Ours plus P L has a score of 52.52 and appears at lower memory and intermediate training time.

RA (%) versus computation time (in seconds per epoch) and memory cost (in gigabytes) by using different self-supervised AT methods where CIFAR-10 was used

Figure 9.
A scatter plot compares training time, memory and labelled scores for five methods, including Ours and Ours plus P L.The scatter plot compares time in seconds per training epoch on the horizontal axis with memory in gigabytes on the vertical axis. Five methods are plotted. R o C L has a labelled score of 39.93 and appears at high memory with moderately high training time. A C L has a score of 44.23 and appears at intermediate memory and training time. A d v C L with P L has a score of 50.25 and appears at the highest memory and longest training time. Ours has a score of 51.15 and appears at the lowest memory and shortest training time. Ours plus P L has a score of 52.52 and appears at lower memory and intermediate training time.

RA (%) versus computation time (in seconds per epoch) and memory cost (in gigabytes) by using different self-supervised AT methods where CIFAR-10 was used

Close modal

4.2.3 Ablation study.

To analyze the contributions of individual components, we conduct an ablation study with the results as shown in Table 4. Starting from the baseline CL model, introducing AT via RoCL (Kim et al., 2020) significantly improves the robustness but degrades the SA. Reformulating the contrastive objective in CE loss as a classification problem using equation (10) improves the representation quality with slight robustness gain. Combining both CE loss and the proposed AT loss via equation (15) yields a clear improvement in robustness, indicating the compatibility of the classification perspective with adversarial optimization. Aligning augmentation strategies stabilizes the training and improves both standard and robust performance. Finally, an additional loss based on an AIR (Xu et al., 2023b) is merged to achieve the best trade-off, demonstrating the effectiveness of the complete framework.

Table 4.

Ablation study on the proposed self-supervised adversarial training, which is integrated by cross entropy reformulation in equation (10), adversarial training in equation (15), augmentation alignment in equation (15) and adversarial invariant regularization (AIR) in Xu et al. (2023b) where CIFAR-10 was used

Methods CE reform.ATAug align.AIRRASA
SimCLR baseline××××0.0391.77
+ AT (RoCL)× ✓××39.9378.37
+ CE reformulation ✓×××40.9877.42
+ CE + AT (ours (15)) ✓ ✓××48.3576.34
+ CE + AT + aug alignment ✓ ✓ ✓×51.1576.90
+ CE + AT + aug alignment + AIR ✓ ✓ ✓ ✓53.0577.21

In general, AT is performed to pursue robust features holding the perturbation invariance as illustrated in Figure 10. In this study, the image data in latent representation using the trained encoder are visualized via t-distributed neighbor embedding. Figure 11 shows two-dimensional (2D) visualizations of the learned representations of clean images fθ(x) (blue dots) and the corresponding adversarial images fθ(x+δ) (orange dots). The image samples of class “cat” on CIFAR-10 are displayed. The trained image encoder using SimCLR (Chen et al., 2020) in Figure 11(a) and the proposed self-supervised AT in Figure 11(b) are compared. It can be seen that CL encoder via SimCLR is susceptible to attack samples so that the clean and attack samples are mapped into different points in latent space. Using the proposed AT, the encoder is learned to hold the invariant property in presence of ambient attack or perturbation. Thus, the resulting classifier is able to classify attack images as good as their original images. The blue and orange dots are mostly overlapping since the proposed model views them as the same, and is accordingly robust to attacks or perturbation noises. For quantitative evaluation, this study calculates the relative invariance ρ, which is defined as an inverse ratio of the accumulated distances between clean and attack samples for those latent samples of a method relative to SimCLR. The higher the value ρ, the more invariant or robust the adversarial samples obtained by the learned encoder fθ. This study compares 2D latent spaces by using the learned image encoders according to different self-supervised AT methods. Relative to CL encoder in Figure 11(a), four AT encoders in Figure 12 have higher overlapping between clean and attack samples which means better robustness. In this comparison, RoCL has the largest number of visible orange dots or sensitive attack images, which results in the lowest RAs in Table 2. The proposed AT obtained the highest relative invariance ρ=2.01 among different methods.

Figure 10.
A diagram of adversarial training bringing latent representations of x 1, x 2 and x 3 closer to their perturbed counterparts.The diagram contains x 1, x 2 and x 3, with perturbed inputs x 1 plus delta 1, x 2 plus delta 2 and x 3 plus delta 3. All inputs pass through f theta into a latent representation space. The upper region contains f theta x 1, f theta x 2 and f theta x 3, each separated from its corresponding perturbed representation. Double-headed arrows connect each pair. An arrow labelled Adversarial Training leads to a second region. In this region, each f theta x input is positioned close to its corresponding f theta x plus delta representation.

Illustration of perturbation invariance for the features after defense model fθ through adversarial training

Figure 10.
A diagram of adversarial training bringing latent representations of x 1, x 2 and x 3 closer to their perturbed counterparts.The diagram contains x 1, x 2 and x 3, with perturbed inputs x 1 plus delta 1, x 2 plus delta 2 and x 3 plus delta 3. All inputs pass through f theta into a latent representation space. The upper region contains f theta x 1, f theta x 2 and f theta x 3, each separated from its corresponding perturbed representation. Double-headed arrows connect each pair. An arrow labelled Adversarial Training leads to a second region. In this region, each f theta x input is positioned close to its corresponding f theta x plus delta representation.

Illustration of perturbation invariance for the features after defense model fθ through adversarial training

Close modal
Figure 11.
Two scatter plots compare adversarial and clean samples for Sim C L R with rho 1 and Ours with rho 2.01.The visual contains two scatter plots. Panel a is labelled Sim C L R with rho 1. Adversarial and clean samples are widely dispersed and heavily intermixed across the plot. Panel b is labelled Ours with rho 2.01. Clean samples form a dense, regular central distribution, while fewer adversarial samples appear within and around it.

2D latent visualizations by using (a) SimCLR and (b) the proposed AT. Blue and orange dots represent clean and attack images of class “cat” on CIFAR-10, respectively. The values of relative invariance ρ are shown in brackets

Figure 11.
Two scatter plots compare adversarial and clean samples for Sim C L R with rho 1 and Ours with rho 2.01.The visual contains two scatter plots. Panel a is labelled Sim C L R with rho 1. Adversarial and clean samples are widely dispersed and heavily intermixed across the plot. Panel b is labelled Ours with rho 2.01. Clean samples form a dense, regular central distribution, while fewer adversarial samples appear within and around it.

2D latent visualizations by using (a) SimCLR and (b) the proposed AT. Blue and orange dots represent clean and attack images of class “cat” on CIFAR-10, respectively. The values of relative invariance ρ are shown in brackets

Close modal
Figure 12.
Four scatter plots compare point distributions for R o C L, A C L, A d v C L and Ours at different rho values.The visual contains four scatter plots. Panel a is labelled R o C L with rho 1.45. Points are broadly dispersed, with a denser concentration near the centre and many overlapping points. Panel b is labelled A C L with rho 1.75. Points form a broad distribution with a dense central region and scattered overlapping points. Panel c is labelled A d v C L with rho 1.89. Points form a regular dense distribution with additional overlapping points and a concentrated group extending towards the lower region. Panel d is labelled Ours with rho 2.01. Points form a regular, broadly distributed pattern with fewer overlapping points scattered throughout.

Comparison of latent representations by using (a) RoCL, (b) ACL, (c) AdvCL and (d) the proposed AT on CIFAR-10. Clean (blue) and attack (orange) images and the resulting relative invariance ρ are shown

Figure 12.
Four scatter plots compare point distributions for R o C L, A C L, A d v C L and Ours at different rho values.The visual contains four scatter plots. Panel a is labelled R o C L with rho 1.45. Points are broadly dispersed, with a denser concentration near the centre and many overlapping points. Panel b is labelled A C L with rho 1.75. Points form a broad distribution with a dense central region and scattered overlapping points. Panel c is labelled A d v C L with rho 1.89. Points form a regular dense distribution with additional overlapping points and a concentrated group extending towards the lower region. Panel d is labelled Ours with rho 2.01. Points form a regular, broadly distributed pattern with fewer overlapping points scattered throughout.

Comparison of latent representations by using (a) RoCL, (b) ACL, (c) AdvCL and (d) the proposed AT on CIFAR-10. Clean (blue) and attack (orange) images and the resulting relative invariance ρ are shown

Close modal

The adversarial robustness using different methods is further evaluated across two different data sets transferred from CIFAR-10 as a pretraining task to CIFAR-100 as a finetuning task (CIFAR-10 → CIFAR-100) under the settings of cross-task adversarial and common-corruption (Hendrycks and Dietterich, 2019) RT. Fifteen types of common corruptions with corruption severity (CS) ranging from {1,3,5} (CS-1, CS-3, CS-5) were adopted with details in Hendrycks and Dietterich (2019) and Xu et al. (2023b). The adversarial full finetuning (Luo et al., 2023a; Li et al., 2023) was performed in a way where the weights in a pre-trained encoder in a source task were used as the initialized weights to train the whole model in a target task by using adversarial data. In addition to the evaluation of RA (%) under PGD attack, this study compares different methods in terms of accuracy under AutoAttack (Croce and Hein, 2020) (denoted as AA [%]). In this set of comparison, an additional AIR loss (Xu et al., 2023b) was minimized to enforce independence from style factors for adversarial invariance in fulfillment of ACL-AIR, DynACL-AIR (Xu et al., 2023b) and ours-AIR where ACL (Jiang et al., 2020), DynACL (Luo et al., 2023a) and the proposed AT were performed, respectively. Table 5 reports different accuracies over different methods under various RT settings. It is found that dynamic data augmentation in DynACL improves the results of ACL under two cases of cross-task RT evaluation. AIR loss for regularization increases the accuracies. The proposed two-view AT with anchor and class features consistently performs better than ACL and DynACL under two RT settings.

Table 5.

Comparison of different accuracies (%) by using different methods where cross-task adversarial (Adv) and common-corruption (CC) (Hendrycks and Dietterich, 2019) robustness transferability (RT) in CIFAR-10 → CIFAR-100 is evaluated

MethodsAdv-RTCC-RT
AARASACS-1CS-3CS-5
ACL*23.3630.8757.0052.6545.1236.46
ACL-AIR*24.2331.4457.2453.0945.9637.70
DynACL*25.0732.1356.4353.8845.7737.13
DynACL-AIR*25.6332.6258.1054.4546.9038.24
Ours (AT)26.3133.6158.4955.6247.7339.26
Ours-AIR (AT)27.6835.2259.7557.1049.0540.80

The generalizability of adversarial robustness is further investigated toward realistic settings in presence of imbalanced data and small data as illustrated in Table 6. This paper adopted CIFAR-100-LT (Wu et al., 2021) and CIFAR-FS (Goldblum et al., 2020; Dong et al., 2025), constructed from CIFAR-100, as the data sets to evaluate different defense models under long-tailed distribution and few-shot condition, respectively. AIR loss was merged in our TRADES and our AT. The effect of various batch sizes B is evaluated. The settings of CIFAR-100-LT follow (Wu et al., 2021) and ours in CIFAR-100. Again, robust accuracies under AutoAttack (AA) and PGD attack (20 steps) (RA) and SA are reported. Using CIFAR-100-LT, the imbalance rate was set by 10 (Wu et al., 2021). The results of using RoCL (Kim et al., 2020), ACL (Jiang et al., 2020), TRADES (Zhang et al., 2019) and the robust balanced predictions (RoBal), obtained in (Wu et al., 2021), are included for comparison with those of using our TRADES and our AT. It is found that our AT obtains desirable robust accuracies in presence of AutoAttack and PGD attacks although SA of our AT is not as good as that of RoBal. Our two-view TRADES performs better than previous TRADES (Zhang et al., 2019). In addition, the five-way five-shot setting in CIFAR-FS is adopted to assess the effect of adversarial perturbations in few-shot learning (Goldblum et al., 2020). For comparison, a recent method to adversarially robust few-shot learning based on feature purification (FP) and cyclic reconstruction (Dong et al., 2025) is included. Our previous settings in CIFAR-100 are used. In this evaluation, our two-view AT achieves the highest SA with B=128 and the highest robust accuracies under AutoAttack and PGD attack with B=64 and B=128, respectively. These accuracies are higher than those of FP.

Table 6.

Comparison of different accuracies (%) by using defense methods where the conditions of imbalanced data and few shots are evaluated by using CIFAR-100-LT and CIFAR-FS, respectively. TRADES (Zhang et al., 2019; Wu et al., 2021) is supervised while our TRADES in section 3.5 is self-supervised

MethodsImbalanced dataFew shots
AARASAAARASA
RoCL*15.9418.0944.8636.6443.0458.13
ACL*16.8618.4645.4839.9645.4358.73
TRADES (Wu et al., 2021)18.7921.2443.82
TRADES*18.0421.1245.0442.8447.9457.96
Our (TRADES)19.1422.1848.7445.6149.3459.34
RoBal (Wu et al., 2021)18.8019.5950.49
FP (Dong et al., 2025)46.2949.9059.75
Ours (AT, B=256)21.0623.4049.8946.5251.5160.84
Ours (AT, B=128)20.4322.9650.3247.0352.2062.70
Ours (AT, B=64)19.1220.8450.1247.8150.4259.94

The proposed self-supervised AT is further evaluated for sentence embedding. Table 7 shows the results of the proposed method and compares them with the previous methods under supervised and unsupervised settings across different data sets. Results of Spearman’s rank correlation are shown. The higher the correlation value, the better the sentence embedding. The strong augmentation, working well for image encoder, is here applied for text encoder. Strong augmentation in SimCSE was implemented by using a strong dropout by increasing dropout rate p to 0.2. The proposed CL via enhancing the instance discrimination is therefore implemented to carry out a new SimCSE through Algorithm 1. The proposed SimCSE performs better than original SimCSE in most of STS tasks. The consistent implementation of CL view in Section 3.3 does improve the performance of CL. The proposed SimCSE performs better than the previous unsupervised methods, and even achieves higher score than supervised baselines by using sentence BERT (SBERT) (Reimers and Gurevych, 2019) and the advanced post-processing techniques on top of SBERT such as SBERT-flow (Li et al., 2020a) and SBERT-whitening (Su et al., 2021). The improvement was obtained by holding the consistencies in class definition and augmentation bias between CL and AT, which could build a robust model to generalize in test phase.

Table 7.

Comparison of Spearman’s rank correlation on the proposed method without/with AT compared to the previous methods. The last four rows show our results.Supervised (S) and unsupervised (U) settings were evaluated on STS datasets

Methods S/USTS12STS13STS14STS15STS16STSBSICKRAvg.
SBERT (Reimers and Gurevych, 2019)S70.9776.5373.1979.0974.3077.0372.9174.89
SBERT-flow (Li et al., 2020a)S69.7877.2774.3582.0177.4679.1276.2176.60
SBERT-whitening (Su et al., 2021)S69.6577.5774.6682.2778.3979.5276.9177.00
BERT (Devlin et al., 2019)U39.7059.3849.6766.0366.1953.8762.0656.70
CT-BERT (Carlsson et al., 2021)U61.6376.8068.4777.5076.4874.3169.1972.05
ConSERT (Yan et al., 2021)U64.6478.4969.0779.7275.9573.9767.3172.74
SG-BERT (Kim et al., 2021)U66.8480.1371.2381.5677.1777.2368.1674.62
SimCSE (Gao et al., 2021)U68.4082.4174.3880.9178.5676.8572.2376.25
SimCSE*U67.3881.2973.1580.9578.0177.0470.3575.45
Ours (SimCSE, p=0.2)U68.7980.8373.3881.6078.9278.2072.8976.37
Ours (SimCSE, pw=0.1,ps=0.2)U70.3080.9773.3382.0579.3578.8871.6976.65
Ours (SimCSE, pw=0,ps=0.3)U70.1981.9773.9681.7279.2478.2871.8176.74
Ours (AT, pw=0,ps=0.3)U71.6782.4574.3282.9280.0279.9573.2977.80

Next, looking at the results by using the proposed AT relative to those of previous CL methods including BERT (Devlin et al., 2019), CT-BERT (Carlsson et al., 2021), ConSERT (Yan et al., 2021), SG-BERT (Kim et al., 2021) and SimCSE (Gao et al., 2021), it is meaningful that the proposed two-view self-supervised AT via pw and ps can improve the performance by using the adversarial sentence encoder. In average, the proposed self-supervised AT even performs better than the advanced post processing method via whitening (SBERT-whitening) (Su et al., 2021) which is seen as the supervised SBERT (Reimers and Gurevych, 2019). This is because that AT is capable of improving the model by using adversarial or worst-case examples in the training. Similar to standard data augmentation, these examples improve the representation by enhancing the model generalization. The proposed AT performs better than the proposed SimCSE with one view via p and with two views via pw and ps.

In addition, Table 8 shows the Spearman’s rank correlation of different methods on the validation set and test set where STSB data set (Cer et al., 2017) was used. In the experiments, since the final checkpoint is selected based on the best performance of the validation set, such a saved checkpoint is fitted to the set but the overfitting problem may likely occur. When investigating the difference between the performance on validation and test sets, it is found that the proposed SimCSE can reduce the difference between the results on two sets and accordingly alleviate the effect of overfitting. Using the proposed AT, such an effect is further released as the performance gap between two sets is reduced. This effect coincides with that found in the first work (Miyato et al., 2017) on using AT in different natural language tasks.

Table 8.

Top-10 similar sentences given a query sentence

Query: gray cat looking out the window (STSB data set)
BERT1. A cat looking out of a window
2. Two cats are looking at a window
3. Black and white dog in living room standing on…
4. A rooster pecks at a dead mouse
5. A black dog running along the edge of the ocean
6. A brown dog squatting on grass
7. A dog closes a refrigerator door
8. A black and white cat laying on the ground in the…
9. A man looks out the window
10. Cow walking under the tree in a pasture
SBERT1. A cat looking out of a window
2. A cat, perched on a table, looks out the window
3. The cat is standing on the window sill looking…
4. A man looks out the window
5. The sheep is standing under the trees
6. The white train is sitting on the tracks
7. A small black and white goat in a pen looking up…
8. Two cats are looking at a window
9. The train is riding on the tracks in the snow
10. Close up of a white sheep with a black head
Ours (SimCSE)1. A cat is rubbing against a baby
2. A cat looking out of a window
3. A cat is playing with a camera
4. A cat is playing on the floor
5. A cat and a boy play together
6. A tiger is walking around
7. A brown dog running through the grass
8. A grey cat with green eyes looking into the camera
9. A cat is licking a small bottle
10. A black and white cat playing with a blanket
Ours (AT)1. A cat looking out of a window
2. A cat is playing on the floor
3. A cat is playing with a camera
4. A cat is rubbing against a baby
5. A cat and a boy play together
6. The cat teased the dog by touching his head
7. A cat is playing
8. A grey cat with green eyes looking into the camera
9. A cat looking at the camera
10. A person throws a cat on the ceiling

The performance of sentence embedding is further demonstrated by Table 9 where ten most similar sentences given a query sentence “Gray cat looking out the window” are shown by using BERT (Devlin et al., 2019), SBERT (Reimers and Gurevych, 2019) and the proposed SimCSE and AT. The semantically related words are marked by blue. Generally, using BERT, SBERT and the proposed SimCSE, there are four, five and eight sentences related to the subject of query sentence with the important word “cat.” It can be seen that the proposed self-supervised AT retrieves top-10 similar sentences which are all related to the query sentence. In combination with the dropout p=0.2 on both anchor and class features, the perspective of viewing CL as a classification task is implemented in the proposed SimCSE. Relative to SimCSE, applying perturbations for two views pw=0 and ps=0.3 on anchor and class features for CL, respectively, by using the proposed AT does obtain the improvement.

Table 9.

Comparison of Spearman’s rank correlation on validation and test sets, and their difference on STSB dataset

MethodsValidation setTest setDifference
SimCSE (Gao et al., 2021)82.0977.04−5.05
Ours (SimCSE)82.9278.88−4.04
Ours (AT)83.7879.95−3.83

This paper extends the experiments on text representation by evaluating the classification accuracy using two-view CL and two-view AT under the other adversarial perturbations such as TextFooler (Jin et al., 2020) and BERT-Attack (Li et al., 2020b). Table 10 shows the results of RA and SA by using different methods where sentiment classification tasks using Yelp and IMDB (Jin et al., 2020; Li et al., 2020b) are evaluated under the attacks of TextFooler and BERT-Attack. In this evaluation, the experimental settings and the BERT results (Devlin et al., 2019) of these two tasks under two different attacks are referred to those in Jin et al. (2020) and Li et al. (2020b). The results of using CL based on SimCSE (Gao et al., 2021), two-view CL based on our SimCSE with pw=0,ps=0.3 and two-view AT based on our AT with pw=0,ps=0.3 are included in the comparison. The settings of CL, two-view CL and two-view AT are the same as those of sentence embedding. It is found that two-view CL and two-view AT considerably increase RA under two different attacks in two different tasks when compared with baseline BERT and standard CL although the highest standard accuracies in two tasks are obtained by SimCSE. The highest robust accuracies are consistently achieved by using the proposed two-view AT.

This paper has presented the connection between the instance discrimination in CL and the classification task in SL, which aims to address potential inconsistencies of class definition in instance discrimination for CL and distribution view in data augmentation between CL and AT. Using this CL framework, a unified perspective for self-supervised AT was exploited. CL was reformulated as a self-supervised classification task. The instance discrimination was enhanced and extended to carry out the self-supervised variant of AT from an existing supervised AT method. A new CL was also developed. The experiments on image classification, sentence embedding and sentiment classification showed that the proposed AT achieved competitive results on robust performance while considerably reducing the time and memory complexities. The resulting sentence encoder in self-supervised mode even outperformed the other supervised methods. This paper works toward a unified solution for supervised and self-supervised AT. The scalability of implementing the proposed method needs further study in the future.

Table 10.

Comparison of RA (%) and SA (%) using BERT, SimCSE, two-view CL (our SimCSE) and two-view AT (our AT) under adversarial perturbations of TextFooler and BERT-Attack. Yelp and IMDB datasets are evaluated

PerturbationsMethodsYelpIMDB
RASARASA
TextFooler (Jin et al., 2020)BERT (Devlin et al., 2019; Li et al., 2020b)6.695.613.690.9
SimCSE (Gao et al., 2021)7.996.415.792.0
Ours (SimCSE)20.395.123.888.3
Ours (AT)35.394.539.387.9
BERT-Attack (Li et al., 2020b)BERT (Devlin et al., 2019; Li et al., 2020b)5.111.4
SimCSE (Gao et al., 2021)6.713.7
Ours (SimCSE)18.420.4
Ours (AT)31.935.3

Jen-Tzung Chien is currently the Lifetime Chair Professor in National Yang Ming Chiao Tung University, Taiwan. He has authored more than 300 peer-reviewed articles in machine learning, natural language processing and computer vision, and three books including Bayesian Speech and Language Processing, Cambridge University Press, 2015, Source Separation and Machine Learning, Academic Press, 2018, and Machine Learning for Speaker Recognition, Cambridge University Press, 2020. He was a Tutorial Speaker of AAAI, IJCAI, ACL, MM, KDD, ICASSP, CIKM, WSDM, COLING and Interspeech. He received the Best Paper Award in the IEEE Workshop on Automatic Speech Recognition and Understanding in 2011, and the IEEE International Workshop on Machine Learning for Signal Processing in 2023. He serves as an Elected Member of the IEEE Machine Learning for Signal Processing Technical Committee and the IEEE Speech and Language Processing Technical Committee, and the Associate Editor of the IEEE Transactions on Audio, Speech and Language Processing.

Yuan-An Chen received his BS and MS degrees from National Taiwan University of Science and Technology and National Yang Ming Chiao Tung University in 2019 and 2021, respectively, both in electrical and computer engineering. His interests include adversarial learning, contrastive learning and image representation.

Agirre
,
E.
,
Banea
,
C.
,
Cer
,
D.
,
Diab
,
M.
,
Gonzalez-Agirre
,
A.
,
Mihalcea
,
R.
,
Rigau
,
G.
and
Wiebe
,
J.
(
2016
), “
SemEval-2016 task 1: semantic textual similarity, monolingual and cross-lingual evaluation
”,
Proc. of International Workshop on Semantic Evaluation
, pp.
397
-
511
.
Carlini
,
N.
and
Wagner
,
D.A.
(
2017
), “
Towards evaluating the robustness of neural networks
”,
Proc. of IEEE Symposium on Security and Privacy
, pp.
39
-
57
.
Carlsson
,
F.
,
Gyllensten
,
A.C.
,
Gogoulou
,
E.
,
Hellqvist
,
E.Y.
and
Sahlgren
,
M.
(
2021
), “
Semantic re-tuning with contrastive tension
”,
Proc. of International Conference on Learning Representations
, pp.
1
-
21
.
Cer
,
D.
,
Diab
,
M.
,
Agirre
,
E.
,
Lopez-Gazpio
,
I.
and
Specia
,
L.
(
2017
), “
SemEval-2017 task 1: semantic textual similarity multilingual and crosslingual focused evaluation
”,
Proc. of International Workshop on Semantic Evaluation
, pp.
1
-
14
.
Chen
,
T.
,
Kornblith
,
S.
,
Norouzi
,
M.
and
Hinton
,
G.
(
2020
), “
A simple framework for contrastive learning of visual representations
”,
Proc. of International Conference on Machine Learning
, pp.
1597
-
1607
.
Chien
,
J.T.
and
Chang
,
S.T.
(
2023
), “
Bayesian asymmetric quantized neural networks
”,
Pattern Recognition
, Vol.
139
, p.
109463
.
Chien
,
J.T.
and
Chen
,
Y.A.
(
2024
), “
Towards a unified view of adversarial training: a contrastive perspective
”,
Proc. of IEEE International Conference on Acoustics, Speech and Signal Processing
, pp.
5365
-
5369
.
Chien
,
J.T.
and
Chen
,
C.C.
(
2026
), “
Contrastive mixture diffusion models
”,
IEEE Transactions on Pattern Analysis and Machine Intelligence
, pp.
1
-
12
.
Chien
,
J.T.
and
Sun
,
W.Y.
(
2023
), “
Adversarial augmentation for adapter learning
”,
Proc. of IEEE Automatic Speech Recognition and Understanding Workshop
, pp.
1
-
7
.
Chien
,
J.T.
,
Rohmatillah
,
M.
and
Chu
,
C.T.
(
2025
), “
Strategic optimization for worst-case augmentation and classification
”,
IEEE Transactions on Audio, Speech and Language Processing
, Vol.
33
, pp.
111
-
123
.
Chien
,
J.T.
,
Wang
,
H.T.
and
Lee
,
C.H.
(
2024a
), “
Contrastive meta learning for soft prompts using dynamic mixup
”,
Proc. of International Joint Conference on Neural Networks
, pp.
1
-
6
.
Chien
,
J.T.
,
Yeh
,
I.P.
and
Mak
,
M.W.
(
2024b
), “
Collaborative contrastive learning for hypothesis domain adaptation
”,
Proc. of Annual Conference of International Speech Communication Association
, pp.
3225
-
3229
.
Croce
,
F.
and
Hein
,
M.
(
2020
), “
Reliable evaluation of adversarial robustness with an ensemble of diverse parameter-free attacks
”,
Proc. of International Conference on Machine Learning
, pp.
2206
-
2216
.
Devlin
,
J.
,
Chang
,
M.
,
Lee
,
K.
and
Toutanova
,
K.
(
2019
), “
BERT: pretraining of deep bidirectional transformers for language understanding
”,
Proc. of North American Chapter of the Association for Computational Linguistics
, pp.
4171
-
4186
.
Dong
,
J.
,
Wang
,
Y.
,
Xie
,
X.
,
Lai
,
J.
and
Ong
,
Y.S.
(
2025
), “
Generalizable and discriminative representations for adversarially robust fewshot learning
”,
IEEE Transactions on Neural Networks and Learning Systems
, Vol.
36
No.
3
, pp.
5480
-
5493
.
Fan
,
L.
,
Liu
,
S.
,
Chen
,
P.Y.
,
Zhang
,
G.
and
Gan
,
C.
(
2021
), “
When does contrastive learning preserve adversarial robustness from pretraining to finetuning?
”,
Advances in Neural Information Processing Systems
, pp.
21480
-
21492
.
Gan
,
C.X.
,
Mak
,
M.W.
,
Lin
,
W.
and
Chien
,
J.T.
(
2024
), “
Asymmetric clean segments-guided self-supervised learning for robust speaker verification
”,
Proc. of IEEE International Conference on Acoustics, Speech and Signal Processing
, pp.
11081
-
11085
.
Gao
,
T.
,
Yao
,
X.
and
Chen
,
D.
(
2021
), “
SimCSE: simple contrastive learning of sentence embeddings
”,
Proc. of Conference on Empirical Methods in Natural Language Processing
, pp.
6894
-
6910
.
Gao
,
J.
,
Lanchantin
,
J.
,
Soffa
,
M.L.
and
Qi
,
Y.
(
2018
), “
Black-box generation of adversarial text sequences to evade deep learning classifiers
”,
Proc. of IEEE Security and Privacy Workshops
, pp.
50
-
56
.
Goldblum
,
M.
,
Fowl
,
L.
and
Goldstein
,
T.
(
2020
), “
Adversarially robust few-shot learning: a meta-learning approach
”,
Advances in Neural Information Processing Systems
, Vol.
33
, pp.
17886
-
17895
.
He
,
K.
,
Zhang
,
X.
,
Ren
,
S.
, and
Sun
,
J.
(
2016
), “
Deep residual learning for image recognition
”,
Proc. of IEEE Conference on Computer Vision and Pattern Recognition
, pp.
770
-
778
.
Hendrycks
,
D.
and
Dietterich
,
T.
(
2019
), “
Benchmarking neural network robustness to common corruptions and perturbations
”,
Proc. of International Conference on Learning Representations
, pp.
1
-
16
.
Jiang
,
Z.
,
Chen
,
T.
,
Chen
,
T.
and
Wang
,
Z.
(
2020
), “
Robust pre-training by adversarial contrastive learning
”,
Advances in Neural Information Processing Systems
, pp.
16199
-
16210
.
Jin
,
D.
,
Jin
,
Z.
,
Zhou
,
J.T.
and
Szolovits
,
P.
(
2020
), “
Is BERT really robust? A strong baseline for natural language attack on text classification and entailment
”,
Proc. of AAAI Conference on Artificial Intelligence
, pp.
8018
-
8025
.
Kim
,
M.
,
Tack
,
J.
and
Hwang
,
S.J.
(
2020
), “
Adversarial self-supervised contrastive learning
”,
Advances in Neural Information Processing Systems
, pp.
2983
-
2994
.
Kim
,
T.
,
Yoo
,
K.M.
and
Lee
,
S.G.
(
2021
), “
Self-guided contrastive learning for BERT sentence representations
”,
Proc. of Annual Meeting of the Association for Computational Linguistics
, pp.
2528
-
2540
.
Kurakin
,
A.
,
Goodfellow
,
I.J.
and
Bengio
,
S.
(
2018
), “Adversarial examples in the physical world”,
Artificial Intelligence Safety and Security
,
Chapman and Hall/CRC
, pp.
99
-
112
.
Li
,
L.
,
Mak
,
M.W.
and
Chien
,
J.T.
(
2022
), “
Contrastive adversarial domain adaptation networks for speaker recognition
”,
IEEE Transactions on Neural Networks and Learning Systems
, Vol.
33
No.
5
, pp.
2236
-
2245
.
Li
,
L.
,
Ma
,
R.
,
Guo
,
Q.
,
Xue
,
X.
and
Qiu
,
X.
(
2020b
), “
BERT-ATTACK: adversarial attack against BERT using BERT
”, Proc
of Conference on Empirical Methods in Natural Language Processing
, pp.
6193
-
6202
.
Li
,
Z.
,
Yu
,
D.
,
Wu
,
M.
,
Jin
,
C.
and
Yu
,
H.
(
2023
), “
Adversarial supervised contrastive learning
”,
Machine Learning
, Vol.
112
no No.
6
, pp.
2105
-
2130
.
Li
,
B.
,
Zhou
,
H.
,
He
,
J.
,
Wang
,
M.
,
Yang
,
Y.
and
Li
,
L.
(
2020a
), “
On the sentence embeddings from pre-trained language models
”, Proc
of Conference on Empirical Methods in Natural Language Processing
, pp.
9119
-
9130
.
Lin
,
J.K.
,
Liu
,
H.W.
,
Kew
,
W.C.
and
Chien
,
J.T.
(
2026
), “
Adversarial contrastive retrieval-augmented generation
”,
Proc. of IEEE International Conference on Acoustics, Speech and Signal Processing
, pp.
18667
-
18671
.
Lio
,
H.
,
Li
,
S.E.
and
Chien
,
J.T.
(
2022
), “
Adversarial mask transformer for sequential learning
”,
Proc. of IEEE International Conference on Acoustics, Speech and Signal Processing
, pp.
4178
-
4182
.
Luo
,
R.
,
Wang
,
Y.
and
Wang
,
Y.
(
2023a
), “
Rethinking the effect of data augmentation in adversarial contrastive learning
”,
Proc. of International Conference on Learning Representations
, pp.
1
-
17
.
Luo
,
X.
,
Ju
,
W.
,
Gu
,
Y.
,
Mao
,
Z.
,
Liu
,
L.
,
Yuan
,
Y.
and
Zhang
,
M.
(
2023b
), “
Self-supervised graph-level representation learning with adversarial contrastive learning
”,
ACM Transactions on Knowledge Discovery from Data
, Vol.
18
, No.
2
, pp.
1
-
23
.
Madry
,
A.
,
Makelov
,
A.
,
Schmidt
,
L.
,
Tsipras
,
D.
and
Vladu
,
A.
(
2018
), “
Towards deep learning models resistant to adversarial attacks
”,
Proc. of International Conference on Learning Representations
, pp.
1
-
23
.
Marelli
,
M.
,
Menini
,
S.
,
Baroni
,
M.
,
Bentivogli
,
L.
,
Bernardi
,
R.
and
Zamparelli
,
R.
(
2014
), “
A SICK cure for the evaluation of compositional distributional semantic models
”,
Proc. of International Conference on Language Resources and Evaluation
, pp.
216
-
223
.
Miyato
,
T.
,
Dai
,
A.M.
and
Goodfellow
,
I.
(
2017
), “
Adversarial training methods for semi-supervised text classification
”,
Proc. of International Conference on Learning Representations
, pp.
1
-
11
.
Pan
,
L.
,
Hang
,
C.W.
,
Sil
,
A.
and
Potdar
,
S.
(
2022
), “
Improved text classification via contrastive adversarial training
”,
Proc. of AAAI Conference on Artificial Intelligence
, pp.
11130
-
11138
.
Rade
,
R.
and
Moosavi-Dezfooli
,
S.M.
(
2022
), “
Reducing excessive margin to achieve a better accuracy vs. robustness trade-off
”,
Proc. of International Conference on Learning Representations
, pp.
1
-
21
.
Reimers
,
N.
and
Gurevych
,
I.
(
2019
), “
Sentence-BERT: sentence embeddings using Siamese BERT-networks
”, Proc
of Conference on Empirical Methods in Natural Language Processing
, pp.
3982
-
3992
.
Shafahi
,
A.
,
Najibi
,
M.
,
Ghiasi
,
M.A.
,
Xu
,
Z.
,
Dickerson
,
J.
,
Studer
,
C.
,
Davis
,
L.S.
,
Taylor
,
G.
and
Goldstein
,
T.
(
2019
), “
Adversarial training for free!
”,
Advances in Neural Information Processing Systems
, pp.
3358
-
3369
.
Su
,
J.
,
Cao
,
J.
,
Liu
,
W.
and
Ou
,
Y.
(
2021
), “
Whitening sentence representations for better semantics and faster retrieval
”,
arXiv preprint 2103.15316
.
Sun
,
R.
,
Chen
,
L.
,
Liao
,
T.
and
Fan
,
Z.
(
2025
), “
Self-supervised polarization image dehazing method via frequency domain generative adversarial networks
”,
Pattern Recognition
, Vol.
165
.
Tu
,
Y.
,
Mak
,
M.W.
and
Chien
,
J.T.
(
2020
), “
Variational domain adversarial learning with mutual information maximization for speaker verification
”,
IEEE/ACM Transactions on Audio, Speech, and Language Processing
, Vol.
28
, pp.
2013
-
2024
.
Tu
,
Y.
,
Mak
,
M.W.
and
Chien
,
J.T.
(
2024
), “
Contrastive self-supervised speaker embedding with sequential disentanglement
”,
IEEE/ACM Transactions on Audio, Speech, and Language Processing
, Vol.
32
, pp.
2704
-
2715
.
Wang
,
Y.
,
Chen
,
Z.
,
Yang
,
D.
,
Liu
,
Y.
,
Liu
,
S.
,
Zhang
,
W.
and
Qi
,
L.
(
2023
), “
Adversarial contrastive distillation with adaptive denoising
”,
Proc. of IEEE International Conference on Acoustics, Speech and Signal Processing
, pp.
1
-
5
.
Wong
,
E.
,
Rice
,
L.
and
Kolter
,
J.Z.
(
2020
), “
Fast is better than free: revisiting adversarial training
”,
Proc. of International Conference on Learning Representations
, pp.
1
-
17
.
Wu
,
Z.
,
Xiong
,
Y.
,
Yu
,
S.X.
and
Lin
,
D.
(
2018
), “
Unsupervised feature learning via non-parametric instance discrimination
”,
Proc. of IEEE Conference on Computer Vision and Pattern Recognition
, pp.
3733
-
3742
.
Wu
,
T.
,
Liu
,
Z.
,
Huang
,
Q.
,
Wang
,
Y.
and
Lin
,
D.
(
2021
), “
Adversarial robustness under long-tailed distribution
”,
Proc. of IEEE/CVF Conference on Computer Vision and Pattern Recognition
, pp.
8659
-
8668
.
Xu
,
X.
,
Zhang
,
J.
,
Liu
,
F.
,
Sugiyama
,
M.
and
Kankanhalli
,
M.
(
2023a
), “
Efficient adversarial contrastive learning via robustness-aware corset selection
”,
Advances in Neural Information Processing Systems
, pp.
75798
-
75825
.
Xu
,
X.
,
Zhang
,
J.
,
Liu
,
F.
,
Sugiyama
,
M.
and
Kankanhalli
,
M.
(
2023b
), “
Enhancing adversarial contrastive learning via adversarial invariant regularization
”,
Advances in Neural Information Processing Systems
, pp.
16783
-
16803
.
Yan
,
Y.
,
Li
,
R.
,
Wang
,
S.
,
Zhang
,
F.
,
Wu
,
W.
and
Xu
,
W.
(
2021
), “
Con-SERT: a contrastive framework for self-supervised sentence representation transfer
”,
Proc. of Annual Meeting of the Association for Computational Linguistics
, pp.
5065
-
5075
.
Yu
,
H.
and
Dai
,
Q.
(
2024
), “
Self-supervised multi-task learning for medical image analysis
”,
Pattern Recognition
, Vol.
150
, p.
110327
.
Zhang
,
R.
,
Tang
,
S.
and
Cao
,
J.
(
2024a
), “
Self-supervised adversarial training via diverse augmented queries and self-supervised double perturbation
”,
Advances in Neural Information Processing Systems
, pp.
43788
-
43808
.
Zhang
,
H.
,
Yu
,
Y.
,
Jiao
,
J.
,
Xing
,
E.
,
Ghaoui
,
L.E.
and
Jordan
,
M.
(
2019
), “
Theoretically principled trade-off between robustness and accuracy
”,
Proc. of International Conference on Machine Learning
, pp.
7472
-
7482
.
Zhang
,
Y.
,
Zhu
,
R.
,
Zhang
,
S.
,
Zhou
,
X.
,
Chen
,
S.
and
Chen
,
X.
(
2024b
), “
Feature augmentation for self-supervised contrastive learning: a closer look
”,
Proc. of International Joint Conference on Neural Networks
.
Zhang
,
C.
,
Zhang
,
K.
,
Zhang
,
C.
,
Niu
,
A.
,
Feng
,
J.
,
Yoo
,
C.D.
and
Kweon
,
I.S.
(
2022
), “
Decoupled adversarial contrastive learning for self supervised adversarial robustness
”,
Proc. of European Conference on Computer Vision
, pp.
725
-
742
.
Zhu
,
C.
,
Cheng
,
Y.
,
Gan
,
Z.
,
Sun
,
S.
,
Goldstein
,
T.
and
Liu
,
J.
(
2020
), “
FreeLB: enhanced adversarial training for natural language understanding
”,
Proc. of International Conference on Learning Representations
.
Published by Emerald Publishing Limited. This article is published under the Creative Commons Attribution (CC BY 4.0) licence. Anyone may reproduce, distribute, translate and create derivative works of this article (for both commercial and non-commercial purposes), subject to full attribution to the original publication and authors. The full terms of this licence may be seen at Link to the terms of the CC BY 4.0 licenceLink to the terms of the CC BY 4.0 license.

or Create an Account

Close Modal
Close Modal