Comparative Analysis of Stock Price Prediction Using LSTM and GPT-2 Models
Stock price prediction is a challenging task in both financial and academic sectors, as stock prices often behave unpredictably and nonlinearly within complex systems. This research presents a comparative study of two models: LSTM and GPT-2 which are applied to stock price prediction using Apple Inc.’s open-source data from Yahoo Finance, covering the period from 2000 to 2024. The LSTM model produces more accurate results and is better at handling long-term dependencies compared to GPT-2. The GPT-2 model from Hugging Face struggles with temporal modeling, generating inconsistent and unpredictable outputs due to its lack of design for time series data. LSTM excels at finding patterns in the complex financial data, making it a more suitable choice for this project. The LSTM model benefits from the data preparation steps that include feature selection, normalization, handling missing values and all factors that can influence its prediction. GPT-2 shows a weakness in capturing the nonlinear time series stock prices. Its reliance on pre-trained language modeling makes it not suitable for modeling stock data without the specialized adaptations. GPT-2’s outputs often differ from the real time stock data because of its lack of temporal awareness which results in unpredictable predictions. This study shows the strengths and limitations of the two models and emphasizes LSTM’s capability in finding and producing consistent stock price predictions. While GPT-2 performs well in broader contexts, this study demonstrates that LSTM is more effective for stock price prediction. This research shows how machine learning systems can improve and help with future directions of stock price predictions. The work presented in this paper by no means provides any guidance for stock purchasing but is an effort to integrate AI and Machine learning techniques to understand the process of stock price prediction that can be improved by incorporating sophisticated techniques.
Authors
- JJ Po-An Hsieh
- K Prithvi (ORCID: https://orcid.org/0000-0001-7502-7142)
- Sohail Zaidi
- Vivienne Ko
Publication Details
- Published
- 2025-03-15
- DOI
- https://doi.org/10.1109/isec64801.2025.11147253
- Primary Topic
- Stock Market Forecasting Methods
- Type
- article
- Field-Weighted Citation Impact
- 0.00