IUST_NLP at SemEval-2023 Task 10: Explainable Detecting Sexism with Transformers and Task-adaptive Pretraining
Year: 2023

Abstract:
This paper describes our system on SemEval2023 Task 10: Explainable Detection of Online Sexism (EDOS). This work aims to design an automatic system for detecting and classifying sexist content in online spaces. We propose a set of transformer-based pre-trained models with task-adaptive pretraining and ensemble learning. The main contributions of our system include analyzing the performance of different transformer-based pre-trained models and combining these models, as well as providing an efficient method using large amounts of unlabeled data for model adaptive pretraining. We have also explored several other strategies. On the test dataset, our system achieves F1-scores of 83%, 64%, and 47% on subtasks A, B, and C, respectively.

heading: 1 Introduction
text: Discriminatory views against women in online environments can be extremely harmful so in recent years it has become a serious problem in social networks. Identifying online sexism involves many challenges because sexist discrimination and misogyny have different types and appear in different forms. Therefore, the aim of the EDOS shared task (Kirk et al., 2023) is to develop Englishlanguage models for detecting sexism. These models should be more accurate and explainable and include detailed classifications for sexist content from Gab and Reddit. This task covers a wide range of sexist content and aims to distinguish different types of sexist content. There are three hierarchical subtasks within the task:
• SubTask A: Binary Sexism Detection. This subtask involves a binary classification problem, where the goal is to determine whether a given post is sexist or non-sexist using predictive systems.
• SubTask B: Category of Sexism. When classifying sexist posts, a four-class classification system is used, where the predictive systems are tasked with identifying one of the following categories: (1) threats, (2) derogation, (3) animosity, or (4) prejudiced discussions.
• SubTask C: Fine-grained Vector of Sexism. When dealing with sexist posts, a fine-grained classification approach is utilized, where predictive systems are required to assign one of 11 specific vectors to each post.
In this paper, we describe our system for three subtasks. First, we used some models based on transformers. These models are fine-tuned for classification and in addition, they are used by adding classification components in the upper layer. We have also created a model by combining several transformer-based models and adding a classification layer and using it in all three subtasks as ensemble learning. We then built a task-adaptive model to adapt it to our specific domain. We trained this model on a large unlabeled dataset and fine-tuned it on labeled data for all subtasks. For all three subtasks, we used cross-entropy loss for multi-class classification. Our best system was able to achieve an F1-score of 83% (subtask A), 64% (subtask B), and 47% (subtask C) on the test dataset.

