Evaluating C hat GPT ’s Ability to Detect Hate Speech in T urkish Tweets (2024)

Abstract: ChatGPT, developed by OpenAI, has made a significant impact on the world, mainly on how people interact with technology. In this study, we evaluate ChatGPT’s ability to detect hate speech in Turkish tweets and measure its strength using zero- and few-shot paradigms and compare the results to the supervised fine-tuning BERT model. On evaluations with the SIU2023-NST dataset, ChatGPT achieved 65.81% accuracy in detecting hate speech for the few-shot setting, while BERT with supervised fine-tuning achieved 82.22% accuracy. This results supports previous findings that show that, despite its much smaller size, BERT is more suitable for natural language classifications tasks such as hate speech detection.

## introduction chatgpt, developed by openai (openai.), has revolutionized the way people interact with technology. as a state-of-the-art language model, chat-gpt leverages the power of deep learning to understand and generate human-like text, enabling natural and coherent conversations. its applications range from question answering in various domains, to generating creative content like writing, poetry, and more. thanks to its tremendous success as a large language model, there has been interest to test its abilities in various natural language understanding problems, such as sentiment analysis and hate speech detection. hate speech refers to any form of communication, in speech, writing, or behavior, that offends, threatens, or insults individuals or groups based on attributes such as race, ethnicity, religion, sexual orientation, disability, or gender @xcite . hate speech detection, followed by potential measures such as blocking or counter-speech, is aimed to create safer digital spaces. detecting hate speech is a challenging problem, since hate speech is subjective, context-dependent, and the language of tweets show high variability with the use of contractions, emojis, and typos. the performances of hate speech detection systems show a lot of variation in the literature, as researchers often report results on proprietary or different datasets. however, state-of-art methods often use transformer based models, such as bert @xcite or chatgpt @xcite . bert @xcite , a pre-trained contextual language model, is widely used to detect hate speech. bert is a transformer-based model designed for various natural language processing tasks, such as sentiment analysis, named entity recognition, and hate speech detection. it was trained in an unsupervised manner by predicting masked words in a sentence. chatgpt @xcite , on the other hand is also based on the transformer architecture, but is specifically designed for generating coherent and contextually relevant text given an input prompt. it is trained using a language modeling objective, where it learns to predict the next word in a sentence given the context of preceding words. related to the problem at hand, bert uses a bidirectional context, which helps capture complex relationships and dependencies within the text. it is also free, open-source and much smaller (110 million parameters) compared to chatgpt which has 175 billion parameters. nonetheless, chatgpt was selected in this work due to the interest it receives and relatively low cost 1 . in this study, we contribute to the body of work assessing chatgpt's ability to detect implicit or explicit hate speech in turkish tweets, as well as its estimation of the strength of hate speech. its performance is compared to that of fine-tuned berturk classifier and regressor models. the rest of the paper is organized as follows: in section 2, we provide a summary about related works; in section 3, the dataset used to train and test our models is defined; in section 4, the methodology is presented. experiments are provided in section 5. finally, conclusions and future work are presented in section 6. ## related work many studies have been conducted to evaluate chatgpt in detection of hate speech in english, each of which used different dataset, but similar studies are rare for the turkish language. studies show the importance of the prompts when using chatgpt. among the recent works, @xcite chatgpt to classify english text as sexist or racist. they used zero-, one-, and few-shot learning paradigms. for zero-and one-shot learning, they achieved an average accuracy between 55% and 67% depending on the category of text and type of learning. for few-shot learning, they used a different example set in prompt and they found that with few-shot learning, the model's accuracy could be as high as 85%. han and tang (2022) used chatgpt to detect hate speech and investigated designing effective prompts for better performance. they demonstrated that numbers of training examples in the prompt matters. additionally, they discovered that giving the model clear instructions works better than other approaches for incorporating our past knowledge into the model and enhancing its functionality. they achieved accuracy of 86% and macro-f1 of 85% for english comments from youtube and reddit. @xcite examined whether chatgpt can be used for providing natural language explanations (nles) for implicit hateful speech detection. they reported that chatgpt correctly identifies 80% of the implicit hateful tweets in their experiment setting. additionally, they discovered that chatgpt-generated nles tend to be interpreted as clearer than nles created by humans and can reinforce human perception. this does, however, underline the need for more caution when utilizing chatgpt as a tool to aid in data annotation because, in the event that it makes a mistake, it may mislead lay people @xcite aimed to use the potential power of chatgpt to detect harmful content in english.they evaluated chatgpt in comprehending hateful, offensive, and toxic concepts. they showed that chatgpt can achieve an accuracy of approximately 80% when compared to amazon mturker foot_1 annotations. ## dataset overview we use the extended version of the publicly available siu2023-nst dataset foot_2 towards immigrants and refugees @xcite . this dataset is labelled in two ways: binary classification (based on presence or absence of hate speech) and multiclass classification, ranging from insult to threat of harm, assumed to correspond to the strength of hate speech. tables 1 and 2 show the statistics for the train-and test-split of this dataset. ## methodology we evaluate two approaches , namely bert and chatgpt, to detect hate speech and measure the strength of hate speech. the two problems are formulated as a binary-classification problem and a regression problem respectively. in the first approach, we fine-tune the berturk model in the huggingface transformer package foot_3 , using a classification or regression head that consists of a linear layer on top of the pooled output. the input to both models are preprocessed to remove usernames, urls and the # signs, while keeping the text of the hashtags. for the classification problem, we use crossentropy (ce) loss to fine-tune bert: for the second approach, we use the chatgpt with zero-and few-shot learning paradigms. for zero-and few-shot learning, we design two prompts to interact with chatgpt as shown in figure 1 and 2. our few-shot prompt contains seven examples from train-split of the refugee dataset, three of which are examples with non-hate label and four examples with hate labels ranging strength from 1 to 4. ## experiments we conduct two experiments: experiment-1: binary classification problem (hateful and nonhateful); experiment-2: regression problem for predicting strength of hate speech. using the transfer learning approach, we finetune berturk foot_4 model. we use the cross-entropy loss and mean-squared error (mse) loss for the classification and regression problems respectively, using stratified 10-fold cross validation. for zero-and few-shot learning, we use "chatgpt-text-davinci-003" model as it is one of the most powerful versions of the gpt language model developed by openai. it is trained on a larger and more diverse dataset and designed to generate high-quality natural language responses to a wide range of tasks, including language translation, summarization, question-answering, and more. tables 3 and 4 show the results for experiment-1 and experiment-2, respectively. moreover, confusion matrices for these three models are show in figure 3 . ## conclusions and future work in this paper, we evaluate chatgpt's ability for hate speech detection and measuring strength of hate speech in turkish tweets. our experimental results on the extended siu2023-nst dataset show that fine-tuning the pre-trained berturk performs quite well for the challenging problem of hate speech detection. it achieves an accuracy of 82.22% and macro-f1 score of 74.86 in detecting hate speech and a mean square error of 0.46 in estimating the strength of the hate speech. these results are also significantly better than those obtained with chatgpt, whether in zero-or few-shot paradigm. our experience with chatgpt parallels previous results in the literature, showing that the performance depends strongly on the prompt. possibly related to this, the relative results of chatgpt with the zero-or few-shot paradigms are mixed: zeroshot is better in terms of accuracy and mse, while the few-shot is better in terms of precision, recall and macro-f1. on the other hand, the performance of the few-shot increased by increasing samples (from 3 to 7), as expected. as a result, we suggest that chatgpt may be used as an auxiliary tool in big data annotation. however, care must be taken in the design of prompt that the instructions are simple and clear and the number of samples is appropriate. as future work direction, we aim to evaluate the explaining ability of chatgpt in detecting hate speech.