Views
No views yet
model.onnx - FP32 ONNX model (456.3 MB)model_quantized.onnx - INT8 quantized model (124.7 MB, ~70% size reduction). transformers.js symlinks point to this file by default.config.json - Model configurationgeneration_config.json - Generation parametersonnx/ - transformers.js-compatible directory structure1import { pipeline } from '@huggingface/transformers';
2
3// Load the forecasting pipeline
4const forecaster = await pipeline('time-series-forecasting', 'kashif/chronos-2-onnx');
5
6// Your historical time series data
7const timeSeries = [605, 586, 586, 559, 511, 487, 484, 458, ...]; // 100+ timesteps
8
9// Generate 16-step forecast with quantiles
10const output = await forecaster(timeSeries, {
11 prediction_length: 16,
12 quantile_levels: [0.1, 0.5, 0.9], // 10th, 50th (median), 90th percentiles
13});
14
15// Output format: { forecast: [[t1_q1, t1_q2, t1_q3], ...], quantile_levels: [...] }
16console.log('Median forecast:', output.forecast.map(row => row[1])); // Extract median
17
18// Clean up
19await forecaster.dispose();1const batch = [
2 [100, 110, 105, 115, 120, ...], // Series 1
3 [50, 55, 52, 58, 60, ...], // Series 2
4];
5
6const outputs = await forecaster(batch);
7// Returns array of forecasts, one per input series1const result = await forecaster(
2 {
3 target: salesSeries,
4 past_covariates: {
5 temperature: pastTemps,
6 promo: pastPromoFlags,
7 },
8 future_covariates: {
9 temperature: futureTemps,
10 promo: futurePromoFlags,
11 },
12 },
13 {
14 prediction_length: 24,
15 quantile_levels: [0.1, 0.5, 0.9],
16 },
17);
18
19console.log(result.forecast[0]); // Quantile matrix for the target series1interface Chronos2Output {
2 forecast: number[][]; // [prediction_length, num_quantiles]
3 quantile_levels: number[]; // The quantile levels for each column
4}1const median = output.forecast.map(row => row[1]); // 50th percentile
2const lower = output.forecast.map(row => row[0]); // 10th percentile (lower bound)
3const upper = output.forecast.map(row => row[2]); // 90th percentile (upper bound)1@article{ansari2024chronos,
2 title={Chronos: Learning the Language of Time Series},
3 author={Ansari, Abdul Fatir and others},
4 journal={arXiv preprint arXiv:2403.07815},
5 year={2024}
6}