Instructions to use NX-AI/TiRex-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- TiRex-2
How to use NX-AI/TiRex-2 with TiRex-2:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Add README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
datasets:
|
| 3 |
+
- autogluon/chronos_datasets
|
| 4 |
+
- autogluon/fev_datasets
|
| 5 |
+
- Salesforce/GiftEvalPretrain
|
| 6 |
+
- Salesforce/GiftEval
|
| 7 |
+
pipeline_tag: time-series-forecasting
|
| 8 |
+
library_name: tirex-2
|
| 9 |
+
license: other
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
<h1 align="left">
|
| 13 |
+
<img src="tirex.svg" alt="TiRex mascott" height="48" /> TiRex-2
|
| 14 |
+
</h1>
|
| 15 |
+
|
| 16 |
+
This repository provides the pretrained TiRex-2 model and inference code for zero-shot
|
| 17 |
+
multivariate forecasting with past and future-known covariates, as introduced in [TiRex-2:
|
| 18 |
+
Generalizing TiRex to Multivariate Data and Streaming](ADD ARXIV LINK).
|
| 19 |
+
|
| 20 |
+
TiRex-2 is a pretrained time series foundation model that forecasts one or many target
|
| 21 |
+
variates directly from their history, optionally conditioned on past and future-known
|
| 22 |
+
covariates. A single checkpoint serves both univariate and multivariate forecasting and
|
| 23 |
+
operates in a streaming fashion as new observations arrive — all zero-shot, with no
|
| 24 |
+
task-specific training or fine-tuning.
|
| 25 |
+
|
| 26 |
+
## Key facts
|
| 27 |
+
|
| 28 |
+
- **Zero-shot multivariate forecasting**:
|
| 29 |
+
TiRex-2 forecasts multiple target variates out of the box, without training or fine-tuning on you data.
|
| 30 |
+
|
| 31 |
+
- **Past and future-known covariates**:
|
| 32 |
+
TiRex-2 natively conditions on past covariates and future-known covariates, such as
|
| 33 |
+
calendar features, holidays, promotions, or scheduled interventions.
|
| 34 |
+
|
| 35 |
+
- **Small active footprint**:
|
| 36 |
+
TiRex-2 activates 38.4M parameters in univariate mode and an additional 44.1M parameters
|
| 37 |
+
for multivariate forecasting.
|
| 38 |
+
|
| 39 |
+
# Getting started
|
| 40 |
+
|
| 41 |
+
The environment is managed by [Pixi](https://pixi.prefix.dev/latest/). Run the following to install it on your machine
|
| 42 |
+
|
| 43 |
+
```bash
|
| 44 |
+
curl -fsSL https://pixi.sh/install.sh | sh
|
| 45 |
+
git clone https://github.com/NX-AI/tirex-2 && cd tirex-2
|
| 46 |
+
# activate the cpu-only env
|
| 47 |
+
eval "$(pixi shell-hook -e example)" # to execute on GPUs use `example-cu128` or `example-cu126`
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
Minimal usage predicting a simple sine wave:
|
| 51 |
+
```python
|
| 52 |
+
import matplotlib.pyplot as plt, torch
|
| 53 |
+
from tirex2 import TimeseriesType, load_model
|
| 54 |
+
|
| 55 |
+
model = load_model("NX-AI/TiRex-2", device="cpu") # use `device="cuda"` if cuda is available
|
| 56 |
+
y = torch.sin(torch.arange(160).float() / 8)
|
| 57 |
+
ts = TimeseriesType(target=y[:128].unsqueeze(0), past_covariates=None, future_covariates=None)
|
| 58 |
+
forecast = model.forecast([ts], prediction_length=32, output_type="numpy")[0][0]
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
We provide predefined Pixi tasks showcasing examplary forecasts. These run in the CPU-only `example` environment by default:
|
| 62 |
+
- `pixi run minimal` runs above code and creates a plot of the forecast.
|
| 63 |
+
- `pixi run comparison` showcases the additional benefit of future known covariates in forecasting a target.
|
| 64 |
+
|
| 65 |
+
For a more **interactive demo of TiRex-2**, we also provide a [quick-start](https://github.com/NX-AI/tirex-2/blob/main/examples/getting_started.ipynb) notebook.
|
| 66 |
+
|
| 67 |
+
## Cite
|
| 68 |
+
If you use TiRex-2 in your research, please cite our work:
|
| 69 |
+
TBD
|
| 70 |
+
|
| 71 |
+
## Other versions:
|
| 72 |
+
Alongside this pretrained checkpoint we also provide three other versions:
|
| 73 |
+
- [TiRex-2-g](https://huggingface.co/NX-AI/TiRex-2-gifteval-zs): we took care to exclude any overlap with the GiftEval
|
| 74 |
+
datasets ([pretrain](https://huggingface.co/datasets/Salesforce/GiftEvalPretrain) and [evaluation](https://huggingface.co/datasets/Salesforce/GiftEval)).
|
| 75 |
+
- [TiRex-2-gp](https://huggingface.co/NX-AI/TiRex-2-gifteval-pretrain): here we included the [GiftEval-Pretrain collection](https://huggingface.co/datasets/Salesforce/GiftEvalPretrain) in our pretraining corpus.
|
| 76 |
+
- [TiRex-2-f](https://huggingface.co/NX-AI/TiRex-2-fevbench): for the fev-benchmark we took the same measures as for
|
| 77 |
+
GiftEval and removed all [fev-bench eval datasets](https://huggingface.co/datasets/autogluon/fev_datasets) from our pretraining corpus to produce this checkpoint.
|