Views
No views yet
past_values as float32 [batch, context_length] (up to 16384 per row) and returns last_hidden_state, mean_predictions, and full_predictions (in that order). Keep the whole onnx/ directory when copying weights (external_data=True).1python -m venv .venv
2source .venv/bin/activate
3pip install onnxruntime numpy1import numpy as np
2import onnxruntime as ort
3
4session = ort.InferenceSession("onnx/model.onnx", providers=["CPUExecutionProvider"])
5inp = session.get_inputs()[0]
6
7batch_size, context_len = 2, 1024
8past_values = np.random.randn(batch_size, context_len).astype(np.float32)
9
10_, mean_predictions, full_predictions = session.run(
11 None, {inp.name: past_values}
12)
13print(mean_predictions.shape) # (batch_size, horizon_length)
14print(full_predictions.shape) # (batch_size, horizon_length, num_quantiles)python example_compare_to_pytorch.pyonnx/model.onnx from Transformers. Until PR #45233 is merged into transformers, install Transformers from the PR head (or your fork branch that contains the same _preprocess change):1python -m venv .venv
2source .venv/bin/activate
3
4pip install torch onnx numpy onnxruntime onnxscript
5pip install "git+https://github.com/huggingface/transformers.git@refs/pull/45233/head"
6
7python export.pyonnx/.hf upload, then commit and push everything else with git (README.md, config.json, scripts, etc.).1hf upload pdufour/timesfm-2.5-200m-transformers-onnx onnx/model.onnx onnx/model.onnx --repo-type model
2# hf upload pdufour/timesfm-2.5-200m-transformers-onnx onnx/model.onnx.data onnx/model.onnx.data --repo-type model # if external data
3
4git add -A && git commit -m "update" && git pushtimesfm2_5 preprocess1@inproceedings{das2024a,
2 title={A decoder-only foundation model for time-series forecasting},
3 author={Abhimanyu Das and Weihao Kong and Rajat Sen and Yichen Zhou},
4 booktitle={Forty-first International Conference on Machine Learning},
5 year={2024},
6 url={https://openreview.net/forum?id=jn2iTJas6h}
7}