🚀 Chronos-Bolt⚡ (Tiny)
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模型更準確。以下圖表分別報告了Chronos-Bolt在加權分位數損失(WQL)和平均絕對縮放誤差(MASE)方面的概率預測和點預測性能,這些性能是在27個數據集上彙總得到的(有關此基準的詳細信息,請參閱Chronos論文)。值得注意的是,儘管在訓練期間沒有接觸過這些數據集,但零樣本的Chronos-Bolt模型的表現優於在這些數據集上訓練過的常用統計模型和深度學習模型(用 * 突出顯示)。此外,它們的表現也優於其他基礎模型(用 + 表示),這表明這些模型是在我們基準測試中的某些數據集上進行預訓練的,並非完全的零樣本模型。值得一提的是,Chronos-Bolt (Base) 在預測準確性方面也超過了原始的Chronos (Large) 模型,同時速度快了600多倍。
模型規格
Chronos-Bolt模型有以下幾種規格可供選擇:
💻 使用示例
與AutoGluon一起使用
在生產用例中,推薦通過AutoGluon使用Chronos。AutoGluon可以輕鬆地對Chronos模型進行微調,通過協變量回歸器將協變量納入預測中,並與其他統計和機器學習模型進行集成以實現最高的準確性。查看AutoGluon Chronos 教程以瞭解更多詳細信息。
基礎用法
以下是一個使用AutoGluon和Chronos-Bolt進行零樣本推理的最小示例:
pip install 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-tiny"},
},
)
predictions = predictor.predict(df)
將Chronos-Bolt端點部署到SageMaker
SageMaker JumpStart可以讓你用幾行代碼輕鬆部署Chronos端點以用於生產環境。Chronos-Bolt端點可以部署到CPU和GPU實例上,並且支持使用協變量進行預測。更多詳細信息請參閱這個示例筆記本。
基礎用法
以下是一個將Chronos-Bolt (Base) 端點部署到SageMaker的最小示例:
pip install -U 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"]
與推理庫一起使用
你也可以安裝GitHub 配套倉庫中的包。這主要用於研究目的,為Chronos模型提供了一個最小的接口。
基礎用法
通過以下命令安裝庫:
pip install chronos-forecasting
以下是一個使用Chronos-Bolt模型進行推理的最小示例:
import pandas as pd
import torch
from chronos import BaseChronosPipeline
pipeline = BaseChronosPipeline.from_pretrained(
"amazon/chronos-bolt-tiny",
device_map="cuda",
torch_dtype=torch.bfloat16,
)
df = pd.read_csv(
"https://raw.githubusercontent.com/AileenNielsen/TimeSeriesAnalysisWithPython/master/data/AirPassengers.csv"
)
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許可證。