UPB at S em E val-2021 Task 7: Adversarial Multi-Task Learning for Detecting and Rating Humor and Offense (2021)

Abstract: Detecting humor is a challenging task since words might share multiple valences and, depending on the context, the same words can be even used in offensive expressions. Neural network architectures based on Transformer obtain state-of-the-art results on several Natural Language Processing tasks, especially text classification. Adversarial learning, combined with other techniques such as multi-task learning, aids neural models learn the intrinsic properties of data. In this work, we describe our adversarial multi-task network, AMTL-Humor, used to detect and rate humor and offensive texts from Task 7 at SemEval-2021. Each branch from the model is focused on solving a related task, and consists of a BiLSTM layer followed by Capsule layers, on top of BERTweet used for generating contextualized embeddings. Our best model consists of an ensemble of all tested configurations, and achieves a 95.66% F1-score and 94.70% accuracy for Task 1a, while obtaining RMSE scores of 0.6200 and 0.5318 for Tasks 1b and 2, respectively.

## introduction sentiment analysis studies expressed opinions and feelings, affective states, and subjective information introduced while conveying ideas to others. in recent years, social media has encountered a major change in ways of interaction and in the freedom of expressing moods to others. for example, individuals frequently use emojis, or even abbreviations, to emphasize their feelings. therefore, new machine learning systems are developed to predict sentiment valences; however, this task is not trivial, as the detection of sentiments is challenging even for humans. this is mainly generated by the diversity of contexts and differences among people, such as socio-cultural status, age, or gender. for example, certain jokes might be confusing due to past experiences or the current mood while reading the joke. similarly, language ambiguity can introduce difficulties in understanding the text and in altering the perceived emotions. moreover, individuals express a wide range of sentiments, such as happiness, humor, or anger. words that are used to express such feelings, might share multiple valences and meanings, depending on the context. therefore, a sequence of words that is, for example, humorous in a certain context, can be considered offensive in another situation. such examples can rely on bad jokes regarding a person's position in society, ethnicity, or political ideology. another characteristic that impacts a text's level of humor is how clear the idea is conveyed to the reader. in this regard, semeval-2021 task 7 -ha-hackathon: detecting and rating humor and offense @xcite introduced four subtasks: task 1a (classification) includes the class of the text, which can be either humorous or not; task 1b (regression) presents the level of humor as a value between 0 and 5; task 1c (classification) covers the rating of the class of being controversial (i.e., some annotators considered a text to be humorous, while others considered the opposite); task 2 (regression) contains the level of offensiveness from the text (i.e., how offensive is the text as an aggregate score agreed by all annotators). each example in the dataset contains four labels, one for each task. the labels for tasks 1b and 1c depend on whether the text contains humor or not. task 2 is independent of task 1 and all examples from the dataset have assigned scores corresponding to their level of offensiveness. in this work, we introduce an adversarial multitask learning @xcite architecture to detect humor in texts, as well as other related sub-tasks. we focus on tasks 1a, 1b, and 2, while using the data for all tasks during training. our model con-siders bertweet (nguyen et al., 2020) for contextualized embeddings, followed by long short-term memory (lstm) @xcite and capsule layers @xcite as feature extractors. we observe that adversarial learning increases performance for certain choices of hyper-parameters. moreover, training the branch for task 1c on the data for task 1a improves the performance for task 1a. in addition, an ensemble method increases the overall performance on all tasks. the paper is organized as follows. section 2 presents related work associated with the provided tasks. section 3 describes our method, followed by details on the experimental setups and results. finally, section 5 provides conclusions and future research paths. ## related work several studies @xcite @xcite address the problem of detecting sentiments from texts by using multiple related tasks to further improve the performance of the model. adversarial multi-task learning was introduced by @xcite and consists of using multiple branches for each individual task (i.e., private branches), and another branch shared among all tasks (i.e., shared branch). a discriminator trained to distinguish between features from multiple tasks is used to separate shared and task-related features in the latent representation from each branch. this is the adversarial shared-private multi-task learning (asp-mtl) framework that was also employed in other works such as @xcite , where the goal was to label opinions and the associated semantics from texts. results showed that asp-mtl might not achieve better results when compared to classical mtl, and there are other factors that should be taken into consideration, such as dataset split and hyper-parameters. other works @xcite ) used the multi-task technique alongside adversarial learning, but in other configurations than asp-mtl. for example, @xcite employed a model that has a shared feature extractor, and then it is followed by branches for each task with an attention mechanism for the first layer from each branch. by adding new branches to the model, as well as adversarial learning, the f1-score increased when compared to the baseline model. @xcite adopted domain adaptation to improve the performance of a classifier. their idea was to add a discriminator after the feature extractor, as a separate branch, that is used to distinguish between different domains. the experiments showed that adversarial learning aided in reducing the bias found in the dataset, thus increasing the model's capability to generalize. there are multiple natural language processing (nlp) techniques that can be effectively employed to perform text classification in general, as well as sentiment analysis as a specific task @xcite @xcite . for example, neural network methods can be used to detect propaganda in articles by pretraining models on related tasks @xcite or emotions in memes using multimodal multi-task learning @xcite . other methods rely on classical machine learning methods (e.g., support vector machine, naive bayes, or random forest classifiers) and can be successfully used for related tasks, such as fake news detection, obtaining accuracies over 90% on specific datasets @xcite . ## results the amtl-t1a-twice model manages to obtain the highest f1-score on one of the two branches for task 1a. however, accuracy and f1 scores were low when making predictions for task 1.c (46.34% and 61.18%, respectively). these low performance values may be indicative of bias in the dataset towards either 0 or missing values for this task. ensemble models complement the inner configurations and provide more stable predictions. ensemble-1 was the model submitted during the competition for evaluation. the differences between our ensemble-1 configuration and the best models reported for each task were the following: ## conclusions and future work in this work, we present amtl-humor, an adversarial multi-task learning method to deal with the problem of detecting and rating humor and offense for semeval-2021 task 7. more specifically, our model is inspired by the asp-mtl framework and considers bilstm and capsule layers as feature extractors on top of the bert layer that provides contextualized embeddings. two ensemble models were created using variations of our amtl-humor architecture. these configurations were trained either on different settings (such as adversarial learning) or by modifying the structure of the branches. we observed that adversarial learning might perform better than other architectures with similar structures, while considering specific configurations and tasks. another improvement was observed when the model was trained on two tasks using the same branch, namely the amtl-t1a-twice model. this approach of duplicating branches may be used in other context as it adds redundancy to the network and supports generalization. finally, the best results were obtained by using an ensemble over all trained models. in the future, we aim to study how performance can be improved, especially on task 1c, by adapting the hierarchical multi-task learning technique @xcite to the amtl-humor architecture.