论文&实验 Large Language Models AreZero-Shot Time Series Forecasters

一、概览

主要内容:

提出了一种模型LLMTime, 使用llm进行时间序列预测

将时间序列编码为一串数字,可以将时间序列预测转换为文本的下一个token预测

优点:

1.时序预测

2.LLMTIME can be used without any fine-tuning on the downstream data used by other models.(zero-shot 通过上下文学习:Large language models, for example GPT-3 or LLaMA-2, accomplish this form of generalization through in-context learning, which identifies patterns in the language model’s prompt and extrapolates them through next-token prediction.)

困难:

1.如何将时间序列tokenizing, 并将discrete distibutions over tokens转化为highly flexible densities over continuous values(在连续值上的高度灵活密度)

2.时间序列预测的常见应用,如天气或金融数据,需要从仅包含少量可能信息的观测中进行推断,这使得精确的点预测几乎不可能,因此uncertainty estimation(不确定性评估)尤为重要。

3.llm如何zero-shot 推断时间序列,这是不是与时间序列的周期性有关

4.面对时间序列的缺失值该如何处理

By encoding time series as a string of numerical digits, we can frame time series
forecasting as next-token prediction in text. Developing this approach, we find that
large language models (LLMs) such as GPT-3 and LLaMA-2 can surprisingly zero-
shot extrapolate time series at a level comparable to or exceeding the performance
of purpose-built time series models trained on the downstream tasks. To facilitate
this performance, we propose procedures for effectively tokenizing time series data
and converting discrete distributions over tokens into highly flexible densities over
continuous values. We argue the success of LLMs for time series stems from their
ability to naturally represent multimodal distributions, in conjunction with biases
for simplicity, and repetition, which align with the salient features in many time
series, such as repeated seasonal trends. We also show how LLMs can naturally
handle missing data without imputation through non-numerical text, accommodate
textual side information, and answer questions to help explain predictions. While
we find that increasing model size generally improves performance on time series,
we show GPT-4 can perform worse than GPT-3 because of how it tokenizes
numbers, and poor uncertainty calibration, which is likely the result of alignment
interventions such as RLHF.

二、模型

tokenization:

回答困难1.1

将数分为单个数字

Every language model has an associated tokenizer, which breaks an input string into a sequence of tokens, each belonging to V(词汇表)

Time series data typically takes the exact same form as language modeling data, as a collection of sequences {Ui = (u1, . . . , uj, . . . , uni )}, but in time series uj is numerical.

In time series, we design LLaMA tokenizer to map numbers to individual digits

To remedy the tokenization of GPT models, we separate the digits with spaces to force a separate tokenization of each digit and use a comma (" ,") to separate each time step in a time series. Because decimal points are redundant given a fixed precision, we drop them in the encoding to save on context length. Thus, with e.g. 2
digits of precision, we pre-process a time series as follows before feeding into the tokenizer:
               0.123, 1.23, 12.3, 123.0 → " 1 2 , 1 2 3 , 1 2 3 0 , 1 2 3 0 0".

Continuous likelihoods

回答困难1.2

通过将每个数字视为一个具有 B 个可能类别的分类问题,可以将模型的输出概率分布视为一种层次 softmax 分布,其中每个数字的概率分布是由前面的数字决定的。为了将离散的概率分布转化为连续的概率密度分布,可以将输出的每个数字分配到一个离散的 bin 中,然后在每个 bin 上放置一个均匀分布,最终得到一个混合的、连续的概率密度分布。

由于这种方法可以处理任意多个数字位数,因此可以非常灵活地表示高分辨率的连续概率分布。通过这种方式,即使使用离散的数字表示,也可以实现高效、精确和灵活的连续概率密度建模。

三、数据集

Darts

Monash

Informer

结果

模型的不确定性是指模型无法确定预测结果的确切值,给的是概率分布

确定性结果

使用20个样本的逐点中位数来计算MAE

用于衡量模型预测结果与真实观测值之间的平均绝对差异。

MAE 是确定性结果的原因在于其计算方式。MAE 是将预测值与真实观测值的差值取绝对值后求平均得到的指标。这意味着它不考虑差值的方向,只关注差值的大小。因此,对于同样的差值,无论其正负,MAE 的结果都是相同的。

概率结果

回答困难2

使用NLL/D

负对数似然度量了模型生成观测数据的不确定性程度。对于给定的观测数据,概率模型会根据其参数估计出一个概率分布。负对数似然值越小,表示该观测数据在模型下的概率越高,也就是模型的预测结果越准确。

将负对数似然除以维度数目可以得到每个维度的平均负对数似然。这个指标可以用于比较不同模型之间的性能,因为它对数据集的维度进行了归一化。较低的平均负对数似然值表示模型在每个维度上的预测更准确。

四、Origins of Zero-Shot Performance

可以实现零值预测的原因在于(回答困难3):

1.llm更倾向于简单规则LLMs can forecast effectively because they prefer completions derived from simple rules 

2.LLMs对重复序列的偏好使它们能够识别和推断输入中的周期结构。类似地,它们执行加法和乘法的能力使它们能够推断数据中的线性和指数趋势。

五、Special Properties of LLMs

chat models

llama2-7b-chatcodellama-7bdarts数据集和monash数据集上复现结果,darts中的AusBeerDataset数据集为例

结果分析:由结果可以看出llama2-7b-chatcodellama-7b的预测性能都比较差。模型升级反而会使预测降级,文章中也给出了这方面的原因:

1.使用了RLHF使模型过度拟合人类提供的反馈信息,降低了对模型数据真实分布的理解能力

2.标记化改变,难以处理连续的标记流

Missing data 

回答问题4

不采用线性插值等手段,而是直接用NaN来填到缺失位,更符合人类阅读习惯

 

六、实验部分

实验结构:

实验的目录结构如下:

 

其中model部分是各种模型,包括llama gpt gp模型等。

data部分是各种数据集中的数据,包括darts monash数据集等。

experiments部分是实验运行代码,里面有run_darts(在darts数据集上运行各种模型 ),run_monash等运行文件。

conda环境:

我在配置环境的时候踩了很大的坑,torch版本(1.12.1+cu113)/transformer版本(4.31.0)都要注意:

代码讲解:

下面以run_darts为例讲一下:

https://1drv.ms/o/c/3e2a3cf1b27117c3/EtFEZMKXzN1Ntnvkb0tjWocBtEa9stpgc9zKZZnod_vMHA

  • 22
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值