Bert Transformer model for Detecting A rabic GPT 2 Auto-Generated Tweets (2020)

Abstract: During the last two decades, we have progressively turned to the Internet and social media to find news, entertain conversations and share opinion. Recently, OpenAI has developed a machine learning system called GPT-2 for Generative Pre-trained Transformer-2, which can produce deepfake texts. It can generate blocks of text based on brief writing prompts that look like they were written by humans, facilitating the spread false or auto-generated text. In line with this progress, and in order to counteract potential dangers, several methods have been proposed for detecting text written by these language models. In this paper, we propose a transfer learning based model that will be able to detect if an Arabic sentence is written by humans or automatically generated by bots. Our dataset is based on tweets from a previous work, which we have crawled and extended using the Twitter API. We used GPT2-Small-Arabic to generate fake Arabic Sentences. For evaluation, we compared different recurrent neural network (RNN) word embeddings based baseline models, namely: LSTM, BI-LSTM, GRU and BI-GRU, with a transformer-based model. Our new transfer-learning model has obtained an accuracy up to 98%. To the best of our knowledge, this work is the first study where ARABERT and GPT2 were combined to detect and classify the Arabic auto-generated texts.

## introduction in recent years, social media has become an important source of news and information for users in the arab world, with approximately 63% of arab youth indicating that they turn to social media first for news @xcite . due to the lack of editorial checks, fabricated content and misinformation are abundant on different social media platform. for example, recent advances in image and video processing have given rise to so called "deepfakes". similarly, large generative language models, such as gpt-2 and gpt-3, have been used to generate increasingly human-like natural text. such "deepfake" texts can be used by bots, such as twitter bots, to generate sufficiently diverse content in their timelines to evade detection on social media platforms. we define deepfake texts as "automatically generated string sequences, with or without human seed input, that could fool a human into thinking that was generated by another human 1 ." in this paper, we focus on the problem of detecting such deepfake texts. specifically, we employ contextual embeddings, which have led to large improvements for a variety of nlp tasks such as part-of-speech tagging, question answering, and text classification @xcite without the explicit need for feature engineering. these advances in combination with deep learning (dl) enabled the effective detection of auto-generated texts. the trend now is to use deep learning models to solve old machine learning problems including text classification without the need for feature extraction. deep learning approaches such as convolutional neural networks (cnns) and recurrent neural netowrks (rnns) are now applied to enhance the performance of auto-generated text detection models @xcite . despite theirs success, they still suffer from the lack of annotated data for training. gpt-2 @xcite , and bert @xcite are among new approaches recently considered for overcoming this issue. a language understanding model learns contextual and task-independent representations of terms. a huge amount of texts obtained from large corpora is used to build generic (multilingual multi-application) models. numerous deep learning text detection methods have been proposed to help readers determine if a piece of text has been authored by machine or human. the results of employing such language models are very effective in the detection of misinformation and propaganda by providing mechanisms to reveal the nature of news articles and to ensure the authenticity of its source @xcite . in this paper, we propose a method for generating deepfake text using gpt2 and to consequently identify such texts using a pre-trained bert model. as far as we know, it is the first time that such combined approach is proposed for arabic language. the outputs of the generative pre-trained language model will be used as inputs for the transfer-learning model that will detect if the input text is coming from human or machine. our experiment results show that using the pre-trained bert model outperforms rnn models in detecting arabic deepfake texts. the contributions of this work are: several studies have been carried out on the classification and detection of social bots. in this section, we will provide an overview of relevant related works. this can provide a basic understanding on the state-of-the-art of social bot detection methods and approaches. almerekhi and elsayed (2015) proposed a system for the detection of automatically generated arabic tweets. they evaluated their system using 3.5k labelled tweets randomly sampled and labeled by crowd flower. a set of features including formality, structural, tweet-specific, and temporal features has been extracted from arabic tweets to train three classification algorithms, namely: support vector machines (svm), naive bayes, and decision trees. their results show that classification based on individual categories of features outperform the baseline unigram-based classifier in terms of classification accuracy. @xcite proposed a framework for bot detection on twitter. they presented a machine learning based system used for the extraction of a collection of features from six different classes. the features were used in training robust models to identify bots. they evaluated the performance of their detection system using two different datasets: manually-annotated twitter accounts dataset and a public honeypot dataset. their analysis on the contributions of different feature classes suggests that user metadata and content features are the two most valuable sources of data to detect simple bots. @xcite looked at the problem of detecting propaganda accounts on twitter. they crafted three different kinds of features, namely interaction features (ex. retweets and mentions), lexical diversity, and stylistic features (ex. offensiveness and sentiment). using an svm classifier, they found that interaction features where the most effective features for detecting propaganda accounts, and stylistic features benefited overall classification. akyon and kalfaoglu (2019) presented a system for the detection of fake and automated accounts. their system is tackling the problem of using a binary classification model. they constructed a dataset of 1,400 accounts from different countries. there were an equal number of real and automated accounts in their dataset. they proposed a set of derived features and the most effective features from this set were selected to develop a cost-sensitive genetic feature selection algorithm. their results showed that neural network methods and svm achieved the best f1 scores for the detection of automated accounts. @xcite presented a simple model based on capturing regions to detect bots on facebook. features were leveraged in experimentation as bot indicators to separate bots away from the central range of the full feature distributions. they noted that some features that appear to cluster bots tightly are collaborating with high priority in the identification of a user as a human. their system has been developed and evaluated on public pages as bot detection software using standard evaluation metrics such as f1 score. they found that a small percentage of interacting user population were showing signs to be social bots. in the work of @xcite work, a deep neural network based on contextual long short-term memory (lstm) was proposed. the architecture of the system exploits content and metadata features to detect bots at the tweet level. they used the features extracted from user's profile metadata and tweet text as inputs to the lstm. they also proposed a very useful data augmentation technique for generating large labeled datasets based on synthetic minority oversampling. they showed that their model could identify bots from humans with a high accuracy. they also achieved a perfect classification accuracy by applying the same architecture to account-level bot detection. @xcite developed an rnn (bilstm) word embeddings based model to discriminate twitter bots from human accounts without requiring any prior knowledge or handcrafted features. by comparison with similar bot detection systems, their experiments on the cresci-2017 dataset showed that their proposed system achieved reasonable performances. they also confirmed the ability of using bilstm with word embeddings in their model to detect phishing email, webpages or smss. in the work of @xcite , a behavior enhanced deep model for bot detection was proposed and applied to detect bots under two deep learning frameworks. by fusing content and behavior information, the aim of the proposed model is to capture the latent features. using a honeypot method, they collected a public dataset for theirs experiments using a cnn network. their model was investigated by varying the number of filters and the filter width and number of hidden units in the hidden layer. their proposed system achieved the highest f1 score compared to other state of the art systems. ## experimental setup we combined the human generated and deepfake sets, and we randomly divided the combined dataset into 80/20 training and test splits. we utilized 4 competitive deep learning recurrent neural network (rnn) baselines to compare to our proposed transformer-based model. figure 1 showcases the entire architecture of our proposed solution with the explanation of the elements therein in ## conclusion in this paper, we aimed to automatically detect deepfake text. we created a dataset of human generated tweets and deepfake tweets that we generated using gpt2-small-arabic. for classification, we experimented with different rnn models and compared them to arabert, a pre-trained bert model for arabic. the results show that we can effectively distinguish between human generated and machine generated tweets with high accuracy (98.7%) using a fine-tuned arabert model, which outperforms rnn models. for future work, we plan to use explainability tools to determine the reasons for the success of the arabert model. we suspect that the model is able to detect deepfakes due to repetitions in the text, which are a common artifact of automatically generated text, or the style of language of gpt2 generated text.