Next Article in Journal
Lithium-Ion Battery Modeling and State of Charge Prediction Based on Fractional-Order Calculus
Previous Article in Journal
Dynamics of Benjamin–Ono Solitons in a Two-Layer Ocean with a Shear Flow
Previous Article in Special Issue
Reinforcement Learning Recommendation Algorithm Based on Label Value Distribution
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Differentiating Chat Generative Pretrained Transformer from Humans: Detecting ChatGPT-Generated Text and Human Text Using Machine Learning

1
Department of Computer Science, Faculty of Computing and Information Technology, King Abdulaziz University, Jeddah 21589, Saudi Arabia
2
Department of Software Engineering, College of Computer Science and Engineering, University of Jeddah, Jeddah 21493, Saudi Arabia
3
Nautical Science Department, Faculty of Maritime Studies, King Abdulaziz University, Jeddah 21589, Saudi Arabia
4
Faculty of Earth Sciences, King Abdulaziz University, Jeddah 21589, Saudi Arabia
5
Information Technology Department, Faculty of Computing and Information Technology, King Abdulaziz University, Jeddah 21589, Saudi Arabia
6
Department of Mathematics, Faculty of Science, Al-Azhar University, Naser City, Cairo 11884, Egypt
7
Centre for Artificial Intelligence in Precision Medicines, King Abdulaziz University, Jeddah 21589, Saudi Arabia
*
Author to whom correspondence should be addressed.
Mathematics 2023, 11(15), 3400; https://doi.org/10.3390/math11153400
Submission received: 12 June 2023 / Revised: 24 July 2023 / Accepted: 31 July 2023 / Published: 3 August 2023

Abstract

:
Recently, the identification of human text and ChatGPT-generated text has become a hot research topic. The current study presents a Tunicate Swarm Algorithm with Long Short-Term Memory Recurrent Neural Network (TSA-LSTMRNN) model to detect both human as well as ChatGPT-generated text. The purpose of the proposed TSA-LSTMRNN method is to investigate the model’s decision and detect the presence of any particular pattern. In addition to this, the TSA-LSTMRNN technique focuses on designing Term Frequency–Inverse Document Frequency (TF-IDF), word embedding, and count vectorizers for the feature extraction process. For the detection and classification processes, the LSTMRNN model is used. Finally, the TSA is employed for selecting the parameters for the LSTMRNN approach, which enables improved detection performance. The simulation performance of the proposed TSA-LSTMRNN technique was investigated on benchmark databases, and the outcome demonstrated the advantage of the TSA-LSTMRNN system over other recent methods with a maximum accuracy of 93.17% and 93.83% on human- and ChatGPT-generated datasets, respectively.

1. Introduction

Over the decades, Natural Language Processing (NLP) has become an important field of research with an aim to improve the ability of computer systems to generate and understand human language [1]. The recent advancements in this field have led to the development of a large language model that exploits Machine Learning (ML) algorithms to generate humanlike language and learn from a humongous volume of textual data [2]. The Generative Pretrained Transformer (GPT) series, introduced by OpenAI, has received considerable attention in natural language processing [3]. The advancement of ChatGPT marks a crucial milestone in the field of NLP as it signifies a considerable step toward the construction of sophisticated and state-of-the-art computer systems and it also has the potential to understand and generate natural languages [4]. Furthermore, it generates prompt responses that are not only contextually appropriate but also coherent in nature, and it is also trained using massive amounts of text data. The capacity of a model to generate text that is similar to human language has a major impact on communication, education, and language learning areas. The large language model that is currently popular, i.e., the ChatGPT system, represents considerable progress in the domain of NLP. BERT, coined by Google, is another significant example of a large language model [5]. Similar to ChatGPT, BERT can also be finetuned for NLP tasks that involve language translation, Sentimental Analysis (SA), and question–answer tasks and is pretrained using an enormous amount of text data. Though the systems vary in their model architecture and pretraining model, the core functionality of ChatGPT and BERT remains the same [6]. The advancement of such large language models helps in revolutionizing several industries that involve communication, education, and healthcare by allowing natural and more sophisticated interactions between machines and humans [7].
However, the highly prevalent adoption of revolutionary AI-based chatbots including ChatGPT highlights the importance of the capability to recognize whether a text has been written by human being or by AI [8]. This may have serious implications in different fields that involve digital forensics and information security [9]. For example, in the information security domain, the capability of identifying AI-generated text is essential both to detect and to protect against the malicious usage of AI, namely social engineering attacks or the spread of misinformation and disinformation. To ensure the accuracy and trustworthiness of the data [10], it is crucial to develop techniques to identify AI-generated texts. This is crucial because such techniques must be utilized in sensitive fields such as finance and banking, political campaigns, customer reviews, and legal documents (customer reviews of movies, restaurants, or products).
In this background, the current study presents the Tunicate Swarm Algorithm with Long Short-Term Memory Recurrent Neural Network (TSA-LSTMRNN) model to detect both human- and ChatGPT-generated text. The purpose of the proposed TSA-LSTMRNN method is to investigate the model’s decision and identify the presence of any particular pattern. In addition to these, the TSA-LSTMRNN technique focuses on designing TF-IDF, word embedding, and count vectorizers for the purpose of feature extraction. For the detection and classification processes, the LSTMRNN model is used. Finally, the TSA is exploited for selecting the parameters for the LSTMRNN approach, which helps in attaining improved detection performance. The simulation performance of the proposed TSA-LSTMRNN technique was investigated using the benchmark datasets.
The rest of the paper is organized as follows. Section 2 provides information regarding related works, and Section 3 provides details about the proposed model. Then, Section 4 presents the analytical results, and Section 5 concludes the paper.

