Forecaster
TimeLLMForecaster
Interface to the Time-LLM.
Quickstart
python
from sktime.forecasting.time_llm import TimeLLMForecaster
estimator = TimeLLMForecaster(task_name='long_term_forecast', pred_len=24, seq_len=96, llm_model='GPT2', llm_layers=3, llm_dim=768, patch_len=16, stride=8, d_model=128, d_ff=128, n_heads=4, dropout=0.1, device: str | None=None, prompt_domain=False)Parameters(12)
- task_namestr, default=’long_term_forecast’
- Task to perform - can be one of [‘long_term_forecast’, ‘short_term_forecast’].
- pred_lenint, default=24
- Forecast horizon - number of time steps to predict.
- seq_lenint, default=96
- Length of input sequence.
- llm_modelstr, default=’GPT2’
- LLM model to use - can be one of [‘GPT2’, ‘LLAMA’, ‘BERT’].
- llm_layersint, default=3
- Number of transformer layers to use from LLM.
- patch_lenint, default=16
- Length of patches for patch embedding.
- strideint, default=8
- Stride between patches.
- d_modelint, default=128
- Model dimension.
- d_ffint, default=128
- Feed-forward dimension.
- n_headsint, default=4
- Number of attention heads.
- dropoutfloat, default=0.1
- Dropout rate.
- devicestr, default=’cuda’ if available else ‘cpu’
- Device to run model on.
Examples
>>> from sktime.forecasting.time_llm import TimeLLMForecaster
>>> from sktime.datasets import load_airline
>>> y = load_airline ()
>>> forecaster = TimeLLMForecaster (
... pred_len = 36,
... seq_len = 96,
... llm_model = 'GPT2'
... )
>>> forecaster. fit (y, fh = [1 ]) TimeLLMForecaster(pred_len=36)
>>> y_pred = forecaster. predict (fh = [1 ])References
- [1 ] https://github.com/KimMeen/Time-LLM [2 ] Ming Jin, Shiyu Wang, Lintao Ma, Zhixuan Chu, James Y. Zhang, Xiaoming Shi, Pin-Yu Chen, Yuxuan Liang, Yuan-Fang Li, Shirui Pan, Qingsong Wen. Time-LLM: Time Series Forecasting by Reprogramming Large Language Models. https://arxiv.org/abs/2310.01728.