SlowGuess/ACL_2020_OCR huggingface dataset:
Santhosh Rajamanickam
ILLC, University of Amsterdam
rajamanickamsanthosh@gmail.com
Pushkar Mishra
pushkarmishra@fb.com
Helen Yannakoudakis
Dept.of Informatics, King's College London
Ekaterina Shutova
e.shutova@uva.nl
The rise of online communication platforms has been accompanied by some undesirable effects, such as the proliferation of aggressive and abusive behaviour online. Aiming to tackle this problem, the natural language processing (NLP) community has experimented with a range of techniques for abuse detection. While achieving substantial success, these methods have so far only focused on modelling the linguistic properties of the comments and the online communities of users, disregarding the emotional state of the users and how this might affect their language. The latter is, however, inextricably linked to abusive behaviour. In this paper, we present the first joint model of emotion and abusive language detection, experimenting in a multi-task learning framework that allows one task to inform the other. Our results demonstrate that incorporating affective features leads to significant improvements in abuse detection performance across datasets.
Aggressive and abusive behaviour online can lead to severe psychological consequences for its victims (Munro, 2011). This stresses the need for automated techniques for abusive language detection, a problem that has recently gained a great deal of interest in the natural language processing community. The term abuse refers collectively to all forms of expression that vilify or offend an individual or a group, including racism, sexism, personal attacks, harassment, cyber-bullying, and many others. Much of the recent research has focused on detecting explicit abuse, that comes in the form of expletives, derogatory words or threats, with substantial success (Mishra et al., 2019b). However, abuse can also be expressed in more implicit and subtle ways, for instance, through the use of am
biguous terms and figurative language, which has proved more challenging to identify.
The NLP community has experimented with a range of techniques for abuse detection, such as recurrent and convolutional neural networks (Pavlopoulos et al., 2017; Park and Fung, 2017; Wang, 2018), character-based models (Nobata et al., 2016) and graph-based learning methods (Mishra et al., 2018a; Aglionby et al., 2019; Mishra et al., 2019a), obtaining promising results. However, all of the existing approaches have focused on modelling the linguistic properties of the comments or the meta-data about the users. On the other hand, abusive language and behaviour are also inextricably linked to the emotional and psychological state of the speaker (Patrick, 1901), which is reflected in the affective characteristics of their language (Mabry, 1974). In this paper, we propose to model these two phenomena jointly and present the first abusive language detection method that incorporates affective features via a multitask learning (MTL) paradigm.
MTL (Caruana, 1997) allows two or more tasks to be learned jointly, thus sharing information and features between the tasks. In this paper, our main focus is on abuse detection; hence we refer to it as the primary task, while the task that is used to provide additional knowledge — emotion detection — is referred to as the auxiliary task. We propose an MTL framework where a single model can be trained to perform emotion detection and identify abuse at the same time. We expect that affective features, which result from a joint learning setup through shared parameters, will encompass the emotional content of a comment that is likely to be predictive of potential abuse.
We propose and evaluate different MTL architectures. We first experiment with hard parameter sharing, where the same encoder is shared between the tasks. We then introduce two variants of the
Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 4270-4279 July 5 - 10, 2020. ©2020 Association for Computational Linguistics
MTL model to relax the hard sharing constraint and further facilitate positive transfer. Our results demonstrate that the MTL models significantly outperform single-task learning (STL) in two different abuse detection datasets. This confirms our hypothesis of the importance of affective features for abuse detection. Furthermore, we compare the performance of MTL to a transfer learning baseline and demonstrate that MTL provides significant improvements over transfer learning.
Techniques for abuse detection have gone through several stages of development, starting with extensive manual feature engineering and then turning to deep learning. Early approaches experimented with lexicon-based features (Gitari et al., 2015), bag-of-words (BOW) or  $n$ -gram features (Sood et al., 2012; Dinakar et al., 2011), and user-specific features, such as age (Dadvar et al., 2013) and gender (Waseem and Hovy, 2016).
With the advent of deep learning, the trend shifted, with abundant work focusing on neural architectures for abuse detection. In particular, the use of convolutional neural networks (CNNs) for detecting abuse has shown promising results (Park and Fung, 2017; Wang, 2018). This can be attributed to the fact that CNNs are well suited to extract local and position-invariant features (Yin et al., 2017). Character-level features have also been shown to be beneficial in tackling the issue of Out-of-Vocabulary (OOV) words (Mishra et al., 2018b), since abusive comments tend to contain obfuscated words. Recently, approaches to abuse detection have moved towards more complex models that utilize auxiliary knowledge in addition to the abuse-annotated data. For instance, Mishra et al. (2018a, 2019a) used community-based author information as features in their classifiers with promising results. Founta et al. (2019) used transfer learning to fine-tune features from the author metadata network to improve abuse detection.
MTL, introduced by Caruana (1997), has proven successful in many NLP problems, as illustrated in the MTL survey of Zhang and Yang (2017). It is interesting to note that many of these problems are domain-independent tasks, such as part-of-speech tagging, chunking, named entity recognition, etc. (Collobert and Weston, 2008). These tasks are not restricted to a particular dataset or domain, i.e., any text data can be annotated for the phenomena
involved. On the contrary, tasks such as abuse detection are domain-specific and restricted to a handful of datasets (typically focusing on online communication), therefore presenting a different challenge to MTL.
Much research on emotion detection cast the problem in a categorical framework, identifying specific classes of emotions and using e.g., Ekman's model of six emotions (Ekman, 1992), namely anger, disgust, fear, happiness, sadness, surprise. Other approaches adopt the Valence-Arousal-Dominance (VAD) model of emotion (Mehrabian, 1996), which represents polarity, degree of excitement, and degree of control, each taking a value from a range. The community has experimented with a variety of computational techniques for emotion detection, including vector space modelling (Danisman and Alpkocak, 2008), machine learning classifiers (Perikos and Hatzilygeroudis, 2016) and deep learning methods (Zhang et al., 2018). In their work, Zhang et al. (2018) take an MTL approach to emotion detection. However, all the tasks they consider are emotion-related (annotated for either classification or emotion distribution prediction), and the results show improvements over single-task baselines. Akhtar et al. (2018) use a multitask ensemble architecture to learn emotion, sentiment, and intensity prediction jointly and show that these tasks benefit each other, leading to improvements in performance. To the best of our knowledge, there has not yet been an approach investigating emotion in the context of abuse detection.
The tasks in an MTL framework should be related in order to obtain positive transfer. MTL models are sensitive to differences in the domain and distribution of data (Pan and Yang, 2009). This affects the stability of training, which may deteriorate performance in comparison to an STL model (Zhang and Yang, 2017). We experiment with abuse and emotion detection datasets that are from the same data domain — Twitter. All of the datasets were subjected to the same pre-processing steps, namely lower-casing, mapping all mentions and URLs to a common token (i.e.,  $\_ {MTN_{-}}$  and  $\_ {URL_{-}}$ ) and mapping hashtags to words.
<sup>1</sup>We do not own any rights to the datasets (or the containing tweets). In the event of one who wishes to attain any of the datasets, to avoid redistribution infringement, we request them to contact the authors/owners of the source of the datasets.
3.1 Abuse detection task
To ensure that the results are generalizable, we experiment with two different abuse detection datasets.
OffensEval 2019 (OffensEval) This dataset is from SemEval 2019 - Task 6: OffensEval 2019 - Identifying and Categorizing Offensive Language in Social Media (Zampieri et al., 2019a,b). We focus on Subtask A, which involves offensive language identification. It contains 13,240 annotated tweets, and each tweet is classified as to whether it is offensive  $(33\%)$  or not  $(67\%)$ . Those classified as offensive contain offensive language or targeted offense, which includes insults, threats, profane language and swear words. The dataset was annotated using crowdsourcing, with gold labels assigned based on the agreement of three annotators.
Waseem and Hovy 2016 (Waseem&Hovy) This dataset was compiled by Waseem and Hovy (2016) by searching for commonly used slurs and expletives related to religious, sexual, gender and ethnic minorities. The tweets were then annotated with one of three classes: racism, sexism or neither. The annotations were subsequently checked through an expert review, which yielded an inter-annotator agreement of  $\kappa = 0.84$ . The dataset contains 16,907 TweetIDs and their corresponding annotation, out of which only 16,202 TweetIDs were retrieved due to users being reported or tweets having been taken down since it was first published in 2016. The distribution of classes is: 1,939 (12%) racism; 3,148 (19.4%) sexism; and 11,115 (68.6%) neither, which is comparable to the original distribution: (11.7% : 20.0% : 68.3%).
It should be noted that racial or cultural biases may arise from annotating data using crowdsourcing, as pointed out by Sap et al. (2019). The performance of the model depends on the data used for training, which in turn depends on the quality of the annotations and the experience level of the annotators. However, the aim of our work is to investigate the relationship between emotion and abuse detection, which is likely to be independent of the biases that may exist in the annotations.
3.2 Emotion detection task
Emotion (SemEval18) This dataset is from SemEval-2018 Task 1: Affect in Tweets (Mohammad et al., 2018), and specifically from Subtask 5
which is a multilabel classification of 11 emotion labels that best represent the mental state of the author of a tweet. The dataset consists of around 11k tweets (training set: 6839; development set: 887; test set: 3260). It contains the TweetID and 11 emotion labels (anger, anticipation, disgust, fear, joy, love, optimism, pessimism, sadness, surprise, trust) which take a binary value to indicate the presence or absence of the emotion. The annotations were obtained for each tweet from at least 7 annotators and aggregated based on their agreement.
In this section, we describe our baseline models and then proceed by describing our proposed models for jointly learning to detect emotion and abuse.
4.1 Single-Task Learning
As our baselines, we use different Single-Task Learning (STL) models that utilize abuse detection as the sole optimization objective. The STL experiments are conducted for each primary-task dataset separately. Each STL model takes as input a sequence of words  $\{w_{1},w_{2},\dots,w_{n}\}$ , which are initialized with  $k$ -dimensional vectors e from a pretrained embedding space. We experiment with two different architecture variants:
Max Pooling and MLP classifier We refer to this baseline as  $\mathrm{STL}_{\text {maxpool } + \text {MLP }}$ . In this baseline, a two-layered bidirectional Long Short-Term Memory (LSTM) network (Hochreiter and Schmidhuber, 1997) is applied to the embedding representations of words in a post to get contextualized word representations  $\{\mathrm{h}_1, \mathrm{h}_2, \dots, \mathrm{h}_n\}$ :
$$
\mathrm {h} _ {\mathrm {t}} = \left[ \overrightarrow {\mathrm {h} _ {\mathrm {t}}}; \overleftarrow {\mathrm {h} _ {\mathrm {t}}} \right] \tag {1}
$$
with  $\overrightarrow{\mathrm{h_t}}$ ,  $\overleftarrow{\mathrm{h_t}} \in \mathbb{R}^l$  and  $\mathrm{h_t} \in \mathbb{R}^{2 \cdot l}$ , where  $l$  is the hidden dimensionality of the BiLSTM. We then apply a max pooling operation over  $\{\mathrm{h}_1, \mathrm{h}_2, \dots, \mathrm{h}_n\}$ :
$$
r _ {\mathrm {i}} ^ {(\mathrm {p})} = \max  _ {\mathrm {i}} \left(\mathrm {h} _ {1}, \mathrm {h} _ {2}, \dots , \mathrm {h} _ {\mathrm {n}}\right) \tag {2}
$$
where  $\mathbf{r}^{(\mathrm{p})}\in \mathbb{R}^{2\cdot l}$  and where the superscript (p) is used to indicate that the representations correspond to the primary task. This is followed by dropout (Srivastava et al., 2014) for regularization and a 2-layered Multi-layer Perceptron (MLP) (Hinton, 1987):
$$
\mathrm {m} ^ {1 (\mathrm {p})} = \operatorname {B a t c h N o r m} \left(\tanh  \left(W ^ {l _ {1}} \mathrm {r} ^ {(\mathrm {p})}\right)\right) \tag {3}
$$
$$
\mathrm {m} ^ {2 (\mathrm {p})} = \tanh  \left(W ^ {l _ {2}} \mathrm {m} ^ {1 (\mathrm {p})}\right) \tag {4}
$$
$$
\mathrm {m} _ {\mathrm {t}} ^ {(\mathrm {p})} = \mathrm {m} _ {\mathrm {t}} ^ {2 (\mathrm {p})} \tag {5}
$$
where  $W^{l_1}$  and  $W^{l_2}$  are the weight matrices of the 2-layer MLP. Dropout is applied to the output  $\mathfrak{m}^{(\mathrm{p})}$  of the MLP, which is then followed by a linear output layer to get the unnormalized output  $\mathbf{o}^{(\mathrm{p})}$ . For OffensEval, a sigmoid activation  $\sigma$  is then applied in order to make a binary prediction with respect to whether a post is offensive or not, while the network parameters are optimized to minimize the binary cross-entropy (BCE):
$$
\begin{array}{l} L _ {B C E} = - \frac {1}{N} \sum_ {i = 1} ^ {N} y _ {i} \cdot \log (p (y _ {i})) + \\ \left(1 - y _ {i}\right) \cdot \log \left(1 - p \left(y _ {i}\right)\right) \tag {6} \\ \end{array}
$$
where  $N$  is the number of training examples, and  $y$  denotes the true and  $p(y)$  the predicted label. For Waseem&Hovy, a log softmax activation is applied for multiclass classification, while the network parameters are optimized to minimize the categorical cross-entropy, that is, the negative log-likelihood (NLL) of the true labels:
$$
L _ {N L L} = - \frac {1}{N} \sum_ {i = 1} ^ {N} \log (p \left(y _ {i}\right)) \tag {7}
$$
BiLSTM and Attention classifier We refer to this model as  $\mathrm{STL}_{\mathrm{BiLSTM} + \mathrm{attn}}$ . In this baseline (Figure 1; enclosed in the dotted boxes), rather than applying max pooling, we apply dropout to h which is then followed by a third BiLSTM layer and an attention mechanism:
$$
\mathrm {u} _ {\mathrm {t}} ^ {(\mathrm {p})} = W ^ {a} \mathrm {r} _ {\mathrm {t}} ^ {(\mathrm {p})} \tag {8}
$$
$$
a _ {\mathrm {t}} ^ {(\mathrm {p})} = \frac {\exp \left(\mathbf {u} _ {\mathrm {t}} ^ {(\mathrm {p})}\right)}{\sum_ {\mathrm {t}} \exp \left(\mathbf {u} _ {\mathrm {t}} ^ {(\mathrm {p})}\right)} \tag {9}
$$
$$
\mathbf {m} ^ {(p)} = \sum_ {t} a _ {t} ^ {(p)} \mathbf {r} _ {t} ^ {(p)} \tag {10}
$$
where  $\mathbf{r}^{(\mathrm{p})}$  is the output of the third BiLSTM. We then apply dropout to the output of the attention layer  $\mathfrak{m}^{(\mathrm{p})}$ . The remaining components, output layer and activation, are the same as the  $\mathrm{STL}_{\text {maxpool } + M L P}$  model.
Across the two STL baselines, we further experiment with two different input representations: 1) GloVe (G), where the input is projected through the GloVe embedding layer (Pennington et al., 2014); 2) GloVe+ELMo (G+E), where the input is first projected through the GloVe embedding layer and the ELMo embedding layer (Peters et al., 2018) separately, and then the final word representation is obtained by concatenating the output of these two layers. Given these input representations, we have a total of 4 different baseline models for abuse detection. We use grid search to tune the hyperparameters of the baselines on the development sets of the primary task (i.e., abuse detection).
4.2 Multi-task Learning
Our MTL approach uses two different optimization objectives: one for abuse detection and another for emotion detection. The two objectives are weighted by a hyperparameter  $\beta$ $[(1 - \beta)$  for abuse detection and  $\beta$  for emotion detection] that controls the importance we place on each task. We experiment with different STL architectures for the auxiliary task and propose MTL models that contain two network branches – one for the primary task and one for the auxiliary task – connected by a shared encoder which is updated by both tasks alternately.
Hard Sharing Model This model architecture, referred to as  $\mathrm{MTL}_{\text{Hard}}$ , is inspired by Caruana (1997) and uses hard parameter sharing: it consists of a single encoder that is shared and updated by both tasks, followed by task-specific branches. Figure 1 presents  $\mathrm{MTL}_{\text{Hard}}$  where the dotted box represents the  $\mathrm{STL}_{\text{BiLSTM} + \text{attn}}$  architecture that is specific to the abuse detection task. In the right-hand side branch - corresponding to the auxiliary objective of detecting emotion - we apply dropout to h before passing it to a third BiLSTM. This is then followed by an attention mechanism to obtain  $\mathbf{m}^{(\mathrm{a})}$  and then dropout is applied to it. The superscript (a) is used to indicate that these representations correspond to the auxiliary task. Then, we obtain the unnormalized output  $\mathbf{o}^{(\mathrm{a})}$  after passing  $\mathbf{m}^{(\mathrm{a})}$  through a linear output layer with  $\mathbf{o}^{(\mathrm{a})} \in \mathbb{R}^{11}$  (11 different emotions in SemEval18), which is then subjected to a sigmoid activation to obtain a prediction  $p(y)$ . While the primary task on the left is optimized using either Equation 6 or 7 (depending on the dataset used), the auxiliary task is optimized to minimize binary cross-entropy.
Figure 1: MTL Hard Sharing model. The embedding representations  $\{\mathsf{e}_1, \mathsf{e}_2, \dots, \mathsf{e}_n\}$  are either a result of projection through the GloVe embedding layer or a concatenation of the projections through the GloVe and ELMo embedding layer. The different arrows are used to indicate the different passes for the primary and auxiliary task. The units on the left-hand side correspond to the primary task and the units on the right-hand side correspond to the auxiliary task with the Stacked BiLSTM Encoder and embedding layers shared by both tasks. The model inside the dotted box corresponds to the  $\mathrm{STL}_{BiLSTM + attn}$  architecture.
Figure 2: MTL (Gated) Double Encoder architecture. For the MTL Gated Double Encoder model we use two learnable parameters  $\alpha$  that control information flow. For the MTL Double Encoder model, these are fixed and set to 1. The dotted boxes represent the  $\mathrm{STL}_{BiLSTM + attn}$  architecture.
Double Encoder Model This model architecture, referred to as  $\mathrm{MTL}_{\text{Encoder}}$ , is an extension of the previous model that now has two BiLSTM encoders: a task-specific two-layered BiL
STM encoder for the primary task, and a shared two-layered BiLSTM encoder. During each training step of the primary task, the input representation  $e$  for the primary task is passed through
both encoders, which results in two contextualized word representations  $\{\mathrm{h}_1^{(\mathfrak{p})},\mathrm{h}_2^{(\mathfrak{p})},\dots,\mathrm{h}_{\mathfrak{n}}^{(\mathfrak{p})}\}$  and  $\{\mathrm{h}_1^{(\mathrm{s})},\mathrm{h}_2^{(\mathrm{s})},\dots,\mathrm{h}_{\mathrm{n}}^{(\mathrm{s})}\}$ , where superscript (s) is used to denote the representations that result from the shared encoder. These are then summed (Figure 2, where both  $\alpha^{(\mathrm{p})}$  and  $\alpha^{(\mathrm{s})}$  are fixed and set to 1) and the output representation is passed through a third BiLSTM followed by an attention mechanism to get the post representation  $\mathbf{m}^{(\mathrm{p})}$ . The rest of the components of the primary task branch, as well as the auxiliary task branch are the same as those in  $\mathrm{MTL}_{Hard}$ .
Gated Double Encoder Model This model architecture, referred to as  $\mathrm{MTL}_{\text{GatedEncoder}}$ , is an extension of  $\mathrm{MTL}_{\text{Encoder}}$ , but is different in the way we obtain the post representations  $\mathfrak{m}^{(\mathfrak{p})}$ . Representations  $\mathfrak{h}^{(\mathfrak{p})}$  and  $\mathfrak{h}^{(\mathfrak{s})}$  are now merged using two learnable parameters  $\alpha^{(\mathfrak{p})}$  and  $\alpha^{(\mathfrak{s})}$  (where  $\alpha^{(\mathfrak{p})} + \alpha^{(\mathfrak{s})} = 1.0$ ) to control the flow of information from the representations that result from the two encoders (Figure 2):
$$
\alpha^ {(\mathrm {p})} \cdot \mathrm {h} ^ {(\mathrm {p})} + \alpha^ {(\mathrm {s})} \cdot \mathrm {h} ^ {(\mathrm {s})} \tag {11}
$$
The remaining architecture components of the primary task and auxiliary task branch are the same as for  $\mathrm{MTL}_{\text{Encoder}}$ .
5 Experiments and results
Hyperparameters We use pre-trained GloVe embeddings $^2$  with dimensionality 300 and pretrained ELMo embeddings $^3$  with dimensionality 1024. Grid search is performed to determine the optimal hyperparameters. We find an optimal value of  $\beta = 0.1$  that makes the updates for the auxiliary task 10 times less important. The encoders consist of 2 stacked BiLSTMs with hidden_size = 512. For all primary task datasets, the BiLSTM+Attention classifier and the 2-layered MLP classifier have hidden_size = 256. For the auxiliary task datasets, the BiLSTM+Attention classifier and the 2-layered MLP classifier have hidden_size = 512. Dropout is set to 0.2. We use the Adam optimizer (Kingma and Ba, 2014) for all experiments. All model weights are initialized using Xavier Initialization (Glorot and Bengio, 2010). For MTL $GatedEncoder$ ,  $\alpha^{(\mathrm{p})} = 0.9$  and  $\alpha^{(\mathrm{s})} = 0.1$ .
2 https://nlp.stanford.edu/projects/glove/
<sup>3</sup>https://allenlp.org/elmo
STL model	P	R	F1
G	maxpool+MLP	76.35	73.34	74.24
BiLSTM+attn	77.34	72.77	73.97
G+E	maxpool + MLP	77.19	72.73	73.95
BiLSTM+attn	77.40	73.27	74.40
(a) Twitter - OffensEval STL results.
STL model	P	R	F1
G	maxpool+MLP	79.39	78.20	78.33
BiLSTM+attn	77.97	77.57	77.49
G+E	maxpool+MLP	80.66	77.13	78.31
BiLSTM+attn	79.08	77.93	78.16
(b) Twitter - Waseem and Hovy STL results.
Table 1: STL model comparisons. In these tables, G denotes models that use GloVe embeddings and  $\mathrm{G + E}$  denotes models in which word representations are concatenations of their corresponding GloVe and ELMo embeddings. The best performing model is highlighted in bold.
Training All models are trained until convergence for both the primary and the auxiliary task, and early stopping is applied based on the performance on the validation set. For MTL, we ensure that both the primary and the auxiliary task have completed at least 5 epochs of training. The MTL training process involves randomly (with  $p = 0.5$ ) alternating between the abuse detection and emotion detection training steps. Each task has its own loss function, and in each of the corresponding task's training step, the model is optimized accordingly. All experiments are run using stratified 10-fold cross-validation, and we use the paired t-test for significance testing. We evaluate the models using Precision  $(P)$ , Recall  $(R)$ , and F1  $(F1)$ , and report the average macro scores across the 10 folds.
5.2 STL experiments