2. Related Works

Yu et al. [11] presented a large-scale CHatGPT-writtEn AbsTract dataset (CHEAT) to assist in the advancement of the recognition methods and inspect the possible negative effect of ChatGPT on academia. To be specific, the ChatGPT-written abstract data had a total of 35,304 synthetic abstracts, with Mix, Generation, and Polish as eminent representatives. Liao et al. [12] presented an ethical AIGC (Artificial Intelligence Generated Content) system in the healthcare sector. In this study, the authors mainly focused on examining the variances between medical texts generated by ChatGPT and those written by human experts. Further, the study also devised ML workflows to potentially distinguish and find medical texts generated by ChatGPT. At first, the authors built a set of datasets with one containing medical texts generated by ChatGPT and another one written by human experts. Eventually, the authors applied and devised ML approaches to ascertain the origin of the generated medical text.
Alamleh et al. [13] evaluated the performance of ML methods in distinguishing AI-generated text from human-written text. To achieve this objective, the authors gathered responses from computer science students to essay and programming assignments. Then, based on the data, the authors evaluated and trained numerous ML methods such as SVM, LR, NN, RF, and DT. Chen et al. [14] introduced an innovative method to differentiate human-written and ChatGPT-generated texts with the help of language methods. The authors gathered and released the preprocessed data called OpenGPTText, which contained rephrased content generated utilizing ChatGPT. Pardos and Bhandari [15] conducted an initial learning gain assessment of ChatGPT by comparing the efficiency of its hints to hints presented by human tutors on two different algebra topics such as intermediate and elementary algebra. Hamed and Yu [16] displayed how to differentiate ChatGPT-generated publications from their counterparts written by the researchers. By devising a supervised ML approach, the authors demonstrated how to differentiate machine-generated articles from scientist-created articles. The authors developed an algorithmic method that identified the ChatGPT-generated publication with a high precision.
Perkins et al. [17] explored the academic integrity considerations of students using AI tools, in addition to the Large Language Model (LLM), namely ChatGPT, in formal assessment. The authors evaluated the development of these tools and highlighted the possible ways in which the LLM supports the education of students in digital writing including composition and teaching of writing, the possibilities of co-creation between AI and the humans, enhancing Automated Writing Evaluation (AWE), and supporting EFL learners. Maddigan and Susnjak [18] presented a new system called Chat2VIS, which makes the maximum use of LLMs and illustrates how the complicated issue of language understanding can be resolved with high potential for prompt engineering, and it results in simple and precise end-wise solutions compared to the existing methods. Based on the prompts presented, Chat2VIS displays that the LLM presents a dependable method for rendering visualizations from natural language questions, even if the queries were underspecified and highly misspecified.
Only a limited number of studies are available in the literature related to the ChatGPT-generated text detection process. Therefore, there exists a need to improve the detection results for ChatGPT-generated texts. Due to a continuous deepening of the model, the number of parameters involved in DL models also increases quickly, which results in model overfitting. At the same time, different hyperparameters have significant impact on the efficiency of the CNN model. Particularly, hyperparameters such as epoch count, batch size, and learning rate selection are essential to attain effectual outcomes. Since the trial-and-error method for hyperparameter tuning is a tedious and an erroneous process, metaheuristic algorithms are applied. Therefore, in this work, the authors employed the TSA for parameter selection of the LSTMRNN model.

3. The Proposed Model

In the current research paper, the authors established an automated human-generated text and ChatGPT-generated text detection model, named the TSA-LSTMRNN model. The objective of the proposed TSA-LSTMRNN technique is to investigate the model’s decision and compute whether any particular pattern can be detected. The model has three stages, namely feature extraction, LSTMRNN classification, and TSA-based parameter tuning. Figure 1 represents the overall flow of the TSA-LSTMRNN approach.

3.1. Feature Extraction

