Grenzlinie at S em E val-2021 Task 7: Detecting and Rating Humor and Offense (2021)

Abstract: This paper introduces the result of Team Grenzlinie’s experiment in SemEval-2021 task 7: HaHackathon: Detecting and Rating Humor and Offense. This task has two subtasks. Subtask1 includes the humor detection task, the humor rating prediction task, and the humor controversy detection task. Subtask2 is an offensive rating prediction task. Detection task is a binary classification task, and the rating prediction task is a regression task between 0 to 5. 0 means the task is not humorous or not offensive, 5 means the task is very humorous or very offensive. For all the tasks, this paper chooses RoBERTa as the pre-trained model. In classification tasks, Bi-LSTM and adversarial training are adopted. In the regression task, the Bi-LSTM is also adopted. And then we propose a new approach named compare method. Finally, our system achieves an F1-score of 95.05% in the humor detection task, F1-score of 61.74% in the humor controversy detection task, 0.6143 RMSE in humor rating task, 0.4761 RMSE in the offensive rating task on the test datasets.

## introduction humorous is one kind most interesting, most has the power, most has the universal significance transmission art. therefore, humor is one of the ways to improve the quality of daily conversation. in the field of natural language processing, how to make the computer learn humor and improve the quality of human-computer interaction is an important problem. the previous researches task was only to input the humorous corpus into the deep learning network and let the algorithm learn how to generate humorous dialogue. in this case, the sentences are often problematic. because humor is an abstract concept, in different situations, the degree of humor and the way of humor will be different. therefore, before the computer learns to generate humorous sentences, it is an important task for the computer to understand humor and distinguish different degrees and forms of humor. this paper mainly discusses how to identify these humorous sentences automatically. in semeval-2021 task 7, subtask1 includes the humor detection task, the humor rating predicts task and the humor controversy detection task @xcite . subtask2 is an offensive rating predict task. in the detection task, the bi-lstm and adversarial training @xcite ) is adopted, we also try to use focalloss to solve the data unbalance problem. in the regression task, the bi-lstm is also adopted. and then we propose a new method named compare method is also adopted. the rest of the paper is as follows: section 2 briefly introduces the related work. section 3 describes the optimization approach to be used in detail. section 4 describes the experiment process in detail. section 5 is the conclusion of this paper. ## related work on large corpora, pre-trained models (ptms) can learn common language representation, which is beneficial for subsequent nlp tasks and can avoid training new models from scratch @xcite . with the development of computing power and the improvement of training skills, the architecture of ptms is advancing from shallow to deep. the goal of the first version of ptms is to learn good word embedding. since these models are no longer needed by downstream tasks, they are usually very superficial for computational efficiencies, such as skip-gram @xcite and glove @xcite . although these pre-trained embeddings can capture the semantic meaning of words, they are context-free and cannot capture the advanced concepts in the context, such as polysemy disambiguation, syntactic structure, semantic role, anaphora, and so on. the second version of ptms mainly learn context word embedding, such as elmo @xcite , openai, gpt @xcite and bert @xcite . these learned coders still need to represent words in context through downstream tasks. besides, various pre-training tasks are proposed to learn ptms for different purposes. given the pre-trained model, downstream algorithms like random forest, svm, logistic regression, or single linear layer can be adopted to get the result. recent studies have extended the humor detection task to the field of multi-modality and used gesture, speech prosody, and other features in humor detection task @xcite . they also began to work on the joint training and integration of humor detection task and humor generation task @xcite . however, these models still regard humor detection as a binary classification task, without considering humor scoring and controversy. ## methods description baseline model in these tasks, roberta is adopted as the baseline model, and softmax is adopted as the activation function in the classification task. in the regression task first, we try to use relu as the activation function, then we use sigmoid as the activation function, and multiply the output of sigmoid by 5. but we find the method without activation function does the best in regression task. if we add relu after regression task, the rmse will reduce 0.1 0.2. so the activation function is not adopted in the baseline model. to avoid the negative output of the model in the scoring model, we need to add relu as an activation function in the test phase. in the regression task, the mean square loss is adopted as the loss function. in classification tasks, we use the crossentropy loss as the loss function. method1: bi-lstm in this paper, all the subtask use the bi-lstm to extract more abundant features. in this model, bi-lstm is added after the pre-trained model. [cls] (classification symbol) always be added before sentence, and use classifier to compute [cls] representation to get the result. so, there is a problem, that is, the sentence representation from bi-lstm will not integrate on symbol @xcite . but we need the representation of [cls] for the next step. so the output of bi-lstm is sent into a new defined transformer layer, encode the sentence representation into the symbol @xcite . finally, the sentence representation will send into a single linear layer to get the result. method2: adversarial training then the adversarial training is adopted to improve the baseline model. adversarial training is an important way to enhance the robustness of neural networks. in the process of confrontation training, the samples will be mixed with some small disturbances, and then make the neural network adapts to this change, so it has the robustness to the confrontation samples. in the field of the language model, adversarial training improves both robustness and generalization @xcite . where x represents the input representation of the sample, θ represents the disturbance superimposed on the input, f θ () is the neural network function, y is the label of the sample, and l(f θ (x + δ)), y) represents the loss obtained by superimposing a disturbance θ on the sample x, and then comparing it with the label y through the neural network function. max(l) is the optimization objective, that is to find the disturbance that maximizes the loss function. in short, the added disturbance should confuse the neural network as much as possible. in this method, fgm (fast gradient method) @xcite ) is adopted. the idea is very simple, that is, let the direction of disturbance increase along the gradient, and the increase along the gradient means the maximum loss. the formula of fgm is as follows. where is a constant, which controls the degree of disturbance rejection. @xmath0, y), i.e. the gradient of loss function l with respect to input x. method3: focalloss in the classification task, we can see that the data ratio of humorous and non-humorous sentences is close to 2:1, and then in humor's data, the ratio of controversy and noncontroversy is close to 1:1, but we assume that non-humorous sentences are also non-controversy sentences. therefore, these two tasks are faced with the problem of data imbalance. to solve this problem, we use the focalloss @xcite as the loss function. the focalloss is as follows. where p t is the probability of the label t that is outputted by the classifier. n is the number of labels. α and γ are constant. method4: compare method this method is only for humor rating predict task and offensive rating predict task. in the few-shot classification tasks, traditional approach is given a pair of sentences in the same class and given a pair of sentences in different classes. let the classifier identify whether the pair of sentences is the same class or different classes. so the latent feature of each label in the sentence can be extracted. unfortunately, this approach can't be used in regression tasks. based on this idea, we proposed the compare method. this method extends the above idea to the regression task. the approach is shown in figure 1 . in this model, we input sentence a with rating l(a), and sentence b with rating l(b), then three different models that realize the function of m add (l(a) plus l(b)), m sub ab (l(a) minus l(b)), and m sub ba (l(b) minus l(a)). it means to use these models to encode pairs of sentences and output z add , z sub ba , z sub ab . then put these features into the classifier. let the output ratings become the addition and the subtraction of the pair of sentences' rating. furthermore, the sentence representation which rating is close to the addition and subtraction of the pair of sentences' ratings can be used to introduce the z add , z sub ba , z sub ab by minimizing the mseloss of z add , z sub ba , z sub ab and sentence representation. in this task, this approach is not adopted because of the lack of data. the three models have the same construction. to simplify the computation, the last layer's hidden output from roberta is set as the feature of each token. then these token features are concatenated like "[cls] (sentence) [sep] (another sentence) [sep]". and send the concatenated output to a single transformer layer to get the [cls] output for classifying. the loss function c loss and the add loss is as follows. in the equation, ml is mseloss and c is our model, c(f a ) means the output of our model. these loss functions are the loss of the single sentence result and the loss of the result of z add , z sub ba , z sub ab . datasets first of all, we try to find the relationship between tasks. in the beginning, we think that those with low humor ratings or high offensive ratings may be controversial, but unfortunately, we find many counterexamples in the datasets. then we tried to train several tasks together, but the result was not as good as that of training it independently. so we train these tasks independently. secondly, in the task of humor scoring and humor controversy detection, only humorous sentences need to be rating predicted and detected. in the data set, only humorous sentences have humor ratings and humor controversy labels. therefore, how to deal with the label of non-humorous sentences is an important problem. we have tried to set the controversy label of non-humorous sentences to 2, that is, the third category, but this approach will identify humorous sentences as the third category, which will interfere with the model. therefore, in this paper, we set the rating of non-humorous sentences to 0, and the controversy label to 0, i.e. non-controversy. ## result the result of the test datasets is shown in focalloss didn't work as expected and didn't get better results. because focalloss usually use in the datasets that 0 label is more than 1 label, but in the humor detection task, 1 label is more than 0. although we adjusted the alpha in focalloss to 0.67, focalloss still failed to get better results. fgm optimizes the baseline model in humor detection, humor rating, and offensive rating tasks. and based on fgm, bi-lstm does more better in these tasks. because bi-lstm can extract sentence features in more detail, especially bidirectional sequence features. experiments show that these features are more conducive to downstream tasks. finally, compare method only optimizes the offensive rating predict task, but it not good at humor rating predict task, we think the non-humorous sentences. we speculate that non-humorous sentences with a 0 rating interferes with the comparison of two randomly selected sentences in compare method. the number of sentences that select nonhumorous sentences for comparison is too large to help the model predict rating, so the auxiliary task interferes with the baseline model. ## conclusion this paper introduces the experiment in semeval-2021 task 7 hahackathon: detecting and rating humor and offense. in this article, we propose two main assumptions. the first point is that the model is difficult to obtain the real meaning of the tag according to the change of the 0-5 rating. so the method of adding the auxiliary task on the baseline model was proposed. the auxiliary task is comparing different sentences according to the number proposed by us all to strengthen and supplement this process. this method does the best in offensive rating predict task, achieve 0.4761 rmse. second, the output of the pre-training model is similar to the word vector, which needs further processing to be more suitable for downstream tasks. so we try to use bi-lstm. indeed bi-lstm does the best, achieve the 95.05% f1-score in the humor detection task, and 0.6143 rmse in the humor rating task. these approaches do not play an optimized role in the controversy detection task. the baseline does the best, achieve the 61.74% f1-score. the main reason for this problem lies in the interference