STMemoLLM: A Spatial-Temporal Memory-Augmented LLM for Robust Traffic Forecasting

Jian Zhou, Binqing Wu, Zongjiang Shang, Wanghui Qiu, Dongliang Cui, Chenxi Jin, Yue Yu, Xinyi Fu, Ling ChenarXiv 2026

Predicting city traffic is a bit like trying to forecast the weather while half your sensors are broken and the other half are lying to you. Traffic data is notoriously "noisy"—sensors fail, recordings go missing, and random events (like a fender bender) create spikes that don't follow the usual patterns.

While Large Language Models (LLMs) have recently stepped into the ring to help, they have a "flightiness" problem. They are great at reasoning through sequences, but they can be overly sensitive to these random fluctuations and often forget the stable, long-term "rhythms" of a city.

The paper STMemoLLM introduces a way to give these models a "memory" of what normal looks like, allowing them to filter out the noise and focus on what actually matters.

TL;DR

STMemoLLM is a spatial-temporal framework that augments LLMs with a "memory bank" of typical traffic patterns. By compressing messy sensor data into stable "summary tokens" and carefully filtering "detail tokens" from the noise, it achieves state-of-the-art accuracy and remains remarkably robust even when data is missing or corrupted.

What Problem Does This Paper Address?

Traditional deep learning models for traffic forecasting are fragile; they expect high-quality, continuous data. When a sensor in a busy intersection goes dark, these models often stumble.

Recently, researchers started using pre-trained LLMs because they come with "prior knowledge" about temporal reasoning. However, LLMs are generalists. They don't inherently know that Sensor A usually peaks at 8:00 AM while Sensor B stays quiet. Without this "sensor-specific" context, LLMs can get distracted by sample-specific noise, leading to "hallucinated" traffic jams or missed trends. The challenge is balancing stability (the recurring patterns we know exist) with variability (the real-time changes we need to catch).

Methods

The authors propose a three-part architecture to ground the LLM in reality:

  1. The Memory Bank: This is a set of learnable "prototypes"—think of them as templates for common traffic states (e.g., "heavy morning flow" or "stable midnight lull").
  2. Memory-Enhanced Tokenizer: Instead of feeding every single sensor's raw data into the LLM (which is computationally expensive and noisy), this tokenizer uses the memory bank to compress correlated sensors into a few Summary Tokens. It uses a "preference bias" to understand which sensors typically follow which prototypes.
  3. Memory-Calibrated Router: This is the "noise filter." It looks at the residuals—the information left over after summarization. It evaluates these residuals based on three criteria:
  4. Contextual Deviation: Does this sensor's behavior differ wildly from its neighbors?
  5. Compression Deficiency: Did we lose too much important info during summarization?
  6. Prototype Alignment: Does this signal actually look like a known pattern, or is it just random jitter?

    Only the "reliable" signals are turned into Detail Tokens. These complement the summaries, giving the LLM the "fine print" of current traffic without the "ink blots" of noise.

Fig. 1. Overview of STMemoLLM

The final sequence of tokens (Time, Summary, and Detail) is fed into a pre-trained LLM backbone (like LLaMA or DeepSeek) fine-tuned using LoRA (Low-Rank Adaptation) to keep the computational footprint manageable.

Datasets

The model was tested on eight real-world benchmarks across four different tasks:

  • Traffic Flow: PEMS03, PEMS04, PEMS07, PEMS08 (California highway data).
  • Traffic Speed: METR-LA (Los Angeles), PEMS-BAY (Bay Area).
  • Taxi Demand: NYCTaxi.
  • Bike-Sharing Demand: CHBike.

These datasets represent a mix of high-frequency (5-minute) and lower-frequency (30-minute) data, covering different urban dynamics.

Key Insights and Ideas

  • The "Bass Line" and the "Melody": The summary tokens act like the bass line of a song—the steady, predictable rhythm of the city. The detail tokens are the melody—the specific, real-time changes. By separating them, the model doesn't get confused when the melody gets a bit discordant.
  • Robustness is a Feature, Not a Bug: Most models try to "clean" data before processing. STMemoLLM builds the cleaning into the architecture. By checking if a residual signal aligns with a known prototype, it can mathematically "decide" if a spike is a real traffic event or just a sensor glitch.
  • Spatial Awareness via Bias: Instead of just telling the model which sensors are near each other, the "preference bias" helps the model group sensors that behave similarly, which is often more useful than just knowing they are physically close.

Key Results

STMemoLLM outperformed 22 different baselines, including both specialized traffic GNNs and other LLM-based models.

  • Accuracy: It achieved an average 1.92% reduction in Mean Absolute Error (MAE) compared to the previous best model (STD-PLM).
  • Robustness to Corruption: When 20% of the data was randomly masked (simulating sensor failure), STMemoLLM's performance dropped significantly less than its competitors.
  • Structured Missingness: In the nightmare scenario where an entire neighborhood of sensors goes offline, STMemoLLM showed a 12.46% improvement over the strongest baseline.
  • Few-Shot Learning: With only 5% of the training data, it still outperformed other models, proving that the "memory prototypes" act as a powerful head start.
Table showing STMemoLLM's superior performance across PEMS datasets.

Limitations and Future Work

  • Computational Weight: While the token compression helps, running an LLM is still much "heavier" than running a lightweight Graph Neural Network. The authors note that reducing training and memory costs for massive, city-wide networks is a priority.
  • The "Black Swan" Problem: The model relies on prototypes. If a truly unique, never-before-seen event occurs (one that doesn't fit any "memory"), the router might accidentally filter it out as noise. Improving the modeling of these "rare dynamics" is a suggested next step.

Summary updated

Abstract

Traffic forecasting is essential for intelligent transportation systems. However, traditional deep-learning models often rely heavily on high-quality observations. Recent LLM-based approaches incorporate pretrained knowledge to improve forecasting, but they remain sensitive to input perturbations and struggle to preserve long-term patterns. To address this, we propose STMemoLLM, a spatial-temporal memory-augmented LLM for robust traffic forecasting. STMemoLLM introduces memory prototypes to compress inputs into compact summary tokens while extracting reliable dynamics from residual signals, achieving a balance between stability and variability. Specifically, a memory-enhanced tokenizer encodes prototypes and sensor characteristics into attention biases to guide adaptive compression of correlated sensors into semantic summary tokens. A memory-calibrated router further evaluates contextual deviation, compression deficiency, and prototype alignment to identify reliable residual signals, which complement the summaries while suppressing noise. Extensive experiments on eight real-world datasets show that STMemoLLM achieves state-of-the-art performance. Additional experiments examine point masking, additive Gaussian noise, structured missingness, and limited training data, demonstrating strong robustness. Code is available at https://anonymous.4open.science/r/STMemoLLM-70BF.
BibTeX
@misc{zhou2026stmemollm,
  author = {Jian Zhou and Binqing Wu and Zongjiang Shang and Wanghui Qiu and Dongliang Cui and Chenxi Jin and Yue Yu and Xinyi Fu and Ling Chen},
  title = {{STMemoLLM: A Spatial-Temporal Memory-Augmented LLM for Robust Traffic Forecasting}},
  year = {2026},
  eprint = {2611.30148},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.30148},
}
Figure