Abstract
Traffic flow forecasting is a critical yet challenging task due to complex spat-temporal dependencies and frequent distribution shifts caused by real-world events. Traditional deep learning models often struggle to adapt to "black swan" scenarios where historical patterns no longer apply. This paper introduces LEAF (Large Language Model Enhanced Traffic Flow Predictor), a novel framework that combines a dual-branch neural network with the reasoning capabilities of Large Language Models (LLMs). Unlike previous approaches that attempt to use LLMs as numerical generators, LEAF utilizes them as discriminative selectors to identify the most plausible forecast from a set of candidates. Our results on public benchmarks demonstrate that LEAF significantly improves forecasting accuracy and robustness, particularly in long-term scenarios and under distribution shifts.
Introduction
Predicting urban traffic flow is essential for smart city management, yet it remains notoriously difficult. Deep learning models, particularly Graph Neural Networks (GNNs), have become the standard for capturing spatial dependencies. However, these models face two primary hurdles: distribution shift and complex spatial relations. Distribution shift occurs when the future deviates from historical patterns—such as during holidays or sudden road closures—rendering models trained on past data ineffective. Furthermore, traffic dynamics often involve non-pair-wise relations, where groups of sensors (e.g., in a shopping district) behave in unison, a pattern traditional GNNs struggle to model.
While Large Language Models (LLMs) possess vast "world knowledge" and reasoning abilities, they are historically poor at generating precise numerical time-series data. The core insight of this work is that LLMs should be used to judge forecasts rather than write them. By treating forecasting as a discriminative selection task, we can leverage the LLM's logical reasoning to handle environmental changes without requiring it to perform complex arithmetic.
The LEAF Framework
The LEAF framework consists of three main components: a dual-branch predictor, a choice set constructor, and an LLM-based selector.
Dual-Branch Predictor
To capture the multi-faceted nature of traffic, LEAF employs two parallel branches. The Graph Neural Network (GNN) branch models standard pair-wise relationships between adjacent sensors. Simultaneously, a Hypergraph Neural Network branch captures group-level dynamics, modeling how sets of sensors interact across broader spatial regions.
Choice Set Construction and LLM Selection
During the inference phase, the predictor generates initial forecasts. These are then transformed into a "menu" of possible scenarios—including variations like smoothing or trend adjustments. A frozen LLM (specifically LLaMA 3 70B) is provided with a prompt containing historical data, spatial context, and temporal information (e.g., "Friday at 7:00 PM"). The LLM evaluates the candidates and selects the most logical prediction based on its internal understanding of human behavior and traffic patterns.
Ranking Loss Supervision
The selection made by the LLM is not just a final output; it serves as a supervisory signal. Using a ranking loss (hinge loss), the dual-branch predictor is fine-tuned to align its raw predictions with the logical choices identified by the LLM. This creates a feedback loop where the neural network learns to produce better candidates over time.
Experimental Evaluation
LEAF was evaluated on three standard benchmarks from the California Performance Measurement System: PEMS03, PEMS04, and PEMS08. To test robustness, the models were trained on only 10% of the available data. LEAF consistently outperformed state-of-the-art baselines. For instance, on the PEMS08 dataset, LEAF achieved a Mean Absolute Error (MAE) of 24.68, a significant improvement over the next best non-LLM baseline, DyHSL (27.34).
Qualitative analysis revealed that the LLM-based selector excels at identifying temporal transitions. When a standard neural network predicted continued high traffic at the end of a rush hour, the LLM correctly identified the likely downward trend, selecting a more accurate candidate from the choice set. This reasoning capability allows LEAF to maintain lower error rates in long-term (1-hour ahead) forecasts compared to traditional methods.
Discussion and Future Work
LEAF demonstrates a powerful way to "embrace" LLMs in specialized domains like traffic forecasting. By shifting the LLM's role from a generator to a discriminative selector, we bypass its numerical limitations while exploiting its reasoning strengths. While the computational overhead of running a 70B parameter model remains a challenge for real-time edge deployment, the framework provides a robust template for integrating world knowledge into time-series tasks. Future work will focus on exploring parameter-efficient fine-tuning (LoRA) and extending the framework to other spatio-temporal tasks such as energy grid management and weather prediction.
Summary updated