AI Logic

Architectures

Chronos

Updated:

The Chronos pipeline. On the left, tokenization of a time series (mean scaling and quantization); in the center, training a language model with cross-entropy; on the right, inference that samples tokens autoregressively to build a forecast distribution

Background and Overview

Chronos is a pre-trained time series forecasting model that converts time series values into tokens (symbols from a fixed set) and trains an existing language model as is on the task of predicting the next token. It was presented in 2024 by Ansari, Stella, et al. at Amazon (AWS AI Labs) in "Chronos: Learning the Language of Time Series" and published in TMLR.

Previous deep learning forecasting models (such as DeepAR and PatchTST) were usually retrained for each dataset to be forecast. The paper asks whether a language model that predicts the next word and a forecasting model that predicts the next value are fundamentally the same, since both predict the continuation of a sequence. The only difference is that words are chosen from a fixed vocabulary, while time series values are continuous real numbers.

Chronos therefore keeps the model architecture unchanged and designs only the part that turns values into vocabulary symbols (tokenization) for time series.

  • Tokenization: each series is divided by the mean absolute value of its past values (mean scaling), then split into equal-width intervals (bins), and the bin indices become tokens.
  • Model and training: T5 (an encoder-decoder Transformer) is used almost as is, trained with the classification cross-entropy loss of predicting the next token.
  • Data: training uses 28 public datasets, augmented with TSMixup, which mixes time series together, and KernelSynth, which generates synthetic time series with Gaussian processes.

Chronos uses no information about timestamps or days of the week and treats a time series as "just a sequence of numbers." The key point of the paper is showing that, even so, it can learn basic patterns such as seasonal repetition and trends from many time series and use them to forecast.

As a result, on the 15 datasets used in training (Benchmark I), it outperformed all statistical methods, deep learning models trained on each dataset, and other pre-trained models. On the 27 datasets not used in training (Benchmark II), it achieved accuracy on par with the best deep learning models trained on each dataset, without any training (zero-shot).

How It Works

Let a time series be x1:C+H=[x1,…,xC+H]x_{1:C+H} = [x_1, \dots, x_{C+H}]. The first CC values are the available past (context), and the remaining HH values are the future to be forecast. In the figure at the top of this article, the left shows tokenization, the center shows training, and the right shows inference (Figure 1 of the paper).

1. Tokenization

  1. Mean scaling: all values are divided by the mean ss of the absolute values of the past CC values (x~i=xi/s\tilde{x}_i = x_i / s). This brings series whose magnitudes differ by orders of magnitude into the same range. Because the mean is not subtracted, meaningful zeros, such as zero sales or zero solar generation at night, stay zero.
  2. Quantization: BB bin centers c1<⋯<cBc_1 < \dots < c_B are placed evenly over [−15,15][-15, 15], and the index of the bin a value falls into becomes its token. bib_i are the boundaries between adjacent bins.