In this study, TF-IDF is used for the word embedding process, whereas the count vectorizer algorithm is utilized for feature extraction. In data mining, feature extraction is a procedure that contains steps to reduce the data count and make it accessible so as to define huge databases. When it comes to analyzing the mood of a difficult text, the main problem arises from the presence of numerous variables. Generally, to analyze a difficult or huge text, large amounts of memory and processing power are required. This results in the use of the classifier technique, which is more appropriate for trained instances and leads to worse generalizations for novel instances. The researchers mentioned that, in applications containing several features, extraction is the same process as dimensionality reduction. When feature extraction systems are applied to the input data before they are passed onto the classifier system, it is possible to achieve refined outcomes and high classification method accuracy.
In the literature, the count vectorizer feature extraction method has been utilized to cover tweets based on frequent words (count) that occurs in the tweets. Such tweets are then converted into a vector space [19]. A column matrix denotes the count vectorizer that generates a word matrix, whereas a row matrix corresponds to the text selected from the document. Thereby, the word in that specific text instance is counted. The TF-IDF has a weighted feature for execution boosting and was used for tweet analysis in that study. Here, the length defines the TF of a feature in a single document.
T F = c o u n t t , d t o t a l c o u n t d
Here, c o u n t y , d represents the amount of TF t in document d and t o t a l   c o u n t d denotes the total amount of terms present in the document. IDF considers that when the text increases in terms of t , it would be highly informative for training the model.
i d f = i d f t  
In Equation (2), i denotes the overall number of documents and d f t shows the number of documents including the t phrase. Once the term t often appears in various documents, the IDF calculates the weight of the phrase t as low. For instance, a stop word has lower IDF values. Lastly, the TF-IDF is determined as follows:
t f i d f = t f t , d l o g i d f .  
Also, the current study used the word embedding method for feature extraction, namely Glove, pretrained model, FastText, and Word2Vec embedding with 300-D vectors.

3.2. Detection Model Using LSTMRNN

This stage aims to search a DL structure that contains attention layers so as to understand the detection process of human- and ChatGPT-generated texts. Therefore, in the presented LSTMRNN structure, many other processing stages are also involved. The primary one is the convolution of features [20]. The initial step is used for the extraction of high-level semantic features in word sequences. The LSTMRNN approach also determines the temporal connection among the features and creates the feature vectors.
Furthermore, the semantic meaning of the input text is assumed, and the secondary label sets are created with values allocated to individual data. The RNN approach proceeds with a series of pixels such as x = x 1 , x 2 , , x n creating Hidden Layers (HLs) H = H 1 ,   H 2 , ,   H n and outcome layers O = O 1 , O 2 ,   , O n in a subsequent manner.
O t = σ W H t O t + b t
H t = σ W H t 1 H t H t 1 + W x t H t x t + b H t
At this point, W H t O t signifies the vector in the hidden unit H t and the output unit O t ,   H t 1 stands for the hidden unit for the t 1 pixel series, W H t 1 H t refers to the weighted vector in the hidden unit H t 1 to H t for the sequence time t , and b H t and b t refer to the biases.
Additionally, the LSTM stack is utilized to learn the time series features. On the other hand, the model acquires the issues contained in a single sequence of observation. The method must learn the sequences of past observations to predict the next value in order as given below.
i g t = t a n h W x t i g t x t + W H t 1 i g t H t 1 + b i g t
p t = σ W x t p t x t + W H t 1 p t H t 1 + b p t
f g t = σ W x t f g t x t + W H t 1 f g t H t 1 + b f g t
o p t = σ W x t o p t x t + W H t 1 o p t H t 1 + b o p t
C e t = c e t 1 f g t + i g t p t
H t = t a n h C e t o p t
Here, i g i stands for the input gate; p i implies the forecast from the initial layers; f g t exemplifies the forget gate; H t offers the data on output; b i g ,   b p ,   b f g ,   b o p denote the bias vectors; C e t shows the cell state; and W x x implies the weighted matrix. Either the RNN or the LSTM approach is integrated to extract the semantic features in the input tweets.
To be specific, it executes the attention layer so as to enhance the learning of the features as well as the feature weights. The LSTMRNN approach has been utilized to learn a series of sentences and create the weighted features through the attention procedure. Additionally, it also utilizes the secondary labels integrated with the LSTMRNN approach to assist in enhancing the areas of interest from the learning procedure. Therefore, X i denotes the input, f X i , X i + 1 denotes the features created in the second layer, and f X i , X i + 1 , , X i + L 1 corresponds to the L t h layer. The feature value refers to the responses of multi-scale n -grams, for example, unigram X i , bigram X i X i + 1 , and L -gram X i X i + 1 X i + L 1 . Moreover, the scale reweighting is utilized to compute the SoftMax distribution of attention weights in which the descriptor is utilized as the dataset and the output weighted element weights are to be reweighed.
S l i = F L e n s m X l i
X a t t e n i = j = 1 L α L i X L i
i L = S o f t m a x M L P X a t t e n i
In the presented method, the novelty lies in the development of the weighted features by utilizing the attention layer procedure. The presented method recovers the text information in a series mapped by LSTMRNN, whereas the LSTM creates a series of annotations for every input. The vectors utilized are the concatenation of the HLs from the encoded layers. Afterward, the features can be developed using the attention layer model. At the time of the training process, every sample from the training data is passed on to the LSTMRNN approach one time step at a time. The LSTM units process the input, update their internal states, and produce an output at each time step. Then, the outputs are typically used to make the prediction process.

3.3. Hyperparameter Tuning Using TSA

