SUTNLP at SemEval-2023 Task 10: RLAT-Transformer for explainable online sexism detection
Year: 2023

Abstract:
There is no simple definition of sexism, but it can be described as prejudice, stereotyping, or discrimination, especially against women, based on their gender. In online interactions, sexism is relatively rare but still harmful. One out of ten American adults says that they have been harassed because of their gender and have been the target of sexism, so sexism is a growing issue. The Explainable Detection of Online Sexism shared task in SemEval-2023 aims at building sexism detection systems for the English language. In order to address the problem, we use large language models such as RoBERTa and DeBERTa. In addition, we present a novel method called Random Layer Adversarial Training (RLAT) for transformers which is based on adversarial training, and show its impact on boosting all subtasks’ scores. Moreover, we use other discriminative and generalization techniques for subtask A to boost performance. Using our methods to make predictions over subtask A, B, and C test sets, we obtained macro-F1 of 84.45, 67.78, and 52.52 respectively, outperforming proposed baselines on all subtasks. Our code is publicly available on Github.1

heading: 1 Introduction
text: Sexism refers to any negative, abusive, or discriminatory behavior, attitude, or language that targets individuals based on their gender, particularly women, and involves prejudice, stereotyping, or discrimination (Kirk et al., 2023). In essence, sexism encompasses any negative, abusive, or discriminatory behavior or attitude that targets women based on their gender or a combination of their gender with other identity characteristics such as race, religion, or gender identity, for instance, black women, Muslim women, or trans women (Kirk et al., 2023). The internet is a breeding ground
1https://github.com/SUTNLP/RLAT-Transformer
for sexism, with approximately one in ten American adults reporting that they have been harassed due to their gender, and have experienced sexist behavior (Swim et al., 2001).
In order to promote a fair and inclusive online environment, it is vital to acknowledge and combat sexism on online platforms because of their significant scale, extensive reach, and powerful influence.2
Sexism poses a growing problem in the online environment, and its consequences can be severe, such as making online spaces inaccessible and perpetuating social injustices. To address this issue, various automated tools have been deployed to detect and assess sexist content. Nonetheless, most of these tools only provide generic classifications without further explanation. Identifying sexist content and explaining why it is offensive will increase an automated tool’s interpretability, trustworthiness, and understanding of its decisions. This, in turn, will empower both users and moderators to make informed decisions and create a fair and inclusive online environment (Kirk et al., 2023). The aim of the SemEval-2023 Explainable Detection of Online Sexism shared task is to develop and implement sexism detection systems for the English language (Kirk et al., 2023).
In order to deal with the problem, we use large language models such as RoBERTa (Liu et al., 2019) and DeBERTa (He et al., 2020). We introduce a novel method called Random Layer Adversarial Training (RLAT) based on famous adversarial training and demonstrate that it has a positive impact on boosting performance across all subtasks. To the best knowledge of the authors, this is the first research using random layers of a network for adversarial training.
As part of subtask A, we also use virtual adver-
2https://www.theguardian. com/commentisfree/2015/dec/16/ online-sexism-social-media-debate-abuse
347
sarial training and contrastive learning to improve the model’s performance.
In subtask A, our team ranked 18th out of 84 teams, in subtask B, 9th out of 69 teams, and in subtask C, we ranked 6th out of 63 teams. In subtasks A and B, we outperform baseline methods by a substantial margin, and in subtask C, we outperform baseline by a large margin using the RLAT. Several experiments were conducted to examine the effect of the RLAT on the current task.

heading: 2 Background

heading: 2.1 Related Work
text: Due to the widespread prevalence of sexism in online communication, the automated detection of online sexism has become an increasingly important area of research. Various machine learning models have been proposed for detecting sexism in online texts, such as tweets, comments, and other forms of online communication (Waseem and Hovy, 2016; Davidson et al., 2017). These models have been evaluated and compared in terms of their accuracy and performance. Some other studies, such as Bolukbasi et al. (2016); Sun et al. (2019) have also examined the potential for gender bias in these models and put forth strategies to address it. Rodríguez-Sánchez et al. (2020) proposed the use of deep learning approaches to detect sexist attitudes and stereotypes in tweets. Samory et al. (2021a) focused on construct validity and reliability in sexism detection. Ghosh Chowdhury et al. (2019) creates a dataset for detection of personal recollections of sexual harassment from tweets. They further tested several models on their dataset. In other research, Parikh et al. (2019) introduced a dataset consisting of accounts of sexism in 23 categories to investigate sexism categorization as a multi-label classification task.

