模型简介
模型特点
模型能力
使用案例
🚀 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许可证。




