🚀 ChatTime:多模態時間序列基礎模型
ChatTime是一個多模態時間序列基礎模型,創新性地將時間序列建模為外語,構建了統一的時間序列和文本處理框架。它具備零樣本預測能力,支持時間序列和文本的雙模態輸入/輸出。
🚀 快速開始
若想了解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")
📚 詳細文檔
在連續預訓練階段,如圖1(b)所示,我們在 ChengsenWang/ChatTime-1-Pretrain-1M 上對 LLaMA-2-7B-Base 進行預訓練,得到 ChengsenWang/ChatTime-1-7B-Base。

📝 引用
如果您認為這個倉庫或我們的工作對您的研究有幫助,請考慮引用以下論文:
@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。