Accurately predicting carbon dioxide (CO2) emissions is crucial for environmental protection. Currently, there are two main issues with predicting CO2 emissions: (1) existing CO2 emission prediction models mainly rely on Long Short-Term Memory (LSTM) and Gate Recurrent Unit (GRU) models, which can only model unidirectional temporal features, resulting in insufficient accuracy: (2) existing research on CO2 emissions mainly focuses on designing predictive models, without paying attention to model optimization, resulting in models being unable to achieve their optimal performance. To address these issues, this paper proposes a framework for predicting CO2 emissions, called CGAOA-AttBiGRU. In this framework, Attentional-Bidirectional Gate Recurrent Unit (AttBiGRU) is a prediction model that uses BiGRU units to extract bidirectional temporal features from the data, and adopts an attention mechanism to adaptively weight the bidirectional temporal features, thereby improving prediction accuracy. CGAOA is an improved Arithmetic Optimization Algorithm (AOA) used to optimize the five key hyperparameters of the AttBiGRU. We first validated the optimization performance of the improved CGAOA algorithm on 24 benchmark functions. Then, CGAOA was used to optimize AttBiGRU and compared with 12 optimization algorithms. The results indicate that the AttBiGRU optimized by CGAOA has the best predictive performance.