liveBook · Manning

Moirai

As explained in Time Series Forecasting Using Foundation Models

Moirai is a foundation model designed for time-series forecasting across varied datasets.

Moirai is an open-source foundation model for probabilistic time-series forecasting. It produces a distribution of possible future values rather than a single deterministic forecast, supports exogenous features, and is available through a Python package. section 6.1 section 6.5

Its architecture combines patching, an encoder-only transformer, and a mixture of distributions. Patching groups adjacent time steps into tokens, helping the model learn local relationships while reducing the token count and computational burden. section 6.1.1

Figure 6.1 Architecture of Moirai. Here, the series is patched before entering the encoder-only transformer. Then, a mixture of distributions generates a flexible output distribution of future values.
A rectangular object with black text

Description automatically generated

The architecture diagram shows the forecasting path: patch the input series, process patches with an encoder-only transformer, and generate a flexible future distribution. section 6.1.1

Moirai addresses heterogeneous time-series data through several design choices:

  • Handles different frequencies, scales, and numbers of variates; the data is flattened into a single series to accommodate arbitrary variate counts. section 6.1.1
  • Uses the Large-Scale Open Time Series Archive (LOTSA), containing more than 27 billion data points across energy, transportation, climate, sales, health care, and other domains. section 6.1.2
  • Balances frequency coverage during pretraining by subsampling overrepresented series and varies input windows from 2 to 512 time steps. section 6.1.2
  • Provides small, base, and large pretrained versions, with 14 million, 91 million, and 311 million parameters respectively. section 6.1.2

A practical workflow installs uni2ts, converts a long-form dataset to GluonTS’s PandasDataset, initializes a pretrained model, creates a predictor, and samples future paths. The median can serve as the point forecast, while percentiles define prediction intervals. section 6.3 section 6.3.1

Weekly sales and anomaly detection

For four Walmart stores, an eight-week zero-shot forecast uses 100 future samples and a 95% prediction interval. Cross-validation with four non-overlapping eight-step windows reports an MAE of 84,140 and sMAPE of 2.64% for the univariate setup; the evaluation notes that available exogenous features were not used. For daily taxi data, values outside the prediction interval are labeled anomalies. One experiment detected all actual anomalies but also produced many false positives, yielding high recall, low precision, and an F1 score of 0.53. section 6.3.1 section 6.3.2 section 6.4

How Time Series Forecasting Using Foundation Models covers it

How deep it goes
Explains architecture, pretraining, Python inference, probabilistic postprocessing, cross-validation, and anomaly evaluation, while deferring broad benchmarking.
Examples
Uses Walmart weekly store sales for forecasting and New York City taxi data for interval-based anomaly detection.
What it assumes
Assumes Python familiarity and introduces the required PandasDataset, predictor, sampling, cross-validation, and interval-extraction workflow.
What you can do after
Apply it via uni2ts and GluonTS to generate probabilistic forecasts, prediction intervals, cross-validation results, and anomaly labels.
How it connects
Connects patching with PatchTST, preprocessing with GluonTS, and forecasting comparisons with TimeGPT, Lag-Llama, Chronos, and TimesFM.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Time Series Forecasting Using Foundation Models. The section links point to the parts of the book it draws on.