license: apache-2.0
datasets:
- ChengsenWang/ChatTime-1-Pretrain-1M
base_model:
- meta-llama/Llama-2-7b
tags:
- 时间序列
- 预训练模型
- 基础模型
- 多模态
- 多模态时间序列基础模型
pipeline_tag: 时间序列预测
ChatTime:多模态时间序列基础模型
✨ 简介
本文创新性地将时间序列建模为外语,构建了统一处理时间序列与文本的ChatTime框架。作为开箱即用的多模态时间序列基础模型,ChatTime具备零样本预测能力,支持时间序列与文本的双模态输入/输出。我们设计系列实验验证ChatTime在多重任务场景下的优越性能,并创建四个多模态数据集填补数据空白。实验结果证明了ChatTime的潜力与实用性。
如图1(b)所示,在持续预训练阶段,我们在ChengsenWang/ChatTime-1-Pretrain-1M数据集上对LLaMA-2-7B-Base进行预训练,得到ChengsenWang/ChatTime-1-7B-Base模型。
关于ChatTime模型架构、训练数据与流程、实验结果的详细信息,请参阅arXiv论文。

📈 使用指南
我们提供三个最小化示例,展示如何使用ChatTime模型进行多模态时间序列分析。完整代码详见Github仓库。
零样本时间序列预测
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from model.model import ChatTime
dataset = "Traffic"
hist_len = 120
pred_len = 24
model_path = "ChengsenWang/ChatTime-1-7B-Chat"
df = pd.read_csv(f"./dataset/{dataset}.csv")
hist_data = np.array(df["Hist"].apply(eval).values.tolist())[:, -hist_len:][0]
pred_data = np.array(df["Pred"].apply(eval).values.tolist())[:, :pred_len][0]
model = ChatTime(hist_len=hist_len, pred_len=pred_len, model_path=model_path)
out = model.predict(hist_data)
hist_x = np.linspace(0, hist_len-1, hist_len)
pred_x = np.linspace(hist_len, hist_len+pred_len-1, pred_len)
plt.figure(figsize=(8, 2), dpi=500)
plt.plot(hist_x, hist_data, color='#000000')
plt.plot(pred_x, pred_data, color='#000000', label='真实值')
plt.plot(pred_x, out, color='#FF7F0E', label='预测值')
plt.axvline(hist_len, color='red')
plt.legend(loc="upper left")
plt.show()
上下文引导的时间序列预测
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from model.model import ChatTime
dataset = "PTF"
hist_len = 120
pred_len = 24
model_path = "ChengsenWang/ChatTime-1-7B-Chat"
df = pd.read_csv(f"./dataset/{dataset}.csv")
hist_data = np.array(df["Hist"].apply(eval).values.tolist())[:, -hist_len:][0]
pred_data = np.array(df["Pred"].apply(eval).values.tolist())[:, :pred_len][0]
context = df["Text"].values[0]
model = ChatTime(hist_len=hist_len, pred_len=pred_len, model_path=model_path)
out_text = model.predict(hist_data, context)
out = model.predict(hist_data)
hist_x = np.linspace(0, hist_len-1, hist_len)
pred_x = np.linspace(hist_len, hist_len+pred_len-1, pred_len)
plt.figure(figsize=(8, 2), dpi=500)
plt.plot(hist_x, hist_data, color='#000000')
plt.plot(pred_x, pred_data, color='#000000', label='真实值')
plt.plot(pred_x, out_text, color='#FF7F0E', label='文本引导预测')
plt.plot(pred_x, out, color='#1F77B4', label='常规预测')
plt.axvline(hist_len, color='red')
plt.legend(loc="upper left")
plt.show()
时间序列问答
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from model.model import ChatTime
dataset = "TSQA"
model_path = "ChengsenWang/ChatTime-1-7B-Chat"
df = pd.read_csv(f"./dataset/{dataset}.csv")
series = np.array(df["Series"].apply(eval).values.tolist())[0]
question = df["Question"].values[0]
answer = df["Answer"].values[0]
model = ChatTime(model_path=model_path)
out = model.analyze(question, series)
plt.figure(figsize=(8, 2), dpi=500)
plt.plot(series, color='#000000')
plt.show()
print(question)
print(f"\n模型输出: {out} / 参考答案: {answer}\n")
📝 引用
如果本仓库或我们的研究对您的工作有所帮助,请考虑引用论文:
@inproceedings{
author = {王成森 and 齐琪 and 王静宇 and 孙海峰 and 庄梓铨 and 吴金明 and 张雷 and 廖建新},
title = {ChatTime:连接数值与文本数据的统一多模态时间序列基础模型},
booktitle = {人工智能国际会议(AAAI)},
year = {2025},
}
📪 联系方式
如有疑问,请联系cswang@bupt.edu.cn。