heading: 2.2 EDOS task
text: The task of EDOS comprises three hierarchical subtasks:
• SUBTASK A - Binary Sexism Detection involves a two-class (or binary) classification, where the goal of the system is to predict whether a given post is sexist or not sexist.
• SUBTASK B - Category of Sexism which involves a four-class classification for sexist posts: threats, derogation, animosity, and prejudiced discussions
• SUBTASK C - Fine-grained Vector of Sexism task involves a classification of 11 classes for posts that contain sexism, where systems are required to predict one of the 11 fine-grained vectors.

heading: 2.3 Preliminaries
text: In this sub-section, we will give a brief introduction to the methods and approaches we used for our text classification system.

heading: 2.3.1 Large Pre-trained Language Models
text: Recent research demonstrates that pre-trained language models, such as the transformers approach, are effective in text classification (Fallah et al., 2022). The BERT model has emerged as a popular state-of-the-art model in recent years (Devlin et al., 2018). This language model is capable of handling NLP tasks, including text classification (GonzálezCarvajal and Garrido-Merchán, 2020).
Transformer models have become the most effective neural network architecture for neural language modeling. A new model architecture known as DeBERTa (Decoding-enhanced BERT with disentangled attention) improves the BERT and RoBERTa models using two novel techniques. The first is the disentangled attention mechanism, where each token is represented using two vectors that encode its content and position, respectively. The attention weights among tokens are computed using disentangled matrices of their contents and relative positions, respectively. Second, an enhanced mask decoder is used to incorporate absolute positions in the decoding layer to predict the masked tokens in model pre-training (He et al., 2020).

heading: 2.3.2 Adversarial Training
text: A machine learning technique known as adversarial training aims to increase the robustness and generalization of a model by training it on adversarial examples. These are inputs deliberately designed to cause misclassification or errors. As a result, perturbations to the input data are generated and added to the training set in order to create a more challenging and diverse set of data (Goodfellow et al., 2014). In recent years, adversarial training has gained popularity in the field of natural language processing (NLP) for text classification tasks (Miyato et al., 2016), which applied adversarial training to improve the performance of semi-supervised text classification models. The method has been applied to a variety of NLP applications, including
sentiment analysis, spam detection, topic modeling, hate speech, and sexism detection. Some notable works in this area include Iyyer et al. (2018), which proposed a method for generating syntactically controlled adversarial examples for text classification, Wu et al. (2017a), which demonstrated the effectiveness of adversarial training for improving the robustness of relation extraction models, and Zhu et al. (2021) which used adversarial training to make the BERT model more robust and generalized. Zhu et al. (2019) showed the impact of adversarial training on boosting the performance of several benchmarks. Vidgen et al. (2021) proposed a human-and-model-in-the-loop process for dynamically generating datasets through teaching annotators to generate adversarial examples of hate which is challenging for current models to discern. Further they trained more effective and robust hate detection models. Kirk et al. (2022) built a dataset using adversarial examples. They showed that models trained on this dataset perform significantly better at detection of emoji-based hate compared to previous methods while retaining good performance at detection of text-only hate. Samory et al. (2021b) generated adversarial examples from annotated datasets to test sexism detection models’ reliability.

