With the rapid development of social media, public opinion information on social platforms has shown explosive growth. Accurately predicting the trend of social media public opinion dynamics is of great significance in grasping the direction of public opinion development and intervening in the dissemination of undesirable public opinion in a timely manner. This study explores the prediction method of social media opinion dynamics based on time series data modeling technology. First, a multilevel prediction model integrating theme identification layer, feature processing layer, prediction layer and parameter optimization layer is constructed. The LDA model is used to identify the themes of social media public opinion, and feature splicing is used to complete the fusion of multithematic features. In the prediction layer, the multidimensional features are used as input variables, the LSTM model is used to realize the dynamic prediction of public opinion, and the model hyperparameters are optimized by the gray wolf optimization algorithm. The experimental results show that the correlation coefficient of the optimized LSTM model in this paper reaches 0.518 on the public opinion dataset, which is significantly higher than that of the comparison models such as ARMA, Prophet, Informer and the original LSTM, and the standard error RMSE is 2012.117, and the average absolute percentage error MAPE is only 4.275, which is about 30% lower than that of the comparison models. In the prediction of information dissemination in “a hot spot”, the MSLE value of this model is reduced by 0.124 and the MAPE value is reduced by 0.056 compared with the optimal comparative model Informer, and the study shows that the temporal data modeling method integrating multi-topic features can effectively improve the accuracy of the prediction of the dynamics of the public opinion in social media, and it has practical application value for the early warning and intervention of public opinion changes in the hot spot events in the society.