s=1C∑i=1C∣xi∣,q(x)={1(−∞≤x<b1)j(bj−1≤x<bj)B(bB−1≤x<∞),d(j)=cjs = \frac{1}{C} \sum_{i=1}^{C} |x_i|, \qquad q(x) = \begin{cases} 1 & (-\infty \le x < b_1) \\ j & (b_{j-1} \le x < b_j) \\ B & (b_{B-1} \le x < \infty) \end{cases}, \qquad d(j) = c_j
  1. Add special tokens: PAD, used to equalize lengths (and also in place of missing values), and EOS, marking the end of a sequence, are added. In the paper's setting, the vocabulary size is 4096 including the special tokens.

2. Training

The token sequence is fed to the language model, which is trained as a classifier to predict which vocabulary entry the next token is at each position. The loss is the cross-entropy against the correct token zC+h+1z_{C+h+1} (Eq. 2 of the paper).

ℓ(θ)=−∑h=1H+1∑i=1∣Vts∣1(zC+h+1=i)log⁡pθ(zC+h+1=i∣z1:C+h)\ell(\theta) = - \sum_{h=1}^{H+1} \sum_{i=1}^{|V_{ts}|} \mathbf{1}(z_{C+h+1} = i) \log p_\theta(z_{C+h+1} = i \mid z_{1:C+h})

The language model architecture is left untouched, except for resizing the input and output embedding layers to match the vocabulary size. The paper mainly uses T5, and shows that the same method also works with the decoder-only GPT-2.

3. Inference

  1. The past token sequence is fed in, and one next token is sampled from the output probability distribution.
  2. That token is appended to the input, and the next token is sampled. This is repeated HH times (autoregression).
  3. Tokens are mapped back to their bin center values (dequantization) and multiplied by ss to restore the original scale.
  4. Steps 1–3 are repeated many times to produce many forecast trajectories, and quantiles (e.g., 10%, 50%, 90%) and the median are computed from their distribution.

Techniques for increasing training data

Public time series data is limited in both quantity and variety compared with language text. The paper expanded the data in two ways (Section 4).

  • TSMixup: kk time series (kk chosen at random from 1 to KK) are selected from the training data, their scales are normalized, and they are summed with weights drawn from a Dirichlet distribution. It extends image Mixup to three or more series.
  • KernelSynth: kernels such as a linear kernel for trends, an RBF kernel for smooth variation, and periodic kernels for seasonality are chosen at random and combined by addition or multiplication, and synthetic time series are generated from the resulting Gaussian process.

For the final training, 10 million TSMixup series built from the 28 datasets (about 890,000 series, about 84 billion observations) and 1 million KernelSynth series were used at a 9:1 ratio.

Why It Works

From the paper's analysis, the reasons Chronos works and the rationale behind its design choices can be summarized as follows.

  • Classification avoids assuming the shape of the distribution: instead of assuming a form such as a normal distribution, as DeepAR does, or learning only fixed quantiles, it learns classification over 4096 classes. This lets it represent shapes such as bimodal distributions. The paper confirms that, although cross-entropy has no notion of closeness between bins, the model outputs distributions of various shapes that are concentrated on adjacent bins (Figure 15).
  • Language model tools can be used directly: since the architecture and loss are the same as a language model's, language model techniques, such as training libraries, inference acceleration, and Top-k and Top-p sampling, can be used without modification.
  • It learns basic patterns from many time series: on synthetic series, Chronos produced reasonable zero-shot forecasts for seasonal repetition, linear trends, their additive and multiplicative combinations, and autoregressive processes (Section 5.7 of the paper).
  • The data augmentation matters: using TSMixup improves accuracy on unseen data while leaving accuracy on the training datasets nearly unchanged. Mixing in about 10% of KernelSynth synthetic data improves both, while mixing in more makes them worse.
  • Language pre-training does not help: starting from T5 weights pre-trained on text gave results equal to or slightly worse than starting from random initialization. The paper concludes that random initialization is preferable.

As an analogy, Chronos is a model that has practiced "filling in the continuation of a sequence of numbers" on millions of time series. Converting values into bin indices lets it practice on time series with different scales and units, such as weather, electricity, and sales, as if they were the same "language."

Experimental Results

Evaluation was carried out on 15 datasets used in training (Benchmark I) and 27 datasets not used in training (Benchmark II). Probabilistic forecasts are measured with the weighted quantile loss (WQL) and point forecasts with MASE. Both are divided, per dataset, by the score of the seasonal naive method (which simply repeats the value from one period earlier), and models are compared by the geometric mean over all datasets, called the "relative score." Values below 1 mean better than seasonal naive (Tables 7–10 of the paper).

ModelTypeI: WQLI: MASEII: WQLII: MASE
Chronos-T5 (Large, 710M)Pre-trained0.5640.6950.6450.823
Chronos-T5 (Base, 200M)Pre-trained0.5800.7060.6620.832
Chronos-T5 (Small, 46M)Pre-trained0.6030.7270.6670.841
Chronos-T5 (Mini, 20M)Pre-trained0.5980.7320.6780.850
Chronos-GPT2 (90M)Pre-trained0.6230.7410.6870.852
Moirai-1.0-R (Large)Pre-trained (other data)0.6700.8060.7200.876
Lag-LlamaPre-trained (other data)0.9371.1411.0971.291
PatchTSTTrained per dataset0.6010.7400.6840.810
TFTTrained per dataset0.7340.9390.6390.847
DeepARTrained per dataset0.6760.8210.7330.843
DLinearTrained per dataset0.6970.8640.7570.894
AutoETSPer-series statistical model1.0760.9830.8380.953
  • Datasets used in training (I): Chronos-T5 Large and Base achieved the best scores on both WQL and MASE. Even the smallest, Mini (20M), outperformed Moirai-1.0-R Large (311M).
  • Datasets not used in training (II): Large placed second on WQL after TFT, and second on MASE after PatchTST. In other words, it matched models trained on each dataset without any training. ETT is included here; on the hourly version, the WQL was 0.073 for Chronos-T5 (Large), 0.071 for PatchTST, and 0.122 for seasonal naive.
  • Fine-tuning: briefly fine-tuning Chronos-T5 (Small) on each Benchmark II dataset (learning rate decayed from 0.001 to 0 over 1000 steps) made it the best model overall on Benchmark II (Figure 6 of the paper).
  • Size: larger models gave better training loss and better accuracy on both benchmarks.

The training setup uses a context length of 512, a prediction length of 64, AdamW (weight decay 0.01), a learning rate decayed linearly from 0.001 to 0, and 200,000 steps. On 8 A100 GPUs, training Large took about 63 hours (Table 6 of the paper).

Practical Considerations

Keep the following points in mind when using Chronos.

  • It forecasts one series at a time (univariate): Chronos as presented in the paper does not use relationships between variables or externally known information (covariates) such as promotion schedules. When covariates matter, combine it with a model that can handle them (the paper mentions stacking with LightGBM, among others) or consider successor models.
  • The representable range of values is limited: since bins span [−15,15][-15, 15], only values within [−15s,15s][-15s, 15s] can be represented on the original scale. For sparse series with only occasional large values, ss becomes small and peaks may not be representable. Conversely, for series with a large mean and small variation, changes finer than the bin width (30s/(B−1)30s/(B-1) on the original scale) cannot be distinguished. The paper recommends preprocessing with a different normalization, such as standardization, in such cases.
  • Exponential trends and trends from short contexts are weak points: linear trends can be forecast, but exponentially growing trends were not forecast well (taking the logarithm before input is suggested as one option). With short contexts, it tends to underestimate trends.
  • Inference is relatively slow: it generates tokens one at a time autoregressively and produces many trajectories, so larger models are slower at inference than deep learning models trained per dataset. The paper reports speeds comparable to some statistical methods.
  • It does not use time information: calendar information such as days of the week or holidays is not input. For series that vary strongly with the calendar, a longer context makes it easier to pick up the periodicity.

To estimate accuracy on new data correctly, you need to distinguish data used in training from data that was not. The list of datasets used to train Chronos is in Appendix B of the paper. If your evaluation data was included in training, zero-shot accuracy will be overestimated.

Comparison with Other Models

Lining up time series forecasting models from the same perspective gives the following.

ModelTraining approachInput representationOutputRelationships between variables
ChronosPre-trained on many datasets (usable zero-shot)Values turned into bin tokensDistribution sampled from classification probabilitiesNot used (univariate)
TTMPre-trained + light fine-tuningPatchesForecast valuesOptional exogenous mixer
DeepARTrained per datasetRaw values (divided by the mean)Parameters of an assumed distributionWeights shared across many series
PatchTSTTrained per datasetPatchesForecast valuesNot used
TSMixer (Google)Trained per datasetTime × variable tableForecast valuesMixed by MLPs along the variable axis

Rough guidelines for choosing:

  • Little training data, or forecasts needed quickly for many series: trying a pre-trained model such as Chronos zero-shot first is the easy option.
  • Forecast ranges (uncertainty) are also needed: Chronos can produce quantiles from samples, which suits decisions that use ranges, such as setting inventory levels.
  • Relationships between variables or covariates matter: models that can take them as input, such as the extended version of TSMixer (Google) or DeepAR, fit better.
  • Fast inference is needed, or accuracy must be pushed on a single dataset: compare lightweight models trained per dataset, such as PatchTST, against fine-tuned Chronos and choose.

PyTorch example

Show code
python
import torch

"""
A small implementation of Chronos tokenization (Section 3.1 and Eq. 1 of arXiv:2403.07815) and its inverse
mean scaling → quantize into evenly spaced bins over [-15, 15] → bin indices become tokens
"""

N_SPECIAL = 2                     # PAD (0) and EOS (1)
N_TOKENS = 4096                   # vocabulary size including special tokens (the paper's setting)
centers = torch.linspace(-15, 15, N_TOKENS - N_SPECIAL - 1)          # bin centers c_1 … c_B
edges = (centers[1:] + centers[:-1]) / 2                              # boundaries are midpoints of adjacent centers


def tokenize(context):
  """context: [batch, C] (missing values are NaN) → tokens [batch, C] and scale s [batch]"""
  observed = ~torch.isnan(context)
  x = torch.nan_to_num(context)
  s = (x.abs() * observed).sum(-1) / observed.sum(-1).clamp(min=1)   # mean of past |x|
  s = torch.where(s > 0, s, torch.ones_like(s))                      # use 1 when all values are 0
  ids = torch.bucketize(x / s.unsqueeze(-1), edges, right=True) + N_SPECIAL + 1
  ids = ids.clamp(max=N_TOKENS - 1)
  ids[~observed] = 0                                                  # missing values become PAD
  return ids, s


def detokenize(ids, s):
  """tokens → bin centers (dequantization) × s (restore the scale)"""
  idx = (ids - N_SPECIAL - 1).clamp(0, len(centers) - 1)
  return centers[idx] * s.unsqueeze(-1)


context = torch.tensor([[10.0, 12.0, 0.0, 14.0, 11.0, float("nan"), 13.0]])
ids, s = tokenize(context)
print(ids, s)                     # s is the mean absolute value of 10, 12, 0, 14, 11, 13 = 10.0
print(detokenize(ids, s))         # except for the missing value, recovered within half a bin width


# Forecasting with a pre-trained model (pip install chronos-forecasting)
# from chronos import ChronosPipeline
#
# pipeline = ChronosPipeline.from_pretrained(
#   "amazon/chronos-t5-small",    # mini, small, base, large, etc.
#   device_map="cpu",
#   torch_dtype=torch.float32,
# )
# history = torch.tensor([112, 118, 132, 129, 121, 135, 148, 148, 136, 119, 104, 118], dtype=torch.float32)
# samples = pipeline.predict(history, prediction_length=12, num_samples=20)   # [number of series, 20, 12]
# low, median, high = torch.quantile(samples[0], torch.tensor([0.1, 0.5, 0.9]), dim=0)
# This is an inference-only pipeline with no training mechanism, so no model.train() / model.eval() switching is needed

FAQ

Q. How is this different from having a large language model like ChatGPT read numbers as text?
A.

Chronos does not reuse a language model trained on text; it is a model trained only on time series. Its architecture is the same as T5, but its vocabulary consists of 4096 numeric bins, and its weights are trained on time series from random initialization. In the paper, it outperformed LLMTime, which has a large language model read numbers as text, on both WQL and MASE on Benchmark II.

Q. Why do the forecast values change slightly each time?
A.

Because forecasts are produced by sampling the next token from a probability distribution. Chronos is a model that builds a distribution from many forecast trajectories rather than a single forecast. For a point forecast, use the median of many samples (which is also what the paper's MASE evaluation uses); for a range, use quantiles such as 10% and 90%.

Q. Do I need to retrain it on my own data?
A.

It can be used without training (zero-shot) first. In the paper, even on 27 datasets not used in training, it performed on par with deep learning models trained on each dataset. When more accuracy is needed, briefly fine-tuning on each dataset is reported to improve results substantially.

References

  1. Ansari, A. F., Stella, L., Turkmen, C., Zhang, X., Mercado, P., Shen, H., Shchur, O., Rangapuram, S. S., Pineda Arango, S., Kapoor, S., Zschiegner, J., Maddix, D. C., Wang, H., Mahoney, M. W., Torkkola, K., Wilson, A. G., Bohlke-Schneider, M., & Wang, Y. (2024). Chronos: Learning the Language of Time Series. Transactions on Machine Learning Research (10/2024).
  2. amazon-science/chronos-forecasting (official implementation and pre-trained models)
  3. Raffel, C., Shazeer, N., Roberts, A., et al. (2020). Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer. Journal of Machine Learning Research, 21.
  4. Zhang, H., Cisse, M., Dauphin, Y. N., & Lopez-Paz, D. (2017). mixup: Beyond Empirical Risk Minimization. arXiv:1710.09412.
  5. Nie, Y., Nguyen, N. H., Sinthong, P., & Kalagnanam, J. (2023). A Time Series is Worth 64 Words: Long-term Forecasting with Transformers. ICLR 2023.