🚀 Chronos-T5 (Large)
Chronos是一系列基于语言模型架构的预训练时间序列预测模型。它将时间序列通过缩放和量化转换为一系列标记,然后使用交叉熵损失对这些标记进行语言模型训练。训练完成后,根据历史上下文对多个未来轨迹进行采样,从而得到概率预测。Chronos模型在大量公开可用的时间序列数据以及使用高斯过程生成的合成数据上进行了训练。
最新动态
- 🚀 2025年2月14日更新:Chronos-Bolt和原始Chronos模型现已在Amazon SageMaker JumpStart上可用!查看教程笔记本,了解如何用几行代码部署Chronos端点以用于生产环境。
- 🚀 2024年11月27日更新:我们发布了Chronos-Bolt⚡️模型,与相同大小的原始Chronos模型相比,它的准确性提高了(误差降低了5%),速度提高了250倍,内存效率提高了20倍。查看新模型点击此处。
🚀 快速开始
若要了解Chronos模型的详细信息、训练数据和流程以及实验结果,请参考论文Chronos: Learning the Language of Time Series。
图1:Chronos的高层描述。(左)输入的时间序列经过缩放和量化,得到一系列标记。(中)这些标记被输入到语言模型中,该模型可以是编码器 - 解码器模型,也可以是仅解码器模型。模型使用交叉熵损失进行训练。(右)在推理过程中,我们从模型中自回归地采样标记,并将它们映射回数值。对多个轨迹进行采样,以获得预测分布。
✨ 主要特性
Chronos模型基于语言模型架构,通过对大量公开时间序列数据及合成数据的学习,能够实现时间序列的概率预测。其训练过程将时间序列转换为标记序列,利用交叉熵损失进行训练,推理时通过采样多个未来轨迹获得预测分布。
📦 安装指南
要使用Chronos模型进行推理,需要安装GitHub 配套仓库 中的包,运行以下命令:
pip install git+https://github.com/amazon-science/chronos-forecasting.git
💻 使用示例
基础用法
以下是一个使用Chronos模型进行推理的最小示例:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import torch
from chronos import ChronosPipeline
pipeline = ChronosPipeline.from_pretrained(
"amazon/chronos-t5-large",
device_map="cuda",
torch_dtype=torch.bfloat16,
)
df = pd.read_csv("https://raw.githubusercontent.com/AileenNielsen/TimeSeriesAnalysisWithPython/master/data/AirPassengers.csv")
context = torch.tensor(df["#Passengers"])
prediction_length = 12
forecast = pipeline.predict(context, prediction_length)
forecast_index = range(len(df), len(df) + prediction_length)
low, median, high = np.quantile(forecast[0].numpy(), [0.1, 0.5, 0.9], axis=0)
plt.figure(figsize=(8, 4))
plt.plot(df["#Passengers"], color="royalblue", label="historical data")
plt.plot(forecast_index, median, color="tomato", label="median forecast")
plt.fill_between(forecast_index, low, high, color="tomato", alpha=0.3, label="80% prediction interval")
plt.legend()
plt.grid()
plt.show()
📚 详细文档
架构
本仓库中的模型基于 T5架构。唯一的区别在于词汇量大小:Chronos-T5模型使用4096个不同的标记,而原始T5模型使用32128个标记,这使得Chronos-T5模型的参数更少。
📄 许可证
本项目采用Apache-2.0许可证。
📚 引用
如果您发现Chronos模型对您的研究有帮助,请考虑引用相关 论文:
@article{ansari2024chronos,
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},
title = {Chronos: Learning the Language of Time Series},
journal = {arXiv preprint arXiv:2403.07815},
year = {2024}
}
🔒 安全
更多信息请参阅 CONTRIBUTING。