As the global demand for renewable energy and environmental protection continues to grow, anaerobic digestion of food waste as an effective way of resource recycling and energy production has attracted widespread attention. And forecasting methane generation with precision throughout the anaerobic digestion (AD) process is crucial for optimizing the process and improving energy recovery efficiency. Therefore, this paper proposed a new time series prediction model based on the iTransformer method to accurately predict the biogas production during the AD of food waste. The iTransformer uses the attention mechanism to capture the inter-variable relationships, and sequentially processes the historical observations features layer by layer along the time dimension through the feedforward network to capture the complex dynamic characteristics of production process data and build a predictive model. Finally, the proposed method is used to forecast the methane yield and carbon dioxide emissions during the AD of food waste. Compared with the gate recurrent unit (GRU), the autoregressive integrated moving average (ARIMA), the long short-term memory network (LSTM) and Transformer methodologies, the proposed iTransformer method based time series prediction method performs well in the productivity prediction of Garment Employees (PPGM) dataset and the AD dataset, where the mean square error (MSE), coefficient of determination (R2), and accuracy are 0.0231, 0.9036, and 95.9118% on the PPGM dataset, and the MSE, R2, the root mean square error (RMSE) and accuracy are 3946.9602, 0.9949, 7.1596, and 98.5517% on the AD dataset, respectively. Moreover, the impact of different operational parameters on the AD process can be optimized through the prediction results to increase biogas production and reduce carbon emissions.