🚀 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 |
標籤 |
時間序列、預訓練模型、基礎模型、多模態、多模態時間序列基礎模型 |
任務類型 |
時間序列預測 |