In the current study, the TSA is used to improve the parameter selection process for the LSTMRNN model. The TSA is an optimization technique that is based on the biological behavior of animals, i.e., the foraging behavior of tunicates, marine invertebrates that radiate brighter bioluminescence [21]. In particular, the TSA draws its motivation from a peculiar behavior of the tunicates in the ocean, i.e., their jet drive and the swarm intelligence of the foraging processes. Under three major constraints, the mathematical modeling of jet propulsion is proposed: following the position of the best agent, preventing conflicts amongst the exploration agents, and remaining near the optimum agents. Figure 2 depicts the flowchart of the TSA.
To prevent conflicts when finding the best location, the new location of the search agent is evaluated as given below.
A = G M
G = c 2 + c 3 F
F = c 1 · F .
Let A be the vector of a new position of the search agent; F refers to the water flow in the ocean; G indicates the gravity force; and c 1 ,   c 2 , and c 3 denote three randomly generated numbers. The social forces between the agents are kept in a new vector M as given below.
M = P m i n + c 1 P m a x P m i n .
In Equation (18), P m i n = 1 and P m a x = 4 correspondingly describe the first and second subordinates, which demonstrate the speed of establishing a social interaction.
It is crucial to follow the present optimum agent in order to gain a better solution. Therefore, after ensuring that no conflicts are present between the neighboring agents in a swarm, the fittest location of the optimum agent is measured as given below.
P D = X b e s t r r a n d p p x
In Equation (19), P D denotes the length between a better agent and the food origin, r r a n d denotes a stochastic value within [ 0 , 1 ] , X b e s t shows the optimal location, and the vector P p x has the position of the tunicates at iteration x .
In order to ensure that the search agent is still closer to the optimal agent, their locations are calculated using Equation (20):
p p x = X b e s t + A P D ,   i f   r r a n d 0.5 X b e s t A P D ,   i f   r r a n d < 0.5
In Equation (20), p p x indicates the upgraded position of the agents at iteration x with respect to the better-scored location X b e s t .
The location of the existing agent is updated based on the position of two agents so as to model the swarming behaviors of the tunicates.
P p x + 1 = p p x + P p x + 1 2 + c 1
The following steps demonstrate the flow of the original TSA approach:
  • Step 1: Initialize the population of tunicates P p .
  • Step 2: Set the maximum number of iterations and the original value for the parameter.
  • Step 3: Evaluate the fitness value of the exploration agents
  • Step 4: Explore a better agent in the search space.
  • Step 5: Upgrade the position of the exploration agent based on Equation (21).
  • Step 6: Return the newly updated agent to its boundaries.
  • Step 7: Measure the fitness cost of the updated search agents. In case of a solution superior to the prior solution, update P p and keep the better solution in Xbest.
  • Step 8: End the process if the terminating condition is satisfied. Or else, return to steps 5–8.
  • Step 9: Return the better solution (Xbest).
Fitness choice is a key aspect of the TSA algorithm. An encoded outcome is employed herewith to determine the goodness of a candidate’s performance. At present, the accuracy value is the major condition employed to plan an FF.
F i t n e s s = m a x P
P = T P T P + F P  
Here, T P and F P denote true and false positive values, respectively.

4. Results and Discussion

In this section, the results attained from the experimental investigation of the proposed TSA-LSTMRNN approach on human-generated text dataset and ChatGPT-generated text dataset are discussed. The approach was analyzed experimentally under a set of five experiments. Each experiment included a sample set comprising human-generated text and ChatGPT-generated text. The sample texts are given below.
Sample 1:
  • Human-generated text: The selection on the menu was great and so were the prices.
  • ChatGPT-generated text: The menu had a great selection and the prices were good.
Sample 2:
  • Human-generated text: Point your finger at any item on the menu, order it and you won’t be disappointed.
  • ChatGPT-generated text: No matter what you order from the menu, you won’t be disappointed.
Sample 3:
  • Human-generated text: The one down note is the ventilation could use some upgrading.
  • ChatGPT-generated text: The only drawback at this restaurant is that the ventilation could be improved.
Sample 4:
  • Human-generated text: I believe that this place is a great stop for those with a huge belly and hankering for sushi.
  • ChatGPT-generated text: I believe this place is a great stop for those with a big appetite and a desire for sushi.
Sample 5:
  • Human-generated text: It was a truly special dining experience that exceeded all of my expectations.
  • ChatGPT-generated text: I had a great experience at this restaurant and the services are beyond expectations.
