ChengsenWang commited on
Commit
1c9c341
·
verified ·
1 Parent(s): 6de3723

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +150 -3
README.md CHANGED
@@ -1,3 +1,150 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - ChengsenWang/ChatTime-1-Finetune-100K
5
+ base_model:
6
+ - ChengsenWang/ChatTime-1-7B-Base
7
+ tags:
8
+ - time-series
9
+ - pretrained-model
10
+ - foundation-model
11
+ - multimodality
12
+ - multimodal-time-series-foundation-model
13
+ pipeline_tag: time-series-forecasting
14
+ ---
15
+
16
+ # ChatTime: A Multimodal Time Series Foundation Model
17
+
18
+ ## ✨ Introduction
19
+
20
+ In this paper, we innovatively model time series as a foreign language and construct ChatTime, a unified framework for time series and text processing. As an out-of-the-box multimodal time series foundation model, ChatTime provides zero-shot forecasting capability and supports bimodal input/output for both time series and text. We design a series of experiments to verify the superior performance of ChatTime across multiple tasks and scenarios, and create four multimodal datasets to address data gaps. The experimental results demonstrate the potential and utility of ChatTime.
21
+
22
+ As depicted in Figure 1(b), during the continuous pre-training stage, we pre-train [ChatTime-1-7B-Base](https://huggingface.co/ChengsenWang/ChatTime-1-7B-Base) on [ChatTime-1-Finetune-100K](https://huggingface.co/datasets/ChengsenWang/ChatTime-1-Finetune-100K), yielding [ChengsenWang/ChatTime-1-7B-Chat](https://huggingface.co/ChengsenWang/ChatTime-1-7B-Chat).
23
+
24
+ For details on ChatTime models, training data and procedures, and experimental results, please refer to the [arXiv](https://arxiv.org/abs/0000.00000).
25
+
26
+ ![](architecture.png)
27
+
28
+ ## 📈 Usage
29
+
30
+ We present three minimal examples showing how to perform the multimodal time series analysis using the ChatTime model. The detailed code is available in the [Github](https://github.com/ForestsKing/ChatTime).
31
+
32
+ ### Zero-Shot Time Series Forecasting
33
+
34
+ ```python
35
+
36
+ import numpy as np
37
+ import pandas as pd
38
+ import matplotlib.pyplot as plt
39
+ from model.model import ChatTime
40
+
41
+ dataset = "Traffic"
42
+ hist_len = 120
43
+ pred_len = 24
44
+ model_path = "ChengsenWang/ChatTime-1-7B-Chat"
45
+
46
+ df = pd.read_csv(f"./dataset/{dataset}.csv")
47
+ hist_data = np.array(df["Hist"].apply(eval).values.tolist())[:, -hist_len:][0]
48
+ pred_data = np.array(df["Pred"].apply(eval).values.tolist())[:, :pred_len][0]
49
+
50
+ model = ChatTime(hist_len=hist_len, pred_len=pred_len, model_path=model_path)
51
+
52
+ out = model.predict(hist_data)
53
+
54
+ hist_x = np.linspace(0, hist_len-1, hist_len)
55
+ pred_x = np.linspace(hist_len, hist_len+pred_len-1, pred_len)
56
+
57
+ plt.figure(figsize=(8, 2), dpi=500)
58
+ plt.plot(hist_x, hist_data, color='#000000')
59
+ plt.plot(pred_x, pred_data, color='#000000', label='true')
60
+ plt.plot(pred_x, out, color='#FF7F0E', label='pred')
61
+ plt.axvline(hist_len, color='red')
62
+ plt.legend(loc="upper left")
63
+ plt.show()
64
+
65
+ ```
66
+
67
+ ### Context-Guided Time Series Forecasting
68
+
69
+ ```python
70
+
71
+ import numpy as np
72
+ import pandas as pd
73
+ import matplotlib.pyplot as plt
74
+ from model.model import ChatTime
75
+
76
+ dataset = "PTF"
77
+ hist_len = 120
78
+ pred_len = 24
79
+ model_path = "ChengsenWang/ChatTime-1-7B-Chat"
80
+
81
+ df = pd.read_csv(f"./dataset/{dataset}.csv")
82
+ hist_data = np.array(df["Hist"].apply(eval).values.tolist())[:, -hist_len:][0]
83
+ pred_data = np.array(df["Pred"].apply(eval).values.tolist())[:, :pred_len][0]
84
+ context = df["Text"].values[0]
85
+
86
+ model = ChatTime(hist_len=hist_len, pred_len=pred_len, model_path=model_path)
87
+
88
+ out_text = model.predict(hist_data, context)
89
+ out = model.predict(hist_data)
90
+
91
+ hist_x = np.linspace(0, hist_len-1, hist_len)
92
+ pred_x = np.linspace(hist_len, hist_len+pred_len-1, pred_len)
93
+
94
+ plt.figure(figsize=(8, 2), dpi=500)
95
+ plt.plot(hist_x, hist_data, color='#000000')
96
+ plt.plot(pred_x, pred_data, color='#000000', label='true')
97
+ plt.plot(pred_x, out_text, color='#FF7F0E', label='pred_text')
98
+ plt.plot(pred_x, out, color='#1F77B4', label='pred')
99
+ plt.axvline(hist_len, color='red')
100
+ plt.legend(loc="upper left")
101
+ plt.show()
102
+
103
+ ```
104
+
105
+ ### Time Series Question Answering
106
+
107
+ ```python
108
+
109
+ import numpy as np
110
+ import pandas as pd
111
+ import matplotlib.pyplot as plt
112
+ from model.model import ChatTime
113
+
114
+ dataset = "TSQA"
115
+ model_path = "ChengsenWang/ChatTime-1-7B-Chat"
116
+
117
+ df = pd.read_csv(f"./dataset/{dataset}.csv")
118
+ series = np.array(df["Series"].apply(eval).values.tolist())[0]
119
+ question = df["Question"].values[0]
120
+ answer = df["Answer"].values[0]
121
+
122
+ model = ChatTime(model_path=model_path)
123
+
124
+ out = model.analyze(question, series)
125
+
126
+ plt.figure(figsize=(8, 2), dpi=500)
127
+ plt.plot(series, color='#000000')
128
+ plt.show()
129
+
130
+ print(question)
131
+ print(f"\n{out} / {answer}\n")
132
+
133
+ ```
134
+
135
+ ## 📝 Citation
136
+
137
+ If you find this repo or our work useful for your research, please consider citing the paper:
138
+
139
+ ```tex
140
+ @inproceedings{
141
+ author = {Chengsen Wang and Qi Qi and Jingyu Wang and Haifeng Sun and Zirui Zhuang and Jinming Wu and Lei Zhang and Jianxin Liao},
142
+ title = {ChatTime: A Unified Multimodal Time Series Foundation Model Bridging Numerical and Textual Data},
143
+ booktitle = {},
144
+ year = {2024},
145
+ }
146
+ ```
147
+
148
+ ## 📪 Contact
149
+
150
+ If you have any question, please contact [[email protected]]().