许可协议:apache-2.0
任务类型:时间序列预测
标签:
- 时间序列
- 预测
- 预训练模型
- 基础模型
- 时间序列基础模型
- 时序数据
Chronos-Bolt⚡(小尺寸版)
🚀 2025年2月14日更新:Chronos-Bolt模型现已登陆Amazon SageMaker JumpStart!查看教程笔记本,学习如何用几行代码部署Chronos端点至生产环境。
Chronos-Bolt是一系列预训练时间序列预测模型,支持零样本预测。其基于T5编码器-解码器架构,训练数据涵盖近千亿时间序列观测点。该模型将历史时间序列上下文分块为多观测点片段输入编码器,解码器则利用这些表征直接生成多步分位数预测——这种技术称为直接多步预测。相比原始Chronos同尺寸模型,Chronos-Bolt速度提升高达250倍,内存效率提高20倍。
性能表现
下图对比了Chronos-Bolt与原始Chronos模型在预测1024条时间序列(上下文长度512观测点,预测步长64)时的推理耗时:
Chronos-Bolt不仅速度显著提升,精度也更高。下图展示了Chronos-Bolt在27个数据集上(详见Chronos论文)的加权分位数损失(WQL)和平均绝对比例误差(MASE)表现。值得注意的是,零样本的Chronos-Bolt模型超越了这些数据集上训练的常见统计模型和深度学习模型(标*者),也优于其他基础模型(标+者表示曾预训练过部分基准数据集)。Chronos-Bolt(基础版)在预测精度上甚至超越原始Chronos(大尺寸版),同时速度快600多倍。
Chronos-Bolt提供以下尺寸版本:
使用指南
通过AutoGluon使用
推荐使用AutoGluon进行生产级部署。AutoGluon支持Chronos模型的微调、通过协变量回归器整合外生变量,以及与其他统计/机器学习模型的集成预测。详见AutoGluon Chronos教程。
零样本推理最小示例:
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-small"},
},
)
predictions = predictor.predict(df)
部署至SageMaker
通过SageMaker JumpStart可快速部署至CPU/GPU实例,并支持协变量预测。详见示例笔记本。
部署最小示例:
from sagemaker.jumpstart.model import JumpStartModel
model = JumpStartModel(
model_id="autogluon-forecasting-chronos-bolt-base",
instance_type="ml.c5.2xlarge",
)
predictor = model.deploy()
发送JSON格式数据进行预测:
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配套库:
pip install chronos-forecasting
推理最小示例:
from chronos import BaseChronosPipeline
pipeline = BaseChronosPipeline.from_pretrained(
"amazon/chronos-bolt-small",
device_map="cuda",
torch_dtype=torch.bfloat16,
)
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许可证。