Skip to main content
Time-LLM is a reprogramming framework to repurpose LLMs for general time series forecasting with the backbone language models kept intact. In other words, it transforms a forecasting task into a “language task” that can be tackled by an off-the-shelf LLM. References Figure 1. Time-LLM Architecture. Figure 1. Time-LLM Architecture.

1. Time-LLM

TimeLLM

Bases: BaseModel TimeLLM Time-LLM is a reprogramming framework to repurpose an off-the-shelf LLM for time series forecasting. It trains a reprogramming layer that translates the observed series into a language task. This is fed to the LLM and an output projection layer translates the output back to numerical predictions. Parameters:

TimeLLM.fit

Fit. The fit method, optimizes the neural network’s weights using the initialization parameters (learning_rate, windows_batch_size, …) and the loss function as defined during the initialization. Within fit we use a PyTorch Lightning Trainer that inherits the initialization’s self.trainer_kwargs, to customize its inputs, see PL’s trainer arguments. The method is designed to be compatible with SKLearn-like classes and in particular to be compatible with the StatsForecast library. By default the model is not saving training checkpoints to protect disk memory, to get them change enable_checkpointing=True in __init__. Parameters: Returns:

TimeLLM.predict

Predict. Neural network prediction with PL’s Trainer execution of predict_step. Parameters: Returns:

Usage example

2. Auxiliary Functions

ReprogrammingLayer

Bases: Module ReprogrammingLayer

FlattenHead

Bases: Module FlattenHead

PatchEmbedding

Bases: Module PatchEmbedding

TokenEmbedding

Bases: Module TokenEmbedding

ReplicationPad1d

Bases: Module ReplicationPad1d