🚀 Chronos-T5 (Small)
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模型進行推理,可通過運行以下命令在GitHub 配套倉庫 中安裝該包:
pip install git+https://github.com/amazon-science/chronos-forecasting.git
✨ 主要特性
Chronos模型基於語言模型架構,可將時間序列轉換為標記進行訓練,訓練完成後能通過採樣未來軌跡獲得概率預測。該模型在大量公開時間序列數據和合成數據上訓練,具有較高的準確性和效率。
📦 安裝指南
通過以下命令安裝Chronos模型所需的包:
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-small",
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模型的參數更少。
引用
如果您發現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。
📄 許可證
本項目採用Apache-2.0許可證。