# A Deep Learning Approach to Classify AI-Generated and Human-Written Texts
## 3 Materials and Method
### Dataset Creation  
The dataset was created by combining sentences generated by AI with human-generated sentences. AI-generated sentences were produced using OpenAI's ChatGPT-4o [25], Gemini-2.0 Flash [26], and standard Microsoft 365 Copilot Chat (Free version) [27], spanning various academic topics. The dataset used in this study consisted of 4000 statements deliberately curated to represent a broad spectrum of academic disciplines, including engineering, medicine, social sciences, and natural sciences. This approach ensured a comprehensive and diverse dataset, reflecting the varied linguistic structures and domain specific language encountered in scholarly writing. The AI-generated content was produced using three leading language models: OpenAI's ChatGPT, Google's Gemini, and GitHub's Copilot. The prompts for these models were carefully crafted to elicit high-quality, scholarly responses across multiple subjects, ensuring that the generated text mirrors the complexity and depth expected in academic discourse. This rigorous design process aimed to produce contextually rich samples that accurately reflect real-world academic writing. In contrast, the human-authored component of the dataset was sourced from peer-reviewed academic publications and samples of university-level writing. Sentences were meticulously selected and validated by domain experts to confirm their authenticity, coherence, and alignment with the stylistic and thematic conventions of scholarly communication. This verification process ensured that the human-written text maintained a high standard of linguistic quality, providing a robust baseline for model evaluation. To further strengthen this study's experimental reproducibility and evaluate the model's generalization capability, an external test set of 400 newly collected phrases was included. This test set comprised new AI outputs and human-written academic sentences not present in the original training data, allowing for a more rigorous assessment of the model's ability to distinguish between known and novel text samples. Combining the AI and human-written datasets resulted in a labeled dataset, with AI-generated texts marked as \"AI\" and human-written ones as \"Human\". In this study, no distinct datasets were created for each specific LLM model. Instead, outputs generated by ChatGPT, Gemini, and Copilot were grouped together and uniformly labeled as \"AI\". The train_test_split tool from scikit-learn was used to divide the dataset into testing and training sets, with 70% for training and 30% for testing. Class distribution was balanced across both sets. The LSTM model was developed using TensorFlow. The core structure of the model is as follows:  
* Embedding layer: Used to create numerical representations of text, with the vocabulary size reduced to a maximum of 10,000 words. In this study, the tokenizer vocabulary was capped at 10,000 words to achieve a balance between computational efficiency and effective text representation. Based on Zipf's Law, a small set of high-frequency words accounts for most of the text, making this limit sufficient for capturing essential semantics while avoiding the burden of rare words. Prior research [28] also supports that focusing on frequent terms improves model performance without significant semantic loss. Moreover, restricting the vocabulary size helps the model generalize better by reducing overfitting and unnecessary memorization. * LSTM layer: composed of LSTM layers, with a kernel regularizer applied. * Dropout layer: included to prevent overfitting. * The test data ratio: the proportion of data used for testing training data. It was set to 30% for the first three tests. * Batch normalization layer: added to normalize the distributions between layers. * Dense layer: the output layer uses a sigmoid activation function to classify text as AI-generated or human-written. * The Adam algorithm was used as the optimizer for training the model and the learning rate was set to 0.0005.