许可协议:Apache-2.0
任务类型:时间序列预测
标签:
- 时间序列
- 预测
- 预训练模型
- 基础模型
- 时间序列基础模型
Chronos-T5(迷你版)
🚀 2025年2月14日更新:Chronos-Bolt及原版Chronos模型现已登陆Amazon SageMaker JumpStart!查看教程笔记本,学习如何用几行代码部署Chronos端点至生产环境。
🚀 2024年11月27日更新:我们发布了Chronos-Bolt⚡️系列模型,相比同尺寸原版Chronos模型,其误差降低5%,速度提升高达250倍,内存效率提高20倍。探索新模型请访问此处。
Chronos是基于语言模型架构的预训练时间序列预测模型家族。通过缩放和量化将时间序列转换为标记序列,并利用交叉熵损失训练语言模型。训练完成后,通过给定历史上下文采样多条未来轨迹获得概率预测。Chronos模型在大量公开时间序列数据及高斯过程生成的合成数据上进行了训练。
关于模型细节、训练数据与流程及实验结果,请参阅论文《Chronos:学习时间序列的语言》。
图1:Chronos核心流程示意图。(左)输入时间序列经缩放量化转为标记序列。(中)标记输入语言模型(编码器-解码器或纯解码架构),通过交叉熵损失训练。(右)推理时自回归采样标记并映射回数值,通过多轨迹采样获得预测分布。
架构
本仓库模型基于T5架构,唯一区别在于词汇量:Chronos-T5采用4096个标记(原版T5为32128个),参数量更少。
使用指南
通过运行以下命令安装配套仓库中的工具包进行推理:
pip install git+https://github.com/amazon-science/chronos-forecasting.git
基础推理示例:
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-mini",
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="历史数据")
plt.plot(forecast_index, median, color="tomato", label="预测中位数")
plt.fill_between(forecast_index, low, high, color="tomato", alpha=0.3, label="80%预测区间")
plt.legend()
plt.grid()
plt.show()
引用
若Chronos模型对您的研究有帮助,请引用相关论文:
@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许可证。