The current study used a set of measures to examine the classification outcomes such as accuracy ( a c c u y ), precision ( p r e c n ), recall ( r e c a l ), Mathew Correlation Coefficient (MCC), and F-score ( F s c o r e ).
Precision measures the proportion of the correctly predicted positive instances of the overall instances that were predicted as positive.
P r e c i s i o n = T P T P + F P
Recall measures the proportion of the positive samples that were correctly classified.
R e c a l l = T P T P + F N
Accuracy measures the proportion of the correctly classified samples (positives and negatives) against the total number of samples (number of samples that were classified).
A c c u r a c y = T P + T N T P + T N + F P + F N  
F-score is a measure that combines the harmonic mean of the precision and recall measures.
F - s c o r e = 2 T P 2 T P + F P + F N
In Table 1 and Figure 3, the detection outcomes of the proposed TSA-LSTMRNN technique on the human-generated text dataset are provided. The results indicate that the proposed approach appropriately recognized the human-generated text dataset as positive and negative samples. For instance, in experiment 1, the TSA-LSTMRNN technique attained average a c c u y , p r e c n , r e c a l , F s c o r e , and MCC values of 93.17%, 92.56%, 93.17%, 92.77%, and 85.72%, respectively. Furthermore, in experiment 2, the TSA-LSTMRNN method reached average a c c u y , p r e c n , r e c a l , F s c o r e , and MCC values of 93.17%, 90.55%, 91.17%, 90.75%, and 87.71%, respectively. Moreover, in experiment 3, the proposed TSA-LSTMRNN algorithm accomplished average a c c u y , p r e c n , r e c a l , F s c o r e , and MCC values of 87.83%, 87.71%, 87.83%, 87.77%, and 75.55%, correspondingly. Meanwhile, in experiment 4, the TSA-LSTMRNN system yielded average a c c u y , p r e c n , r e c a l , F s c o r e , and MCC values of 91.33%, 90.83%, 91.33%, 91.02%, and 82.16%, respectively. Finally, in experiment 5, the TSA-LSTMRNN approach reached average a c c u y , p r e c n , r e c a l , F s c o r e , and MCC values of 88.75%, 88.57%, 88.75%, 88.65%, and 77.32%, correspondingly.
Figure 4 showcases the a c c u y values accomplished by the proposed TSA-LSTMRNN technique in training and validation methods on human-generated text database. The results indicate that the TSA-LSTMRNN technique achieved high a c c u y values over higher epochs. Also, a maximum validation a c c u y that was greater than the training a c c u y was achieved, which exhibits that the TSA-LSTMRNN technique establishes its capability on human-generated text databases.
A loss study was conducted for the proposed TSA-LSTMRNN system at the time of training and validation upon the human-generated text database, and the results are revealed in Figure 5. The results point out that the TSA-LSTMRNN method achieved similar training and validation loss values. It can be understood that the TSA-LSTMRNN technique operates effectively on human-generated text databases.
A brief PR study was conducted on the TSA-LSTMRNN approach using the human-generated text database, and the results are shown in Figure 6. The outcomes indicate that the TSA-LSTMRNN algorithm enhanced the PR values. In addition to this, it is noticeable that the TSA-LSTMRNN technique can gain superior PR values in both the classes.
Figure 7 shows the results of the ROC analysis accomplished using the TSA-LSTMRNN technique on the human-generated text database. The results describe that the TSA-LSTMRNN approach enhanced the ROC values. Moreover, the TSA-LSTMRNN system extended the ROC values in both the class labels.
In Table 2 and Figure 8, the detection outcomes of the TSA-LSTMRNN method on ChatGPT-generated text dataset are provided. The outcomes point out that the proposed TSA-LSTMRNN method properly recognized both positive and negative instances in the ChatGPT-generated text dataset. For instance, in experiment 1, the TSA-LSTMRNN method accomplished average a c c u y , p r e c n , r e c a l , F s c o r e , and MCC values of 78%, 81.51%, 78%, 78.65%, and 59.41%, correspondingly. Moreover, in experiment 2, the TSA-LSTMRNN technique attained average a c c u y , p r e c n , r e c a l , F s c o r e , and MCC values of 82.17%, 83.96%, 82.17%, 82.70%, and 66.10%, respectively. Additionally, in experiment 3, the proposed TSA-LSTMRNN methodology achieved average a c c u y , p r e c n , r e c a l , F s c o r e , and MCC values of 82.42%, 84.34%, 82.42%, 82.97%, and 66.73%, respectively. In the meantime, in experiment 4, the TSA-LSTMRNN system attained average a c c u y , p r e c n , r e c a l , F s c o r e , and MCC values of 81.58%, 84.19%, 81.58%, 82.24%, and 65.73%, correspondingly. Lastly, in experiment 5, the TSA-LSTMRNN technique yielded average a c c u y , p r e c n , r e c a l , F s c o r e , and MCC values of 93.83%, 94.52%, 93.83%, 94.12%, and 88.35%, correspondingly.
Figure 9 shows the a c c u y curve plotted on the values achieved by the TSA-LSTMRNN technique in both training and validation models using the ChatGPT-generated text database. The outcomes imply that the TSA-LSTMRNN technique attained improved a c c u y values over superior epochs. Additionally, the enhanced validation a c c u y value exceeded the training a c c u y value, indicating that the TSA-LSTMRNN methodology works effectively on the ChatGPT-generated text database.
The loss curve of the TSA-LSTMRNN system, at the time of training and validation, on the ChatGPT-generated text database, is shown in Figure 10. The outcomes indicate that the TSA-LSTMRNN system realized adjacent training and validation loss values. Thus, it is obvious that the TSA-LSTMRNN system achieves capably on the ChatGPT-generated text database.
Figure 11 shows a brief PR curve of the TSA-LSTMRNN methodology upon the ChatGPT-generated text database. The results indicate that the TSA-LSTMRNN system affects superior values of PR. Afterward, it can be observed that the TSA-LSTMRNN technique obtained enhanced the PR values in both the class labels.
In Figure 12, an ROC curve of the TSA-LSTMRNN technique is plotted for the ChatGPT-generated text database. The outcomes imply that the TSA-LSTMRNN approach accomplished higher ROC values. Moreover, it is clear that the TSA-LSTMRNN algorithm can yield higher ROC values in both the classes.
In Table 3, the comprehensive comparison outcomes of the TSA-LSTMRNN system on both human-generated text dataset and the ChatGPT-generated text datasets are provided.
Figure 13 represents the classification outcomes achieved by the proposed TSA-LSTMRNN technique and other ML approaches on human-generated text datasets. The result indicates that both XGBoost and CNN methods obtained the least a c c u y values, i.e., 83.86% and 84.08%, correspondingly. Then, the DT and SVM models reported moderately improved a c c u y values of 86.70% and 86.72%, respectively. Although the ELM model produced a near-optimal a c c u y of 89.80%, the TSA-LSTMRNN algorithm established its supremacy with an increased a c c u y of 93.17%.
Figure 14 represents the classification results of the TSA-LSTMRNN approach and of other ML techniques on ChatGPT-generated text dataset. The outcome indicates that both SVM and XGBoost approaches produced the least a c c u y values, i.e., 82.30% and 84.96%, correspondingly, followed by the CNN and ELM approaches, which reported moderately improved a c c u y values of 86.93% and 86.34%, correspondingly. Though the DT approach accomplished a near-optimal a c c u y of 88.01%, the TSA-LSTMRNN method showed its supremacy with an improved a c c u y of 93.83%. These results highlight the significant performance of the proposed TSA-LSTMRNN technique.

