Abstract
While Large Language Models (LLMs) dominate tasks like natural language processing and computer vision, harnessing their power for spatial-temporal forecasting remains challenging. The disparity between sequential text and complex spatial-temporal data hinders this application. To address this issue, this paper introduces STG-LLM, an innovative approach empowering LLMs for spatial-temporal forecasting. We tackle the data mismatch by proposing: 1) STG-Tokenizer: This spatial-temporal graph tokenizer transforms intricate graph data into concise tokens capturing both spatial and temporal relationships; 2) STG-Adapter: This minimalistic adapter, consisting of linear encoding and decoding layers, bridges the gap between tokenized data and LLM comprehension. By fine-tuning only a small set of parameters, it can effectively grasp the semantics of tokens generated by STG-Tokenizer, while preserving the original natural language understanding capabilities of LLMs. Extensive experiments on diverse spatial-temporal benchmark datasets show that STG-LLM successfully unlocks LLM potential for spatial-temporal forecasting. Remarkably, our approach achieves competitive performance on par with dedicated SOTA methods.
Introduction
Spatial-temporal forecasting—predicting how data changes across both space and time—is essential for urban planning, epidemic tracking, and traffic management. Traditionally, this domain has been dominated by specialized models like Graph Neural Networks (GNNs). Despite the reasoning prowess of Large Language Models (LLMs), they face significant hurdles in this field:
- Data Mismatch: LLMs are optimized for sequential text, whereas spatial-temporal data is multi-dimensional and graph-structured.
- Token Explosion: Describing complex networks in natural language consumes excessive tokens, quickly exceeding context window limits.
- Domain Knowledge Gaps: Standard LLMs lack inherent understanding of physical dependencies in systems like power grids or highway networks.
Methodology: The STG-LLM Framework
To bridge the gap between raw graph data and LLM reasoning, the researchers developed STG-LLM. The framework consists of two primary components designed to minimize computational overhead while maximizing data representational efficiency.
STG-Tokenizer
Instead of converting numerical data into verbose text, the STG-Tokenizer treats each node in a graph as a single "token." It aggregates a node's recent temporal history and auxiliary information (e.g., time-of-day, day-of-week) into a compact vector. This approach allows the LLM's self-attention mechanism to naturally capture spatial relationships between different locations without the burden of a massive token count.
STG-Adapter and Training Strategy
The STG-Adapter acts as a translation layer. It employs a linear encoding layer to map graph tokens into the LLM's internal embedding space and a decoding layer to transform the LLM's output back into numerical forecasts. To preserve the LLM's pre-trained "common sense" and reduce compute requirements, the main LLM backbone (GPT-2 in these experiments) is frozen. Only the adapter, positional embeddings, and layer normalization parameters are fine-tuned—representing just 1.7% of the total parameters.
Experimental Evaluation
STG-LLM was evaluated across six diverse real-world datasets covering traffic (PEMS03, 04, 07, 08), energy (Electricity), and finance (ExchangeRate).
Key Results
- Competitive Performance: As shown in the benchmarking results, STG-LLM achieves performance on par with or superior to dedicated state-of-the-art (SOTA) models like PDFormer and GraphWaveNet. For instance, on the PEMS04 dataset, it achieved a Mean Absolute Error (MAE) of 18.14, outperforming PDFormer's 18.31.
- Few-Shot Efficiency: The model demonstrates remarkable few-shot capabilities. With only 50 samples (approximately 0.5% of the training data), STG-LLM reached performance levels that traditional deep learning models typically require the full dataset to achieve.
- Synergy with Text: Incorporating simple natural language prompts alongside graph tokens further improved accuracy, confirming that the LLM successfully integrates linguistic context with numerical spatial-temporal data.
Conclusion and Future Work
STG-LLM demonstrates that LLMs can be effectively repurposed for spatial-temporal tasks through efficient tokenization and lightweight adaptation. While current results are promising, future research will address context window limitations for extremely large graphs and explore the benefits of larger backbones like Llama-3. Additionally, investigating how LLMs handle dynamic topologies in evolving networks remains a key area for development.
Summary updated