RACAI at C limate A ctivism 2024: Improving Detection of Hate Speech by Extending LLM Predictions with Handcrafted Features (2024)

Abstract: This paper describes the system that participated in the Climate Activism Stance and Hate Event Detection shared task organized at The 7th Workshop on Challenges and Applications of Automated Extraction of Socio-political Events from Text (CASE 2024). The system tackles the important task of hate speech detection by combining large language model predictions with manually designed features, while trying to explain where the LLM approach fails to predict the correct results.

## introduction hate speech identification is an important task when analyzing climate change activism events. the shared task @xcite organized at the case 2024 workshop provided a place to test different approaches for detecting hate speech in short messages specific to social media platforms, such as x (previously known as twitter). hate speech can be defined as any message that denigrates individuals or groups based on some characteristic such as race, color, ethnicity, gender, sexual orientation, nationality, or religion @xcite . messages of interest for the task are exchanged during or related to climate change activism events. since many recent works focus on the application of large language models (llms) for classifying messages as hateful or not, this work investigated the possibility of improving llm predictions using handcrafted features. a decision tree was trained in the hope that the resulting decisions could explain the failure of llm predictions in certain cases. the rest of this paper is organized as follows: section 2 provides related work, section 3 briefly introduces the task and describes the dataset, section 4 gives an overview of the participating system, including pre-processing and architecture, section 5 presents the results, and section 6 gives conclusions and future work. ## related work the survey of @xcite presents a number of methods and features useful for hate speech classification, including simple surface features, word generalization, sentiment analysis, lexical resources, linguistic features, knowledge-based features, and meta-information. further analysis is provided by @xcite . @xcite provides a review of existing resources and benchmark corpora for hate speech detection. the survey of jahan and oussalah (2023) presents different methods employing word embedding representations (both static and contextualized) for hate speech detection. the recent haspeede3 shared task @xcite provided another place for evaluating hate speech detection systems. the system of @xcite employed two pre-trained cased bert-based @xcite llms, with initial pre-processing by turning hashtags into words to reduce noise. the system of di bonaventura et al. (2023) made use of alberto @xcite llm, combined with the ontology of dangerous speech @xcite . apart from general hate speech detection, specific lexical phenomena have been studied. @xcite studied the usage of pejorative language in social media. @xcite acknowledges the distinctions between hate speech and offensive language, which makes the task of hate speech detection more challenging. ## dataset and task the goal of the hate speech detection task is to identify for a given message if it contains hate speech or not. this is a binary label associated with each provided message in the dataset. dataset files (with splits for training, validation and testing) were provided in csv format, containing three columns: index is a numeric value identifying the message; tweet is the actual message; label is a numeric value, 1 if the message contains hate speech and 0 otherwise. the dataset is described in detail by @xcite . the training file contains 7,284 messages of various sizes. the shortest message has only 29 characters, while the largest has 985 characters. the validation file has 1,561 messages with sizes from 29 characters to 940 characters. the test file has 1,562 messages with sizes from 1 character to 960 characters. the size distribution is given in figure 1 . overall there are 10,407 messages in the entire dataset, 1,277 marked as containing hate speech (12.27%). the messages are included as they were collected from the internet, without any preprocessing. therefore, they contain elements such as hashtags, emojis, user references, new lines, spelling errors, inconsistent casing (including all uppercase letters for the entire message or message parts), new lines, urls. some messages contain a large number of hashtags (the maximum number in the training set is 26 in a single message), urls (maximum 6) or user mentions (maximum 50 in a single message). this is sometimes used to make a message easily discoverable by people looking for a certain hashtag. however, hashtags (sometimes comprised of multiple words, such as "#stopfakegreen") are used to convey a message, which could be hateful. an example message is: this is why uk politicians are so reluctant to divest from fossil fuels: 1/7 govuk #corruption #torycorruption #extinctionrebelliom #xr #keepitintheground #climatejustice #fridaysforfuture #greennewdeal #ukpolitics #talkingclimate lets_discuss_cc. in this message, simply ignoring the hashtags provide no clues as to why it was marked as hate speech. however, considering the hashtags (especially "#corruption" and "#torycorruption") clarifies the labeling. urls present in the dataset are shortened, always starting with " https://t.co " and followed by a code. therefore url itself does not add information useful for hate speech detection. @xcite mention that rigorous measures were taken to anonymize all usernames and identifiable user information within the dataset. therefore, the text associated with the user references was not considered relevant for this work. ## results and discussion the llm used for training the system was bertlarge-uncased. the choice of an uncased model version is justified by the pre-processing step that removes capitalization and transforms the text into lowercase characters. the model was trained for at least 5 epochs and a maximum of 20 epochs, with early stopping, when there was no improvement for 3 epochs. during the first 3 epochs, the llm was frozen and only the last linear layers were actually trained. a batch size of 128 was used. the learning rates for the llm and the other layers were kept separated. the best hyper-parameters were determined by performing a grid search, with the encoder learning rate possible values of 1e-05, 2e-05, 3e-05, 5e-05, 9e-06, and the learning rate for the linear layers with values of 5e-05, 4e-05, 3e-05, 2e-05, 8e-05. as the time constraints associated with the shared task, further exploration was not possible within the allocated time. during training, a 10-fold cross validation approach was used. for each hyper-parameter values 10 experiments were performed and the best values were selected. this resulted in the final system using 3e-05 for the encoder learning rate and 2e-05 as the learning rate for the linear layers. the final model training lasted 11 epochs. results are given in interestingly, all three systems, including the basic tf-idf were able to surpass the f1 and accuracy scores reported by @xcite , using a bert model. this is probably due to the pre-processing described in section 4.1. each system has its strong points, "tf-idf" provides the best precision and accuracy, "bert" provides the best recall and f1, while the combination of the two systems, as well as additional features, using the decision tree "dt" provides good values for all metrics. however, since the shared task evaluation was conducted based on f1 score only, the results of the fine-tuned bert model were submitted for the final evaluation. analyzing the decision tree diagram, shows that apart from the tf-idf and bert predictions (these are the top-level decision nodes in the tree), the most important features are the number of hashtags that were split during pre-processing, the number of remaining hashtags (without being split) and the number of urls. analyzing the message numbers, an average of 0.57 hashtags were split on non-hate messages, compared to an average of 0.11 in hate messages. this seem to indicate that the presence of a large number of these elements makes the text harder to classify by both bert and tf-idf. however, the results of the decision tree classifier indicate that relying solely on these numbers to adjust the predictions is not possible. instead, research is needed into properly handling messages with a large number of hashtags and urls. furthermore, research is needed into handling difficult hashtags, containing multiple words or names that are harder to split using automated methods. ## conclusion results, as discussed above, indicate that simpler algorithms, such as tf-idf, may provide good enough results for certain tasks within a reduced amount of time compared to deep neural networks. however, the result is clearly influenced by proper pre-processing operations, since tf-idf when applied on pre-processed text provides improved results compared to the baseline bert approach applied on raw text. explainable ai approaches try to improve our understanding of black-box neural models by explaining their predictions and thus contributing to our trust in such models @xcite @xcite . in this paper, by using a decision tree to combine llm results with tf-idf and other features, the final model tries to explain and improve upon failures of the llm approach. this highlighted a need for further research into handling social media messages with a large number of hashtags, urls, or complex hashtags that may not be easily split into words. during the pre-processing operations, special characters, including emojis were discarded. however, the inclusion of emoji representations, such as emoji2vec @xcite , may improve the system's results. furthermore, the current work focused only on bert-like llm. exploration of other model architectures for hate speech detection is needed. inclusion of additional features, such as the usage of pejorative words, could better the explanation of when the llm fails to provide correct results. the dataset provided for this task provided boolean indications of messages containing or not hate speech. other tasks offered additional classification, such as the targets of hate speech (individual, organization, and community targets). for the purposes of this work only the task-specific dataset was considered, with no additional resources. however, further investigation may involve combining other datasets in order to better understand if a certain type of hate speech is less likely to be identified by the proposed system. even more, other authors explore the intensity associated with hate speech @xcite or other classifications @xcite . extending the dataset with additional indicators may allow future work to better explore a model's failures and provide clues that may aid in improving the model's performance. in accordance with open science principles, the source code of the participating system is made open source in our github repository 3 . a rendered diagram of the decision tree is available in the same place 4 , while the image size prevents its inclusion directly in the paper.