5. Conclusions

In the current study, the authors developed an automated human-generated text and ChatGPT-generated text detection model, named the TSA-LSTMRNN approach. The purpose of the TSA-LSTMRNN technique is to investigate the model’s decision and compute whether any particular pattern can be detected. Moreover, the TSA-LSTMRNN technique focuses on the design of TF-IDF, word embedding, and count vectorizers for the feature extraction process. For the detection and classification processes, the LSTMRNN model is used. At last, the TSA is exploited for the purpose of parameter selection for the LSTMRNN approach, which enables improved detection performance. The proposed TSA-LSTMRNN technique was experimentally validated using two benchmark databases, and the outcomes demonstrate the superior efficiency of the TSA-LSTMRNN algorithm over other recent systems. In the future, the performance of the TSA-LSTMRNN method can be boosted with the help of ensemble models.

Author Contributions

Conceptualization, I.K. and M.R.; methodology, I.K., F.Y.A. and M.R.; software, I.K. and F.Y.A.; validation, I.K., F.Y.A. and H.A.A.; formal analysis, F.Y.A. and M.R.; investigation, I.K.; resources, F.Y.A., H.A.A. and D.H.; data curation, F.Y.A., H.A.A. and D.H.; writing—original draft, I.K. and M.R.; writing—review & editing, I.K. and F.Y.A.; visualization, H.A.A. and D.H.; supervision, I.K.; project administration, M.R.; funding acquisition, D.H. All authors have read and agreed to the published version of the manuscript.

Funding

This research work was funded by Institutional Fund Projects under grant no. (IFPFP-266-22).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Data sharing does not apply to this article as no datasets were generated during the current study.

Acknowledgments