heading: 2.3.3 Virtual Adversarial Training
text: Adversarial training is a technique used to improve the robustness of supervised learning algorithms by adding perturbations to the input data. On the other hand, virtual adversarial training extends supervised learning algorithms to semi-supervised settings by generating adversarial examples in the unlabeled data space. In other words, while adversarial training focuses on regularizing supervised learning algorithms, virtual adversarial training leverages both labeled and unlabeled data to enhance the performance of these algorithms in semisupervised settings. Recent studies have demonstrated that virtual adversarial training has achieved state-of-the-art results in various benchmark semisupervised tasks (Miyato et al., 2016). This approach has also been utilized in various machine learning applications, including supervised and semi-supervised learning (Miyato et al., 2019), as well as sequence labeling (Chen et al., 2020a).

heading: 2.3.4 Contrastive Learning
text: A popular method for learning embedding spaces is contrastive learning, which ensures that pairs of
data samples with similar labels are represented closely and pairs with dissimilar labels are represented at a greater distance. In supervised or unsupervised settings, it can produce task-specific or general-purpose representations using different loss functions (Zhang et al., 2022). This technique has previously been used in research to perform various specific tasks such as learn sentence embeddings (Gao et al., 2021; Fang et al., 2020), classify text by producing better text representations using contrastive samples (Du et al., 2021), and to solve hierarchical text classification problems (Wang et al., 2022).

heading: 3 System Overview
text: Overall we developed our models based on large pre-trained language models and random layer adversarial training. Subtask A is built on random layer adversarial training, virtual adversarial training and contrastive learning. Subtasks B and C are solved similarly and are dependent only on random layer adversarial training. So we describe our system in two different sections.

heading: 3.1 Subtask A

heading: 3.1.1 Base Transformer
text: As the base transformer for this subtask, we use RoBERTa-Large. To calculate the loss of each batch of training data, we employ cross-entropy loss. Considering the imbalance of the training dataset, sample-based loss weighting was adopted to overcome this issue by weighting samples based on the inverse ratio of their class frequency in the training dataset. Using LCE , we present crossentropy loss in Equation 5.

heading: 3.1.2 Random Layer Adversarial Training
text: Several researchers in the field of NLP have used adversarial training to enhance generalization of their model. These reseraches mostly apply adversarial training to the embedding layer (Zhu et al., 2021; Liu et al., 2020; Wang et al., 2019; Zhu et al., 2019; Cui et al., 2022a; Lu et al., 2022). Sankaranarayanan et al. (2018) shows intermediate layers could be quite effective in further regularization and boost of performance for adversarial training to be applied to.
Through experiments on development data, we observe that a random layer perturbation method works best for the current task. In order to do that we devise an algorithm called Random Layer Adversarial Training (RLAT) which employs different
random layers to which adversarial training is applied. Suppose the i-th dense layer of network is denoted by Hi and word embedding layer is denoted by WE . According to the Equation 1, in each batch a random layer is uniformly selected for adversarial training. The selected random layer is denoted by AL.
AL = Uniform({H1, · · · , HL,WE}) (1)
The RLAT method tries to find the optimal parameters θ∗ by minimizing the maximum possible adversarial perturbation δ to the outputs of a random layer, inside a norm ball of ϵ which is stated as follows:
θ∗ = argmin θ
ED,U {
max δ:∥δ∥≤ϵ L(fθ(X + δ), Y )
}
(2) In Equation 2, network parameters are denoted by θ, D and U are dataset distribution and the uniform distribution on random layer selection respectively. X is the random layer output and Y represents the label. fθ is the network function and L represents the loss function. K-projected gradient descent (K-PGD) (Madry et al., 2017) is adopted to train the network using adversarial training. K is a hyperparameter which is tuned using development data.

heading: 3.1.3 Virtual Adversarial Training (VAT)
text: To further boost the transformer’s generalization capability, VAT is adopted as another objective in the training process of our model. We use an algorithm which is developed based on VAT called SMART (Jiang et al., 2019). SMART is applied to the embedding layer. We denote the loss of VAT by LVAT .
Virtual adversarial training adds a perturbation to the input and minimizes the distance between the output of the original input and the output of the perturbed input. The perturbation is added in a way so that the distance between the two outputs is maximized. Contrary to adversarial training, this method does not use label information. According to Miyato et al. (2019), virtual adversarial loss can be formulated like Equation 3.
LVAT = D[fθ(X), fθ(X + δvadv)]
s.t. δvadv = argmax δ:∥δ∥≤ϵ
D[fθ(X), fθ(X + δ)] (3)
In Equation 3, X is the input, fθ and θ are the function and parameters of the network respectively, D is a distance metric, δvadv is the perturbation and, ϵ is the a constraint for the maximum 2-norm of the perturbation.