heading: 2 Background
text: Detecting and addressing sexist content in online spaces has emerged as a significant issue. In this work, we leverage a dataset obtained from two online networks, Reddit and Gab, comprising of user-generated text content. While 20,000 of the dataset are labeled, a substantial portion of it (two million) remains unlabeled. Our system employs both datasets to perform the subtasks. Figure 1 displays a sample input and output for each subtask.
498
State-of-the-art results in Natural Language Processing (NLP) tasks have been achieved by pretrained models such as BERT, RoBERTa, ERNIE, XLM-RoBERTa, and DeBERTa (Devlin et al., 2019; Liu et al., 2019; Sun et al., 2019; Conneau et al., 2019; He et al., 2020). These models, which are trained on large datasets with numerous parameters, have demonstrated the potential to improve system performance and generalization in recent studies. Therefore, we used several pretrained models such as BERT (Devlin et al., 2019), RoBERTa (Liu et al., 2019), XLM-RoBERTa (Conneau et al., 2019), competitive pre-trained models such as DeBERTa (He et al., 2020), and largescale pre-trained models such as ERNIE (Sun et al., 2019). While pre-trained models have demonstrated excellent performance in sentence-level or paragraph-level tasks and binary classification subtask A, our preliminary tests revealed that they did not perform well in subtasks B and C, which involve classifying into four and eleven classes, respectively. The limited amount of training data available, differences in the scope of our work, and pre-trained models’ training can explain these results. However, training these models in our specific domain can potentially enhance the results.
In recent years, there has been significant research into detecting sexism on social media platforms. Several approaches have been proposed, ranging from rule-based models to machine learning algorithms. Binary classification of shared content in online networks as sexist and not-sexist has been considered in many recent works and Some of the best methods used in sexism detection include deep learning, ensemble methods, and hybrid approaches. In this work (Rodríguez-Sánchez
et al., 2020), a new work is proposed that aims to understand and analyze how sexism is expressed, from overt hate or violence to subtle expressions, in online conversations. the authors first collected a dataset of 10,000 tweets on various topics including politics, sports, culture, etc. Then, using this dataset, they trained different models for sexism detection using deep learning methods. For example, they used convolutional neural networks, recurrent neural networks, and hybrid neural networks. The performance of each model was then evaluated using accuracy, precision, and recall metrics. Finally, the authors concluded that convolutional and hybrid neural networks are more accurate and precise in detecting sexism on Twitter. In (Schütz et al., 2021) binary and multi-class classification, two multilingual transformer models are used, one based on multilingual BERT and the other based on XLM-R. This paper’s approach uses two different strategies to adapt transformers to detect sexist content. first, unsupervised pre-training with additional data, and second, supervised fine-tuning with additional and augmented data. The authors compare their model’s performance with several state-of-the-art methods, including traditional machine learning models and deep learning models like convolutional neural networks and long shortterm memory networks. The evaluation results show that the proposed multilingual transformer model outperforms all other methods, achieving state-of-the-art performance in detecting sexism across multiple languages.
The structure of our paper is as follows: Section 3 describes our methodological approach and describes the models used. Our experimental setup and employed datasets will be described in Section 4 of this paper, followed by a documentation of the results (Section 5) and a final discussion and conclusion (Section 6).

heading: 3 System Overview
text: This section describes the methods we have used in our system. The main challenge in this work is the rather small number of training datasets for all three subtasks (subtask A includes 14,000 training instances, and subtasks B and C include 3,398 training instances). This rather small size makes it difficult to effectively pre-training complex NLP methods such as transformers. For this reason, we use different transfer learning methods. As a basis for textual content modeling, we apply sev-
eral pre-trained transformer-based models: BERT, DeBERTa, and RoBERTa. To adapt these generalpurpose models to the task of recognition (subtask A) and sexism classification (subtask B and C), we use a large unlabeled dataset that has the same content as the training set. Also, in another approach, we combine several pre-trained models and train them by adding a classification layer for each subtask.
In Section 3.1 our system that uses transformerbased models is described for three subtasks. Then, we describe our task-adaptive system on the domain of this particular task (see Section 3.2). Also, the ensemble model system is described in Section 3.3. Finally, we describe the optimization algorithm and loss function in Section 3.4.

heading: 3.1 Transformer-based Model
text: The architecture of this model is shown in Figure 2. For all three subtasks A, B, and C, we experimented with pre-trained transformer-based models such as BERT, RoBERTa, and DeBERTa. Since the distribution of classes in all three subtasks is unbalanced, model training is conducted with and without classweights1in the loss function. Also, the model is fine-tuned using the training dataset. The output layer of the model is different for each subtask, there are two classes for subtask A, four classes for subtask B, and 11 classes for subtask C. The classification layer of the pre-trained transformer-based model for sequence classification was utilized.
1This argument allows you to define float values to the importance to apply to each class.

heading: 3.2 Task-adaptive Model
text: Transformer-based models can overfit small data sets (Howard and Ruder, 2018). Therefore, we used pre-trained models for all subtasks to overcome this issue. Furthermore to adapt our model to the scope of this particular task, in our experiments, we trained the pre-trained transformer model in an unsupervised manner on a large unlabeled dataset. This large unlabeled dataset was provided by (Kirk et al., 2023), and it contains unlabeled examples from the same domain (i.e, also from Gab and Reddit). We only used the pre-trained BERT model. Then we fine-tuned the adaptive model with the labeled data, and finally, we make predictions for each subtask. The architecture of our task-adaptive model can be seen in Figure 3.

