Multimodal extension for time series foundation models
Project description
TSFMx
TSFMx (TSFMx Standardizes Fusion of Multimodal exogenous features) is a framework for extending TSFMs (including TimesFM and Chronos) with multimodal inputs such as text.
Installation
pip install tsfmx[all]
Quick Start
1. Setup
Clone the Time-MMD dataset:
./scripts/clone_time_mmd.sh
Split the dataset into train / val / test:
PYTHONPATH=. uv run python scripts/split_time_mmd_datasets.py \
--train-ratio 0.7 \
--val-ratio 0.1
2. Pre-compute Text Embeddings
TimesFM:
PYTHONPATH=. uv run python scripts/cache_time_mmd_datasets.py \
--model-config examples/time_mmd/configs/models/timesfm.yml \
--text-encoder-type english
PYTHONPATH=. uv run python scripts/cache_time_mmd_datasets.py \
--model-config examples/time_mmd/configs/models/timesfm.yml \
--text-encoder-type english --augment
Chronos:
PYTHONPATH=. uv run python scripts/cache_time_mmd_datasets.py \
--model-config examples/time_mmd/configs/models/chronos.yml \
--text-encoder-type english
PYTHONPATH=. uv run python scripts/cache_time_mmd_datasets.py \
--model-config examples/time_mmd/configs/models/chronos.yml \
--text-encoder-type english --augment
3. Fusion Hyperparameter Tuning
Run a W&B Sweeps search for the fusion mode (adapter frozen, fusion layer trained):
TimesFM:
PYTHONPATH=. uv run python scripts/tune_time_mmd_fusion_sweep.py \
--model-config examples/time_mmd/configs/models/timesfm.yml \
--sweep-config examples/time_mmd/configs/sweeps/fusion_3layers.yml
Chronos:
PYTHONPATH=. uv run python scripts/tune_time_mmd_fusion_sweep.py \
--model-config examples/time_mmd/configs/models/chronos.yml \
--sweep-config examples/time_mmd/configs/sweeps/fusion_3layers.yml
To run the adapter mode (adapter fine-tuned, no fusion):
TimesFM:
PYTHONPATH=. uv run python scripts/tune_time_mmd_adapter_sweep.py \
--model-config examples/time_mmd/configs/models/timesfm.yml \
--sweep-config examples/time_mmd/configs/sweeps/adapter.yml
Chronos:
PYTHONPATH=. uv run python scripts/tune_time_mmd_adapter_sweep.py \
--model-config examples/time_mmd/configs/models/chronos.yml \
--sweep-config examples/time_mmd/configs/sweeps/adapter.yml
4. Fine-tune Hyperparameter Tuning
After fusion tuning, run a W&B Sweeps search for the finetune mode (adapter + fusion trained jointly), starting from the best fusion checkpoint:
TimesFM:
PYTHONPATH=. uv run python scripts/tune_time_mmd_finetune_sweep.py \
--model-config examples/time_mmd/configs/models/timesfm.yml \
--sweep-config examples/time_mmd/configs/sweeps/finetune_1layer.yml \
--fusion-checkpoint-path outputs/sweeps/fusion/best_checkpoints/best_val_loss.pt
Chronos:
PYTHONPATH=. uv run python scripts/tune_time_mmd_finetune_sweep.py \
--model-config examples/time_mmd/configs/models/chronos.yml \
--sweep-config examples/time_mmd/configs/sweeps/finetune_1layer.yml \
--fusion-checkpoint-path outputs/sweeps/fusion/best_checkpoints/best_val_loss.pt
5. Visualize Forecasts
After training, generate per-sample forecast plots from a saved checkpoint:
TimesFM:
PYTHONPATH=. uv run python scripts/visualize_time_mmd_predictions.py \
--model-config examples/time_mmd/configs/models/timesfm.yml \
--checkpoint-path outputs/sweeps/fusion/best_checkpoints/best_val_loss.pt \
--output-dir outputs/visualizations/timesfm
Chronos:
PYTHONPATH=. uv run python scripts/visualize_time_mmd_predictions.py \
--model-config examples/time_mmd/configs/models/chronos.yml \
--checkpoint-path outputs/sweeps/fusion/best_checkpoints/best_val_loss.pt \
--output-dir outputs/visualizations/chronos
Use --max-samples N to limit the number of plots per split, and --splits train val test to select which splits to visualize.
Benchmark Comparison with MM-TSFlib
MM-TSFlib is cloned under third_party/MM-TSFlib (not tracked by git). MM-TSFlib is run on its own pre-processed Time-MMD CSVs; tsfmx is evaluated on the raw Time-MMD data split 70/10/20. Both cover the same underlying domains and split ratio.
./scripts/setup_mm_tsflib.sh
1. Run MM-TSFlib benchmark
./scripts/run_mm_tsflib_benchmark.sh 0 Autoformer YOUR_HF_TOKEN
Requires a HuggingFace token with access to LLaMA 3.
2. Evaluate tsfmx checkpoint
PYTHONPATH=. uv run python scripts/eval_tsfmx_checkpoint.py \
--model-config examples/time_mmd/configs/models/timesfm.yml \
--checkpoint-path outputs/sweeps/fusion/best_checkpoints/best_val_loss.pt
3. Compare results
PYTHONPATH=. uv run python scripts/compare_benchmark_results.py
Acknowledgments
We thank the Time-MMD team for providing the multimodal time series dataset used in our examples and experiments.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tsfmx-1.3.0.tar.gz.
File metadata
- Download URL: tsfmx-1.3.0.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c5496ccd9524ba57b14b0f81ea2d378e9dd5a569eee9226ae45f6059a7e3590
|
|
| MD5 |
e95d74bb1614df7eac36c78ffd3782de
|
|
| BLAKE2b-256 |
147dcced28e026796bb96c5c6d777cc255cc11df968bd0c9edeaad4e5716a2b7
|
Provenance
The following attestation bundles were made for tsfmx-1.3.0.tar.gz:
Publisher:
publish-to-pypi.yml on himura467/tsfmx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsfmx-1.3.0.tar.gz -
Subject digest:
0c5496ccd9524ba57b14b0f81ea2d378e9dd5a569eee9226ae45f6059a7e3590 - Sigstore transparency entry: 1789288040
- Sigstore integration time:
-
Permalink:
himura467/tsfmx@1a709582395506d0d998ec151c361b2cbdf2d7af -
Branch / Tag:
refs/tags/v1.3.0 - Owner: https://github.com/himura467
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@1a709582395506d0d998ec151c361b2cbdf2d7af -
Trigger Event:
release
-
Statement type:
File details
Details for the file tsfmx-1.3.0-py3-none-any.whl.
File metadata
- Download URL: tsfmx-1.3.0-py3-none-any.whl
- Upload date:
- Size: 31.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36c4134b52f5a09d88cb50b304227503b812ed654f755f92edda25fd5ebdb9fe
|
|
| MD5 |
d96a0083a5e00c3910772c3bdb8472f5
|
|
| BLAKE2b-256 |
4ee9a9179d1bafd32414a4993599d99a379ef09348cd12eb4a5b3db993eb1060
|
Provenance
The following attestation bundles were made for tsfmx-1.3.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on himura467/tsfmx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsfmx-1.3.0-py3-none-any.whl -
Subject digest:
36c4134b52f5a09d88cb50b304227503b812ed654f755f92edda25fd5ebdb9fe - Sigstore transparency entry: 1789288101
- Sigstore integration time:
-
Permalink:
himura467/tsfmx@1a709582395506d0d998ec151c361b2cbdf2d7af -
Branch / Tag:
refs/tags/v1.3.0 - Owner: https://github.com/himura467
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@1a709582395506d0d998ec151c361b2cbdf2d7af -
Trigger Event:
release
-
Statement type: