Abstract
Air quality forecasting is of great importance in environmental protection, government decision-making, and public health. Existing research methods have failed to effectively model long-term and complex relationships in time series PM2.5 data and exhibited low precision in long-term prediction. To address this issue, this paper proposes a new lightweight deep learning model using sparse attention-based Transformer networks (STN). Consisting of encoder and decoder layers, the STN adopts a multi-head sparse attention mechanism to reduce time complexity to $O(L \log L)$. Extensive experiments on two real-world datasets in China—the Beijing and Taizhou PM2.5 datasets—show that the proposed method not only has relatively small time complexity but also outperforms state-of-the-art methods. On single-step PM2.5 forecasting tasks, the STN achieves an $R^2$ of 0.937 in Beijing and 0.924 in Taizhou. For long-term prediction (up to 48 hours), the STN consistently performs best among all compared methods.
Introduction
Accurate PM2.5 forecasting is a "wicked problem" in environmental science. Traditional deterministic models based on fluid dynamics and chemistry are computationally expensive and often lack the resolution of real-world observations. Conversely, statistical models like ARIMA or shallow machine learning (SVR, Random Forest) struggle with the non-linear, "bursty" nature of pollution data. While Deep Learning—specifically Recurrent Neural Networks (RNNs) and LSTMs—has improved results, these models suffer from gradient vanishing, making it difficult to capture patterns from days or weeks ago. The Transformer architecture addresses these memory issues, but its standard self-attention mechanism requires $O(L^2)$ resources, which is prohibitive for long-term time-series. This paper introduces the Sparse Attention-based Transformer Network (STN) to bridge this gap.
Methodology: The Sparse Transformer Network (STN)
The STN architecture (Figure 1) optimizes the Transformer for air quality data through several key innovations:
- Multi-head Sparse Attention: Instead of calculating relationships between every single time point, the STN uses a sparse mechanism based on Kullback–Leibler (K-L) divergence. It identifies the most "informative" queries and ignores redundant data, reducing complexity to $O(L \log L)$. This demonstrates that in air quality data, focusing on dominant queries makes the model more robust to noise.
- Two-Branch Encoder: The encoder features a parallel structure. One branch processes the full sequence, while the other uses 1D convolutions and max-pooling to distill dominant features and reduce the hidden state size, improving robustness over standard CNN approaches.
- Generative Decoder: Unlike RNNs that predict one step at a time and accumulate error, the STN decoder uses a masked sparse attention mechanism to predict multiple future time steps in a parallel, generative fashion.
Datasets and Experimental Setup
The model was evaluated on two real-world, hourly datasets in China (Figure 2):
- Beijing PM2.5 Dataset: Contains ~43,800 records (2010–2014) including PM2.5 levels and meteorological features like dew point, temperature, and wind speed.
- Taizhou PM2.5 Dataset: Contains ~26,000 records (2017–2019) collected by the authors' team, featuring similar meteorological variables plus relative humidity.
The study employed a year-independent split (e.g., training on 2010-2013 and testing on 2014), providing a much stricter and more realistic test than random shuffling.
Key Results and Discussion
The STN consistently outperformed SVR, ARIMA, Random Forest, XGBoost, CNN, LSTM, and the standard Transformer across all metrics ($R^2$, RMSE, MAE).
- Short-Term Accuracy: In single-step (1h) prediction, the STN achieved an $R^2$ of 0.937 in Beijing (reducing RMSE to 19.04 µg/m³) and 0.924 in Taizhou (reducing RMSE to 5.79 µg/m³).
- Long-Term Performance: The STN's advantage is most apparent in multi-step forecasting for the next 6, 12, 24, and 48 hours. For the 25–48 hour window in Beijing, the STN maintained an $R^2$ of 0.295, nearly double that of SVR-POLY (0.157).
- Computational Efficiency: The STN was significantly faster than the original Transformer, saving approximately 1.2 to 1.5 seconds per execution on the test sets due to the reduced complexity of the attention mechanism.
Conclusion
The Sparse Attention-based Transformer Network (STN) offers a lightweight yet powerful approach to air quality forecasting. By breaking the sequential bottleneck of RNNs and the quadratic complexity of standard Transformers, it captures long-term dependencies effectively. Future research will focus on improving predictions for abrupt pollution spikes and further optimizing complexity for deployment on low-power monitoring stations.
Summary updated