shchuro commited on
Commit
d8f5052
·
verified ·
1 Parent(s): 6f8ced4

Add instructions for deploying models to SageMaker

Browse files
Files changed (1) hide show
  1. README.md +50 -6
README.md CHANGED
@@ -14,6 +14,8 @@ tags:
14
 
15
  Chronos-Bolt is a family of pretrained time series forecasting models which can be used for zero-shot forecasting. It is based on the [T5 encoder-decoder architecture](https://arxiv.org/abs/1910.10683) and has been trained on nearly 100 billion time series observations. It chunks the historical time series context into patches of multiple observations, which are then input into the encoder. The decoder then uses these representations to directly generate quantile forecasts across multiple future steps—a method known as direct multi-step forecasting. Chronos-Bolt models are up to 250 times faster and 20 times more memory-efficient than the [original Chronos](https://arxiv.org/abs/2403.07815) models of the same size.
16
 
 
 
17
  The following plot compares the inference time of Chronos-Bolt against the original Chronos models for forecasting 1024 time series with a context length of 512 observations and a prediction horizon of 64 steps.
18
 
19
  <center>
@@ -40,18 +42,21 @@ Chronos-Bolt models are available in the following sizes.
40
 
41
  </div>
42
 
 
43
 
44
- ## Usage with AutoGluon
45
 
46
- The recommended way of using Chronos for production use cases is through [AutoGluon](https://auto.gluon.ai/stable/index.html), which features effortless fine-tuning, augmenting Chronos models with exogenous information through covariate regressors, ensembling with other statistical and machine learning models, as well as seamless deployments on AWS with SageMaker.
47
- Check out the AutoGluon Chronos [tutorial](https://auto.gluon.ai/stable/tutorials/timeseries/forecasting-chronos.html).
 
48
 
49
  A minimal example showing how to perform zero-shot inference using Chronos-Bolt with AutoGluon:
50
 
 
51
  ```
52
  pip install autogluon
53
  ```
54
-
55
  ```python
56
  from autogluon.timeseries import TimeSeriesPredictor, TimeSeriesDataFrame
57
 
@@ -60,14 +65,53 @@ df = TimeSeriesDataFrame("https://autogluon.s3.amazonaws.com/datasets/timeseries
60
  predictor = TimeSeriesPredictor(prediction_length=48).fit(
61
  df,
62
  hyperparameters={
63
- "Chronos": {"model_path": "amazon/chronos-bolt-base"},
64
  },
65
  )
66
 
67
  predictions = predictor.predict(df)
68
  ```
69
 
70
- ## Usage with inference library
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  Alternatively, you can install the package in the GitHub [companion repo](https://github.com/amazon-science/chronos-forecasting).
73
  This is intended for research purposes and provides a minimal interface to Chronos models.
 
14
 
15
  Chronos-Bolt is a family of pretrained time series forecasting models which can be used for zero-shot forecasting. It is based on the [T5 encoder-decoder architecture](https://arxiv.org/abs/1910.10683) and has been trained on nearly 100 billion time series observations. It chunks the historical time series context into patches of multiple observations, which are then input into the encoder. The decoder then uses these representations to directly generate quantile forecasts across multiple future steps—a method known as direct multi-step forecasting. Chronos-Bolt models are up to 250 times faster and 20 times more memory-efficient than the [original Chronos](https://arxiv.org/abs/2403.07815) models of the same size.
16
 
17
+ ## Performance
18
+
19
  The following plot compares the inference time of Chronos-Bolt against the original Chronos models for forecasting 1024 time series with a context length of 512 observations and a prediction horizon of 64 steps.
20
 
21
  <center>
 
42
 
43
  </div>
44
 
45
+ ## Usage
46
 
47
+ ### Zero-shot inference with Chronos-Bolt in AutoGluon
48
 
49
+ The recommended way of using Chronos for production use cases is through [AutoGluon](https://auto.gluon.ai/stable/index.html).
50
+ AutoGluon offers effortless **fine-tuning** of Chronos models, incorporating **covariates** into the forecast through covariate regressors, and **ensembling** with other statistical and machine learning models for maximum accuracy.
51
+ Check out the AutoGluon Chronos [tutorial](https://auto.gluon.ai/stable/tutorials/timeseries/forecasting-chronos.html) for more details.
52
 
53
  A minimal example showing how to perform zero-shot inference using Chronos-Bolt with AutoGluon:
54
 
55
+ Install the required dependencies.
56
  ```
57
  pip install autogluon
58
  ```
59
+ Forecast with the Chronos-Bolt model.
60
  ```python
61
  from autogluon.timeseries import TimeSeriesPredictor, TimeSeriesDataFrame
62
 
 
65
  predictor = TimeSeriesPredictor(prediction_length=48).fit(
66
  df,
67
  hyperparameters={
68
+ "Chronos": {"model_path": "autogluon/chronos-bolt-base"},
69
  },
70
  )
71
 
72
  predictions = predictor.predict(df)
73
  ```
74
 
75
+
76
+ ### Deploying a Chronos-Bolt endpoint to SageMaker
77
+ SageMaker JumpStart makes it easy to deploy Chronos endpoints for production use with just a few lines of code.
78
+ Chronos-Bolt endpoints can be deployed to **both CPU and GPU** instances, as well as support forecasting with **covariates**.
79
+ More details are available in this [example notebook](https://github.com/amazon-science/chronos-forecasting/blob/main/notebooks/deploy-chronos-bolt-to-amazon-sagemaker.ipynb).
80
+
81
+ A minimal example showing how to deploy a Chronos-Bolt (Base) endpoint to SageMaker:
82
+
83
+ Update the SageMaker SDK to make sure that all the latest models are available.
84
+ ```
85
+ pip install -U sagemaker
86
+ ```
87
+ Deploy an inference endpoint to SageMaker.
88
+ ```python
89
+ from sagemaker.jumpstart.model import JumpStartModel
90
+
91
+ model = JumpStartModel(
92
+ model_id="autogluon-forecasting-chronos-bolt-base",
93
+ instance_type="ml.c5.2xlarge",
94
+ )
95
+ predictor = model.deploy()
96
+ ```
97
+ Now you can send time series data to the endpoint in JSON format.
98
+ ```python
99
+ import pandas as pd
100
+ df = pd.read_csv("https://raw.githubusercontent.com/AileenNielsen/TimeSeriesAnalysisWithPython/master/data/AirPassengers.csv")
101
+
102
+ payload = {
103
+ "inputs": [
104
+ {"target": df["#Passengers"].tolist()}
105
+ ],
106
+ "parameters": {
107
+ "prediction_length": 12,
108
+ }
109
+ }
110
+ forecast = predictor.predict(payload)["predictions"]
111
+ ```
112
+
113
+
114
+ ### Usage with inference library
115
 
116
  Alternatively, you can install the package in the GitHub [companion repo](https://github.com/amazon-science/chronos-forecasting).
117
  This is intended for research purposes and provides a minimal interface to Chronos models.