Time Series Forecasting
Transformers
Safetensors
tabby
feature-extraction
time-series
foundation-model
probabilistic-forecasting
quantile-regression
patchtst
custom_code
Instructions to use paris-noah/Tabby with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use paris-noah/Tabby with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("paris-noah/Tabby", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Release Tabby seed 42 with max(H, 128) inference
Browse filesMerge the seed-42 epoch-14 prompt with the 175000-step Tabby-Pretrain backbone. Set min_forecast_span=128 for inference and refresh the model card with provenance and GIFT-Eval results.
- README.md +31 -110
- config.json +4 -2
- model.safetensors +2 -2
README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
---
|
| 2 |
license: cc-by-nc-4.0
|
| 3 |
pipeline_tag: time-series-forecasting
|
|
|
|
| 4 |
tags:
|
| 5 |
- time-series
|
| 6 |
- time-series-forecasting
|
|
@@ -8,139 +9,59 @@ tags:
|
|
| 8 |
- probabilistic-forecasting
|
| 9 |
- quantile-regression
|
| 10 |
- patchtst
|
| 11 |
-
library_name: transformers
|
| 12 |
---
|
| 13 |
|
| 14 |
-
# Tabby
|
| 15 |
|
| 16 |
-
|
| 17 |
-
99 quantiles of the future.
|
| 18 |
|
| 19 |
-
|
| 20 |
-
165,000 steps and then adapted on GIFT-Eval train set by a small prompt module, with the
|
| 21 |
-
backbone frozen throughout. This repository ships **both halves merged into one
|
| 22 |
-
checkpoint**, so it runs on its own — you do not need to fetch a separate
|
| 23 |
-
backbone. The frozen backbone alone is published as **Tabby-Pretrain**.
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
##
|
| 27 |
|
| 28 |
-
|
| 29 |
-
[](https://github.com/huawei-noah/trustworthyAI/tree/master/TabbyTSFM)
|
| 30 |
-
[](https://arxiv.org/abs/2609.13956)
|
| 31 |
-
## Quick start
|
| 32 |
|
| 33 |
-
```
|
| 34 |
-
pip install torch transformers einops numpy
|
| 35 |
-
```
|
| 36 |
|
| 37 |
```python
|
| 38 |
import torch
|
| 39 |
from transformers import AutoModel
|
| 40 |
|
| 41 |
model = AutoModel.from_pretrained("paris-noah/Tabby", trust_remote_code=True).eval()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
| 44 |
-
q = model.predict(history, prediction_length=96) # [4, 99, 96]
|
| 45 |
|
| 46 |
-
|
| 47 |
-
lo, hi = q[:, 9], q[:, 89] # the 0.10 / 0.90 band
|
| 48 |
-
```
|
| 49 |
|
| 50 |
-
|
| 51 |
-
Index 49 is the median.
|
| 52 |
|
| 53 |
-
|
| 54 |
-
`[B, Tc]` batch, or anything `torch.as_tensor` accepts. Series may be shorter
|
| 55 |
-
than the window and may contain `NaN`, which is read as unobserved rather than as
|
| 56 |
-
a value. Nothing needs to be scaled or normalised beforehand — normalisation is
|
| 57 |
-
internal and the output comes back in the input's own units.
|
| 58 |
|
| 59 |
-
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|---|---|---|---|---|
|
| 66 |
-
| **Tabby-Pretrain**, zero-shot | 0.7192 | 0.4922 | 0.6915 | 0.5715 |
|
| 67 |
-
| **Tabby** | **0.6966** (−3.14 %) | **0.4806** (−2.36 %) | **0.6770** (−2.10 %) | **0.5644** (−1.24 %) |
|
| 68 |
|
| 69 |
-
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|---|---|
|
| 73 |
-
| Total parameters | 146.70 M |
|
| 74 |
-
| — frozen backbone | 145.84 M, 20 layers, `d_model` 768, 12 heads, MLP 3072 |
|
| 75 |
-
| — prompt module | 0.85 M stored, of which 0.73 M trainable (0.50 % of the backbone) |
|
| 76 |
-
| Patch size | 16 |
|
| 77 |
-
| Backbone window | 8192 steps (512 patches) |
|
| 78 |
-
| History used | 8096 steps, horizon 96 (the published protocol) |
|
| 79 |
-
| Quantiles | 99, levels 0.01 … 0.99 |
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
|
|
|
| 83 |
|
| 84 |
-
```
|
| 85 |
-
P(x) = P_shared + sigma(g) * P_adaptive(x)
|
| 86 |
-
```
|
| 87 |
|
| 88 |
-
|
| 89 |
-
statistics of the input window through a rank-4 map, so the prompt depends on the
|
| 90 |
-
series rather than being one global prefix. The history is split into 16 adaptive
|
| 91 |
-
segments and a cross-attention refiner lets each prompt slot read them, which is
|
| 92 |
-
what makes the prompt sensitive to *where* in the history the information sits.
|
| 93 |
-
`g` is a learned scalar gate, initialised at `sigma(+5) ≈ 0.993`.
|
| 94 |
-
|
| 95 |
-
## Files
|
| 96 |
-
|
| 97 |
-
| File | What it is |
|
| 98 |
-
|---|---|
|
| 99 |
-
| `model.safetensors` | merged backbone + prompt weights, 587 MB, 278 tensors |
|
| 100 |
-
| `config.json` | full config for both halves, with `auto_map` for `trust_remote_code` |
|
| 101 |
-
| `modeling_tabby.py` | `TabbyForForecasting`: the inference model |
|
| 102 |
-
| `configuration_tabby.py` | `TabbyConfig` |
|
| 103 |
-
| `patchtstfm_adapter.py`, `modeling_patchtst_fm.py`, `basic.py`, `normalization.py`, `configuration_patchtst_fm.py`, `tools.py` | the backbone, vendored from the pretraining repository |
|
| 104 |
-
| `prompt_blocks.py` | statistics extractors, segment refiner, prompt generator |
|
| 105 |
-
| `input_preprocessing.py` | the visible-history-only asinh normalisation |
|
| 106 |
-
|
| 107 |
-
The backbone weights are bit-for-bit those of **Tabby-Pretrain**, and the prompt
|
| 108 |
-
weights are bit-for-bit the released seed-4 prompt checkpoint. Merging changed no
|
| 109 |
-
value; it only renamed keys onto one module tree.
|
| 110 |
-
|
| 111 |
-
## Things that change the numbers
|
| 112 |
-
|
| 113 |
-
1. **`prediction_length`.** The published results are at 96. Other horizons work —
|
| 114 |
-
pass any `1 ≤ H ≤ 8176` — but they are not what the table above measures.
|
| 115 |
-
2. **History length.** The results use 8096 steps. Feeding less is allowed and
|
| 116 |
-
degrades gracefully, but the segment split anchors to 8096, so a much shorter
|
| 117 |
-
history shifts the prompt's view of the series. History longer than
|
| 118 |
-
`8192 − H` is truncated to the most recent values.
|
| 119 |
-
3. **Batch size changes the last bits.** Different batch sizes select different
|
| 120 |
-
GEMM kernels, so forecasts move by about `1e-7` relative. This is ordinary
|
| 121 |
-
floating-point behaviour, not a bug, and it is why a batched run and a
|
| 122 |
-
one-at-a-time run are not bitwise identical.
|
| 123 |
-
4. **Multivariate data.** Tabby is univariate. Multivariate series are forecast
|
| 124 |
-
one variate at a time with no cross-variate information.
|
| 125 |
-
|
| 126 |
-
## Training
|
| 127 |
-
|
| 128 |
-
The backbone was pretrained for 165,000 steps in bf16 on a mix of real series
|
| 129 |
-
(BLAST, GIFT-Eval Pretraining pool) and synthetic series (Chronos KernelSynth,
|
| 130 |
-
CauKer-V2), with a masked-patch objective and a 99-quantile pinball loss. See
|
| 131 |
-
**Tabby-Pretrain** for the full recipe.
|
| 132 |
-
|
| 133 |
-
Post-training adapted the prompt only, on 48 GIFT-Eval tasks: prompt length 160,
|
| 134 |
-
history 8096, horizon 96, segmented context-aware prompts (S=16,
|
| 135 |
-
`adaptive_horizon`, `min_seg_len` 48, `season_period` 48), rank-4 context map,
|
| 136 |
-
both gates initialised at logit 5.0. AdamW at lr 1e-3, weight decay 1e-4, cosine
|
| 137 |
-
anneal over 20 epochs to 10 % of peak, gradient clip 1.0, effective batch 48,
|
| 138 |
-
seed 4, stopped at epoch 20 (`val_loss` 1.9750). Roughly 3.5 hours on one H200.
|
| 139 |
-
For the 26 short-horizon tasks the training target is truncated to the horizon
|
| 140 |
-
each task is actually evaluated at.
|
| 141 |
-
|
| 142 |
-
Reference environment: Python 3.12.3, PyTorch 2.6.0+cu124.
|
| 143 |
-
|
| 144 |
-
## License
|
| 145 |
-
|
| 146 |
-
CC BY-NC 4.0 — non-commercial use only.
|
|
|
|
| 1 |
---
|
| 2 |
license: cc-by-nc-4.0
|
| 3 |
pipeline_tag: time-series-forecasting
|
| 4 |
+
library_name: transformers
|
| 5 |
tags:
|
| 6 |
- time-series
|
| 7 |
- time-series-forecasting
|
|
|
|
| 9 |
- probabilistic-forecasting
|
| 10 |
- quantile-regression
|
| 11 |
- patchtst
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# Tabby — seed 42, 128-step minimum forecast mask
|
| 15 |
|
| 16 |
+
This is a self-contained Tabby checkpoint: the frozen [Tabby-Pretrain](https://huggingface.co/paris-noah/Tabby-Pretrain) backbone plus a seed-42 prompt. Its 99 quantile forecasts cover levels 0.01 through 0.99. The backbone weights come from pretraining step **175,000** (Hub revision `7fff2ae809bf49907f9dfaacce08092885fa6006`). The prompt was trained with the backbone frozen and selected at epoch 14 (`val_loss=2.0483945271`).
|
|
|
|
| 17 |
|
| 18 |
+
## Resources
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
- [Open in Colab](https://colab.research.google.com/drive/1DaxdRa1iRV2tFVO8iilqRTDITYUOVEQQ?usp=sharing)
|
| 21 |
+
- [TabbyTSFM GitHub code](https://github.com/huawei-noah/trustworthyAI/tree/master/TabbyTSFM)
|
| 22 |
+
- [Technical report](https://arxiv.org/abs/2609.13956)
|
| 23 |
|
| 24 |
+
## Inference rule
|
| 25 |
|
| 26 |
+
For a requested horizon `H`, the model masks `max(H, 128)` future positions and returns **the first `H` forecasts** from that span. The backbone window is 8,192 positions. Consequently, the most observed history it can use is `8192 - max(H, 128)`, even when the evaluation input cap is 8,096. For example, `H=96` uses at most 8,064 history points; `H=168` uses at most 8,024.
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
The original seed-42 training checkpoint records `min_forecast_span=0`. This release changes **only the inference setting** to 128. All 25 prompt tensors and all 253 backbone tensors are unchanged. `config.json` records `min_forecast_span=128`, so ordinary `predict` calls use the released rule without a separate flag.
|
|
|
|
|
|
|
| 29 |
|
| 30 |
```python
|
| 31 |
import torch
|
| 32 |
from transformers import AutoModel
|
| 33 |
|
| 34 |
model = AutoModel.from_pretrained("paris-noah/Tabby", trust_remote_code=True).eval()
|
| 35 |
+
history = torch.randn(2, 8096).cumsum(-1)
|
| 36 |
+
quantiles = model.predict(history, prediction_length=96) # [2, 99, 96]
|
| 37 |
+
median = quantiles[:, 49] # 0.50 quantile
|
| 38 |
+
```
|
| 39 |
|
| 40 |
+
The model forecasts each variate separately. It accepts missing history values as `NaN` and performs its own visible-history normalization.
|
|
|
|
| 41 |
|
| 42 |
+
## Architecture and training
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
The frozen backbone has 20 layers, width 768, 12 attention heads, and 16-step patches. The full release has 146.7 million parameters, including a 160-token prompt module. The prompt uses 16 adaptive context segments, a rank-4 context map, and a cross-attention refiner. Only the prompt was adapted after pretraining, using 48 GIFT-Eval training tasks. The released prompt has seed 42 and was selected at epoch 14; the backbone remains frozen.
|
|
|
|
| 45 |
|
| 46 |
+
## GIFT-Eval results
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
Seasonal-Naive-normalized geometric means across the same 97 configurations, with an 8,096-point input history cap and the minimum mask span of 128:
|
| 49 |
|
| 50 |
+
| Model | MASE | CRPS |
|
| 51 |
+
| --- | ---: | ---: |
|
| 52 |
+
| Tabby-Pretrain, zero-shot | 0.7040 | 0.4827 |
|
| 53 |
+
| Tabby, seed 42 prompt | **0.6880** | **0.4758** |
|
| 54 |
|
| 55 |
+
These results come from the supplied GIFT-Eval evaluation CSVs. Prompt post-training used GIFT-Eval training tasks; the corresponding leaderboard submission marks `testdata_leakage` as `Yes`. The prompt checkpoint is a new seed and the inference rule also differs from the previous seed-4 Tabby release, so their score difference does not isolate either change.
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
+
The accompanying TIME result archive contains 98 task outputs at an 8,096-point input cap for this prompted model. Its public leaderboard aggregate should be computed by TIME's official pipeline when the results are submitted.
|
| 58 |
|
| 59 |
+
## Files and provenance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
+
- `model.safetensors`: 278 tensors (253 backbone, 25 prompt), 146.7 million parameters.
|
| 62 |
+
- `config.json`: architecture, prompt settings, backbone revision, and 128-step minimum mask span.
|
| 63 |
+
- `modeling_tabby.py`, `configuration_tabby.py`, and their local modules: the existing Hugging Face Tabby inference implementation, which already supports this mask rule.
|
| 64 |
|
| 65 |
+
The source checkpoint was supplied as `checkpoint_best.pt` (SHA-256 `e22d69898d391616b7b1204dc3d0bb24f4f0ed37b4ac7267e97054901f9b10a2`). The backbone snapshot's `model.safetensors` SHA-256 is `5c6252a480b8d46a92c0c2eb85a43d35be3aa73097c17b7cfc6d46b922c43f3e`. The merged weights were checked tensor by tensor against both sources and loaded with `AutoModel.from_pretrained` for a CPU forecast.
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
Code: [TabbyTSFM](https://github.com/huawei-noah/trustworthyAI/tree/master/TabbyTSFM). License: CC BY-NC 4.0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
| 21 |
"history_length": 8096,
|
| 22 |
"mask_ratio": 0.4,
|
| 23 |
"max_segments": 16,
|
| 24 |
-
"min_forecast_span":
|
| 25 |
"min_seg_len": 48,
|
| 26 |
"mlp_ratio": 4.0,
|
| 27 |
"model_type": "tabby",
|
|
@@ -31,11 +31,13 @@
|
|
| 31 |
"num_quantiles": 99,
|
| 32 |
"patch_size": 16,
|
| 33 |
"prediction_length": 96,
|
|
|
|
|
|
|
| 34 |
"pretrain_step": 175000,
|
| 35 |
"prompt_gate_init": 5.0,
|
| 36 |
"prompt_init_mode": "anchor_delta",
|
| 37 |
"prompt_len": 160,
|
| 38 |
-
"prompt_seed":
|
| 39 |
"query_from_base": true,
|
| 40 |
"return_dict": true,
|
| 41 |
"season_period": 48,
|
|
|
|
| 21 |
"history_length": 8096,
|
| 22 |
"mask_ratio": 0.4,
|
| 23 |
"max_segments": 16,
|
| 24 |
+
"min_forecast_span": 128,
|
| 25 |
"min_seg_len": 48,
|
| 26 |
"mlp_ratio": 4.0,
|
| 27 |
"model_type": "tabby",
|
|
|
|
| 31 |
"num_quantiles": 99,
|
| 32 |
"patch_size": 16,
|
| 33 |
"prediction_length": 96,
|
| 34 |
+
"pretrain_repo": "paris-noah/Tabby-Pretrain",
|
| 35 |
+
"pretrain_revision": "7fff2ae809bf49907f9dfaacce08092885fa6006",
|
| 36 |
"pretrain_step": 175000,
|
| 37 |
"prompt_gate_init": 5.0,
|
| 38 |
"prompt_init_mode": "anchor_delta",
|
| 39 |
"prompt_len": 160,
|
| 40 |
+
"prompt_seed": 42,
|
| 41 |
"query_from_base": true,
|
| 42 |
"return_dict": true,
|
| 43 |
"season_period": 48,
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7669bc44a331f12cada1966f25c3a5101e84dd93a5649e75ceb9f69a2017b436
|
| 3 |
+
size 586813596
|