TPLLM: A Traffic Prediction Framework Based on Pretrained Large Language Models

Yilong Ren, Yue Chen, Shuai Liu, Boyue Wang, Haiyang Yu, Zhiyong CuiarXiv 2024

Abstract

Traffic prediction constitutes a pivotal facet within the purview of Intelligent Transportation Systems (ITS), and the attainment of highly precise predictions holds profound significance for efficacious traffic management. The precision of prevailing deep learning-driven traffic prediction models typically sees an upward trend with a rise in the volume of training data. However, the procurement of comprehensive spatiotemporal datasets for traffic is often fraught with challenges, primarily stemming from the substantial costs associated with data collection and retention. Consequently, developing a model that can achieve accurate predictions and good generalization ability in areas with limited historical traffic data is a challenging problem. It is noteworthy that the rapidly advancing pretrained Large Language Models (LLMs) of recent years have demonstrated exceptional proficiency in cross-modality knowledge transfer and few-shot learning. Recognizing the sequential nature of traffic data, similar to language, we introduce TPLLM, a novel traffic prediction framework leveraging LLMs. In this framework, we construct a sequence embedding layer based on Convolutional Neural Networks (CNNs) and a graph embedding layer based on Graph Convolutional Networks (GCNs) to extract sequence features and spatial features, respectively. These are subsequently integrated to form inputs that are suitable for LLMs. A Low-Rank Adaptation (LoRA) fine-tuning approach is applied to TPLLM, thereby facilitating efficient learning and minimizing computational demands. Experiments on two real-world datasets demonstrate that TPLLM exhibits commendable performance in both full-sample and few-shot prediction scenarios, effectively supporting the development of ITS in regions with scarce historical traffic data.

Introduction

Accurate traffic prediction is the backbone of Intelligent Transportation Systems (ITS), enabling everything from congestion alerts to emissions reduction. However, modern deep learning models are data-hungry; they typically require massive, high-quality historical datasets to perform well. In many regions, collecting and storing years of sensor data is prohibitively expensive or technically unfeasible. This creates a "data scarcity" trap: regions that need smart traffic management the most often lack the historical data required to train the models that provide it. TPLLM seeks to bridge this gap by leveraging the "prior knowledge" embedded in Large Language Models (LLMs)—which are already experts at understanding complex sequences—to predict traffic patterns even when data is limited.

Methodology

The core philosophy of TPLLM (Traffic Prediction LLM) is that traffic data, much like natural language, is inherently sequential and structural. The framework consists of three main stages:

  1. Hybrid Embedding Layer: Since LLMs cannot process raw sensor values directly, TPLLM utilizes a custom input module. A Sequence Embedding layer using 1-D Convolutional Neural Networks (CNNs) extracts temporal patterns, while a Graph Embedding layer using Graph Convolutional Networks (GCNs) captures spatial relationships between sensors.
  2. LLM Backbone: The framework employs a pretrained GPT-2 model. The Transformer blocks in GPT-2 are adept at capturing long-range dependencies in sequences, whether they are words or traffic flow values.
  3. Parameter-Efficient Fine-Tuning (PEFT): To avoid the high costs of retraining a massive model and to prevent overfitting, TPLLM uses Low-Rank Adaptation (LoRA). This technique freezes the original LLM weights and only trains a small fraction (approximately 0.95%) of additional parameters, preserving general reasoning while adapting to traffic specifics.
The TPLLM framework overview, illustrating the pretraining, fine-tuning, and downstream task pipeline.

Experimental Setup

The authors evaluated TPLLM on two real-world benchmarks from the Caltrans Performance Measurement System:

  • PeMS04: Traffic flow data from 307 sensors in the San Francisco Bay Area (Jan–Feb 2018).
  • PeMS08: Data from 170 sensors in the San Bernardino area (July–Aug 2016).

The models were tested in both full-sample (standard training) and few-shot (using only 10% of the training data) scenarios.

Key Insights: Traffic as Language

A central insight of this work is the structural congruence between multivariate time-series and textual data. Just as a sentence is a collection of word vectors, a traffic snapshot is a collection of sensor vectors. This allows the LLM to treat a "traffic state" as a "word" and a "time sequence" as a "sentence," enabling the transfer of knowledge from language modeling to spatio-temporal traffic prediction.

Comparison between textual language data and time-series traffic data, highlighting their sequential similarity.

Results and Discussion

TPLLM consistently outperformed established baselines like STGCN, ASTGCN, and STSGCN across various metrics (MAE, RMSE, MAPE).

  • Full-Sample Performance: On the PeMS04 dataset, TPLLM achieved an average Mean Absolute Error (MAE) of 19.53, significantly lower than the popular ASTGCN (21.83).
  • Few-Shot Resilience: The framework's true strength appeared when training data was reduced to 10%. While traditional models saw their error rates spike, TPLLM’s performance degraded the least. In the 15-minute prediction task on PeMS08, TPLLM's MAE only rose by 1.56 points, demonstrating superior generalization.
  • Efficiency: Despite the large backbone, LoRA allowed training on standard consumer-grade hardware (NVIDIA RTX 4090).

Conclusion and Future Work

TPLLM demonstrates that LLMs possess "universal computation" abilities that can be effectively transferred to the domain of spatio-temporal traffic data. While the model currently acts as a "black box," future work could improve interpretability or integrate exogenous data like weather and local events via text prompts. Additionally, scaling to larger models like Llama-3 could further enhance accuracy.

Summary updated

BibTeX
@misc{ren2024tpllm,
  author = {Yilong Ren and Yue Chen and Shuai Liu and Boyue Wang and Haiyang Yu and Zhiyong Cui},
  title = {{TPLLM: A Traffic Prediction Framework Based on Pretrained Large Language Models}},
  year = {2024},
  eprint = {2403.02221},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.02221},
}
Figure