heading: 3.1.4 Contrastive Training (CON)
text: We employ contrastive training to further boost the discrimination power of our model. (Cui et al., 2022b) shows that contrastive training is effective when applied to the last hidden layer of the network. Kaku et al. (2021) shows that contrastive training could also be effective when applied to intermediate layers beside the final layer. Following Kaku et al. (2021), we use contrastive training not only to the final layer but also to some intermediate layers. We do this by applying NT-XENT loss (Chen et al., 2020b) to the hidden representation of the last L hidden layers of the transformer. According to the NT-XENT loss, if samples with indices of i and j have the same label in a batch, their contrastive loss is computed by the Equation 4, where lij denotes the contrastive loss and 2N is the size of batch. L is a hyperparameter which is tuned using development data. The overall contrastive loss is denoted by LCON .
lij = exp(sim(zi, zj)/τ)∑2N
k=1 1[k ̸=i] exp(sim(zi, zk)/τ) (4)

heading: 3.1.5 Overall
text: To train the transformer for each batch all losses including LCE , LRAT , LVAT , and LCON are calculated and the total loss of LT is calculated using Equation 5. λ1, λ2, and λ3 are hyperparameters that are tuned using development data.
LT = LCE+λ1LRLAT+λ2LVAT+λ3LCON (5)

heading: 3.2 Subtasks B and C
text: DeBERTa-v3-Large is used as the transformer for both subtasks. We adopt the RLAT as described in 3.1.2 alongside cross-entropy for both subtasks. The total loss for both subtasks B and C is computed as follows:
LT = LCE + LRLAT (6)

heading: 4 Experimental Setup

heading: 4.1 Dataset and Evaluation
text: According to the organizers, the dataset consists of 20,000 samples where each sample is a comment collected from Reddit or Gab (Kirk et al., 2023). Each sample is tagged by three annotators. For subtask A, when the annotators’ votes are unanimous in favour of one label, this is taken as the gold label. If there is any disagreement, one of the experts reviews the entry and decides the gold label. For subtasks B and C, when at least two annotators agree on a label, this is taken as the gold label but in cases of 3-way disagreement, one of the experts decides the gold label (Kirk et al., 2023). The number of train, development and test set samples are shown in Table 1 for each subtask.
For subtask A, a comment is given and the objective is to classify it as sexist or not sexist. For subtasks B and C, a sexist comment is given and the objective is to classify the comment as one of the sexist categories. Datasets for subtasks B and C are highly unbalanced presenting a new challenge for our method to handle. Figures 2c and 2b present the sample count of each class in subtasks B and C respectively (names of labels in figures are reduced to the first number of classes to avoid using too much space). In subtask B, the ratio of the most frequent class to the least frequent is approximately 5 and for subtask C, this ratio is much severe and is about 14. This obviously indicates that as we dig deeper into subtasks, not only are there fewer data for each class, but the data imbalance worsens as well. There are 2, 4, and 11 classes for subtasks A, B, and C respectively (Kirk et al., 2023).
To estimate the performance of the system, the organizers employ macro-F1 score as the main metric for all subtasks (Kirk et al., 2023).

heading: 4.2 Parameter Settings
text: We use Huggingface3 transformer models and their respective checkpoints. For all subtasks,
3https://huggingface.com/
AdamW (Loshchilov and Hutter, 2017) algorithm is adopted as the optimization algorithm. For each subtask we adopt early stopping with patience of 4 and after training the model checkpoint with the best performance on development set is used for prediction on test set. All of the later mentioned hyperparameters are set using development set for each subtask.

