Instructions to use litert-community/t0-gamma with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/t0-gamma with LiteRT:
# 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
t0-gamma for LiteRT
This repository contains theforecastingcompany/t0-gamma, The Forecasting Company's model for probabilistic time-series forecasting, as one float32 LiteRT file for the CPU. One call takes the last 512 values of one series and returns the next 64 steps at 21 quantile levels. On a Galaxy S26 (Snapdragon, SM8850), one forecast took 22.1 to 23.2 ms on the CPU, with a median of 22.3 ms over five calls. Speed still being tuned (updates follow).
On the phone and on a Mac, the outputs matched the publisher's PyTorch model on six test series (Accuracy).
To try it, download this repository and run the Python example in Use it; from an app, call the signature described there. The publisher's other options (several series in one call, covariates, other horizons, chosen quantile levels) are not in this file. Only the CPUs of the Galaxy S26 and a Mac were tried: not the phone's GPU or NPU, and no other phone.
Files
| file | bytes | what |
|---|---|---|
t0-gamma-fp32.tflite |
1,022,984,064 | the model, in float32 |
LICENSE |
10,768 | the Apache License 2.0 |
NOTICE |
707 | the attribution notice |
Use it
Python
pip install -U huggingface_hub "ai-edge-litert==2.3.0" "numpy==2.5.5"
hf download litert-community/t0-gamma --local-dir t0-gamma
cd t0-gamma
Save this as example.py in that folder and run python example.py. It forecasts a series that stays at 1.5 and prints the median for the first three future steps; put your own 512 values, oldest first, in history.
import numpy as np
from ai_edge_litert import interpreter
model = interpreter.Interpreter(model_path="t0-gamma-fp32.tflite", num_threads=4)
forecast = model.get_signature_runner("serving_default")
history = np.full((1, 512), 1.5, dtype=np.float32)
quantiles = forecast(context=history)["quantiles"]
median = quantiles[0, :, 10]
print(median[:3])
We ran it with Python 3.12 on a Mac with Apple silicon, where it printed [1.5000015 1.5000015 1.5000002].
From an app
The file has one signature, serving_default:
| tensor | type | shape | content |
|---|---|---|---|
input context |
float32 | [1, 512] | the last 512 values of one series, oldest first; NaN marks a missing value |
output quantiles |
float32 | [1, 64, 21] | the next 64 steps (axis 1) at 21 quantile levels (axis 2): 0.01, 0.05, 0.10, โฆ, 0.95, 0.99; index 10 is the median |
The file scales the series itself, so pass raw values; the forecast comes back in the same units.
Accuracy
Before converting, we set a threshold: on six synthetic test series of 512 values, every output value had to differ from the value of the publisher's PyTorch model by at most 0.005. Where the publisher's value is above 1 in magnitude, the difference is divided by that magnitude. The six series are a constant, a rising line through zero, two repeating patterns added together, a non-negative series with a step up, isolated spikes, and a series with missing values (single ones and a run of 32). The reference is the publisher's predict with horizon=64 and the 21 trained levels, run with tfc-t0 0.6.1 in float32 on a Mac's CPU. The largest difference was 0.000031 on the Galaxy S26, and the same with ai-edge-litert 2.3.0 on the Mac.
Speed
The phone times at the top come from five forecasts in a row on the Galaxy S26 (Android 16), run by LiteRT 2.3.0 for Android on the CPU with the thread count set to 4. Each time covers writing the 512 input values, running the model and reading the output; loading the model and eight earlier calls came first and are not counted: the first call took 32.8 ms, and the other seven took 22.1 to 25.4 ms. The process's peak resident memory was at least 1.92 GiB: a once-per-second sampler caught the process once, so the true peak can be higher.
License
The publisher releases t0-gamma under the Apache License 2.0, and this repository uses the same license. t0-gamma-fp32.tflite is the publisher's weights converted to LiteRT, a modified form of their model, and NOTICE keeps the publisher's attributions. LICENSE and NOTICE come unchanged from the publisher's repository.
- Downloads last month
- 3
Model tree for litert-community/t0-gamma
Base model
theforecastingcompany/t0-gamma