The authors gratefully acknowledge technical and financial support provided by the Ministry of Education and Deanship of Scientific Research (DSR), King Abdulaziz University (KAU), Jeddah, Saudi Arabia.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Gao, C.A.; Howard, F.M.; Markov, N.S.; Dyer, E.C.; Ramesh, S.; Luo, Y.; Pearson, A.T. Comparing scientific abstracts generated by ChatGPT to real abstracts with detectors and blinded human reviewers. NPJ Digit. Med. 2023, 6, 75. [Google Scholar] [CrossRef] [PubMed]
  2. Pavlik, J.V. Collaborating with ChatGPT: Considering the Implications of Generative Artificial Intelligence for Journalism and Media Education. J. Mass Commun. Educ. 2023, 78, 84–93. [Google Scholar] [CrossRef]
  3. Qadir, J. Engineering Education in the Era of ChatGPT: Promise and Pitfalls of Generative AI for Education. In Proceedings of the 2023 IEEE Global Engineering Education Conference (EDUCON), Kuwait, Kuwait, 1–4 May 2022. [Google Scholar]
  4. Dergaa, I.; Chamari, K.; Zmijewski, P.; Saad, H.B. From human writing to artificial intelligence generated text: Examining the prospects and potential threats of ChatGPT in academic writing. Biol. Sport 2023, 40, 615–622. [Google Scholar] [CrossRef] [PubMed]
  5. Shen, Y.; Heacock, L.; Elias, J.; Hentel, K.D.; Reig, B.; Shih, G.; Moy, L. ChatGPT and other large language models are double-edged swords. Radiology 2023, 307, e230163. [Google Scholar] [CrossRef] [PubMed]
  6. Shahriar, S.; Hayawi, K. Let’s have a chat! A Conversation with ChatGPT: Technology, Applications, and Limitations. arXiv 2023, arXiv:2302.13817. [Google Scholar] [CrossRef]
  7. Sallam, M. The Utility of ChatGPT as an Example of Large Language Models in Healthcare Education, Research and Practice: Systematic Review on the Future Perspectives and Potential Limitations. MedRxiv 2023. [Google Scholar] [CrossRef]
  8. OguzhanTopsakal, E. Framework for A Foreign Language Teaching Software for Children Utilizing AR, Voicebots and ChatGPT (Large Language Models). J. Cogn. Syst. 2022, 7, 33–38. [Google Scholar]
  9. Mhlanga, D. Open AI in Education, the Responsible and Ethical Use of ChatGPT Towards Lifelong Learning; Springer: Berlin/Heidelberg, Germany, 2023. [Google Scholar]
  10. Kasneci, E.; Seßler, K.; Küchemann, S.; Bannert, M.; Dementieva, D.; Fischer, F.; Gasser, U.; Groh, G.; Günnemann, S.; Hüllermeier, E. ChatGPT for good? On opportunities and challenges of large language models for education. Learn. Individ. Differ. 2023, 103, 102274. [Google Scholar] [CrossRef]
  11. Yu, P.; Chen, J.; Feng, X.; Xia, Z. CHEAT: A Large-scale Dataset for Detecting ChatGPT-writtEn AbsTracts. arXiv 2023, arXiv:2304.12008. [Google Scholar]
  12. Liao, W.; Liu, Z.; Dai, H.; Xu, S.; Wu, Z.; Zhang, Y.; Huang, X.; Zhu, D.; Cai, H.; Liu, T.; et al. Differentiate ChatGPT-generated and Human-written Medical Texts. arXiv 2023, arXiv:2304.11567. [Google Scholar]
  13. Alamleh, H.; AlQahtani, A.A.S.; ElSaid, A. Distinguishing Human-Written and ChatGPT-Generated Text Using Machine Learning. In 2023 Systems and Information Engineering Design Symposium (SIEDS); IEEE: Piscataway, NJ, USA, 2023; pp. 154–158. [Google Scholar]
  14. Chen, Y.; Kang, H.; Zhai, V.; Li, L.; Singh, R.; Ramakrishnan, B. GPT-Sentinel: Distinguishing Human and ChatGPT Generated Content. arXiv 2023, arXiv:2305.07969. [Google Scholar]
  15. Pardos, Z.A.; Bhandari, S. Learning gain differences between ChatGPT and human tutor-generated algebra hints. arXiv 2023, arXiv:2302.06871. [Google Scholar]
  16. Hamed, A.A.; Wu, X. Improving Detection of ChatGPT-Generated Fake Science Using Real Publication Text: Introducing xFakeBibs a Supervised-Learning Network Algorithm. Preprints 2023, in press. [Google Scholar] [CrossRef]
  17. Perkins, M. Academic Integrity Considerations of AI Large Language Models in the post-pandemic era: ChatGPT and Beyond. J. Univ. Teach. Learn. Pract. 2023, 20, 7. [Google Scholar] [CrossRef]
  18. Maddigan, P.; Susnjak, T. Chat2vis: Generating data visualisations via natural language using chatgpt, codex and gpt-3 large language models. arXiv 2023, arXiv:2302.02094. [Google Scholar] [CrossRef]
  19. Jalil, Z.; Abbasi, A.; Javed, A.R.; Badruddin Khan, M.; Abul Hasanat, M.H.; Malik, K.M.; Saudagar, A.K.J. COVID-19 related sentiment analysis using state-of-the-art machine learning and deep learning techniques. Front. Public Health 2022, 9, 2276. [Google Scholar] [CrossRef] [PubMed]
  20. Singh, C.; Imam, T.; Wibowo, S.; Grandhi, S. A deep learning approach for sentiment analysis of COVID-19 reviews. Appl. Sci. 2022, 12, 3709. [Google Scholar] [CrossRef]
  21. Houssein, E.H.; Helmy, B.E.D.; Elngar, A.A.; Abdelminaam, D.S.; Shaban, H. An improved tunicate swarm algorithm for global optimization and image segmentation. IEEE Access 2021, 9, 56066–56092. [Google Scholar] [CrossRef]
