Chronos: Learning the Language of Time Series
Paper
•
2403.07815
•
Published
•
47
This is an ONNX export of the Chronos-2 time series forecasting model, optimized for use with transformers.js.
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 structureimport { pipeline } from '@huggingface/transformers';
// Load the forecasting pipeline
const forecaster = await pipeline('time-series-forecasting', 'kashif/chronos-2-onnx');
// Your historical time series data
const timeSeries = [605, 586, 586, 559, 511, 487, 484, 458, ...]; // 100+ timesteps
// Generate 16-step forecast with quantiles
const output = await forecaster(timeSeries, {
prediction_length: 16,
quantile_levels: [0.1, 0.5, 0.9], // 10th, 50th (median), 90th percentiles
});
// Output format: { forecast: [[t1_q1, t1_q2, t1_q3], ...], quantile_levels: [...] }
console.log('Median forecast:', output.forecast.map(row => row[1])); // Extract median
// Clean up
await forecaster.dispose();
const batch = [
[100, 110, 105, 115, 120, ...], // Series 1
[50, 55, 52, 58, 60, ...], // Series 2
];
const outputs = await forecaster(batch);
// Returns array of forecasts, one per input series
const result = await forecaster(
{
target: salesSeries,
past_covariates: {
temperature: pastTemps,
promo: pastPromoFlags,
},
future_covariates: {
temperature: futureTemps,
promo: futurePromoFlags,
},
},
{
prediction_length: 24,
quantile_levels: [0.1, 0.5, 0.9],
},
);
console.log(result.forecast[0]); // Quantile matrix for the target series
Chronos-2 uses automatic preprocessing:
All preprocessing is handled automatically by the pipeline.
The model outputs quantile forecasts:
interface Chronos2Output {
forecast: number[][]; // [prediction_length, num_quantiles]
quantile_levels: number[]; // The quantile levels for each column
}
Extract specific quantiles:
const median = output.forecast.map(row => row[1]); // 50th percentile
const lower = output.forecast.map(row => row[0]); // 10th percentile (lower bound)
const upper = output.forecast.map(row => row[2]); // 90th percentile (upper bound)
@article{ansari2024chronos,
title={Chronos: Learning the Language of Time Series},
author={Ansari, Abdul Fatir and others},
journal={arXiv preprint arXiv:2403.07815},
year={2024}
}
Apache 2.0