wmgifford commited on
Commit
8fbf7e6
1 Parent(s): 14c14cc

all the models

Browse files
ttm-1024-96-r1/config.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "adaptive_patching_levels": 3,
3
+ "architectures": [
4
+ "TinyTimeMixerForPrediction"
5
+ ],
6
+ "context_length": 1024,
7
+ "d_model": 192,
8
+ "d_model_scale": 3,
9
+ "decoder_adaptive_patching_levels": 0,
10
+ "decoder_d_model": 128,
11
+ "decoder_d_model_scale": 2,
12
+ "decoder_mode": "common_channel",
13
+ "decoder_num_layers": 2,
14
+ "decoder_raw_residual": false,
15
+ "dropout": 0.2,
16
+ "expansion_factor": 2,
17
+ "frequency_token_vocab_size": 5,
18
+ "gated_attn": true,
19
+ "head_dropout": 0.2,
20
+ "init_processing": true,
21
+ "init_std": 0.02,
22
+ "loss": "mse",
23
+ "mode": "common_channel",
24
+ "model_type": "tinytimemixer",
25
+ "norm_eps": 1e-05,
26
+ "norm_mlp": "LayerNorm",
27
+ "num_input_channels": 1,
28
+ "num_layers": 2,
29
+ "num_patches": 16,
30
+ "patch_last": true,
31
+ "patch_length": 64,
32
+ "patch_stride": 64,
33
+ "positional_encoding_type": "sincos",
34
+ "post_init": false,
35
+ "prediction_channel_indices": null,
36
+ "prediction_filter_length": null,
37
+ "prediction_length": 96,
38
+ "resolution_prefix_tuning": false,
39
+ "scaling": "std",
40
+ "self_attn": false,
41
+ "self_attn_heads": 1,
42
+ "stride_ratio": 1,
43
+ "torch_dtype": "float32",
44
+ "transformers_version": "4.37.2",
45
+ "use_decoder": true,
46
+ "use_positional_encoding": false
47
+ }
ttm-1024-96-r1/generation_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "transformers_version": "4.37.2"
4
+ }
ttm-1024-96-r1/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52b46320096e115cbac8b4cf42c0cd37d71def0ac9ddcfcbec6621e3d99b0f20
3
+ size 3804872
ttm-1024-96-r1/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e639e25398173ec543de7ee513b880a92c37f68f9018d1dbd251549d14b65204
3
+ size 4792
ttm-1024-96-r2/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
ttm-1024-96-r2/config.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "adaptive_patching_levels": 3,
3
+ "architectures": [
4
+ "TinyTimeMixerForPrediction"
5
+ ],
6
+ "categorical_vocab_size_list": null,
7
+ "context_length": 1024,
8
+ "d_model": 384,
9
+ "d_model_scale": 3,
10
+ "decoder_adaptive_patching_levels": 0,
11
+ "decoder_d_model": 256,
12
+ "decoder_d_model_scale": 2,
13
+ "decoder_mode": "common_channel",
14
+ "decoder_num_layers": 2,
15
+ "decoder_raw_residual": false,
16
+ "distribution_output": "student_t",
17
+ "dropout": 0.4,
18
+ "enable_forecast_channel_mixing": false,
19
+ "exogenous_channel_indices": null,
20
+ "expansion_factor": 2,
21
+ "fcm_context_length": 1,
22
+ "fcm_gated_attn": true,
23
+ "fcm_mix_layers": 3,
24
+ "fcm_prepend_past": true,
25
+ "fcm_use_mixer": true,
26
+ "frequency_token_vocab_size": 8,
27
+ "gated_attn": true,
28
+ "head_dropout": 0.4,
29
+ "init_embed": "pytorch",
30
+ "init_linear": "pytorch",
31
+ "init_processing": true,
32
+ "init_std": 0.02,
33
+ "loss": "mse",
34
+ "mode": "common_channel",
35
+ "model_type": "tinytimemixer",
36
+ "norm_eps": 1e-05,
37
+ "norm_mlp": "LayerNorm",
38
+ "num_input_channels": 1,
39
+ "num_layers": 2,
40
+ "num_parallel_samples": 100,
41
+ "num_patches": 8,
42
+ "patch_last": true,
43
+ "patch_length": 128,
44
+ "patch_stride": 128,
45
+ "positional_encoding_type": "sincos",
46
+ "post_init": false,
47
+ "prediction_channel_indices": null,
48
+ "prediction_filter_length": null,
49
+ "prediction_length": 96,
50
+ "resolution_prefix_tuning": false,
51
+ "scaling": "std",
52
+ "self_attn": false,
53
+ "self_attn_heads": 1,
54
+ "stride_ratio": 1,
55
+ "torch_dtype": "float32",
56
+ "transformers_version": "4.37.2",
57
+ "use_decoder": true,
58
+ "use_positional_encoding": false
59
+ }
ttm-1024-96-r2/generation_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "transformers_version": "4.37.2"
4
+ }
ttm-1024-96-r2/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5af4b472920903f243b289e08aec727e80e3755d51dc7c3627a7f422f9190140
3
+ size 11879480
ttm-1024-96-r2/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4280fa8a9513a77547ec686aee3c38f6cbe088849148b78e22c9d0655ff6ef53
3
+ size 4856
ttm-1536-96-r2/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
ttm-1536-96-r2/config.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "adaptive_patching_levels": 3,
3
+ "architectures": [
4
+ "TinyTimeMixerForPrediction"
5
+ ],
6
+ "categorical_vocab_size_list": null,
7
+ "context_length": 1536,
8
+ "d_model": 384,
9
+ "d_model_scale": 3,
10
+ "decoder_adaptive_patching_levels": 0,
11
+ "decoder_d_model": 256,
12
+ "decoder_d_model_scale": 2,
13
+ "decoder_mode": "common_channel",
14
+ "decoder_num_layers": 2,
15
+ "decoder_raw_residual": false,
16
+ "distribution_output": "student_t",
17
+ "dropout": 0.4,
18
+ "enable_forecast_channel_mixing": false,
19
+ "exogenous_channel_indices": null,
20
+ "expansion_factor": 2,
21
+ "fcm_context_length": 1,
22
+ "fcm_gated_attn": true,
23
+ "fcm_mix_layers": 3,
24
+ "fcm_prepend_past": true,
25
+ "fcm_use_mixer": true,
26
+ "frequency_token_vocab_size": 8,
27
+ "gated_attn": true,
28
+ "head_dropout": 0.4,
29
+ "init_embed": "pytorch",
30
+ "init_linear": "pytorch",
31
+ "init_processing": true,
32
+ "init_std": 0.02,
33
+ "loss": "mse",
34
+ "mode": "common_channel",
35
+ "model_type": "tinytimemixer",
36
+ "norm_eps": 1e-05,
37
+ "norm_mlp": "LayerNorm",
38
+ "num_input_channels": 1,
39
+ "num_layers": 2,
40
+ "num_parallel_samples": 100,
41
+ "num_patches": 12,
42
+ "patch_last": true,
43
+ "patch_length": 128,
44
+ "patch_stride": 128,
45
+ "positional_encoding_type": "sincos",
46
+ "post_init": false,
47
+ "prediction_channel_indices": null,
48
+ "prediction_filter_length": null,
49
+ "prediction_length": 96,
50
+ "resolution_prefix_tuning": false,
51
+ "scaling": "std",
52
+ "self_attn": false,
53
+ "self_attn_heads": 1,
54
+ "stride_ratio": 1,
55
+ "torch_dtype": "float32",
56
+ "transformers_version": "4.37.2",
57
+ "use_decoder": true,
58
+ "use_positional_encoding": false
59
+ }
ttm-1536-96-r2/generation_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "transformers_version": "4.37.2"
4
+ }
ttm-1536-96-r2/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:559ef888f0fbb79ec54a2dbf7108ac3d13bec5a4da147de63cf11e5deb4260d1
3
+ size 12344144
ttm-1536-96-r2/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a4adf648f23a2b1d9939f7365e65f6dd41b38a09e18fde6479e5883c373717e
3
+ size 4920
ttm-r1/README.md ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ pipeline_tag: time-series-forecasting
4
+ tags:
5
+ - time series
6
+ - forecasting
7
+ - pretrained models
8
+ - foundation models
9
+ - time series foundation models
10
+ - time-series
11
+ ---
12
+
13
+ # Granite-TimeSeries-TTM-R1 Model Card
14
+
15
+ <p align="center" width="100%">
16
+ <img src="ttm_image.webp" width="600">
17
+ </p>
18
+
19
+ TinyTimeMixers (TTMs) are compact pre-trained models for Multivariate Time-Series Forecasting, open-sourced by IBM Research.
20
+ **With less than 1 Million parameters, TTM (accepted in NeurIPS 24) introduces the notion of the first-ever “tiny” pre-trained models for Time-Series Forecasting.**
21
+
22
+
23
+ TTM outperforms several popular benchmarks demanding billions of parameters in zero-shot and few-shot forecasting. TTMs are lightweight
24
+ forecasters, pre-trained on publicly available time series data with various augmentations. TTM provides state-of-the-art zero-shot forecasts and can easily be
25
+ fine-tuned for multi-variate forecasts with just 5% of the training data to be competitive. Refer to our [paper](https://arxiv.org/pdf/2401.03955.pdf) for more details.
26
+
27
+
28
+ **The current open-source version supports point forecasting use-cases specifically ranging from minutely to hourly resolutions
29
+ (Ex. 10 min, 15 min, 1 hour.).**
30
+
31
+ **Note that zeroshot, fine-tuning and inference tasks using TTM can easily be executed in 1 GPU machine or in laptops too!!**
32
+
33
+
34
+ **New updates:** TTM-R1 comprises TTM variants pre-trained on 250M public training samples. We have another set of TTM models released recently under TTM-R2 trained on a much larger pretraining
35
+ dataset (~700M samples) which can be accessed from [here](https://huggingface.co/ibm-granite/granite-timeseries-ttm-r2). In general, TTM-R2 models perform better than
36
+ TTM-R1 models as they are trained on larger pretraining dataset. However, the choice of R1 vs R2 depends on your target data distribution. Hence requesting users to
37
+ try both R1 and R2 variants and pick the best for your data.
38
+
39
+
40
+
41
+ ## Model Description
42
+
43
+ TTM falls under the category of “focused pre-trained models”, wherein each pre-trained TTM is tailored for a particular forecasting
44
+ setting (governed by the context length and forecast length). Instead of building one massive model supporting all forecasting settings,
45
+ we opt for the approach of constructing smaller pre-trained models, each focusing on a specific forecasting setting, thereby
46
+ yielding more accurate results. Furthermore, this approach ensures that our models remain extremely small and exceptionally fast,
47
+ facilitating easy deployment without demanding a ton of resources.
48
+
49
+ Hence, in this model card, we plan to release several pre-trained
50
+ TTMs that can cater to many common forecasting settings in practice. Additionally, we have released our source code along with
51
+ our pretraining scripts that users can utilize to pretrain models on their own. Pretraining TTMs is very easy and fast, taking
52
+ only 3-6 hours using 6 A100 GPUs, as opposed to several days or weeks in traditional approaches.
53
+
54
+ Each pre-trained model will be released in a different branch name in this model card. Kindly access the required model using our
55
+ getting started [notebook](https://github.com/IBM/tsfm/blob/main/notebooks/hfdemo/ttm_getting_started.ipynb) mentioning the branch name.
56
+
57
+
58
+ ## Model Releases (along with the branch name where the models are stored):
59
+
60
+
61
+ - **512-96:** Given the last 512 time-points (i.e. context length), this model can forecast up to next 96 time-points (i.e. forecast length)
62
+ in future. This model is targeted towards a forecasting setting of context length 512 and forecast length 96 and
63
+ recommended for hourly and minutely resolutions (Ex. 10 min, 15 min, 1 hour, etc). This model refers to the TTM-Q variant used in the paper. (branch name: main) [[Benchmark Scripts]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/tinytimemixer/ttm-r1_benchmarking_512_96.ipynb)
64
+
65
+ - **1024-96:** Given the last 1024 time-points (i.e. context length), this model can forecast up to next 96 time-points (i.e. forecast length)
66
+ in future. This model is targeted towards a long forecasting setting of context length 1024 and forecast length 96 and
67
+ recommended for hourly and minutely resolutions (Ex. 10 min, 15 min, 1 hour, etc). (branch name: 1024-96-v1) [[Benchmark Scripts]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/tinytimemixer/ttm-r1_benchmarking_1024_96.ipynb)
68
+
69
+
70
+
71
+
72
+ ## Model Capabilities with example scripts
73
+
74
+ The below model scripts can be used for any of the above TTM models. Please update the HF model URL and branch name in the `from_pretrained` call appropriately to pick the model of your choice.
75
+
76
+ - Getting Started [[colab]](https://colab.research.google.com/github/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/ttm_getting_started.ipynb)
77
+ - Zeroshot Multivariate Forecasting [[Example]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/ttm_getting_started.ipynb)
78
+ - Finetuned Multivariate Forecasting:
79
+ - Channel-Independent Finetuning [[Example 1]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/ttm_getting_started.ipynb) [[Example 2]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/tinytimemixer/ttm_m4_hourly.ipynb)
80
+ - Channel-Mix Finetuning [[Example]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/tutorial/ttm_channel_mix_finetuning.ipynb)
81
+ - **New Releases (extended features released on October 2024)**
82
+ - Finetuning and Forecasting with Exogenous/Control Variables [[Example]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/tutorial/ttm_with_exog_tutorial.ipynb)
83
+ - Finetuning and Forecasting with static categorical features [Example: To be added soon]
84
+ - Rolling Forecasts - Extend forecast lengths beyond 96 via rolling capability [[Example]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/ttm_rolling_prediction_getting_started.ipynb)
85
+ - Helper scripts for optimal Learning Rate suggestions for Finetuning [[Example]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/tutorial/ttm_with_exog_tutorial.ipynb)
86
+
87
+ ## Benchmarks
88
+
89
+ TTM outperforms popular benchmarks such as TimesFM, Moirai, Chronos, Lag-Llama, Moment, GPT4TS, TimeLLM, LLMTime in zero/fewshot forecasting while reducing computational requirements significantly.
90
+ Moreover, TTMs are lightweight and can be executed even on CPU-only machines, enhancing usability and fostering wider
91
+ adoption in resource-constrained environments. For more details, refer to our [paper](https://arxiv.org/pdf/2401.03955.pdf) TTM-Q referred in the paper maps to the `512-96` model
92
+ uploaded in the main branch. For other variants (TTM-B, TTM-E and TTM-A) please refer [here](https://huggingface.co/ibm-granite/granite-timeseries-ttm-r2). For more details, refer to the paper.
93
+
94
+ ## Recommended Use
95
+ 1. Users have to externally standard scale their data independently for every channel before feeding it to the model (Refer to [TSP](https://github.com/IBM/tsfm/blob/main/tsfm_public/toolkit/time_series_preprocessor.py), our data processing utility for data scaling.)
96
+ 2. The current open-source version supports only minutely and hourly resolutions(Ex. 10 min, 15 min, 1 hour.). Other lower resolutions (say weekly, or monthly) are currently not supported in this version, as the model needs a minimum context length of 512 or 1024.
97
+ 3. Enabling any upsampling or prepending zeros to virtually increase the context length for shorter-length datasets is not recommended and will
98
+ impact the model performance.
99
+
100
+
101
+ ## Model Details
102
+
103
+ For more details on TTM architecture and benchmarks, refer to our [paper](https://arxiv.org/pdf/2401.03955.pdf).
104
+
105
+ TTM-1 currently supports 2 modes:
106
+
107
+ - **Zeroshot forecasting**: Directly apply the pre-trained model on your target data to get an initial forecast (with no training).
108
+
109
+ - **Finetuned forecasting**: Finetune the pre-trained model with a subset of your target data to further improve the forecast.
110
+
111
+ **Since, TTM models are extremely small and fast, it is practically very easy to finetune the model with your available target data in few minutes
112
+ to get more accurate forecasts.**
113
+
114
+ The current release supports multivariate forecasting via both channel independence and channel-mixing approaches.
115
+ Decoder Channel-Mixing can be enabled during fine-tuning for capturing strong channel-correlation patterns across
116
+ time-series variates, a critical capability lacking in existing counterparts.
117
+
118
+ In addition, TTM also supports exogenous infusion and categorical data infusion.
119
+
120
+
121
+ ### Model Sources
122
+
123
+ - **Repository:** https://github.com/ibm-granite/granite-tsfm/tree/main/tsfm_public/models/tinytimemixer
124
+ - **Paper:** https://arxiv.org/pdf/2401.03955.pdf
125
+
126
+
127
+ ### Blogs and articles on TTM:
128
+ - Refer to our [wiki](https://github.com/ibm-granite/granite-tsfm/wiki)
129
+
130
+
131
+ ## Uses
132
+
133
+ ```
134
+ # Load Model from HF Model Hub mentioning the branch name in revision field
135
+
136
+ model = TinyTimeMixerForPrediction.from_pretrained(
137
+ "https://huggingface.co/ibm/TTM", revision="main"
138
+ )
139
+
140
+ # Do zeroshot
141
+ zeroshot_trainer = Trainer(
142
+ model=model,
143
+ args=zeroshot_forecast_args,
144
+ )
145
+ )
146
+
147
+ zeroshot_output = zeroshot_trainer.evaluate(dset_test)
148
+
149
+
150
+ # Freeze backbone and enable few-shot or finetuning:
151
+
152
+ # freeze backbone
153
+ for param in model.backbone.parameters():
154
+ param.requires_grad = False
155
+
156
+ finetune_forecast_trainer = Trainer(
157
+ model=model,
158
+ args=finetune_forecast_args,
159
+ train_dataset=dset_train,
160
+ eval_dataset=dset_val,
161
+ callbacks=[early_stopping_callback, tracking_callback],
162
+ optimizers=(optimizer, scheduler),
163
+ )
164
+ finetune_forecast_trainer.train()
165
+ fewshot_output = finetune_forecast_trainer.evaluate(dset_test)
166
+
167
+ ```
168
+
169
+
170
+ ## Training Data
171
+
172
+ The original r1 TTM models were trained on a collection of datasets from the Monash Time Series Forecasting repository. The datasets used include:
173
+ - Australian Electricity Demand: https://zenodo.org/records/4659727
174
+ - Australian Weather: https://zenodo.org/records/4654822
175
+ - Bitcoin dataset: https://zenodo.org/records/5122101
176
+ - KDD Cup 2018 dataset: https://zenodo.org/records/4656756
177
+ - London Smart Meters: https://zenodo.org/records/4656091
178
+ - Saugeen River Flow: https://zenodo.org/records/4656058
179
+ - Solar Power: https://zenodo.org/records/4656027
180
+ - Sunspots: https://zenodo.org/records/4654722
181
+ - Solar: https://zenodo.org/records/4656144
182
+ - US Births: https://zenodo.org/records/4656049
183
+ - Wind Farms Production data: https://zenodo.org/records/4654858
184
+ - Wind Power: https://zenodo.org/records/4656032
185
+
186
+
187
+ ## Citation
188
+ Kindly cite the following paper, if you intend to use our model or its associated architectures/approaches in your
189
+ work
190
+
191
+ **BibTeX:**
192
+
193
+ ```
194
+ @inproceedings{ekambaram2024tinytimemixersttms,
195
+ title={Tiny Time Mixers (TTMs): Fast Pre-trained Models for Enhanced Zero/Few-Shot Forecasting of Multivariate Time Series},
196
+ author={Vijay Ekambaram and Arindam Jati and Pankaj Dayama and Sumanta Mukherjee and Nam H. Nguyen and Wesley M. Gifford and Chandra Reddy and Jayant Kalagnanam},
197
+ booktitle={Advances in Neural Information Processing Systems (NeurIPS 2024)},
198
+ year={2024},
199
+ }
200
+ ```
201
+
202
+ ## Model Card Authors
203
+
204
+ Vijay Ekambaram, Arindam Jati, Pankaj Dayama, Wesley M. Gifford, Sumanta Mukherjee, Chandra Reddy and Jayant Kalagnanam
205
+
206
+
207
+ ## IBM Public Repository Disclosure:
208
+
209
+ All content in this repository including code has been provided by IBM under the associated
210
+ open source software license and IBM is under no obligation to provide enhancements,
211
+ updates, or support. IBM developers produced this code as an
212
+ open source project (not as an IBM product), and IBM makes no assertions as to
213
+ the level of quality nor security, and will not be maintaining this code going forward.
ttm-r1/config.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "adaptive_patching_levels": 3,
3
+ "architectures": [
4
+ "TinyTimeMixerForPrediction"
5
+ ],
6
+ "context_length": 512,
7
+ "d_model": 192,
8
+ "decoder_adaptive_patching_levels": 0,
9
+ "decoder_d_model": 128,
10
+ "decoder_mode": "common_channel",
11
+ "decoder_num_layers": 2,
12
+ "decoder_raw_residual": false,
13
+ "distribution_output": "student_t",
14
+ "dropout": 0.2,
15
+ "expansion_factor": 2,
16
+ "frequency_token_vocab_size": 5,
17
+ "gated_attn": true,
18
+ "head_dropout": 0.2,
19
+ "init_processing": true,
20
+ "init_std": 0.02,
21
+ "loss": "mse",
22
+ "mode": "common_channel",
23
+ "model_type": "tinytimemixer",
24
+ "norm_eps": 1e-05,
25
+ "norm_mlp": "LayerNorm",
26
+ "num_input_channels": 1,
27
+ "num_layers": 2,
28
+ "num_parallel_samples": 100,
29
+ "num_patches": 8,
30
+ "patch_last": true,
31
+ "patch_length": 64,
32
+ "patch_stride": 64,
33
+ "positional_encoding_type": "sincos",
34
+ "post_init": false,
35
+ "prediction_channel_indices": null,
36
+ "prediction_filter_length": null,
37
+ "prediction_length": 96,
38
+ "resolution_prefix_tuning": false,
39
+ "scaling": "std",
40
+ "self_attn": false,
41
+ "self_attn_heads": 1,
42
+ "torch_dtype": "float32",
43
+ "transformers_version": "4.37.2",
44
+ "use_decoder": true,
45
+ "use_positional_encoding": false
46
+ }
ttm-r1/generation_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "transformers_version": "4.37.2"
4
+ }
ttm-r1/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:30f8d9be619518e18c4c15c6ee504e491b9624b48e251661cd5f967bce097731
3
+ size 3240592
ttm-r1/ttm_image.jpg ADDED
ttm-r1/ttm_image.webp ADDED
ttm-r2/README.md ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ pipeline_tag: time-series-forecasting
4
+ tags:
5
+ - time series
6
+ - forecasting
7
+ - pretrained models
8
+ - foundation models
9
+ - time series foundation models
10
+ - time-series
11
+ ---
12
+
13
+ # Granite-TimeSeries-TTM-R2 Model Card
14
+
15
+ <p align="center" width="100%">
16
+ <img src="ttm_image.webp" width="600">
17
+ </p>
18
+
19
+ TinyTimeMixers (TTMs) are compact pre-trained models for Multivariate Time-Series Forecasting, open-sourced by IBM Research.
20
+ **With model sizes starting from 1M params, TTM (accepted in NeurIPS 24) introduces the notion of the first-ever “tiny” pre-trained models for Time-Series Forecasting.**
21
+
22
+
23
+ TTM outperforms several popular benchmarks demanding billions of parameters in zero-shot and few-shot forecasting. TTMs are lightweight
24
+ forecasters, pre-trained on publicly available time series data with various augmentations. TTM provides state-of-the-art zero-shot forecasts and can easily be
25
+ fine-tuned for multi-variate forecasts with just 5% of the training data to be competitive. Refer to our [paper](https://arxiv.org/pdf/2401.03955.pdf) for more details.
26
+
27
+
28
+ **The current open-source version supports point forecasting use-cases specifically ranging from minutely to hourly resolutions
29
+ (Ex. 10 min, 15 min, 1 hour.).**
30
+
31
+ **Note that zeroshot, fine-tuning and inference tasks using TTM can easily be executed in 1 GPU machine or in laptops too!!**
32
+
33
+
34
+ **TTM-R2 comprises TTM variants pre-trained on larger pretraining datasets (~700M samples).** We have another set of TTM models released under `TTM-R1` trained on ~250M samples
35
+ which can be accessed from [here](https://huggingface.co/ibm-granite/granite-timeseries-ttm-r1) In general, `TTM-R2` models perform better than `TTM-R1` models as they are
36
+ trained on larger pretraining dataset. However, the choice of R1 vs R2 depends on your target data distribution. Hence requesting users to try both
37
+ R1 and R2 variants and pick the best for your data.
38
+
39
+
40
+
41
+ ## Model Description
42
+
43
+ TTM falls under the category of “focused pre-trained models”, wherein each pre-trained TTM is tailored for a particular forecasting
44
+ setting (governed by the context length and forecast length). Instead of building one massive model supporting all forecasting settings,
45
+ we opt for the approach of constructing smaller pre-trained models, each focusing on a specific forecasting setting, thereby
46
+ yielding more accurate results. Furthermore, this approach ensures that our models remain extremely small and exceptionally fast,
47
+ facilitating easy deployment without demanding a ton of resources.
48
+
49
+ Hence, in this model card, we plan to release several pre-trained
50
+ TTMs that can cater to many common forecasting settings in practice. Additionally, we have released our source code along with
51
+ our pretraining scripts that users can utilize to pretrain models on their own. Pretraining TTMs is very easy and fast, taking
52
+ 3-6 hours for R1 versions and 12-24 hours for R2 versions using 6 A100 GPUs, as opposed to several days or weeks in traditional approaches.
53
+
54
+ Each pre-trained model will be released in a different branch name in this model card. Kindly access the required model using our
55
+ getting started [notebook](https://github.com/IBM/tsfm/blob/main/notebooks/hfdemo/ttm_getting_started.ipynb) mentioning the branch name.
56
+
57
+
58
+ ## Model Releases (along with the branch name where the models are stored):
59
+
60
+
61
+ - **512-96-r2**: Given the last 512 time-points (i.e. context length), this model can forecast up to next 96 time-points (i.e. forecast length)
62
+ in future. This model is pre-trained with a larger pretraining dataset for improved accuracy. Recommended for hourly and minutely
63
+ resolutions (Ex. 10 min, 15 min, 1 hour, etc). (branch name: 512-96-r2) [[Benchmarks]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/tinytimemixer/ttm-r2_benchmarking_512_96.ipynb)
64
+
65
+ - **1024-96-r2**: Given the last 1024 time-points (i.e. context length), this model can forecast up to next 96 time-points (i.e. forecast length)
66
+ in future. This model is pre-trained with a larger pretraining dataset for improved accuracy. Recommended for hourly and minutely
67
+ resolutions (Ex. 10 min, 15 min, 1 hour, etc). (branch name: 1024-96-r2) [[Benchmarks]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/tinytimemixer/ttm-r2_benchmarking_1024_96.ipynb)
68
+
69
+
70
+ - **1536-96-r2**: Given the last 1536 time-points (i.e. context length), this model can forecast up to next 96 time-points (i.e. forecast length)
71
+ in future. This model is pre-trained with a larger pretraining dataset for improved accuracy. Recommended for hourly and minutely
72
+ resolutions (Ex. 10 min, 15 min, 1 hour, etc). (branch name: 1536-96-r2) [[Benchmarks]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/tinytimemixer/ttm-r2_benchmarking_1536_96.ipynb)
73
+
74
+
75
+
76
+ ## Model Capabilities with example scripts
77
+
78
+ The below model scripts can be used for any of the above TTM models. Please update the HF model URL and branch name in the `from_pretrained` call appropriately to pick the model of your choice.
79
+
80
+ - Getting Started [[colab]](https://colab.research.google.com/github/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/ttm_getting_started.ipynb)
81
+ - Zeroshot Multivariate Forecasting [[Example]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/ttm_getting_started.ipynb)
82
+ - Finetuned Multivariate Forecasting:
83
+ - Channel-Independent Finetuning [[Example 1]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/ttm_getting_started.ipynb) [[Example 2]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/tinytimemixer/ttm_m4_hourly.ipynb)
84
+ - Channel-Mix Finetuning [[Example]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/tutorial/ttm_channel_mix_finetuning.ipynb)
85
+ - **New Releases (extended features released on October 2024)**
86
+ - Finetuning and Forecasting with Exogenous/Control Variables [[Example]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/tutorial/ttm_with_exog_tutorial.ipynb)
87
+ - Finetuning and Forecasting with static categorical features [Example: To be added soon]
88
+ - Rolling Forecasts - Extend forecast lengths beyond 96 via rolling capability [[Example]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/hfdemo/ttm_rolling_prediction_getting_started.ipynb)
89
+ - Helper scripts for optimal Learning Rate suggestions for Finetuning [[Example]](https://github.com/ibm-granite/granite-tsfm/blob/main/notebooks/tutorial/ttm_with_exog_tutorial.ipynb)
90
+
91
+ ## Benchmarks
92
+
93
+ TTM outperforms popular benchmarks such as TimesFM, Moirai, Chronos, Lag-Llama, Moment, GPT4TS, TimeLLM, LLMTime in zero/fewshot forecasting while reducing computational requirements significantly.
94
+ Moreover, TTMs are lightweight and can be executed even on CPU-only machines, enhancing usability and fostering wider
95
+ adoption in resource-constrained environments. For more details, refer to our [paper](https://arxiv.org/pdf/2401.03955.pdf).
96
+ - TTM-B referred in the paper maps to the `512-96-r2` model.
97
+ - TTM-E referred in the paper maps to the `1024-96-r2` model.
98
+ - TTM-A referred in the paper maps to the `1536-96-r2` model
99
+
100
+ Please note that the Granite TTM models are pre-trained exclusively on datasets
101
+ with clear commercial-use licenses that are approved by our legal team. As a result, the pre-training dataset used in this release differs slightly from the one used in the research
102
+ paper, which may lead to minor variations in model performance as compared to the published results. Please refer to our paper for more details.
103
+
104
+ ## Recommended Use
105
+ 1. Users have to externally standard scale their data independently for every channel before feeding it to the model (Refer to [TSP](https://github.com/IBM/tsfm/blob/main/tsfm_public/toolkit/time_series_preprocessor.py), our data processing utility for data scaling.)
106
+ 2. The current open-source version supports only minutely and hourly resolutions(Ex. 10 min, 15 min, 1 hour.). Other lower resolutions (say weekly, or monthly) are currently not supported in this version, as the model needs a minimum context length of 512 or 1024.
107
+ 3. Enabling any upsampling or prepending zeros to virtually increase the context length for shorter-length datasets is not recommended and will
108
+ impact the model performance.
109
+
110
+
111
+
112
+ ## Model Details
113
+
114
+ For more details on TTM architecture and benchmarks, refer to our [paper](https://arxiv.org/pdf/2401.03955.pdf).
115
+
116
+ TTM-1 currently supports 2 modes:
117
+
118
+ - **Zeroshot forecasting**: Directly apply the pre-trained model on your target data to get an initial forecast (with no training).
119
+
120
+ - **Finetuned forecasting**: Finetune the pre-trained model with a subset of your target data to further improve the forecast.
121
+
122
+ **Since, TTM models are extremely small and fast, it is practically very easy to finetune the model with your available target data in few minutes
123
+ to get more accurate forecasts.**
124
+
125
+ The current release supports multivariate forecasting via both channel independence and channel-mixing approaches.
126
+ Decoder Channel-Mixing can be enabled during fine-tuning for capturing strong channel-correlation patterns across
127
+ time-series variates, a critical capability lacking in existing counterparts.
128
+
129
+ In addition, TTM also supports exogenous infusion and categorical data infusion.
130
+
131
+
132
+ ### Model Sources
133
+
134
+ - **Repository:** https://github.com/ibm-granite/granite-tsfm/tree/main/tsfm_public/models/tinytimemixer
135
+ - **Paper:** https://arxiv.org/pdf/2401.03955.pdf
136
+
137
+
138
+ ### Blogs and articles on TTM:
139
+ - Refer to our [wiki](https://github.com/ibm-granite/granite-tsfm/wiki)
140
+
141
+
142
+ ## Uses
143
+
144
+ ```
145
+ # Load Model from HF Model Hub mentioning the branch name in revision field
146
+
147
+ model = TinyTimeMixerForPrediction.from_pretrained(
148
+ "https://huggingface.co/ibm/TTM", revision="main"
149
+ )
150
+
151
+ # Do zeroshot
152
+ zeroshot_trainer = Trainer(
153
+ model=model,
154
+ args=zeroshot_forecast_args,
155
+ )
156
+ )
157
+
158
+ zeroshot_output = zeroshot_trainer.evaluate(dset_test)
159
+
160
+
161
+ # Freeze backbone and enable few-shot or finetuning:
162
+
163
+ # freeze backbone
164
+ for param in model.backbone.parameters():
165
+ param.requires_grad = False
166
+
167
+ finetune_forecast_trainer = Trainer(
168
+ model=model,
169
+ args=finetune_forecast_args,
170
+ train_dataset=dset_train,
171
+ eval_dataset=dset_val,
172
+ callbacks=[early_stopping_callback, tracking_callback],
173
+ optimizers=(optimizer, scheduler),
174
+ )
175
+ finetune_forecast_trainer.train()
176
+ fewshot_output = finetune_forecast_trainer.evaluate(dset_test)
177
+
178
+ ```
179
+
180
+
181
+ ## Training Data
182
+
183
+ The r2 TTM models were trained on a collection of datasets as follows:
184
+ - Australian Electricity Demand: https://zenodo.org/records/4659727
185
+ - Australian Weather: https://zenodo.org/records/4654822
186
+ - Bitcoin dataset: https://zenodo.org/records/5122101
187
+ - KDD Cup 2018 dataset: https://zenodo.org/records/4656756
188
+ - London Smart Meters: https://zenodo.org/records/4656091
189
+ - Saugeen River Flow: https://zenodo.org/records/4656058
190
+ - Solar Power: https://zenodo.org/records/4656027
191
+ - Sunspots: https://zenodo.org/records/4654722
192
+ - Solar: https://zenodo.org/records/4656144
193
+ - US Births: https://zenodo.org/records/4656049
194
+ - Wind Farms Production data: https://zenodo.org/records/4654858
195
+ - Wind Power: https://zenodo.org/records/4656032
196
+ - PEMSD3, PEMSD4, PEMSD7, PEMSD8, PEMS_BAY: https://drive.google.com/drive/folders/1g5v2Gq1tkOq8XO0HDCZ9nOTtRpB6-gPe
197
+ - LOS_LOOP: https://drive.google.com/drive/folders/1g5v2Gq1tkOq8XO0HDCZ9nOTtRpB6-gPe
198
+
199
+
200
+
201
+ ## Citation
202
+ Kindly cite the following paper, if you intend to use our model or its associated architectures/approaches in your
203
+ work
204
+
205
+ **BibTeX:**
206
+
207
+ ```
208
+ @inproceedings{ekambaram2024tinytimemixersttms,
209
+ title={Tiny Time Mixers (TTMs): Fast Pre-trained Models for Enhanced Zero/Few-Shot Forecasting of Multivariate Time Series},
210
+ author={Vijay Ekambaram and Arindam Jati and Pankaj Dayama and Sumanta Mukherjee and Nam H. Nguyen and Wesley M. Gifford and Chandra Reddy and Jayant Kalagnanam},
211
+ booktitle={Advances in Neural Information Processing Systems (NeurIPS 2024)},
212
+ year={2024},
213
+ }
214
+ ```
215
+
216
+ ## Model Card Authors
217
+
218
+ Vijay Ekambaram, Arindam Jati, Pankaj Dayama, Wesley M. Gifford, Sumanta Mukherjee, Chandra Reddy and Jayant Kalagnanam
219
+
220
+
221
+ ## IBM Public Repository Disclosure:
222
+
223
+ All content in this repository including code has been provided by IBM under the associated
224
+ open source software license and IBM is under no obligation to provide enhancements,
225
+ updates, or support. IBM developers produced this code as an
226
+ open source project (not as an IBM product), and IBM makes no assertions as to
227
+ the level of quality nor security, and will not be maintaining this code going forward.
ttm-r2/config.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "adaptive_patching_levels": 3,
3
+ "architectures": [
4
+ "TinyTimeMixerForPrediction"
5
+ ],
6
+ "categorical_vocab_size_list": null,
7
+ "context_length": 512,
8
+ "d_model": 192,
9
+ "d_model_scale": 3,
10
+ "decoder_adaptive_patching_levels": 0,
11
+ "decoder_d_model": 128,
12
+ "decoder_d_model_scale": 2,
13
+ "decoder_mode": "common_channel",
14
+ "decoder_num_layers": 2,
15
+ "decoder_raw_residual": false,
16
+ "distribution_output": "student_t",
17
+ "dropout": 0.4,
18
+ "enable_forecast_channel_mixing": false,
19
+ "exogenous_channel_indices": null,
20
+ "expansion_factor": 2,
21
+ "fcm_context_length": 1,
22
+ "fcm_gated_attn": true,
23
+ "fcm_mix_layers": 3,
24
+ "fcm_prepend_past": true,
25
+ "fcm_use_mixer": true,
26
+ "frequency_token_vocab_size": 5,
27
+ "gated_attn": true,
28
+ "head_dropout": 0.4,
29
+ "init_embed": "pytorch",
30
+ "init_linear": "pytorch",
31
+ "init_processing": true,
32
+ "init_std": 0.02,
33
+ "loss": "mse",
34
+ "mode": "common_channel",
35
+ "model_type": "tinytimemixer",
36
+ "norm_eps": 1e-05,
37
+ "norm_mlp": "LayerNorm",
38
+ "num_input_channels": 1,
39
+ "num_layers": 2,
40
+ "num_parallel_samples": 100,
41
+ "num_patches": 8,
42
+ "patch_last": true,
43
+ "patch_length": 64,
44
+ "patch_stride": 64,
45
+ "positional_encoding_type": "sincos",
46
+ "post_init": false,
47
+ "prediction_channel_indices": null,
48
+ "prediction_filter_length": null,
49
+ "prediction_length": 96,
50
+ "resolution_prefix_tuning": false,
51
+ "scaling": "std",
52
+ "self_attn": false,
53
+ "self_attn_heads": 1,
54
+ "stride_ratio": 1,
55
+ "torch_dtype": "float32",
56
+ "transformers_version": "4.37.2",
57
+ "use_decoder": true,
58
+ "use_positional_encoding": false
59
+ }
ttm-r2/generation_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "transformers_version": "4.37.2"
4
+ }
ttm-r2/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a706726a7eb01bbcb42994b7dcb3c06ea9557898dbae8d480eb04fe8ccb89710
3
+ size 3240592
ttm-r2/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0cefcfb5a52810ab0e1103fe206c6d5b00a4c86159a4a957681031122ec23ee7
3
+ size 4920
ttm-r2/ttm_image.webp ADDED