模型概述
模型特點
模型能力
使用案例
🚀 Chronos - Bolt⚡ (Mini)
Chronos - Bolt是一系列預訓練的時間序列預測模型,可用於零樣本預測。它基於T5編解碼器架構,在近1000億個時間序列觀測值上進行了訓練。該模型將歷史時間序列上下文分塊為多個觀測值的片段,然後輸入到編碼器中。解碼器再利用這些表示直接生成多個未來步驟的分位數預測,這種方法被稱為直接多步預測。與相同規模的原始Chronos模型相比,Chronos - Bolt模型的速度提升了多達250倍,內存效率提高了20倍。
🚀 快速開始
最新消息
2025年2月14日更新:Chronos - Bolt模型現已在Amazon SageMaker JumpStart上可用!查看教程筆記本,瞭解如何用幾行代碼部署Chronos端點以供生產使用。
✨ 主要特性
性能優勢
- 速度快:以下圖表比較了Chronos - Bolt與原始Chronos模型在預測1024個時間序列時的推理時間,上下文長度為512個觀測值,預測範圍為64步。
模型規格
Chronos - Bolt模型有以下幾種規格:
模型 | 參數數量 | 基於的模型 |
---|---|---|
[chronos - bolt - tiny](https://huggingface.co/amazon/chronos - bolt - tiny) | 9M | [t5 - efficient - tiny](https://huggingface.co/google/t5 - efficient - tiny) |
[chronos - bolt - mini](https://huggingface.co/amazon/chronos - bolt - mini) | 21M | [t5 - efficient - mini](https://huggingface.co/google/t5 - efficient - mini) |
[chronos - bolt - small](https://huggingface.co/amazon/chronos - bolt - small) | 48M | [t5 - efficient - small](https://huggingface.co/google/t5 - efficient - small) |
[chronos - bolt - base](https://huggingface.co/amazon/chronos - bolt - base) | 205M | [t5 - efficient - base](https://huggingface.co/google/t5 - efficient - base) |
📦 安裝指南
使用AutoGluon
推薦在生產用例中通過AutoGluon使用Chronos。AutoGluon提供了對Chronos模型的輕鬆微調,通過協變量回歸器將協變量納入預測,以及與其他統計和機器學習模型進行集成以實現最高準確性。查看AutoGluon Chronos [教程](https://auto.gluon.ai/stable/tutorials/timeseries/forecasting - chronos.html)瞭解更多詳情。
安裝所需依賴:
pip install autogluon
部署Chronos - Bolt端點到SageMaker
SageMaker JumpStart可以讓你用幾行代碼輕鬆部署Chronos端點以供生產使用。Chronos - Bolt端點可以部署到CPU和GPU實例上,並且支持使用協變量進行預測。更多詳情可查看[示例筆記本](https://github.com/amazon - science/chronos - forecasting/blob/main/notebooks/deploy - chronos - bolt - to - amazon - sagemaker.ipynb)。
更新SageMaker SDK以確保所有最新模型可用:
pip install -U sagemaker
使用推理庫
你也可以安裝GitHub [配套倉庫](https://github.com/amazon - science/chronos - forecasting)中的包。這主要用於研究目的,為Chronos模型提供了一個最小化的接口。
安裝庫:
pip install chronos - forecasting
💻 使用示例
基礎用法
使用AutoGluon進行零樣本推理
from autogluon.timeseries import TimeSeriesPredictor, TimeSeriesDataFrame
df = TimeSeriesDataFrame("https://autogluon.s3.amazonaws.com/datasets/timeseries/m4_hourly/train.csv")
predictor = TimeSeriesPredictor(prediction_length=48).fit(
df,
hyperparameters={
"Chronos": {"model_path": "amazon/chronos-bolt-mini"},
},
)
predictions = predictor.predict(df)
部署Chronos - Bolt(Base)端點到SageMaker
from sagemaker.jumpstart.model import JumpStartModel
model = JumpStartModel(
model_id="autogluon-forecasting-chronos-bolt-base",
instance_type="ml.c5.2xlarge",
)
predictor = model.deploy()
import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/AileenNielsen/TimeSeriesAnalysisWithPython/master/data/AirPassengers.csv")
payload = {
"inputs": [
{"target": df["#Passengers"].tolist()}
],
"parameters": {
"prediction_length": 12,
}
}
forecast = predictor.predict(payload)["predictions"]
使用推理庫進行推理
import pandas as pd # requires: pip install pandas
import torch
from chronos import BaseChronosPipeline
pipeline = BaseChronosPipeline.from_pretrained(
"amazon/chronos-bolt-mini",
device_map="cuda", # use "cpu" for CPU inference and "mps" for Apple Silicon
torch_dtype=torch.bfloat16,
)
df = pd.read_csv(
"https://raw.githubusercontent.com/AileenNielsen/TimeSeriesAnalysisWithPython/master/data/AirPassengers.csv"
)
# context must be either a 1D tensor, a list of 1D tensors,
# or a left-padded 2D tensor with batch as the first dimension
# Chronos-Bolt models generate quantile forecasts, so forecast has shape
# [num_series, num_quantiles, prediction_length].
forecast = pipeline.predict(
context=torch.tensor(df["#Passengers"]), prediction_length=12
)
📚 詳細文檔
引用說明
如果你發現Chronos或Chronos - Bolt模型對你的研究有用,請考慮引用相關論文:
@article{ansari2024chronos,
title={Chronos: Learning the Language of Time Series},
author={Ansari, Abdul Fatir and Stella, Lorenzo and Turkmen, Caner and Zhang, Xiyuan, and Mercado, Pedro and Shen, Huibin and Shchur, Oleksandr and Rangapuram, Syama Syndar and Pineda Arango, Sebastian and Kapoor, Shubham and Zschiegner, Jasper and Maddix, Danielle C. and Mahoney, Michael W. and Torkkola, Kari and Gordon Wilson, Andrew and Bohlke-Schneider, Michael and Wang, Yuyang},
journal={Transactions on Machine Learning Research},
issn={2835-8856},
year={2024},
url={https://openreview.net/forum?id=gerNCVqqtR}
}
📄 許可證
本項目採用Apache - 2.0許可證。