heading: 4.2.1 Choice of Base Transformers
text: The base transformer for each subtask is chosen between RoBERTa-Large and DeBERTa-Large. The choice is based on the performance of the base transformer on the development data of each subtask. Consequently RoBERTa-Large is adopted for subtask A and DeBERTa-v3-Large is adopted for subtasks B and C.

heading: 4.2.2 Subtask A
text: We train for 10 epochs. Learning rate is set to 4e−6 and the weight decay is 1e− 2, L is set to 4. K is set to 2 for PGD. λ1 is set to 1, λ2 and λ3 are set to 0.5 and 0.4 respectively.

heading: 4.2.3 Subtask B
text: We train the model for 30 epochs. Learning rate is set to 1e− 5 and weight decay is 9e− 3, K is set to 2 for PGD.

heading: 4.2.4 Subtask C
text: We train the model for 30 epochs. Learning rate is set to 6e− 6 and weight decay is 7e− 3, K is set to 4 for PGD.

heading: 5 Results

heading: 5.1 Model Performance
text: As the organizers of the task have not proposed a baseline, for each subtask we set the base transformer of the subtask with only cross-entropy loss as the baseline method for the subtask. Hence RoBERTa-Large is used for subtask A baseline and DeBERTa-v3-Large is used for subtasks B and C baselines. All of the following results are based on the test data.
Results of subtask A are shown in Table 2. All of RLAT, VAT, and CON contribute positively to boost the performance of the model. As can be seen excluding any of them results in a drop in performance. RLAT contributes most to the boost as its exclusion has the largest drop. Tables 3 and 4 provide results of subtask B and C, respectively. It is evident that adding RLAT has a huge effect on
the performance of both subtasks. Further, confusion matrices for subtasks A, B, and C are depicted in Figure 2. In the confusion matrix of subtask B, we observe that the model is unable to accurately
discriminate between classes 2 (Derogation) and 3 (Animosity). A closer look at the confusion matrix of subtask C reveals more information. As we see a significant portion of samples with label 3.2 (Immutable gender stereotypes) are classified as class 2.1 (Descriptive attacks), and a huge portion of samples with label 2.2 (Aggressive and emotive attacks) are classified as class 3.1 (Casual use of gendered slurs, profanities insults).

heading: 5.2 RLAT Analysis
text: In order to better understand the RLAT method, here we try to analyze it. The results for the RLAT method are shown in Table 5. Many researchers use the embedding layer to conduct adversarial training with transformers (Dong et al., 2020; Wu et al., 2017b; Ju et al., 2019; Zhu et al., 2021; Liu et al., 2020; Wang et al., 2019; Zhu et al., 2019; Cui et al., 2022a; Lu et al., 2022). To this end we compare the RLAT method with the method in which Adversarial Training (AT) is applied only to the embedding layer. For subtask B, when adversarial training is applied to the embedding layer, our model experiences a −0.3% drop in Macro-F1 score in comparison to the baseline. When RLAT is applied our model experiences a +1.08% gain in Macro-F1 score compared to the baseline. For subtask C, our model with RLAT experiences a +7.12% gain in Macro-F1 score in comparison to the baseline which is higher by +3.91% compared to the case when AT is applied to the embedding layer. This analysis shows the superiority of using RLAT in comparison to conventional AT.

heading: 6 Conclusion
text: This paper presents SUTNLP’s submission to SemEval-2023 Task 10 "Explainable Detection of Online Sexism” competition. To solve this problem, we use transformers and further propose Random Layer Adversarial Training (RLAT) to boost the performance of the base models by large margins. We conducted experiments to show the superiority of RLAT compared to conventional adversarial training used in NLP for the current task. For all subtasks, the performance of the model is evaluated by macro-F1. Using macro-F1 criteria, appending the RLAT to base transformers shows gains of 1.08% in Macro-F1 and 7.12% Macro-F1 for subtasks B and C respectively. In the future, we intend to analyse the RLAT method to determine how it performs on other NLP tasks and further
improve it.

heading: Future Work
text: In the future, we intend to analyse the RLAT method to determine how it performs on other NLP tasks and further
improve it