跳转至

Paper

TS ❤ GPT

GPT的风还是吹到了Time Series,看到Nixtla和Google都在做一些相关的工作,这里就一起跟进一下。

2023-Nixtla-TimeGPT

Paper Abstract

In this paper, we introduce TimeGPT, the first foundation model for time series, capable of generating accurate predictions for diverse datasets not seen during training. We evaluate our pre-trained model against established statistical, machine learning, and deep learning methods, demonstrating that TimeGPT zero-shot inference excels in performance, efficiency, and simplicity.

简单来说,TimeGPT-11第一个发布的时间序列基础模型,专注于zero-shot的时序预测。 论文的Benchmark对比了统计学,(统计)机器学习和深度学习的方法,证明了TimeGPT的优越性。

这里注意摘要中提到说TimeGPT是在performance, efficiency, and simplicity方面都全面领先的, 这个是比较出乎意料的。首先,更好的performance是可以理解的,毕竟都上DL了,在标准数据集上跑分高还是能做的(1)。 但是在efficiency和simplicity上怎么能做到领先的呢?

  1. 没错,言下之意就是在工业级的生产环境是很难跑到这个分数的,也很可能比其他统计学的方法更差。

首先是efficiency,论文提到TimeGPT在单个序列的GPU平均推理时间是0.6ms,与此同时一些统计学方法在的训练+推理的时间会达到 600ms, 其他像LGBM, LSTM这些方法平均每个序列的训练+推理时间为57ms,因此得出结论: TimeGPT比其他方法快好几个数量级。 Emmm...你要真这么比也不是不行:-) 不过0.6ms的推理时间确实是很快了,完全具有批量上生成环境的可能。

至于simplicity,文章没有提及很多。不过论文给出的模型架构确实很简单,基本就是Transformer原封不动拿过来用。

另外simplicity可能也是表现在使用方式上,Nixtla给出了调用TimeGPT的SDK, 确实也是简单易用的:

import pandas as pd
from nixtla import NixtlaClient


# Get your API Key at dashboard.nixtla.io

# 1. Instantiate the NixtlaClient
nixtla_client = NixtlaClient(api_key = 'YOUR API KEY HERE')

# 2. Read historic electricity demand data
df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short.csv')

# 3. Forecast the next 24 hours
fcst_df = nixtla_client.forecast(df, h=24, level=[80, 90])

# 4. Plot your results (optional)
nixtla_client.plot(df, timegpt_fcst_df, time_col='timestamp', target_col='value', level=[80, 90])

论文目前透露的信息不太多,模型也是闭源的。等后面有更多的信息放出来或者有相关开源的模型时,还是值得尝试一下效果的。

TODO: 2024-Salesforce-MOIRAI

Unified Training of Universal Time Series Forecasting Transformers2

TODO: 2024-CMU-MOMENT

MOMENT: A Family of Open Time-series Foundation Models3

TODO: 2024-Amazon-Chronos

Chronos: Learning the Language of Time Series4

2024-Google-TimesFM

A decoder-only foundation model for time-series forecasting5是Google发在ICML 2024 的一篇关于时序预测基础模型的文章。 模型在GitHub开源: google-research/timesfm

论文要解决的问题和TimeGPT是基本一致的(1), 主要也是zero-shot时间序列的预测问题。 这篇文章给出的信息还是非常充分的,尤其是在数据预处理和模型架构上做的微小调整。

  1. 论文中也提到了: "To the best of our knowledge, the very recent work in TimeGPT-1is the only other parallel work on a zero-shot foundation model for time-series forecasting. However the model is not public access, and several model details and the benchmark dataset have not been revealed."

在数据预处理部分,TimesFM是围绕patch展开的。这里的patch,其实就是一段时序数据。 patch的思想很简单,也是经过之前很多工作验证过的,这使得用patch来对标NLP里面的Token显得更加合理(1)。 另外介绍了关于patch的masking和窗口的处理,这些都是为了提高模型的泛化能力,也是比较有意思的部分。

  1. 这里的patch和NLP里面的Token是很相似的,只不过这里patch是时序数据的一段,而Token是文本的一段。 另外,时间序列任务上拿单个时间点作为输入,就类似NLP中用character做输入,会损失很多信息。 所以这里用patch来对应token是很自然且合理的。

在模型架构方面,TimesFM是一个decoder-only的模型,这个和TimeGPT是一样的。模型的架构也是比较类似,如下:

总的来说,TimesFM的工作是提供了一个时序预训练模型的基础,且其表现至少在benchmark上是很好的, 是可以考虑在生产环境做进一步尝试的。


  1. A. Garza and M. Mergenthaler-Canseco, “TimeGPT-1,” arXiv preprint arXiv:2310.03589, 2023. 

  2. G. Woo, C. Liu, A. Kumar, C. Xiong, S. Savarese, and D. Sahoo, “Unified training of universal time series forecasting transformers,” arXiv preprint arXiv:2402.02592, 2024. 

  3. M. Goswami, K. Szafer, A. Choudhry, Y. Cai, S. Li, and A. Dubrawski, “MOMENT: A family of open time-series foundation models,” arXiv preprint arXiv:2402.03885, 2024. 

  4. A. F. Ansari et al., “Chronos: Learning the language of time series,” arXiv preprint arXiv:2403.07815, 2024. 

  5. A. Das, W. Kong, R. Sen, and Y. Zhou, “A decoder-only foundation model for time-series forecasting,” arXiv preprint arXiv:2310.10688, 2023.