Embracing Large Language Models in Traffic Flow Forecasting (2025)

Abstract: Traffic flow forecasting aims to predict future traffic flows based on historical traffic conditions and the road network. It is an important problem in intelligent transportation systems, with a plethora of methods being proposed. Existing efforts mainly focus on capturing and utilizing spatio-temporal dependencies to predict future traffic flows. Though promising, they fall short in adapting to test-time environmental changes in traffic conditions. To tackle this challenge, we propose to introduce large language models (LLMs) to help traffic flow forecasting and design a novel method named Large Language Model Enhanced Traffic Flow Predictor (LEAF). LEAF adopts two branches, capturing different spatio-temporal relations using graph and hypergraph structures, respectively. The two branches are first pre-trained individually, and during test time, they yield different predictions. Based on these predictions, a large language model is used to select the most likely result. Then, a ranking loss is applied as the learning objective to enhance the prediction ability of the two branches. Extensive experiments on several datasets demonstrate the effectiveness of LEAF. Our code is available at https://github.com/YushengZhao/LEAF.

## introduction traffic flow forecasting is an integral part of intelligent transportation systems @xcite and smart cities @xcite . the target of traffic flow forecasting is to predict future traffic flows using historical data and spatial information (i.e. the road network), which has a wide range of applications including traffic signal control @xcite , route planning @xcite , and congestion management @xcite . due to its value in real-world applications, great efforts have been made to resolve the problem of traffic flow forecasting @xcite @xcite . early works mainly model the traffic systems using physical rules or shallow models @xcite @xcite . with the advent of deep learning, the main-stream of traffic flow forecasting methods utilizes graph neural networks @xcite @xcite , recurrent neural networks @xcite , and transformers @xcite to capture the rich spatio-temporal relations @xcite @xcite @xcite @xcite . despite their success, existing traffic flow forecasting methods have two limitations, which hinder their applications in the real world. firstly, existing methods are generally unable to adapt to environmental changes of traffic conditions during test time. most existing methods make the assumption that test data follow the same distri-bution as the training data, which may fail to hold in the real world @xcite , especially for time series data @xcite @xcite . traffic conditions change over time due to a variety of factors like special events, changes in weather, or the shift of eras. traditional models @xcite , including fusion models @xcite have poor generalization ability, suffering from performance degradation under distribution shifts. in contrast, llms have strong generalization ability to adapt well under such distribution shifts @xcite @xcite . moreover, llms have strong reasoning ability, which enables them to infer the current environment from the data to benefit forecasting. due to the high cost of collecting large-scale data, the zero-shot generalization/reasoning ability is especially useful. to utilize llms, a naive solution is to use the generative ability of llms to make direct predictions @xcite @xcite , as shown in figure 1 (upper part). however, this is too challenging for language models, as accurate forecasting relies on both historical data and complex spatio-temporal relations. secondly, existing methods are weak in capturing the rich structure of spatio-temporal relations in traffic data. the traffic network is complicated and the temporal dimension adds another layer of complexity. prior works focus on capturing the complex spatio-temporal relations, using graph structures @xcite or hypergraph structures @xcite @xcite . graphs capture pair-wise relations, while hypergraphs model nonpair-wise relations. adopting only one of them is not enough, as the spatio-temporal relations in traffic data are rich by nature. for example, traffic congestion at one vertex affects adjacent vertices (pair-wise relations), whereas road closures affect a large set of vertices (non-pair-wise relations). modeling the rich structure of spatio-temporal relations is challenging in predicting future traffic flows. to that end, this paper proposes a novel method termed large language model enhanced traffic flow predictor (leaf) for adaptive and structureperspective traffic flow forecasting. the core idea of leaf is to utilize the discriminative ability of llms to enhance the task of traffic flow forecasting using a predictor and a selector, where the predictor generates predictions and the selector chooses the most likely result. to enhance adaptability, we build an llm-based selector that selects from a range of possible future traffic flows using the discriminative ability of an llm, as shown in figure 1 (lower part). the selection results are used to guide the predictor with a ranking loss @xcite , which only requires that the positive candidate (the ones chosen by the llm) is better than the negative candidates (the ones not chosen). the llm is good at understanding the changing traffic conditions and is open to further information provided by humans, making it an adaptable predictor. to better capture the rich structures of spatio-temporal relations, we build a dual-branch predictor composed of a graph branch which captures pair-wise relations of spatio-temporal traffic data, and a hypergraph branch, which captures non-pair-wise relations. during test time, the dual-branch predictor generates different forecasting results, and subsequently, a set of transformations is applied to obtain a wealth of choices of future traffic flows. our contribution is summarized as follows: ## conclusion in this paper, we propose a novel framework named large language model enhanced traffic flow predictor (leaf), consisting of a dual-branch traffic flow predictor and an llm-based selector. the predictor adopts two branches: the graph branch and the hypergraph branch, capturing the pair-wise and non-pair-wise relations, respectively. the selector uses the discriminative ability of the llm to choose the best forecast of the predictor. the selection results are then used to supervise the predictor. we perform extensive experiments to demonstrate the effectiveness of leaf.