heading: 3.3 Ensemble Model
text: In this model, we experiment with the combination of transformer-based models. The architecture of the ensemble model is shown in Figure 4. The input is given to three pre-trained models, then the output of these models, which are the representation of the input sentence, are combined. In this model, we tested different combinations of transformerbased models. Our ensemble model takes the input and feeds it into three pre-trained models. We then added a dropout layer to the outputs of each pretrained model. Finally, we combined the outputs of the dropout layers to obtain a representation of the input sentence. A first dense layer with a Relu activation function and a dropout layer as follows:
h1 = Dropout(Relu(htW1 + b1)) (1)
where h1 ∈ R1×d, W1 ∈ Rd×d and b1 ∈ Rd are the embedding, learnable weight, and bias of the first dense layer respectively. ht ∈ R3×768 It is also a combination of the output of pre-trained models. The last dense layer is as follows:
hout = Dropout(Relu(h1W2 + b2)) (2)
where hout ∈ R1×d, W2 ∈ Rd×d and b2 ∈ Rd are the final embedding of the last layer, learnable weight, and bias respectively. Finally, the hout is transformed to fit the two-class for subtask A, four-class for subtask B and 11-class for subtask C classification.

heading: 3.4 Optimization and Loss Function
text: For all three subtasks A, B, and C, we used the cross-entropy loss function for multi-class classification as follows:
CE = −ΣMc=1yi,clog(pi,c) (3) where M denotes the number of classes, yi,c is a binary indicator (0 or 1) that indicates whether c is a correct class of i-th instance and pi,c means the predicted probability of class c.

heading: 4 Experimental Setup
text: To fine-tune the pre-trained transformer-based models used in our systems, we employed the AdamW optimizer (Kingma and Ba, 2014) with default hyperparameters. Additionally, we explored the impact of additional hyperparameters, as detailed in
Table 1. To determine the optimal values of the hyperparameters, we utilized the dev dataset. Experiments were done with Nvidia GTX 1080.

heading: 4.1 Data
text: We used the training, validation, and test data sets provided by SemEval2023 Task 10 (Kirk et al., 2023). The statistics of the corpus are presented in Table 2. In all three subtasks, 70% of the total data is allocated to training data, 10% to dev data, and 20% to test data. Also, for the task-adaptive system, we used the unlabeled data set provided to us.

heading: 4.2 Evaluation
text: Our system makes classifications for all three subtasks. Therefore, the output of the model is pre-
dicting one class from two classes for subtask A, predicting one class from four classes for subtask B, and predicting one class from 11 classes for subtask C. To evaluate the results, we used F1-score and other metrics such as precision and recall.

