🚀 ChatTime:多模态时间序列基础模型
ChatTime是一个创新的多模态时间序列基础模型,它将时间序列建模为一种外语,构建了统一的时间序列和文本处理框架。该模型具备零样本预测能力,支持时间序列和文本的双模态输入/输出,在多个任务和场景中展现出卓越性能。
🚀 快速开始
在指令微调阶段,我们在ChengsenWang/ChatTime-1-Finetune-100K上对ChengsenWang/ChatTime-1-7B-Base进行微调,得到了ChengsenWang/ChatTime-1-7B-Chat。
有关ChatTime模型、训练数据和过程以及实验结果的详细信息,请参考arXiv。

✨ 主要特性
- 创新建模:将时间序列创新性地建模为外语,构建统一处理框架。
- 零样本预测:具备零样本预测能力,无需大量训练数据即可进行预测。
- 双模态支持:支持时间序列和文本的双模态输入/输出,满足多样化需求。
- 卓越性能:在多个任务和场景中展现出卓越性能。
💻 使用示例
基础用法
零样本时间序列预测
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='true')
plt.plot(pred_x, out, color='#FF7F0E', label='pred')
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='true')
plt.plot(pred_x, out_text, color='#FF7F0E', label='pred_text')
plt.plot(pred_x, out, color='#1F77B4', label='pred')
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 = {Chengsen Wang and Qi Qi and Jingyu Wang and Haifeng Sun and Zirui Zhuang and Jinming Wu and Lei Zhang and Jianxin Liao},
title = {ChatTime: A Unified Multimodal Time Series Foundation Model Bridging Numerical and Textual Data},
booktitle = {AAAI Conference on Artificial Intelligence},
year = {2025},
}
📄 许可证
本项目采用Apache-2.0许可证。
📪 联系我们
如果你有任何问题,请联系 cswang@bupt.edu.cn。
📦 模型与数据信息
属性 |
详情 |
基础模型 |
ChengsenWang/ChatTime-1-7B-Base |
训练数据 |
ChengsenWang/ChatTime-1-Finetune-100K |
标签 |
时间序列、预训练模型、基础模型、多模态、多模态时间序列基础模型 |
任务类型 |
时间序列预测 |