chronos t5 large

amazon

Introduction

Chronos-T5 is a series of pretrained models for time series forecasting, developed by Amazon. These models leverage language model architectures to transform time series data into sequences of tokens. The models have been trained on both public and synthetic data to produce probabilistic forecasts.

Architecture

Chronos-T5 models are based on the T5 architecture with a reduced vocabulary size of 4096 tokens, compared to the original 32128 in T5. This reduction results in fewer parameters. The models range in size from the chronos-t5-tiny with 8M parameters to the chronos-t5-large with 710M parameters. The architecture is designed to scale and quantize input time series into tokens, which are processed by a language model to generate forecasts.

Training

Chronos models are trained using cross-entropy loss on a large dataset of time series data. This includes both publicly available datasets and synthetic data generated using Gaussian processes. The training process involves transforming time series data into token sequences that the model learns to predict.

Guide: Running Locally

  1. Install the Package:
    Install the required package from the GitHub repository:

    pip install git+https://github.com/amazon-science/chronos-forecasting.git
    
  2. Perform Inference:

    • Import necessary libraries and load the model:

      import torch
      from chronos import ChronosPipeline
      
      pipeline = ChronosPipeline.from_pretrained(
        "amazon/chronos-t5-large",
        device_map="cuda",
        torch_dtype=torch.bfloat16,
      )
      
    • Load your dataset and prepare the input context:

      import pandas as pd
      df = pd.read_csv("https://raw.githubusercontent.com/AileenNielsen/TimeSeriesAnalysisWithPython/master/data/AirPassengers.csv")
      context = torch.tensor(df["#Passengers"])
      
    • Predict and visualize the forecast:

      prediction_length = 12
      forecast = pipeline.predict(context, prediction_length)
      
    • Cloud GPUs: Consider using cloud platforms such as AWS or Google Cloud for GPU resources to enhance performance.

License

This project is licensed under the Apache-2.0 License, allowing for open-source use and distribution.

More Related APIs in Time Series Forecasting