Advanced Next-Word Prediction: Leveraging Text Generation with LSTM Model

Authors

  • Syed Hasham Hameed Department of Computer Science, University of Engineering and Technology Taxila, Taxila, 47080, Pakistan.
  • Muhammad Munwar Iqbal Department of Computer Science, University of Engineering and Technology Taxila, Taxila, 47080, Pakistan.
  • Hasnat Ahmed Department of Computer Science, University of Engineering and Technology Taxila, Taxila, 47080, Pakistan.
  • Wahab Ali Department of Computer Science, SZABIST University Islamabad, Islamabad, Pakistan.
  • Saqib Majeed University Institute of Information Technology, PMAS-Arid Agriculture University, Rawalpindi, Pakistan.
  • Malik Muhammad Ibrahim Department of Computer Science, University of Engineering and Technology Taxila, Taxila, 47080, Pakistan.

Keywords:

Next Word Prediction, LSTM, RNN, NLP, Tensor Flow, Keras, Deep Learning

Abstract

Natural Language Processing (NLP) increasingly relies on machine learning to make better predictions of sequential text. This work focuses on the application of Long Short-Term Memory Networks, a variant of Recurrent Neural Networks that is specialized for modeling long-term dependencies. Traditional RNNs leave much to be desired in predicting sequences that contain repeated patterns or contextual dependencies. The research uses “The Adventures of Sherlock Holmes” as the training dataset and applies TensorFlow and Keras frameworks for implementation. The major preprocessing steps included word tokenization, n-gram creation, and one-hot encoding to prepare the dataset for modeling. The LSTM model was trained over 100 epochs to optimize prediction capabilities. Through this work, we show that LSTM is effective in next-word prediction and can potentially improve the performance and practicality of language models for real-world applications. The model achieved a commendable accuracy of 87.6%, demonstrating its effectiveness.

Downloads

Published

2025-02-25

How to Cite

Syed Hasham Hameed, Muhammad Munwar Iqbal, Hasnat Ahmed, Wahab Ali, Saqib Majeed, & Malik Muhammad Ibrahim. (2025). Advanced Next-Word Prediction: Leveraging Text Generation with LSTM Model. Journal of Computing & Biomedical Informatics. Retrieved from https://jcbi.org/index.php/Main/article/view/786

Issue

Section

Articles