In order to improve the detection accuracy of CO2 and other gases in the flue gas emitted from thermal power plants, a CO2 concentration detection model based on tunable semiconductor laser absorption spectroscopy was proposed. First, a variational mode decomposition model was used to filter the harmonic signal after removing the outliers to reduce the influence of noise on the detection results. Suitable absorption lines and concentration characteristics were then selected according to the gas absorption properties and correlation theory. Finally, the CO2 concentration inversion was completed using long short-term memory networks, and a Bayesian optimization algorithm was introduced to optimize the hyperparameters of the network. The experimental results showed that the R
2 and RMSE of the test set were 0.998 84 and 0.116 08, respectively, in the concentration range of 1%–12%. In addition, the Allan analysis of variance revealed that the maximum measurement error of CO2 was only 0.005 619% when the integration time was 38 s. Compared to the traditional CO2 detection schemes, the detection accuracy and stability are significantly improved, which provides a feasible scheme for flue gas detection in thermal power plants.