Figure 1. Overall flow of the TSA-LSTMRNN approach.
Figure 1. Overall flow of the TSA-LSTMRNN approach.
Mathematics 11 03400 g001
Figure 2. Flowchart of TSA.
Figure 2. Flowchart of TSA.
Mathematics 11 03400 g002
Figure 3. Average outcomes of the TSA-LSTMRNN approach on human-generated text dataset.
Figure 3. Average outcomes of the TSA-LSTMRNN approach on human-generated text dataset.
Mathematics 11 03400 g003
Figure 4. Accuracy curve of the TSA-LSTMRNN approach on human-generated text dataset.
Figure 4. Accuracy curve of the TSA-LSTMRNN approach on human-generated text dataset.
Mathematics 11 03400 g004
Figure 5. Loss curve of the TSA-LSTMRNN approach on human-generated text dataset.
Figure 5. Loss curve of the TSA-LSTMRNN approach on human-generated text dataset.
Mathematics 11 03400 g005
Figure 6. PR curve of the TSA-LSTMRNN approach on human-generated text dataset.
Figure 6. PR curve of the TSA-LSTMRNN approach on human-generated text dataset.
Mathematics 11 03400 g006
Figure 7. ROC curve of the TSA-LSTMRNN approach on human-generated text dataset.
Figure 7. ROC curve of the TSA-LSTMRNN approach on human-generated text dataset.
Mathematics 11 03400 g007
Figure 8. Average outcomes of the TSA-LSTMRNN approach on ChatGPT-generated text dataset.
Figure 8. Average outcomes of the TSA-LSTMRNN approach on ChatGPT-generated text dataset.
Mathematics 11 03400 g008
Figure 9. Accuracy curve of the TSA-LSTMRNN approach on ChatGPT-generated text dataset.
Figure 9. Accuracy curve of the TSA-LSTMRNN approach on ChatGPT-generated text dataset.
Mathematics 11 03400 g009
Figure 10. Loss curve of the TSA-LSTMRNN approach on ChatGPT-generated text dataset.
Figure 10. Loss curve of the TSA-LSTMRNN approach on ChatGPT-generated text dataset.
Mathematics 11 03400 g010
Figure 11. PR curve of the TSA-LSTMRNN approach on ChatGPT-generated text dataset.
Figure 11. PR curve of the TSA-LSTMRNN approach on ChatGPT-generated text dataset.
Mathematics 11 03400 g011
Figure 12. ROC curve of the TSA-LSTMRNN approach on ChatGPT generated text dataset.
Figure 12. ROC curve of the TSA-LSTMRNN approach on ChatGPT generated text dataset.
Mathematics 11 03400 g012
Figure 13. A c c u y outcomes of the TSA-LSTMRNN approach on human-generated text dataset.
Figure 13. A c c u y outcomes of the TSA-LSTMRNN approach on human-generated text dataset.
Mathematics 11 03400 g013
Figure 14. A c c u y outcomes of the TSA-LSTMRNN approach on ChatGPT-generated text dataset.
Figure 14. A c c u y outcomes of the TSA-LSTMRNN approach on ChatGPT-generated text dataset.
Mathematics 11 03400 g014
Table 1. Detection outcomes of the proposed TSA-LSTMRNN approach on human-generated text dataset.
Table 1. Detection outcomes of the proposed TSA-LSTMRNN approach on human-generated text dataset.
Human Dataset
ClassAccuyPrecnRecalFScoreMCC
Exp. 1
Positive91.0096.3091.0093.5785.72
Negative95.3388.8295.3391.9685.72
Average93.1792.5693.1792.7785.72
Exp. 2
Positive89.0094.6889.0091.7581.71
Negative93.3386.4293.3389.7481.71
Average91.1790.5591.1790.7581.71
Exp. 3
Positive89.0089.9089.0089.4575.55
Negative86.6785.5386.6786.0975.55
Average87.8387.7187.8387.7775.55
Exp. 4
Positive90.0094.2490.0092.0782.16
Negative92.6787.4292.6789.9782.16
Average91.3390.8391.3391.0282.16
Exp. 5
Positive89.5090.8689.5090.1877.32
Negative88.0086.2788.0087.1377.32
Average88.7588.5788.7588.6577.32
Table 2. Detection outcomes of the TSA-LSTMRNN approach on ChatGPT-generated text dataset.
Table 2. Detection outcomes of the TSA-LSTMRNN approach on ChatGPT-generated text dataset.
ChatGPT Dataset
Class AccuyPrecnRecalFScoreMCC
Exp. 1
Positive92.0077.3192.0084.0259.41
Negative64.0085.7164.0073.2859.41
Average78.0081.5178.0078.6559.41
Exp. 2
Positive91.0081.9891.0086.2666.10
Negative73.3385.9473.3379.1466.10
Average82.1783.9682.1782.7066.10
Exp. 3
Positive91.5082.0691.5086.5266.73
Negative73.3386.6173.3379.4266.73
Average82.4284.3482.4282.9766.73
Exp. 4
Positive92.5080.7992.5086.2565.73
Negative70.6787.6070.6778.2365.73
Average81.5884.1981.5882.2465.73
Exp. 5
Positive97.0093.2797.0095.1088.35
Negative90.6795.7790.6793.1588.35
Average93.8394.5293.8394.1288.35
Table 3. Comparative outcomes of the TSA-LSTMRNN approach with other techniques on two datasets.
Table 3. Comparative outcomes of the TSA-LSTMRNN approach with other techniques on two datasets.
Accuracy (%)
AlgorithmsHuman DatasetChatGPT Dataset
Decision Tree86.7088.01
SVM Model86.7282.30
XGBoost83.8684.96
CNN Model84.0886.93
ELM Model89.8086.34
TSA-LSTMRNN93.1793.83
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Katib, I.; Assiri, F.Y.; Abdushkour, H.A.; Hamed, D.; Ragab, M. Differentiating Chat Generative Pretrained Transformer from Humans: Detecting ChatGPT-Generated Text and Human Text Using Machine Learning. Mathematics 2023, 11, 3400. https://doi.org/10.3390/math11153400

AMA Style

Katib I, Assiri FY, Abdushkour HA, Hamed D, Ragab M. Differentiating Chat Generative Pretrained Transformer from Humans: Detecting ChatGPT-Generated Text and Human Text Using Machine Learning. Mathematics. 2023; 11(15):3400. https://doi.org/10.3390/math11153400

Chicago/Turabian Style

Katib, Iyad, Fatmah Y. Assiri, Hesham A. Abdushkour, Diaa Hamed, and Mahmoud Ragab. 2023. "Differentiating Chat Generative Pretrained Transformer from Humans: Detecting ChatGPT-Generated Text and Human Text Using Machine Learning" Mathematics 11, no. 15: 3400. https://doi.org/10.3390/math11153400

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop