Comparative Study of Llama and Bert for Sentiment Analysis on Stock-Related Social Media and Its Impact on Price Prediction

With the growing impact of retail investors and online communities on financial markets, sentiment analysis of social media has become an increasingly valuable tool for stock price forecasting. This study investigates the effectiveness of two state-of-the-art transformer-based language models-BERT and LLaMA-for sentiment analysis on Stocktwits messages related to three U.S. equities: AAPL, AMD, and TSLA. We collected Stocktwits messages from July 1, 2010, to December 31, 2024, and classified each message as positive or negative using both models. These sentiment labels were combined with historical stock price features-Open, High, Low, and Close (OHLC)-to create multimodal input vectors. A Long ShortTerm Memory (LSTM) neural network was then used to predict the next-day closing prices based on a 7 -day sliding window of both sentiment and price data. Model performance was evaluated using Mean Absolute Error (MAE), Root Mean Squared Error (RMSE), and <tex xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">$\mathbf{R}^{\mathbf{2}}$</tex>. Results show that incorporating sentiment significantly improves predictive accuracy over price-only models. Additionally, LLaMA outperformed BERT in sentiment classification, leading to better forecasting performance for several of the target stocks. These findings highlight the promise of integrating transformerbased sentiment analysis with deep learning models for enhanced financial market prediction.

Authors

Institutions

Publication Details

Published
2025-06-27
DOI
https://doi.org/10.1109/is3c65361.2025.11131062
Primary Topic
Sentiment Analysis and Opinion Mining
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Comparative Study of Llama and Bert for Sentiment Analysis on Stock-Related Social Media and Its Impact on Price Prediction

Sheng-Chih Yang, Chien-Cheng Lee, Ash Narayan Sah, Xin-Yuan Lin
Sentiment Analysis and Opinion Mining
article

Comparative Study of Llama and Bert for Sentiment Analysis on Stock-Related Social Media and Its Impact on Price Prediction

Sheng-Chih Yang, Chien-Cheng Lee, Ash Narayan Sah, Xin-Yuan Lin
article en

Abstract

With the growing impact of retail investors and online communities on financial markets, sentiment analysis of social media has become an increasingly valuable tool for stock price forecasting. This study investigates the effectiveness of two state-of-the-art transformer-based language models-BERT and LLaMA-for sentiment analysis on Stocktwits messages related to three U.S. equities: AAPL, AMD, and TSLA. We collected Stocktwits messages from July 1, 2010, to December 31, 2024, and classified each message as positive or negative using both models. These sentiment labels were combined with historical stock price features-Open, High, Low, and Close (OHLC)-to create multimodal input vectors. A Long ShortTerm Memory (LSTM) neural network was then used to predict the next-day closing prices based on a 7 -day sliding window of both sentiment and price data. Model performance was evaluated using Mean Absolute Error (MAE), Root Mean Squared Error (RMSE), and <tex xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">$\mathbf{R}^{\mathbf{2}}$</tex>. Results show that incorporating sentiment significantly improves predictive accuracy over price-only models. Additionally, LLaMA outperformed BERT in sentiment classification, leading to better forecasting performance for several of the target stocks. These findings highlight the promise of integrating transformerbased sentiment analysis with deep learning models for enhanced financial market prediction.

National Chin-Yi University of Technology (TW), Yuan Ze University (TW)
Openalex Percentile: Top 88%
Sentiment Analysis and Opinion Mining
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.