Reproducibility Report: Contextualizing Hate Speech Classiﬁers with Post-hoc Explanation
Anonymous Author(s)
AfﬁliationAddress email
Reproducibility
Summary
The presented report evaluates Contextualizing Hate Speech Classiﬁers with Post-hoc Explanation Kennedy et al.
(2020)paper within the scope of ML Reproducibility Challenge 2020.
Our work focuses on both aspects constituting the paper:the method itself and the validity of the stated results.
In the following sections, we have described the paper, relatedworks, algorithmic frameworks, our experiments and evaluations.
Scope of Reproducibility
For the GHC (a dataset), the most important difference between BERT+WR and BERT+SOC is the increase in recall.
While, for Stormfront (a dataset), there are similar improvements for in-domain data and the NYT dataset.
But, forverifying the claims we also have tried to run the same experiment on a new data-set.
Methodology
We have tried to re-implement the author’s code and verify the claims made in their original paper.
We have experimentedon NVIDIA Tesla GPU which was less efﬁcient than the original author’s resource (NVIDIA GeForceRTX 2080 Ti).
Results
We have able to reproduce claims as mentioned in the following section 2 (Scope of Reproducibility) marked as point 2and 3.
But we are not on the same page with the authors for a few reported experiments mentioned as point 1 and 4 inthe same section.
What was easy
The original authors provide code for most of the experiments presented in the paper.
The code was easy to run andallowed us to verify the correctness of our re-implementation.
The explanations in the code made the work pretty easyfor us.
What was difﬁcult
Training the models was very time taking as we had to wait for hours to get that working and the resources the originalauthors used is not readily available everywhere.
Communication with original authors
We were in contact with the second author via E-mail, as he was responsive and shared details that were not explicitlymentioned in the paper.
Submitted to ML Reproducibility
Introduction
Hate-speech classiﬁcation comes under larger efforts to reduce the damage caused by offensive and oppressive language
Waldron (2012); Gelber and McNamara (2016).
While the relative sparsity of hate speech necessitates sampling usingkeywords Olteanu et al.
(2018) or a selection from environments with very high rates of hate-speech de Gibert et al.(2018), the performance has increased with access to more sophisticated algorithms and data. Mondal et al. Silva et al.
Thus, present-day text classiﬁers struggles with learning a model of hateful speech that generalizesto applications in real-world Wiegand et al.
The over-sensitivity of neural hate speech classiﬁers to groupidentiﬁers like "Jews," "black," and "gay," classiﬁes to hate speech when used in the correct context, is a particularissue. Dixon et al.
The performance of neural text classiﬁers in detecting hateful speech is state-of-the-art, butthey are uninterpretable and could break if given an unexpected input data. Niven and Kao (2019).
Hence not easyto contextualize the method of the model to identifying words.
To estimate model agnostic and context-independentpost-hoc feature importance, the author uses explanation algorithm of Sampling and Occlusion (SOC). Jin et al.(2020).
They used the SOC explanation algorithm on the Gab Hate Dataset Kennedy et al.
(2020), a new data-set for“hate-based rhetoric”, and the Stormfront dataset which is the largest white nationalists online community, characterisedby pseudo-rational discussions on race de Gibert et al.
Using the SOC information, which revealed thatmodels are biased with respect to group identiﬁers, therefore they suggested a new approach based on regularizationto improve the model’s sensitivity towards the group identiﬁers surrounded by context.
They regulate the groupidentiﬁers importance during training, forcing models for investigation of the context in which they operate.
Theydiscovered that regularisation reduces the importance of group identiﬁers while increasing the importance of hatespeech’s more generalizable features, such as dehumanising and abusive language.
They found that regularisationsigniﬁcantly decreases the false positive rate in studies on an out-of-domain news article’s test-set comprising groupidentiﬁers that are heuristically expected as "non-hate" speech.
Concurrently, out-of-sample classiﬁcation performancefor in-domain is either maintained or enhanced.
Scope of reproducibility
The paper here points out that most of the Hate Speech classiﬁers available now are majorly tilted or over-sensitive tosome of the identiﬁers or words like (gay, black, and Muslim) but they don’t take into account the fact that the merepresence of the word would not make it oppressive but the context in which it is used gives us the correct classiﬁcation.
If the context is not taken into account then many samples would result in false positives.
Thereby, reducing theaccuracy.
The work here is formulated to detect hate speech as disambiguating the use of offensive words from abusiveversus non-abusive contexts.
We plan to use the code that is available from the authors themselves and then as per thepaper we will be reviewing and testing the claims made.
Some of the major claims of the paper are:
In GHC dataset, the most signiﬁcant difference between BERT+WR and BERT+SOC is the increase in recall.
For Stormfront (a dataset), same improvements is seen for in-domain data and the NYT dataset.
Paper claims performance for their proposed method as (Precision = 56.11, Recall = 54.23, F1 = [-54.
-]54.71 and
NYT Acc = 93.89) on average4.
The efﬁciency claimed in the paper is as follows (BERT = 5:1 mins, BERT+OC = 13:36 mins, BERT+SOC = 19:3 mins)
We have tried to verify the above claims made in the paper using the data-sets presented by the original authors and aswell as on a new data-set.
To train the model the authors have used GeForce RTX 2080 Ti GPU, which we tried toimplement using our institutional resources.
Methodology
The authors in their previous paper Jin et al.
(2020) have explained methods which are used in the current paper.
Wehere ﬁrst explain the parts of the previous paper and then show how it is used in the current paper.
The methods andapproach is described below:
3.1 Model descriptions
3.1.1 Context-Independent Importance (CII)
Given a phrase p :
= x i : j appearing in a speciﬁc input x 1: T , ﬁrst the setting is relaxed and then they deﬁne the importanceof a phrase independent of contexts of length N adjacent to it.
For an intuitive example, to evaluate the CII up to one word of very in the sentence The ﬁlm is very interesting in a sentiment analysis model, then sample some possibleadjacent words, and average the prediction difference after some practice of masking the word very (as shown in
Figure 1 below).
The N-context independent importance is formally written in Equation 1.
[Equation]
where x − δ denotes the resulting sequence after masking out a context of length N surrounding the phrase p from theinput x. Here, ˆ x δ is a sequence of length N sampled from a distribution p (ˆ x δ | x − δ ) , which is conditioned on the phrasep as well as other words in the sentence x. Accordingly, they use s ( x − δ ; ˆ x δ ) to denote the model prediction score afterreplacing the masked-out context x − δ with a sampled context ˆ x δ .
x \ p is used to denote the operation of masking outthe phrase p from the input sentence x. Following the notion of N-CII, they deﬁne CII of a phrase p by increasing thesize of the context N to sufﬁciently large ( e.g., length of the sentence).
The CII can be equivalently written as given in
Equation 2.
[Equation]
[Figure]
To assess the issue in depth, they explore hate speech models’ bias towards group identiﬁers and why that leads tofalse-positive errors during prediction.
Then they examine the models themselves to see how sensitive models are togroup identiﬁers.
Linear classiﬁers can be examined in terms of their most highly-weighted features.
Then, for the taskof extracting comparable information from the ﬁne-tuned methods discussed above, a post-hoc explanation algorithm isused.
They gathered a set of twenty-ﬁve identity words from the top features in a bag-of-words logistic regression ofhate speech GHC train , which they use in subsequent analyses.
Explanation-based measures
: BERT models can model complex word and phrase compositions; for example, somewords are only offensive when used with particular ethnic groups.
Sampling and Occlusion (SOC) algorithm is usedto capture this, which is capable of generating hierarchical explanations for a prediction.
SOC begins by assigningimportance scores to sentences in such a manner that compositional effects between the phrase and the context x δaround it are eliminated.
SOC assigns an importance score φ ( p ) where p is a phrase in a sentence x to show how thephrase contributes to the sentence being classiﬁed as hate speech.
Then, in the 2-way classiﬁer, the algorithm computesthe difference of the unnormalized prediction score s ( x ) between "hate" and "non-hate.
The algorithm then calculates the average change in s ( x ) for different inputs when the phrase is masked with padding tokens (noted as x \ p ), in whichthe N-word contexts around the phrase p are sampled from a pre-trained language model, while other words remain thesame as the given x .
Formally, the importance score φ ( p ) is measured as given in Equation 3.
[Equation]
Meanwhile, the SOC algorithm generates a hierarchical layout by performing agglomerative clustering over explanations.
Then, they compute average word importance using SOC explanations from GHCtest and present the top 20 in Figure. [Figure]
Bias in Prediction: Models of hate speech can be overly sensitive to group identiﬁers.
They create an adversarial testset of New York Times (NYT) articles that are ﬁltered to contain a balanced, random sample of the twenty-ﬁve (GHC Dataset) and ten (Stromfront dataset) group identiﬁers, as shown in Figure 2 and Figure 3 respectively, to provide anexternal measure of models’ over-sensitivity to group identiﬁers.
Explanation Regularization:
Given that SOC explanations are differentiable fully, at the time of training, the SOCexplanations on the group identiﬁers are regularized to be close to 0 in addition to the classiﬁcation objective L (cid:48) .
Thecombined learning objective is by the following Equation 4.
[Equation]
where S denotes the set of group names and x denotes the word sequence to be input. The strength of the regularisationis determined by the hyper-parameter α . They also experiment with regularising input occlusion (OC) explanations,which is speciﬁed as the change in prediction when a word or phrase is masked out, avoiding the sampling step in SOC.
Visualizing Effects of Regularization: The effect of regularization can be seen by considering Figure 5. Herevisualization of SOC hierarchically clustered explanations before and after regularization are done to correct the falsepositive predictions.
3.2 Datasets
The original authors chose two publicly available dataset for the experiments that features the logical parts of hatespeech, versus only the use of explicitly hostile language and slurs.
The "Gab Hate Corpus" Kennedy et al.
(2020)is a huge dataset with arbitrary 27,655 example, which have been annotated on as per the typology of "hate basedmanner of speaking", motivated by the criminal codes of hate-speech outside the U.S. also, research of sociology onbias and dehumanization.
A social network Gab contains high pace of "hate discourse" Zannettou et al. Limaet al. (2018) and populated by the "Extreme right" Anthony (2016)
; Benson (2016).
Likewise with deference to areaand deﬁnitions de Gibert et al.
(2018) annotated and sampled posts of "Stormfront" web space Meddaugh and Kay(2009) and annotated at the label of sentence as per a comparable annotation guide as utilized in the GHC dataset.
[Table] [Table]
Train set and test set were randomly produced by the authors for the Stormfront dataset (80/20), as mentioned in theirpaper with "hate" as a +ve label, and the test set was made by the authors from the GHC dataset by picking randomstratiﬁed data regarding the "target population" tag (potential qualities including race/identity target, sexual religious andso forth).
A solitary "hate" mark was made by picking the association of the 2 fundamental labels, “human degradation”and “calls for violence”.
Training set of the GHC contains 24,353 posts with 2,027 marked as "Hate", and test set of the GHC contains 1,586 posts with 372 marked as "Hate".
Out of 7,896 posts in the training set of Stormfront dataset,1,059 marked as hate, out of 979 posts, 122 marked as hate in the validation set, and out of 1,998 posts, 246 marked ashate in the test dataset.
We have trained the model on our new Twitter hate-speech dataset taken from Kaggle 1 .
Trainset of new Twitter hate-speech dataset (new train) contains 6,555 posts with 780 marked as "Hate", test set for the (newtest) contains 1,634 posts with 196 marked as "Hate", and validation set for the (new val) contains 1,156 posts with140 marked as "Hate".
Table 1 presents the number of "hate" and "non hate" labels of GHC Dataset.
Table 2 showsthe number of "hate" and "non hate" labels in Stormfront dataset as well as in Twitter hate-speech dataset. We havemade the new Twitter hate-speech dataset in such a way that it contains similar percent of "hate" and "non hate" labelscompared to Stormfront dataset.
The Figure 6 shows the comparison of old vs new dataset.
3.3 Computational requirements
The authors have used GPU GeForce RTX 2080 Ti for training the model.
The training times for the authors for
BERT+OC and BERT+SOC were only 2 times and 4 times respectively greater than that of the BERT.
Whereas wehave experimented on NVIDIA Tesla GPU.
The detailed comparisons of GPU and time are shown in Table 3 and 4.
The authors framework were far superior to ours which may be the reason that their training time and usage are moreefﬁcient than ours.
[Table]
[Table]
Reimplementation of code
This section shortly summarizes the main structure of the code accompanying this reproducibility check.
The authors’code was largely used as the starting point for our reimplementation in PyTorch and various other python libraries (like numpy, scikit-learn, scikit-image, matplotlib and torchtext).
We ﬁne-tuned over the BERTbase model using the publiccode 2 .
Results
We have investigated different methods such as BERT, Word identiﬁers removal before BERT training (BERT+WR), BERT with regularizing occlusion (BERT+OC) and BERT with regularizing sampling and occlusion (BERT+SOC) withsimilar parameter and hyper-parameter values as described by the authors.
We have also used the NYT test set as blinddataset to measure how good a model has learnt the contexts with the group identiﬁers for hate speech.
Experiment hasbeen done on the GHC, Stormfront and external labelled Twitter hate-speech dataset for evaluating the classiﬁcation ofhate speech in-domain and accuracy on the test set of NYT.
We have used the same 25 terms (for GHC); 10 terms for Stormfront as in the paper.
Accordingly, for the Stormfront dataset we have ﬁltered the NYT dataset to have these 10terms (N = 5,000).
[Table]
Performances (as reported in this paper and what we obtained during reproducibility experiment) are shown in Table5 and Table 6 for Stromfront and GHC dataset respectively.
We have reported standard deviation and mean for theperformances for 10 executions of BERT+SOC (as reported in paper), BERT + OC, BERT + WR and BERT. We havetested the reproduced results also.
Though our reproduced results are comparable as per reported in the paper for mostof the methods in Stromfront datasets but we obtain lower precision, recall and F1-score for GHC dataset (BERT+SOCwith α = 0 . 1 ).
Testing on blind dataset NYT is comparable for most of the cases.
Only in few cases our reproducedresults differ from the paper’s reported range values for Stromfront dataset like higher precision (+ 9%) and loweraccuracy (- 5%) in BERT+ ( α = 1 . 0 ).
[Table] [Table]
Table 7 shows precision, recall and f1-score obtained by BERT+SOC ( α = 1 . 0 ), BERT+OC ( α = 0 . 1 ), BERT +WRand BERT methods on new Twitter hate corpus.
Comparisons of different metrics on new Twitter hate-speech datasetand Stromfront dataset are shown in Figure 7 which shows signiﬁcant increase of precision ( 20%) on new Twitterhate-speech dataset compared to Stromfront using BERT+SOC ( α =1.0).
Discussion
We have able to reproduce few claims as reported by the authors in the paper - (i) For Stormfront (a dataset), sameimprovements are seen for in-domain data as well as NYT and (ii) The authors claims some performances such as(Precision = 56.11, Recall = 54.23, F1 = 54.71 and NYT Acc = 93.89) on average.
But we are not in the same page withthe authors for a few reported experiments - In GHC dataset, the main difference between BERT+SOC and BERT+WRis the increase in recall as we have obtained lower precision, recall and f1-accuracy.
This may be due the experimentalframework differences.
Due to a bar on time, we could not run the BERT+SOC several times to make the comparisonmore detailed.
In the future, we would also try to verify their claims using similar GPU conﬁgurations and incorporatemore new datasets.
6.1 What was easy
The authors’ code which was publicly available, covered almost all the experiments in their paper. It also helped usto validate the correctness of our replicated codebase.
The link to our code is stated in section 4 and additionally, theoriginal paper is quite complete, straightforward to follow, and the ReadMe ﬁle in their project helped a lot.
6.2 What was difﬁcult
For replicating the experiments one will need the GPU similar to the one used by the original authors or it will bedifﬁcult to get results on time as was in our case.
6.3 Communication with original authors
While working on the challenge, we stood in E-mail contact with the second author and want to thank the author for hisresponsive communication, which helped us to clarify a great deal of implementation and evaluation speciﬁcs.
Forexample, which particular BERT model from the library was used by them to train the model.
We also got the data-setsthat they used to carry out the experiments.
The communication with the author helped us a lot in understanding thepaper.