heading: 5 Results
text: In this section, we examine the results of the systems that we explained in the previous section. Our best system was able to Macro-F1 score 83%, 64%, and 47% on the test sets and 84%, 68%, and 49% on dev sets in subtasks A, B, and C, respectively. Using the BERT model, we obtained the official result submitted for subtask A on the test dataset. Our official submission system was based on the BERT model, in which we utilized class-weight in the loss function. We then improved it using other models such as DeBERTa and ensemble models. Also, the official results for subtasks B and C have been using DeBERTa’s model, which in this paper we have improved by adding class weights to the cross-entropy loss function. These weights are calculated based on the ratio of the number of samples in each class to the total number of samples. They are then normalized and used as the weight of each class in the loss function. The official scores that we have submitted are as follows: 77% in subtask A, 64% in subtask B, and 42% in subtask C, which can be seen in Table 3.
Table 4 shows the results of our different models. These results are based on the Macro-F1 score. The performance benchmark of our systems is the final results of the test dataset, but for better under-
standing, we have also presented the results of the models on the dev dataset. To obtain the performance of our systems on the test dataset, we first trained the mentioned models with different values of hyperparameters and then choose the optimal hyperparameters on the dev set. Finally, for our system and combination of hyperparameters, we make predictions on the held-out test set. We presented the average results of at least three tests as the final results on the test set. To deal with the unbalanced data, we used the class-weight method in the Loss function, which could improve the results, especially in subtasks B and C. Also, in all models, the learning rate of 2e−5 had the best performance on the dev set. The results of our main models on three subtasks’ dev sets with different batch sizes are presented in Table 5. In the pre-trained and taskadaptive models, batch size 32 and in the ensemble model batch size 48 gave the best results.
Using the DeBERTabase, task-adaptive, and ensemble models, we were able to achieve promising results in subtask A, with the best performance belonging to model DeBERTabase on the test set. For subtasks B and C, we obtained the best results on the test sets using the DeBERTabase model with class-weight. The classification layer of the pre-trained DeBERTabase for sequence classification model was utilized in the DeBERTabase model. However, in the ensemble model, pretrained transformer-based models are only used for feature extraction. Then, several dense layers are added to combine the extracted features, and finally, an output layer is added for classification, which is trained on the data. Due to the small number of data samples and their insufficient amount for fine-tuning the model, the ensemble
could not achieve better results, especially in subtask C, which had very few data samples and a higher number of classes compared to other subtasks.
A confusion matrix of the DeBERTa model predictions on subtask A, is shown in Figure 5. Because the classes are unbalanced, the false negative error is more than the false positive error.

heading: 6 Conclusion
text: In this work, we described our system for SemEval2023 Task 10. The purpose of this task was to identify and classify sexist content in online spaces. To do this, we used different types of transformer-based models as well as their combinations. We also presented a task-adaptive system in the domain of this particular task. In the above sections, we examined the essential components for ensuring the repeatability of our systems and evaluated the performance of the architectures. Our best system was able to achieve an F1-score of 83%
in subtask A, 64% in subtask B, and 47% in subtask C on test sets. In future work, larger pre-trained models such as DeBERTa-v3 can be used for classification or task-adaptative pretraining, and it is also promising to use other unsupervised methods or use more data to train the task-adaptive model.

heading: 7 Acknowledgments
text: I am grateful to the organizers of the SemEval2023 competition, the reviewers, as well as all of those with whom I have had the pleasure to work during this and other related projects.

heading: A Detailed Experimental Setup
text: The data is highly imbalanced across all three subtasks(see Figure 6). To deal with this problem, we used class-weight in the Loss function of our models. This method improved the F1-score by almost 2% in the BERT model and for subtask A, and we observed very little improvement for subtasks B and C. But in other models such as DeBERTa, the class-weight was able to significantly improve the performance of the model on the test data in all three subtasks and increase the F1-score in most cases. Figure 7 shows the confusion matrix of the B and C subtasks. These results come from the DeBERTa model, which uses class-weight in the loss function. In this task, for each model, we first obtained the best hyperparameters using the dev dataset, then for the testing phase of the model, we combined the dev and training datasets and retrained the model, Then we evaluated the test dataset. This could increase the F1-score for all subtasks by an average of 1%.
A.1 Task-Adaptive System In the task-adapted system, we trained the pretrained BERTbase model as an unsupervised for both Masked Language Model(MLM) and Next Sentence Prediction (NSP) tasks. To achieve this, we examined 2 million unlabeled datasets and filtered out those containing less than two sentences. Finally, about 900,000 data remained, with which we trained the model with a learning rate of 2e− 5, batch size of 32, and in 2 epochs. Finally, we finetuned the model with labeled data.

heading: Future Work
text: In future work, larger pre-trained models such as DeBERTa-v3 can be used for classification or task-adaptative pretraining, and it is also promising to use other unsupervised methods or use more data to train the task-adaptive model