Chen-yang Cao, Yin-Xin Bao, Weiwei Jiang, Quan Shi
Accurate traffic flow prediction is essential for intelligent transportation systems, yet most existing methods still forecast future traffic states mainly from the current historical input window and its derived representations. In real traffic systems, however, similar recent observations may correspond to different future evolutions under different latent traffic regimes, while short-term disturbances can further mislead input-local modeling. To address this issue, we propose an Adaptive Semantic Pattern Matching Transformer (ASPMformer) for traffic flow prediction. Rather than departing from the input-driven forecasting paradigm, ASPMformer complements it in three ways: a Context Embedding module enhances local semantic dependencies between adjacent time steps and reduces sensitivity to short-term fluctuations; an explicit spatiotemporal pattern repository enables the current input to be matched with reusable representative traffic patterns in both temporal and spatial dimensions; and a multi-granularity temporal modeling module enlarges the receptive field to capture long-range traffic trends. Extensive experiments on five public benchmark datasets, including PeMS03, PeMS04, PeMS07, PeMS08, and SZ-taxi, show that ASPMformer achieves competitive and consistent improvements over strong baselines. The results further suggest that the proposed pattern repository is particularly beneficial under heterogeneous and disturbance-prone traffic conditions, where relying solely on the current historical window is less sufficient. For the main content of the model, see https://github.com/ccy123q/ASPMformer.