a12354 commited on
Commit
8d2b389
·
verified ·
1 Parent(s): 8bf4a7e

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. README.md +150 -0
  2. dataset/PTF.csv +2 -0
  3. dataset/TSQA.csv +10 -0
  4. dataset/Traffic.csv +2 -0
  5. demo.ipynb +0 -0
  6. model/__init__.py +0 -0
  7. model/model.py +124 -0
  8. rats40k_adapter/logs/pipeline_20260608_175250_sft.log +0 -0
  9. rats40k_adapter/logs/pipeline_20260608_175250_zeroshot.log +27 -0
  10. rats40k_adapter/logs/sft_4gpu_20260608_172354.log +148 -0
  11. rats40k_adapter/logs/sft_4gpu_20260608_173130.log +138 -0
  12. rats40k_adapter/logs/sft_4gpu_20260608_174152.log +48 -0
  13. rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-800/README.md +202 -0
  14. rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-800/adapter_config.json +37 -0
  15. rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-800/added_tokens.json +0 -0
  16. rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-800/special_tokens_map.json +30 -0
  17. rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-800/tokenizer.json +0 -0
  18. rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-800/tokenizer_config.json +0 -0
  19. rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-800/trainer_state.json +594 -0
  20. rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-946/README.md +202 -0
  21. rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-946/adapter_config.json +37 -0
  22. rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-946/tokenizer.json +0 -0
  23. requirements.md +201 -0
  24. requirements.txt +8 -0
  25. tsqa_adapter/README.md +73 -0
  26. tsqa_adapter/eval_tsqa.py +228 -0
  27. tsqa_adapter/finetune_tsqa_lora.py +351 -0
  28. tsqa_adapter/outputs/sft_20260615_141604/adapter/README.md +202 -0
  29. tsqa_adapter/outputs/sft_20260615_141604/adapter/adapter_config.json +37 -0
  30. tsqa_adapter/outputs/sft_20260615_141604/adapter/added_tokens.json +0 -0
  31. tsqa_adapter/outputs/sft_20260615_141604/adapter/checkpoint-250/README.md +202 -0
  32. tsqa_adapter/outputs/sft_20260615_141604/adapter/checkpoint-250/adapter_config.json +37 -0
  33. tsqa_adapter/outputs/sft_20260615_141604/adapter/checkpoint-250/added_tokens.json +0 -0
  34. tsqa_adapter/outputs/sft_20260615_141604/adapter/checkpoint-250/special_tokens_map.json +30 -0
  35. tsqa_adapter/outputs/sft_20260615_141604/adapter/checkpoint-250/tokenizer_config.json +0 -0
  36. tsqa_adapter/outputs/sft_20260615_141604/adapter/checkpoint-250/trainer_state.json +209 -0
  37. tsqa_adapter/outputs/sft_20260615_141604/adapter/special_tokens_map.json +30 -0
  38. tsqa_adapter/outputs/sft_20260615_141604/adapter/tokenizer.json +0 -0
  39. tsqa_adapter/outputs/sft_20260615_141604/adapter/tokenizer_config.json +0 -0
  40. tsqa_adapter/outputs/sft_20260615_141604/eval/metrics.json +118 -0
  41. tsqa_adapter/outputs/sft_20260615_141604/eval/predictions.jsonl +0 -0
  42. tsqa_adapter/outputs/sft_20260615_141604/eval/shards/predictions.rank0.jsonl +0 -0
  43. tsqa_adapter/outputs/sft_20260615_141604/eval/shards/predictions.rank1.jsonl +0 -0
  44. tsqa_adapter/outputs/sft_20260615_141604/eval/shards/predictions.rank2.jsonl +0 -0
  45. tsqa_adapter/outputs/sft_20260615_141604/eval/shards/predictions.rank3.jsonl +0 -0
  46. tsqa_adapter/run_sft_4gpu.sh +163 -0
  47. tsqa_adapter/tsqa_common.py +197 -0
  48. utils/__init__.py +0 -0
  49. utils/prompt.py +57 -0
  50. utils/tools.py +64 -0
README.md ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center">
2
+
3
+ # ChatTime: A Multimodal Time Series Foundation Model
4
+
5
+ <a href='https://ojs.aaai.org/index.php/AAAI/article/view/33384'><img src='https://img.shields.io/badge/Paper-PDF-orange'></a>
6
+ [![huggingface](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Datasets-FFD21E)](https://huggingface.co/collections/ChengsenWang/chattime-datasets-6731b504efecc8a6e439741c)
7
+ [![huggingface](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Models-FFD21E)](https://huggingface.co/collections/ChengsenWang/chattime-models-6731b650cb98bc7842713fde)
8
+
9
+ </div>
10
+
11
+ ## ✨ Introduction
12
+
13
+ Human experts typically integrate numerical and textual multimodal information to analyze time series. However, most traditional deep learning predictors rely solely on unimodal numerical data, using a fixed-length window for training and prediction on a single dataset, and cannot adapt to different scenarios. The powered pre-trained large language model has introduced new opportunities for time series analysis. Yet, existing methods are either inefficient in training, incapable of handling textual information, or lack zero-shot forecasting capability. 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. Specifically, in the unimodal zero-shot forecasting task, ChatTime achieves 99.9% of the previous state-of-the-art using only 4% of the pre-training data. In the multimodal tasks of context-guided forecasting and time series question answering, ChatTime outperforms the previous state-of-the-art by 3.7% and 36.6%, respectively.
14
+
15
+ ![](./img/architecture.png)
16
+
17
+ ## 📈 Usage
18
+
19
+ We present three minimal examples showing how to perform the multimodal time series analysis using the ChatTime model. The code and corresponding results are available in the [notebook](./demo.ipynb).
20
+
21
+ ### Zero-Shot Time Series Forecasting
22
+
23
+ ```python
24
+
25
+ import numpy as np
26
+ import pandas as pd
27
+ import matplotlib.pyplot as plt
28
+ from model.model import ChatTime
29
+
30
+ dataset = "Traffic"
31
+ hist_len = 120
32
+ pred_len = 24
33
+ model_path = "ChengsenWang/ChatTime-1-7B-Chat"
34
+
35
+ df = pd.read_csv(f"./dataset/{dataset}.csv")
36
+ hist_data = np.array(df["Hist"].apply(eval).values.tolist())[:, -hist_len:][0]
37
+ pred_data = np.array(df["Pred"].apply(eval).values.tolist())[:, :pred_len][0]
38
+
39
+ model = ChatTime(hist_len=hist_len, pred_len=pred_len, model_path=model_path)
40
+
41
+ out = model.predict(hist_data)
42
+
43
+ hist_x = np.linspace(0, hist_len-1, hist_len)
44
+ pred_x = np.linspace(hist_len, hist_len+pred_len-1, pred_len)
45
+
46
+ plt.figure(figsize=(8, 2), dpi=500)
47
+ plt.plot(hist_x, hist_data, color='#000000')
48
+ plt.plot(pred_x, pred_data, color='#000000', label='true')
49
+ plt.plot(pred_x, out, color='#FF7F0E', label='pred')
50
+ plt.axvline(hist_len, color='red')
51
+ plt.legend(loc="upper left")
52
+ plt.show()
53
+
54
+ ```
55
+
56
+ ### Context-Guided Time Series Forecasting
57
+
58
+ ```python
59
+
60
+ import numpy as np
61
+ import pandas as pd
62
+ import matplotlib.pyplot as plt
63
+ from model.model import ChatTime
64
+
65
+ dataset = "PTF"
66
+ hist_len = 120
67
+ pred_len = 24
68
+ model_path = "ChengsenWang/ChatTime-1-7B-Chat"
69
+
70
+ df = pd.read_csv(f"./dataset/{dataset}.csv")
71
+ hist_data = np.array(df["Hist"].apply(eval).values.tolist())[:, -hist_len:][0]
72
+ pred_data = np.array(df["Pred"].apply(eval).values.tolist())[:, :pred_len][0]
73
+ context = df["Text"].values[0]
74
+
75
+ model = ChatTime(hist_len=hist_len, pred_len=pred_len, model_path=model_path)
76
+
77
+ out_text = model.predict(hist_data, context)
78
+ out = model.predict(hist_data)
79
+
80
+ hist_x = np.linspace(0, hist_len-1, hist_len)
81
+ pred_x = np.linspace(hist_len, hist_len+pred_len-1, pred_len)
82
+
83
+ plt.figure(figsize=(8, 2), dpi=500)
84
+ plt.plot(hist_x, hist_data, color='#000000')
85
+ plt.plot(pred_x, pred_data, color='#000000', label='true')
86
+ plt.plot(pred_x, out_text, color='#FF7F0E', label='pred_text')
87
+ plt.plot(pred_x, out, color='#1F77B4', label='pred')
88
+ plt.axvline(hist_len, color='red')
89
+ plt.legend(loc="upper left")
90
+ plt.show()
91
+
92
+ ```
93
+
94
+ ### Time Series Question Answering
95
+
96
+ ```python
97
+
98
+ import numpy as np
99
+ import pandas as pd
100
+ import matplotlib.pyplot as plt
101
+ from model.model import ChatTime
102
+
103
+ dataset = "TSQA"
104
+ model_path = "ChengsenWang/ChatTime-1-7B-Chat"
105
+
106
+ df = pd.read_csv(f"./dataset/{dataset}.csv")
107
+ series = np.array(df["Series"].apply(eval).values.tolist())[0]
108
+ question = df["Question"].values[0]
109
+ answer = df["Answer"].values[0]
110
+
111
+ model = ChatTime(model_path=model_path)
112
+
113
+ out = model.analyze(question, series)
114
+
115
+ plt.figure(figsize=(8, 2), dpi=500)
116
+ plt.plot(series, color='#000000')
117
+ plt.show()
118
+
119
+ print(question)
120
+ print(f"\n{out} / {answer}\n")
121
+
122
+ ```
123
+
124
+ ### Continuous Pre-Training and Instruction Fine-Tuning
125
+
126
+ The code for Continuous Pre-Training and Instruction Fine-Tuning for ChatTime is located within the [training](./training/) folder, while the model weights are available at [ChengsenWang/ChatTime-1-7B-Base](https://huggingface.co/ChengsenWang/ChatTime-1-7B-Base) and [ChengsenWang/ChatTime-1-7B-Chat](https://huggingface.co/ChengsenWang/ChatTime-1-7B-Chat), respectively.
127
+
128
+ ## :floppy_disk: Datasets
129
+
130
+ Refer to following repositories for instructions on downloading and utilizing the datasets.
131
+
132
+ - The datasets used in the ChatTime paper for Continuous Pre-Training and Instruction Fine-Tuning are available in the HuggingFace repositories: [ChengsenWang/ChatTime-1-Pretrain-1M](https://huggingface.co/datasets/ChengsenWang/ChatTime-1-Pretrain-1M) and [ChengsenWang/ChatTime-1-Finetune-100K](https://huggingface.co/datasets/ChengsenWang/ChatTime-1-Finetune-100K).
133
+ - Unimodal zero-shot forecasting datasets can be accessed via the previous [Google Drive](https://drive.google.com/drive/folders/1S7u4exc5NkKRWfdgqYBZ-VqSz9XfrEDV?usp=sharing), while multimodal datasets for context-guided forecasting and time series question-answering tasks are available on HuggingFace at [ChengsenWang/CGTSF](https://huggingface.co/datasets/ChengsenWang/CGTSF) and [ChengsenWang/TSQA](https://huggingface.co/datasets/ChengsenWang/TSQA).
134
+
135
+ ## 📝 Citation
136
+
137
+ If you find this repo or our work useful for your research, please consider citing the [paper](https://arxiv.org/abs/2412.11376):
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 = {AAAI Conference on Artificial Intelligence},
144
+ year = {2025},
145
+ }
146
+ ```
147
+
148
+ ## 📪 Contact
149
+
150
+ If you have any question, please contact [cswang@bupt.edu.cn]().
dataset/PTF.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ Idx,Date,Hist,Pred,Text
2
+ 1,2022/1/10,"[91.0, 93.0, 70.0, 54.0, 25.0, 26.0, 54.0, 88.0, 181.0, 324.0, 324.0, 307.0, 273.0, 264.0, 262.0, 295.0, 301.0, 226.0, 250.0, 215.0, 252.0, 153.0, 139.0, 158.0, 120.0, 94.0, 72.0, 48.0, 37.0, 31.0, 56.0, 92.0, 229.0, 341.0, 331.421686746988, 278.0, 257.0, 256.0, 269.0, 232.0, 291.0, 290.0, 266.0, 234.0, 273.0, 167.0, 131.0, 141.0, 128.0, 120.0, 103.0, 65.0, 38.0, 36.0, 62.0, 104.0, 205.0, 352.0, 300.0, 318.0, 285.0, 290.0, 311.0, 294.0, 280.0, 289.0, 232.0, 254.0, 243.0, 213.0, 151.0, 155.0, 128.0, 147.0, 148.0, 150.0, 118.0, 85.0, 75.0, 57.0, 103.0, 96.0, 150.0, 205.0, 269.0, 226.0, 224.0, 297.0, 260.0, 286.0, 240.0, 244.0, 256.0, 208.0, 153.0, 134.0, 138.0, 145.0, 153.0, 164.0, 87.0, 99.0, 67.0, 43.0, 56.0, 75.0, 102.0, 155.0, 208.0, 219.0, 217.0, 221.0, 231.0, 232.0, 213.0, 212.0, 196.0, 148.0, 118.0, 100.0]","[98.0, 68.0, 66.0, 43.0, 31.0, 30.0, 44.0, 96.0, 228.0, 351.0, 334.0, 253.0, 268.0, 254.0, 271.0, 267.0, 260.0, 211.0, 246.0, 228.0, 209.0, 159.0, 154.0, 108.0]","This sequence records traffic flow at a highway in Paris, France, with a collection granularity of 1 hour. The target date for prediction is Monday, January 10, 2022. It is a weekday with overcast and light breeze. The minimum temperature is 1 degrees, and the maximum temperature is 4 degrees. The sun will rise at 9:41 and set at 18:14."
dataset/TSQA.csv ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ Task,Size,Question,Answer,Label,Series
2
+ Outliers,512,"Given the following definitions:
3
+ Outlier: The data point that significantly differs from other observations in a time series.
4
+ Sudden spike: The rapid and significant increase in the value of a variable over a short period, followed by a return to the original baseline.
5
+ Level shift: The significant and sustained change in the average level of a time series.
6
+ Select one of the following answers that best describes the provided time series:
7
+ (a) This time series has no obvious outlier.
8
+ (b) This time series has a sudden spike.
9
+ (c) This time series has a level shift.
10
+ Only answer (a), (b), or (c).",(c),level shift,"[0.7184792798575108, 0.5890992628753317, 0.720379226692959, 0.7371817534266486, 0.8218986846647067, 0.8831912599405045, 0.924568275381516, 1.105450126561668, 1.104915171493406, 1.105075077212364, 1.172752127438253, 1.1017339697399184, 1.1885389876081582, 1.0229032988686375, 1.0173509225272503, 0.9778380959636221, 0.9905061842429381, 0.9192487309319277, 0.955159815166365, 0.9386546300931191, 1.0365586552042338, 0.9848060010135675, 0.9031910437874903, 0.9490722460363644, 0.7736690375506368, 0.7973083717713468, 0.6195164348946642, 0.4505078990428173, 0.5258964311649057, 0.41695857834045796, 0.40094083046178974, 0.4074777885743717, 0.4898508983261235, 0.5204220132901043, 0.6147843655529912, 0.7104068479820054, 0.6888432643084303, 0.7093100484404489, 0.9203034882926628, 0.9595492099364219, 1.0524983080812496, 1.0540235235303996, 1.0545795711233983, 1.0504204593712156, 1.0150624010493834, 0.9674438806947031, 0.9480584014886574, 0.8387509457584394, 0.756715885697077, 0.6876310725765916, 0.6741053133041839, 0.5765459677947272, 0.8150541280061177, 0.8010140835380615, 0.8017261681809998, 0.8522744537466967, 0.997448921515707, 1.0254380922548936, 1.0854623631951241, 1.1810641178273915, 1.1917727690594564, 1.156212392946056, 1.0032228674436472, 1.0097138291132903, 0.9644046450619518, 0.9786099232959252, 0.9015820258468665, 0.9600845692636649, 0.9254786568752694, 1.0275123161011555, 1.0439750545550874, 0.9781885938000409, 0.9794484252067047, 0.8996776075842985, 0.8288172338731659, 0.7377456987757804, 0.6666415913497841, 0.4954252371332561, 0.3871874702376371, 0.39201341491430786, 0.4691953202649433, 0.32902849388076194, 0.5139388807727633, 0.6274850412452753, 0.5259500940219756, 0.6234727127754345, 0.7352204681274915, 0.8887733771487537, 0.8788745652679044, 0.8321993334089987, 0.9906538408377465, 1.0884153923116429, 1.0419565131523847, 1.0989571442112747, 1.0968068649354548, 0.9917228083304463, 0.9140857106015, 0.8268703694816582, 0.7841652686982843, 0.6563931372557668, 0.704137218562753, 0.6463851364825651, 0.7506367510170829, 0.7554979826318322, 0.9260291687003874, 0.9089546087562222, 0.9693357182731545, 1.1030492035662054, 1.2037368783717812, 1.1546801365968427, 1.1832562640065416, 1.2227138316112929, 1.0586537993195908, 1.1019346318306265, 1.0957716907972106, 1.0435114304268116, 0.9432916345837352, 0.9631075724933503, 0.9909790612209175, 0.902075105613618, 1.038934325071035, 0.9956296391923886, 0.9671387170483486, 0.9262196734645687, 0.960294897621253, 0.7043583357537013, 0.5390751263748786, 0.5065810639874693, 0.42986439305645174, 0.45645353834092917, 0.4199892080755012, 0.44424909650077626, 0.4999027503106028, 0.5419331322097575, 0.5928239178075897, 0.7700799966350905, 0.7657828913531622, 0.8342811572897805, 0.8853906370913285, 0.920301247256349, 1.0980213455034573, 1.026281140574831, 1.0574832942885364, 1.0565905379973175, 1.0225231206444396, 0.9959311509374223, 0.831378237673205, 0.8535538463246993, 0.6864405593142846, 0.6795595826003835, 0.6267738101529042, 0.6322335718113458, 0.7141720760554285, 0.7070980364621493, 0.9013901134388234, 0.9182868748935803, 0.9901188442633743, 1.0602930122437244, 1.1437313511943954, 1.2521610849514286, 1.1573637604198495, 1.1488324866917643, 1.001628768089996, 0.9539103891985391, 1.0421937873720968, 0.9169351532898107, 0.9181443865083075, 0.9870397344023188, 0.9743500980619964, 0.9278090932905554, 0.9869314160638195, 1.0825826963691016, 0.9183086209574945, 0.865278855396822, 0.9217381982644645, 0.7578601168462166, 0.6473126784348423, 0.49641592532600703, 0.4970296783009491, 0.488547021540167, 0.433373127695315, 0.47983095468527404, 0.5537629501662963, 0.5759671849077381, 0.6090143186894204, 0.6387543942622422, 0.7652722032542528, 0.77676853522667, 0.8821526879120217, 1.044484519382665, 1.109259890307919, 1.0820707143438995, 1.0370613573514775, 1.0957628304825053, 1.0580424077326653, 1.0143376747856974, 0.8715637233344328, 0.8556943613327225, 0.6927027258079334, 0.6766893669789288, 0.6184844783413905, 0.7306990192316035, 0.6672370783283702, 0.7944649559832869, 0.8326901828736859, 0.9656049723383584, 1.056679107562601, 1.0943165393078627, 1.189886820998889, 1.1271927149892658, 1.1977011068367385, 1.155952373861953, 1.146964840734465, 1.0975866934126028, 0.9554315747980717, 1.011860502416628, 0.9022676830321746, 0.9262251486399553, 0.9745082808375313, 1.038931255746843, 0.9345750120587087, 0.8758563063048941, 0.9220831095921272, 0.842203342897673, 0.8026814852580891, 0.7262943394431286, 0.6914774930999312, 0.6369795018288573, 0.4672892885082276, 0.44424805787729965, 0.46526279273593074, 0.500063884334687, 0.5849212005758848, 0.5546111154221287, 0.6168837755228581, 0.657730971092552, 0.7936078881771494, 0.9071219549558203, 0.8848795364518045, 0.9504371476718672, 0.9855640423604446, 1.0823133640844074, 1.1432619064607117, 1.1330658313270692, 1.0361077987982434, 1.0065302028833885, 0.8992705087877719, 0.8473733436759884, 0.7801492907831172, 0.7784846618295218, 0.7820701339727955, 0.7214826681707797, 0.6764354492853714, 0.7458898813294413, 0.8580283210552919, 1.0190915082844239, 1.1499430819819825, 1.0546364390285556, 1.1545070867266525, 1.1532497822886496, 1.1305042496753939, 1.1374751941014465, 1.1451052573144964, 1.0984450376615762, 1.0007209086705193, 1.0750979382290524, 0.9965740706335955, 0.954945626857081, 0.9927980457832121, 0.9502067760650941, 0.9484691011475065, 0.969721516082676, 0.9095044917595535, 0.8942393452053652, 0.7287712533676985, 0.7777980882341948, 0.6176006587423752, 0.5124213502594732, 0.5528431556689122, 0.5088449418686641, 0.4093617807757338, 0.49731713222991464, 0.6206976435456033, 0.6294345145659748, 0.5547663124623439, 0.7297202990060477, 0.7950380657536229, 0.831397425599947, 0.9575384453262332, 1.0249258749103494, -0.8686413077216231, -0.9014042639103335, -0.9462897790105698, -0.9316112945419105, -0.9754026372137907, -1.077839091816972, -1.157768612443351, -1.1915681981266364, -1.2840146438930529, -1.252211472967503, -1.2552632923579257, -1.29625542078108, -1.231867952201975, -1.2033132751820963, -1.0883172493629345, -1.0111279420606132, -0.9992633330998815, -0.9131983391171828, -0.8964812349542782, -0.7614250697098287, -0.8925261308611362, -0.8094410002909738, -0.9102688878990173, -0.9733338417324072, -1.0751505114862114, -1.08965194203292, -1.1332817204148675, -1.0534382410528467, -1.0266754644760356, -1.0573439518397016, -1.05377027626065, -1.0147742871806245, -1.0408024164375704, -1.0856486422810674, -1.1869376217613805, -1.3950229148750681, -1.3792567179476216, -1.4717478634994605, -1.5317027101151302, -1.4264296167170638, -1.5201952762047963, -1.4922805074819232, -1.474855988413353, -1.3262341224940994, -1.3433518932104842, -1.148255309119935, -1.2108637890969522, -1.170299113941676, -1.1037421737466713, -1.0299891380609636, -0.9801008341287212, -0.9219634549696611, -0.9440461984330617, -0.949804377990094, -0.9885212669436836, -1.0256829385851371, -1.092873856822888, -1.2608438528577888, -1.3027736041696603, -1.3753573093523024, -1.3663938480689783, -1.1903586828226393, -1.2538803807814365, -1.2296561913245694, -1.1579183208404322, -0.9523518474970951, -0.9687948405224851, -0.9273789482728185, -0.8936287525613079, -0.8287063101123809, -0.89361260639647, -0.8566734799821512, -0.9633913927865125, -0.930982596691703, -1.0173425290824007, -1.0502330054462965, -1.0460491041715922, -1.1066482922541603, -1.0229610734038308, -0.946362419019918, -1.0331157273243892, -0.9874075984844329, -1.0337622602453653, -1.1325618354127178, -1.1113564082958935, -1.3232618273810468, -1.3439881342221736, -1.3713247605456274, -1.4038137962805697, -1.5491725053059193, -1.4841590287800477, -1.50520534277329, -1.355380088374908, -1.342253809326822, -1.26080369201156, -1.3406527075717005, -1.2320227367651089, -1.1141442807091895, -1.0909547976576186, -0.9540556636574512, -0.9860605117821389, -0.9356540439356138, -0.9377912768226226, -0.8857871716175939, -0.9384607110429724, -1.0733243486264663, -1.143056463993184, -1.2162740042438915, -1.2822887309171298, -1.2431976299079925, -1.3339066849209409, -1.3297762401849913, -1.2231484954481255, -1.0920329828785025, -1.1800048627095034, -1.0328385682751826, -0.9202726745569217, -0.7891465772196437, -0.8762666442708366, -0.8784231692731526, -0.8717536169965459, -0.8603014629464936, -0.9226663401142484, -0.9819918646207833, -0.9097043171805149, -1.0391453679781164, -0.9906326441860036, -1.0915032920557335, -1.0608382893948707, -0.9929730232149548, -1.0420644752097894, -0.9075342280312644, -1.0900297099874714, -1.158505114064349, -1.097432139767959, -1.3377460636392786, -1.3955892901697475, -1.4135665251561769, -1.4412389424090744, -1.547702582250635, -1.4959451430179962, -1.4829898408214726, -1.462563567091084, -1.41932614034306, -1.2829777790162316, -1.1146926650263587, -1.1547526038403548, -1.1381595627684011, -0.9968758247992633, -1.0262957815583647, -0.9749502120447681, -0.9474722009574156, -0.9230359787169641, -0.9228611755947898, -0.9665611614309083, -1.0332284786854837, -1.126236833497266, -1.2415048570179552, -1.202358663939116, -1.302625950830468, -1.2919299268612776, -1.2109660266822126, -1.223029696230018, -1.146203360911823, -1.04322395678094, -1.067441817682095, -0.9384951034814264, -0.8819257164076604, -0.7802247105535728, -0.8847861901734233, -0.8278844293526411, -0.9727255949214483, -0.9088699584498551, -0.909283992724327, -1.0602938994992108, -1.049115026219483, -1.0838396855648236, -1.099354029693472, -1.0991181806527086, -1.0352571864811166, -0.912042018895675, -1.0669180542157057, -1.0913646542328168, -1.1229398349215658, -1.3194876846639794, -1.3033349559935388, -1.4686132454704097, -1.5381050213529202, -1.4900032373003065, -1.4321854813962085, -1.532427222954205, -1.4976727140596693, -1.4382496653991432, -1.3442376786640833, -1.3336434067107883, -1.1632603878446588, -1.2172793937290909, -1.0604347948010637, -1.031032133803601, -0.9581722564315434, -1.0146383797910858, -0.944432859524993, -0.8691707703538908, -0.9225368218258704, -0.9795864659593785, -0.8815830883518108, -1.128362532866554, -1.169702435779416, -1.278496184783831, -1.332390242524425, -1.2435415920629027, -1.3418778988547932, -1.2541078864208102, -1.1018046739923812, -1.0157833995179433, -0.9593342499913821, -0.943846730987557, -0.8432493600910623, -0.8810471427656916, -0.8627731693147348, -0.8181214820983312, -0.9059203435094004]"
dataset/Traffic.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ Hist,Pred
2
+ "[0.5481484285024462, 0.1368960204047248, -0.2229498366807815, -0.6393428998797244, -0.9117976202444646, -1.1482677549006544, -1.323050028342186, -1.3076280630385213, -1.323050028342186, -1.2510808569250849, -0.9323602406493506, -0.30005966319910415, 0.1625992959108324, 0.45047598157923735, 0.6149769448183257, 1.0416513182197116, 1.2884027630783443, 1.3809345549003318, 1.3449499691917812, 1.4888883120259835, 1.4580443814186546, 1.1084798345355915, 0.9645414917013887, 0.728071357045199, 0.39392877546580046, 0.0032389877729654547, -0.3977321101223129, -0.6650461753858319, -0.9632041712566799, -1.1893929957104266, -1.3281906834434074, -1.4001598548605088, -1.4104411650629518, -1.3744565793544012, -1.173971030406762, -0.9683448263579013, -0.5211078325516294, -0.1149960795551296, 0.26027174283404114, 0.5532890836036675, 0.6509615305268766, 1.067354593725819, 0.8103218386647435, 0.6715241509317624, 0.9285569059928381, 0.7589152876525282, 0.6201175999195473, 0.31167829384625634, -0.10985542445390811, -0.46456062643819274, -0.7678592774102622, -1.0762985834835532, -1.2819247875324138, -1.4515664058727238, -1.441285095670281, -1.364175269151958, -1.173971030406762, -0.7318746917017116, -0.1921059060734524, 0.35280353465602826, 0.8720096998794017, 0.589273669312218, 0.5430077734012244, 1.015948042713604, 1.2010116263575785, 1.1598863855478065, 1.6790925507711794, 1.8795780997188185, 1.7459210670870595, 2.3319557486263123, 1.643107965062629, 0.985104112106275, 0.15745864080961072, -0.2229498366807815, -0.7729999325114837, -1.0814392385847746, -1.2613621671275277, -1.364175269151958, -1.4258631303666163, -1.323050028342186, -1.0814392385847746, -0.695890105993161, -0.007042322429477873, 0.4453353264780157, 0.7897592182598572, 0.4710386019841233, 0.5173044978951169, 0.7126493917415347, 1.236996212066129, 1.3603719344954457, 1.8024682732004964, 2.1160482343750084, 2.0595010282615718, 2.095485613970123, 1.4374817610137682, 1.0879172141307052, 0.476179257085345, -0.01218297753069918, -0.6136396243736167, -0.9837667916615658, -1.1996743059128696, -1.3744565793544012, -1.3898785446580657, -1.3076280630385213, -1.1020018589896607, -0.6804681406894963, 0.08034881429128791, 0.38878812036457916, 1.062213938624598, 0.6252582550207689, 0.5070231876926738, 0.8463064243732941, 1.2112929365600218, 1.581420103847971, 1.5197322426333126, 1.84873416911149, 1.7099364813785085, 2.0646416833627934, 1.591701414050414, 1.1393237651429202]","[0.5944143244134397, 0.0032389877729654547, -0.6136396243736167, -0.9991887569652305, -1.1791116855079835, -1.3436126487470719, -1.4053005099617302, -1.3384719936458507, -1.1688303753055402, -0.567373728462623, -0.007042322429477873, 0.39906943056702215, 0.985104112106275, 0.7640559427537496, 0.7383526672476424, 0.8720096998794017, 1.4066378304064393, 1.365512589596667, 1.8898594099212618, 1.8744374446175975, 2.033797752755464, 2.1160482343750084, 1.6688112405687368, 1.1187611447380343]"
demo.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
model/__init__.py ADDED
File without changes
model/model.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ from statistics import mode
3
+
4
+ import numpy as np
5
+ import torch
6
+ from transformers import (
7
+ LlamaForCausalLM,
8
+ LlamaTokenizer,
9
+ pipeline,
10
+ )
11
+
12
+ from utils.prompt import getPrompt
13
+ from utils.tools import Discretizer, Serializer
14
+
15
+
16
+ class ChatTime:
17
+ def __init__(self, model_path, hist_len=None, pred_len=None,
18
+ max_pred_len=16, num_samples=8, top_k=100, top_p=1.0, temperature=1.0):
19
+ self.model_path = model_path
20
+ self.hist_len = hist_len
21
+ self.pred_len = pred_len
22
+
23
+ self.max_pred_len = max_pred_len
24
+ self.num_samples = num_samples
25
+ self.top_k = top_k
26
+ self.top_p = top_p
27
+ self.temperature = temperature
28
+
29
+ self.discretizer = Discretizer()
30
+ self.serializer = Serializer()
31
+
32
+ self.model = LlamaForCausalLM.from_pretrained(
33
+ self.model_path,
34
+ low_cpu_mem_usage=True,
35
+ return_dict=True,
36
+ torch_dtype=torch.float16,
37
+ device_map="auto",
38
+ )
39
+
40
+ self.tokenizer = LlamaTokenizer.from_pretrained(self.model_path, trust_remote_code=True)
41
+ self.tokenizer.pad_token = self.tokenizer.eos_token
42
+ self.tokenizer.padding_side = "right"
43
+ self.eos_token_id = self.tokenizer.eos_token_id
44
+
45
+ def predict(self, hist_data, context=None):
46
+ if self.hist_len is None or self.pred_len is None:
47
+ raise ValueError("hist_len and pred_len must be specified before prediction")
48
+
49
+ series = hist_data
50
+ prediction_list = []
51
+ remaining = self.pred_len
52
+
53
+ while remaining > 0:
54
+ dispersed_series = self.discretizer.discretize(series)
55
+ serialized_series = self.serializer.serialize(dispersed_series)
56
+ serialized_series = getPrompt(flag="prediction", context=context, input=serialized_series)
57
+
58
+ pipe = pipeline(
59
+ task="text-generation",
60
+ model=self.model,
61
+ tokenizer=self.tokenizer,
62
+ min_new_tokens=2 * min(remaining, self.max_pred_len) + 8,
63
+ max_new_tokens=2 * min(remaining, self.max_pred_len) + 8,
64
+ do_sample=True,
65
+ num_return_sequences=self.num_samples,
66
+ top_k=self.top_k,
67
+ top_p=self.top_p,
68
+ temperature=self.temperature,
69
+ eos_token_id=self.eos_token_id,
70
+ )
71
+ samples = pipe(serialized_series)
72
+
73
+ pred_list = []
74
+ for sample in samples:
75
+ serialized_prediction = sample["generated_text"].split("### Response:\n")[1]
76
+ dispersed_prediction = self.serializer.inverse_serialize(serialized_prediction)
77
+ pred = self.discretizer.inverse_discretize(dispersed_prediction)
78
+
79
+ if len(pred) < min(remaining, self.max_pred_len):
80
+ pred = np.concatenate([pred, np.full(min(remaining, self.max_pred_len) - len(pred), np.NaN)])
81
+
82
+ pred_list.append(pred[:min(remaining, self.max_pred_len)])
83
+
84
+ prediction = np.nanmedian(pred_list, axis=0)
85
+ prediction_list.append(prediction)
86
+ remaining -= prediction.shape[-1]
87
+
88
+ if remaining <= 0:
89
+ break
90
+
91
+ series = np.concatenate([series, prediction], axis=-1)
92
+
93
+ prediction = np.concatenate(prediction_list, axis=-1)
94
+
95
+ return prediction
96
+
97
+ def analyze(self, question, series):
98
+ dispersed_series = self.discretizer.discretize(series)
99
+ serialized_series = self.serializer.serialize(dispersed_series)
100
+ serialized_series = getPrompt(flag="analysis", instruction=question, input=serialized_series)
101
+
102
+ pipe = pipeline(
103
+ task="text-generation",
104
+ model=self.model,
105
+ tokenizer=self.tokenizer,
106
+ max_new_tokens=self.max_pred_len,
107
+ do_sample=True,
108
+ num_return_sequences=self.num_samples,
109
+ top_k=self.top_k,
110
+ top_p=self.top_p,
111
+ temperature=self.temperature,
112
+ eos_token_id=self.eos_token_id,
113
+ )
114
+ samples = pipe(serialized_series)
115
+
116
+ response_list = []
117
+ for sample in samples:
118
+ response = sample["generated_text"].split("### Response:\n")[1].split('.')[0] + "."
119
+ response = re.findall(r"\([abc]\)", response)[0]
120
+ response_list.append(response)
121
+
122
+ response = mode(response_list)
123
+
124
+ return response
rats40k_adapter/logs/pipeline_20260608_175250_sft.log ADDED
The diff for this file is too large to render. See raw diff
 
rats40k_adapter/logs/pipeline_20260608_175250_zeroshot.log ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ accelerate: 0.34.2
2
+ Run id: 20260608_175250
3
+ Python: /dev/shm/suiqk/conda_envs/scalerag-ts-v4/bin/python
4
+ Accelerate: /dev/shm/suiqk/conda_envs/scalerag-ts-v4/bin/python -m accelerate.commands.accelerate_cli
5
+ CUDA_VISIBLE_DEVICES: 0,1,2,3
6
+ Model path: /mnt/share01/sqk/models/ChatTime-1-7B-Chat
7
+ Data path: /mnt/share01/sqk/datasets/RATs40K/RATs-Uni-TSImage_Reason.json
8
+ Output dir: /mnt/share01/sqk/ChatTime/rats40k_adapter/outputs/pipeline_20260608_175250/zeroshot
9
+ Log file: /mnt/share01/sqk/ChatTime/rats40k_adapter/logs/pipeline_20260608_175250_zeroshot.log
10
+ Dataset: /mnt/share01/sqk/datasets/RATs40K/RATs-Uni-TSImage_Reason.json
11
+ Split: TSAD_test
12
+ Total samples: 6034
13
+ World size: 4
14
+ Per-device eval batch size: 4
15
+ Maximum global eval batch size: 16
16
+ Output dir: /mnt/share01/sqk/ChatTime/rats40k_adapter/outputs/pipeline_20260608_175250/zeroshot
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+ [rank0]:[W608 19:20:59.606662159 ProcessGroupNCCL.cpp:4561] [PG ID 0 PG GUID 0 Rank 0] using GPU 0 to perform barrier as devices used by this process are currently unknown. This can potentially cause a hang if this rank to GPU mapping is incorrect. Specify device_ids in barrier() to force use of a particular device, or call init_process_group() with a device_id.
26
+ Saved predictions: /mnt/share01/sqk/ChatTime/rats40k_adapter/outputs/pipeline_20260608_175250/zeroshot/RATs-Uni-TSImage_Reason_Reason_by_chattime_zeroshot.json
27
+ Saved metrics: /mnt/share01/sqk/ChatTime/rats40k_adapter/outputs/pipeline_20260608_175250/zeroshot/TSAD_test_metrics.json
rats40k_adapter/logs/sft_4gpu_20260608_172354.log ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ accelerate: 0.34.2
2
+ Run id: 20260608_172354
3
+ Python: /dev/shm/suiqk/conda_envs/scalerag-ts-v4/bin/python
4
+ Accelerate: /dev/shm/suiqk/conda_envs/scalerag-ts-v4/bin/python -m accelerate.commands.accelerate_cli
5
+ CUDA_VISIBLE_DEVICES: 0,1,2,3
6
+ Model path: /mnt/share01/sqk/models/ChatTime-1-7B-Chat
7
+ Data path: /mnt/share01/sqk/datasets/RATs40K/RATs-Uni-TSImage_Reason.json
8
+ Adapter output dir: /mnt/share01/sqk/ChatTime/rats40k_adapter/outputs/sft_20260608_172354/adapter
9
+ Eval output dir: /mnt/share01/sqk/ChatTime/rats40k_adapter/outputs/sft_20260608_172354/eval
10
+ Log file: /mnt/share01/sqk/ChatTime/rats40k_adapter/logs/sft_4gpu_20260608_172354.log
11
+ ⚙️ Running in WANDB offline mode
12
+ ⚙️ Running in WANDB offline mode
13
+ ⚙️ Running in WANDB offline mode
14
+ ⚙️ Running in WANDB offline mode
15
+ SFT token length check: max_prompt_len=2818, max_total_len=3134, max_seq_length=4096
16
+ Traceback (most recent call last):
17
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/importlib/metadata/__init__.py", line 563, in from_name
18
+ return next(cls.discover(name=name))
19
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20
+ StopIteration
21
+
22
+ During handling of the above exception, another exception occurred:
23
+
24
+ Traceback (most recent call last):
25
+ File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 283, in <module>
26
+ main()
27
+ File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 249, in main
28
+ model = load_model(args)
29
+ ^^^^^^^^^^^^^^^^
30
+ File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 185, in load_model
31
+ quantization_config = BitsAndBytesConfig(
32
+ ^^^^^^^^^^^^^^^^^^^
33
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/utils/quantization_config.py", line 509, in __init__
34
+ self.post_init()
35
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/utils/quantization_config.py", line 567, in post_init
36
+ if self.load_in_4bit and not version.parse(importlib.metadata.version("bitsandbytes")) >= version.parse(
37
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/importlib/metadata/__init__.py", line 1009, in version
39
+ return distribution(distribution_name).version
40
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/importlib/metadata/__init__.py", line 982, in distribution
42
+ return Distribution.from_name(distribution_name)
43
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/importlib/metadata/__init__.py", line 565, in from_name
45
+ raise PackageNotFoundError(name)
46
+ importlib.metadata.PackageNotFoundError: No package metadata was found for bitsandbytes
47
+ SFT token length check: max_prompt_len=2818, max_total_len=3134, max_seq_length=4096
48
+ Traceback (most recent call last):
49
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/importlib/metadata/__init__.py", line 563, in from_name
50
+ return next(cls.discover(name=name))
51
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
52
+ StopIteration
53
+
54
+ During handling of the above exception, another exception occurred:
55
+
56
+ Traceback (most recent call last):
57
+ File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 283, in <module>
58
+ main()
59
+ File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 249, in main
60
+ model = load_model(args)
61
+ ^^^^^^^^^^^^^^^^
62
+ File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 185, in load_model
63
+ quantization_config = BitsAndBytesConfig(
64
+ ^^^^^^^^^^^^^^^^^^^
65
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/utils/quantization_config.py", line 509, in __init__
66
+ self.post_init()
67
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/utils/quantization_config.py", line 567, in post_init
68
+ if self.load_in_4bit and not version.parse(importlib.metadata.version("bitsandbytes")) >= version.parse(
69
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
70
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/importlib/metadata/__init__.py", line 1009, in version
71
+ return distribution(distribution_name).version
72
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/importlib/metadata/__init__.py", line 982, in distribution
74
+ return Distribution.from_name(distribution_name)
75
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/importlib/metadata/__init__.py", line 565, in from_name
77
+ raise PackageNotFoundError(name)
78
+ importlib.metadata.PackageNotFoundError: No package metadata was found for bitsandbytes
79
+ SFT token length check: max_prompt_len=2818, max_total_len=3134, max_seq_length=4096
80
+ Traceback (most recent call last):
81
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/importlib/metadata/__init__.py", line 563, in from_name
82
+ return next(cls.discover(name=name))
83
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
84
+ StopIteration
85
+
86
+ During handling of the above exception, another exception occurred:
87
+
88
+ Traceback (most recent call last):
89
+ File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 283, in <module>
90
+ main()
91
+ File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 249, in main
92
+ model = load_model(args)
93
+ ^^^^^^^^^^^^^^^^
94
+ File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 185, in load_model
95
+ quantization_config = BitsAndBytesConfig(
96
+ ^^^^^^^^^^^^^^^^^^^
97
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/utils/quantization_config.py", line 509, in __init__
98
+ self.post_init()
99
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/utils/quantization_config.py", line 567, in post_init
100
+ if self.load_in_4bit and not version.parse(importlib.metadata.version("bitsandbytes")) >= version.parse(
101
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
102
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/importlib/metadata/__init__.py", line 1009, in version
103
+ return distribution(distribution_name).version
104
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
105
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/importlib/metadata/__init__.py", line 982, in distribution
106
+ return Distribution.from_name(distribution_name)
107
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
108
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/importlib/metadata/__init__.py", line 565, in from_name
109
+ raise PackageNotFoundError(name)
110
+ importlib.metadata.PackageNotFoundError: No package metadata was found for bitsandbytes
111
+ W0608 17:25:51.569000 4051992 site-packages/torch/distributed/elastic/multiprocessing/api.py:897] Sending process 4052417 closing signal SIGTERM
112
+ W0608 17:25:51.569000 4051992 site-packages/torch/distributed/elastic/multiprocessing/api.py:897] Sending process 4052418 closing signal SIGTERM
113
+ W0608 17:25:51.570000 4051992 site-packages/torch/distributed/elastic/multiprocessing/api.py:897] Sending process 4052419 closing signal SIGTERM
114
+ E0608 17:25:51.748000 4051992 site-packages/torch/distributed/elastic/multiprocessing/api.py:869] failed (exitcode: 1) local_rank: 3 (pid: 4052420) of binary: /dev/shm/suiqk/conda_envs/scalerag-ts-v4/bin/python
115
+ Traceback (most recent call last):
116
+ File "<frozen runpy>", line 198, in _run_module_as_main
117
+ File "<frozen runpy>", line 88, in _run_code
118
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/commands/accelerate_cli.py", line 52, in <module>
119
+ main()
120
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/commands/accelerate_cli.py", line 48, in main
121
+ args.func(args)
122
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/commands/launch.py", line 1165, in launch_command
123
+ multi_gpu_launcher(args)
124
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/commands/launch.py", line 799, in multi_gpu_launcher
125
+ distrib_run.run(args)
126
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/torch/distributed/run.py", line 909, in run
127
+ elastic_launch(
128
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/torch/distributed/launcher/api.py", line 138, in __call__
129
+ return launch_agent(self._config, self._entrypoint, list(args))
130
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
131
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/torch/distributed/launcher/api.py", line 269, in launch_agent
132
+ raise ChildFailedError(
133
+ torch.distributed.elastic.multiprocessing.errors.ChildFailedError:
134
+ ============================================================
135
+ rats40k_adapter/finetune_rats40k_lora.py FAILED
136
+ ------------------------------------------------------------
137
+ Failures:
138
+ <NO_OTHER_FAILURES>
139
+ ------------------------------------------------------------
140
+ Root Cause (first observed failure):
141
+ [0]:
142
+ time : 2026-06-08_17:25:51
143
+ host : simtech-gpuserver
144
+ rank : 3 (local_rank: 3)
145
+ exitcode : 1 (pid: 4052420)
146
+ error_file: <N/A>
147
+ traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html
148
+ ============================================================
rats40k_adapter/logs/sft_4gpu_20260608_173130.log ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ accelerate: 0.34.2
2
+ Run id: 20260608_173130
3
+ Python: /dev/shm/suiqk/conda_envs/scalerag-ts-v4/bin/python
4
+ Accelerate: /dev/shm/suiqk/conda_envs/scalerag-ts-v4/bin/python -m accelerate.commands.accelerate_cli
5
+ CUDA_VISIBLE_DEVICES: 0,1,2,3
6
+ Model path: /mnt/share01/sqk/models/ChatTime-1-7B-Chat
7
+ Data path: /mnt/share01/sqk/datasets/RATs40K/RATs-Uni-TSImage_Reason.json
8
+ Adapter output dir: /mnt/share01/sqk/ChatTime/rats40k_adapter/outputs/sft_20260608_173130/adapter
9
+ Eval output dir: /mnt/share01/sqk/ChatTime/rats40k_adapter/outputs/sft_20260608_173130/eval
10
+ Log file: /mnt/share01/sqk/ChatTime/rats40k_adapter/logs/sft_4gpu_20260608_173130.log
11
+ ⚙️ Running in WANDB offline mode
12
+ ⚙️ Running in WANDB offline mode
13
+ ⚙️ Running in WANDB offline mode
14
+ ⚙️ Running in WANDB offline mode
15
+ SFT token length check: max_prompt_len=2818, max_total_len=3134, max_seq_length=4096
16
+ SFT token length check: max_prompt_len=2818, max_total_len=3134, max_seq_length=4096
17
+ SFT token length check: max_prompt_len=2818, max_total_len=3134, max_seq_length=4096
18
+
19
+
20
+
21
+
22
+
23
+ trainable params: 39,976,960 || all params: 6,860,320,768 || trainable%: 0.5827
24
+ trainable params: 39,976,960 || all params: 6,860,320,768 || trainable%: 0.5827
25
+ /dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/accelerator.py:494: FutureWarning: `torch.cuda.amp.GradScaler(args...)` is deprecated. Please use `torch.amp.GradScaler('cuda', args...)` instead.
26
+ self.scaler = torch.cuda.amp.GradScaler(**kwargs)
27
+ No label_names provided for model class `PeftModelForCausalLM`. Since `PeftModel` hides base models input arguments, if label_names is not given, label_names can't be set automatically within `Trainer`. Note that empty label_names list will be used instead.
28
+ /dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/accelerator.py:494: FutureWarning: `torch.cuda.amp.GradScaler(args...)` is deprecated. Please use `torch.amp.GradScaler('cuda', args...)` instead.
29
+ self.scaler = torch.cuda.amp.GradScaler(**kwargs)
30
+ No label_names provided for model class `PeftModelForCausalLM`. Since `PeftModel` hides base models input arguments, if label_names is not given, label_names can't be set automatically within `Trainer`. Note that empty label_names list will be used instead.
31
+ trainable params: 39,976,960 || all params: 6,860,320,768 || trainable%: 0.5827
32
+ /dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/accelerator.py:494: FutureWarning: `torch.cuda.amp.GradScaler(args...)` is deprecated. Please use `torch.amp.GradScaler('cuda', args...)` instead.
33
+ self.scaler = torch.cuda.amp.GradScaler(**kwargs)
34
+ Detected kernel version 5.4.0, which is below the recommended minimum of 5.5.0; this can cause the process to hang. It is recommended to upgrade the kernel to the minimum version or higher.
35
+ No label_names provided for model class `PeftModelForCausalLM`. Since `PeftModel` hides base models input arguments, if label_names is not given, label_names can't be set automatically within `Trainer`. Note that empty label_names list will be used instead.
36
+ [rank1]: Traceback (most recent call last):
37
+ [rank1]: File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 283, in <module>
38
+ [rank1]: main()
39
+ [rank1]: File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 277, in main
40
+ [rank1]: trainer.train()
41
+ [rank1]: File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/trainer.py", line 2237, in train
42
+ [rank1]: return inner_training_loop(
43
+ [rank1]: ^^^^^^^^^^^^^^^^^^^^
44
+ [rank1]: File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/trainer.py", line 2361, in _inner_training_loop
45
+ [rank1]: model = self._wrap_model(self.model_wrapped)
46
+ [rank1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47
+ [rank1]: File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/trainer.py", line 1985, in _wrap_model
48
+ [rank1]: if self.accelerator.unwrap_model(model, keep_torch_compile=False) is not model:
49
+ [rank1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
50
+ [rank1]: TypeError: Accelerator.unwrap_model() got an unexpected keyword argument 'keep_torch_compile'
51
+ [rank3]: Traceback (most recent call last):
52
+ [rank3]: File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 283, in <module>
53
+ [rank3]: main()
54
+ [rank3]: File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 277, in main
55
+ [rank3]: trainer.train()
56
+ [rank3]: File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/trainer.py", line 2237, in train
57
+ [rank3]: return inner_training_loop(
58
+ [rank3]: ^^^^^^^^^^^^^^^^^^^^
59
+ [rank3]: File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/trainer.py", line 2361, in _inner_training_loop
60
+ [rank3]: model = self._wrap_model(self.model_wrapped)
61
+ [rank3]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62
+ [rank3]: File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/trainer.py", line 1985, in _wrap_model
63
+ [rank3]: if self.accelerator.unwrap_model(model, keep_torch_compile=False) is not model:
64
+ [rank3]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65
+ [rank3]: TypeError: Accelerator.unwrap_model() got an unexpected keyword argument 'keep_torch_compile'
66
+ [rank0]: Traceback (most recent call last):
67
+ [rank0]: File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 283, in <module>
68
+ [rank0]: main()
69
+ [rank0]: File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 277, in main
70
+ [rank0]: trainer.train()
71
+ [rank0]: File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/trainer.py", line 2237, in train
72
+ [rank0]: return inner_training_loop(
73
+ [rank0]: ^^^^^^^^^^^^^^^^^^^^
74
+ [rank0]: File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/trainer.py", line 2361, in _inner_training_loop
75
+ [rank0]: model = self._wrap_model(self.model_wrapped)
76
+ [rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
77
+ [rank0]: File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/trainer.py", line 1985, in _wrap_model
78
+ [rank0]: if self.accelerator.unwrap_model(model, keep_torch_compile=False) is not model:
79
+ [rank0]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80
+ [rank0]: TypeError: Accelerator.unwrap_model() got an unexpected keyword argument 'keep_torch_compile'
81
+ trainable params: 39,976,960 || all params: 6,860,320,768 || trainable%: 0.5827
82
+ /dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/accelerator.py:494: FutureWarning: `torch.cuda.amp.GradScaler(args...)` is deprecated. Please use `torch.amp.GradScaler('cuda', args...)` instead.
83
+ self.scaler = torch.cuda.amp.GradScaler(**kwargs)
84
+ No label_names provided for model class `PeftModelForCausalLM`. Since `PeftModel` hides base models input arguments, if label_names is not given, label_names can't be set automatically within `Trainer`. Note that empty label_names list will be used instead.
85
+ [rank0]:[W608 17:36:00.577053648 ProcessGroupNCCL.cpp:1496] Warning: WARNING: destroy_process_group() was not called before program exit, which can leak resources. For more info, please see https://pytorch.org/docs/stable/distributed.html#shutdown (function operator())
86
+ [rank2]: Traceback (most recent call last):
87
+ [rank2]: File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 283, in <module>
88
+ [rank2]: main()
89
+ [rank2]: File "/mnt/share01/sqk/ChatTime/rats40k_adapter/finetune_rats40k_lora.py", line 277, in main
90
+ [rank2]: trainer.train()
91
+ [rank2]: File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/trainer.py", line 2237, in train
92
+ [rank2]: return inner_training_loop(
93
+ [rank2]: ^^^^^^^^^^^^^^^^^^^^
94
+ [rank2]: File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/trainer.py", line 2361, in _inner_training_loop
95
+ [rank2]: model = self._wrap_model(self.model_wrapped)
96
+ [rank2]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
97
+ [rank2]: File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/transformers/trainer.py", line 1985, in _wrap_model
98
+ [rank2]: if self.accelerator.unwrap_model(model, keep_torch_compile=False) is not model:
99
+ [rank2]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
100
+ [rank2]: TypeError: Accelerator.unwrap_model() got an unexpected keyword argument 'keep_torch_compile'
101
+ W0608 17:36:00.830000 4087788 site-packages/torch/distributed/elastic/multiprocessing/api.py:897] Sending process 4088224 closing signal SIGTERM
102
+ W0608 17:36:00.831000 4087788 site-packages/torch/distributed/elastic/multiprocessing/api.py:897] Sending process 4088226 closing signal SIGTERM
103
+ W0608 17:36:00.832000 4087788 site-packages/torch/distributed/elastic/multiprocessing/api.py:897] Sending process 4088227 closing signal SIGTERM
104
+ E0608 17:36:01.029000 4087788 site-packages/torch/distributed/elastic/multiprocessing/api.py:869] failed (exitcode: 1) local_rank: 1 (pid: 4088225) of binary: /dev/shm/suiqk/conda_envs/scalerag-ts-v4/bin/python
105
+ Traceback (most recent call last):
106
+ File "<frozen runpy>", line 198, in _run_module_as_main
107
+ File "<frozen runpy>", line 88, in _run_code
108
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/commands/accelerate_cli.py", line 52, in <module>
109
+ main()
110
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/commands/accelerate_cli.py", line 48, in main
111
+ args.func(args)
112
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/commands/launch.py", line 1165, in launch_command
113
+ multi_gpu_launcher(args)
114
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/commands/launch.py", line 799, in multi_gpu_launcher
115
+ distrib_run.run(args)
116
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/torch/distributed/run.py", line 909, in run
117
+ elastic_launch(
118
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/torch/distributed/launcher/api.py", line 138, in __call__
119
+ return launch_agent(self._config, self._entrypoint, list(args))
120
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
121
+ File "/dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/torch/distributed/launcher/api.py", line 269, in launch_agent
122
+ raise ChildFailedError(
123
+ torch.distributed.elastic.multiprocessing.errors.ChildFailedError:
124
+ ============================================================
125
+ rats40k_adapter/finetune_rats40k_lora.py FAILED
126
+ ------------------------------------------------------------
127
+ Failures:
128
+ <NO_OTHER_FAILURES>
129
+ ------------------------------------------------------------
130
+ Root Cause (first observed failure):
131
+ [0]:
132
+ time : 2026-06-08_17:36:00
133
+ host : simtech-gpuserver
134
+ rank : 1 (local_rank: 1)
135
+ exitcode : 1 (pid: 4088225)
136
+ error_file: <N/A>
137
+ traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html
138
+ ============================================================
rats40k_adapter/logs/sft_4gpu_20260608_174152.log ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
  0%| | 0/946 [00:00<?, ?it/s]`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`.
 
 
 
 
1
  0%| | 1/946 [00:41<11:01:04, 41.97s/it]
2
  0%| | 2/946 [01:24<11:08:02, 42.46s/it]
3
  0%| | 3/946 [02:07<11:08:46, 42.55s/it]
4
  0%| | 4/946 [02:49<11:08:05, 42.55s/it]
5
  1%| | 5/946 [03:32<11:05:36, 42.44s/it]
6
  1%| | 6/946 [04:14<11:04:02, 42.39s/it]
7
  1%| | 7/946 [04:57<11:04:53, 42.49s/it]
8
  1%| | 8/946 [05:39<11:03:06, 42.42s/it]
 
1
+ accelerate: 0.34.2
2
+ Run id: 20260608_174152
3
+ Python: /dev/shm/suiqk/conda_envs/scalerag-ts-v4/bin/python
4
+ Accelerate: /dev/shm/suiqk/conda_envs/scalerag-ts-v4/bin/python -m accelerate.commands.accelerate_cli
5
+ CUDA_VISIBLE_DEVICES: 0,1,2,3
6
+ Model path: /mnt/share01/sqk/models/ChatTime-1-7B-Chat
7
+ Data path: /mnt/share01/sqk/datasets/RATs40K/RATs-Uni-TSImage_Reason.json
8
+ Adapter output dir: /mnt/share01/sqk/ChatTime/rats40k_adapter/outputs/sft_20260608_174152/adapter
9
+ Eval output dir: /mnt/share01/sqk/ChatTime/rats40k_adapter/outputs/sft_20260608_174152/eval
10
+ Log file: /mnt/share01/sqk/ChatTime/rats40k_adapter/logs/sft_4gpu_20260608_174152.log
11
+ ⚙️ Running in WANDB offline mode
12
+ ⚙️ Running in WANDB offline mode
13
+ ⚙️ Running in WANDB offline mode
14
+ ⚙️ Running in WANDB offline mode
15
+ Applied accelerate compatibility patch: Accelerator.unwrap_model accepts keep_torch_compile.
16
+ Applied accelerate compatibility patch: Accelerator.unwrap_model accepts keep_torch_compile.
17
+ Applied accelerate compatibility patch: Accelerator.unwrap_model accepts keep_torch_compile.
18
+ Applied accelerate compatibility patch: Accelerator.unwrap_model accepts keep_torch_compile.
19
+ SFT token length check: max_prompt_len=2818, max_total_len=3134, max_seq_length=4096
20
+
21
+ SFT token length check: max_prompt_len=2818, max_total_len=3134, max_seq_length=4096
22
+
23
+
24
+
25
+
26
+
27
+ trainable params: 39,976,960 || all params: 6,860,320,768 || trainable%: 0.5827
28
+ /dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/accelerator.py:494: FutureWarning: `torch.cuda.amp.GradScaler(args...)` is deprecated. Please use `torch.amp.GradScaler('cuda', args...)` instead.
29
+ self.scaler = torch.cuda.amp.GradScaler(**kwargs)
30
+ No label_names provided for model class `PeftModelForCausalLM`. Since `PeftModel` hides base models input arguments, if label_names is not given, label_names can't be set automatically within `Trainer`. Note that empty label_names list will be used instead.
31
+ trainable params: 39,976,960 || all params: 6,860,320,768 || trainable%: 0.5827
32
+ trainable params: 39,976,960 || all params: 6,860,320,768 || trainable%: 0.5827
33
+ /dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/accelerator.py:494: FutureWarning: `torch.cuda.amp.GradScaler(args...)` is deprecated. Please use `torch.amp.GradScaler('cuda', args...)` instead.
34
+ self.scaler = torch.cuda.amp.GradScaler(**kwargs)
35
+ No label_names provided for model class `PeftModelForCausalLM`. Since `PeftModel` hides base models input arguments, if label_names is not given, label_names can't be set automatically within `Trainer`. Note that empty label_names list will be used instead.
36
+ /dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/accelerator.py:494: FutureWarning: `torch.cuda.amp.GradScaler(args...)` is deprecated. Please use `torch.amp.GradScaler('cuda', args...)` instead.
37
+ self.scaler = torch.cuda.amp.GradScaler(**kwargs)
38
+ No label_names provided for model class `PeftModelForCausalLM`. Since `PeftModel` hides base models input arguments, if label_names is not given, label_names can't be set automatically within `Trainer`. Note that empty label_names list will be used instead.
39
+ trainable params: 39,976,960 || all params: 6,860,320,768 || trainable%: 0.5827
40
+ /dev/shm/suiqk/conda_envs/scalerag-ts-v4/lib/python3.11/site-packages/accelerate/accelerator.py:494: FutureWarning: `torch.cuda.amp.GradScaler(args...)` is deprecated. Please use `torch.amp.GradScaler('cuda', args...)` instead.
41
+ self.scaler = torch.cuda.amp.GradScaler(**kwargs)
42
+ Detected kernel version 5.4.0, which is below the recommended minimum of 5.5.0; this can cause the process to hang. It is recommended to upgrade the kernel to the minimum version or higher.
43
+ No label_names provided for model class `PeftModelForCausalLM`. Since `PeftModel` hides base models input arguments, if label_names is not given, label_names can't be set automatically within `Trainer`. Note that empty label_names list will be used instead.
44
+
45
  0%| | 0/946 [00:00<?, ?it/s]`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`.
46
+ `use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`.
47
+ `use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`.
48
+ `use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`.
49
+
50
  0%| | 1/946 [00:41<11:01:04, 41.97s/it]
51
  0%| | 2/946 [01:24<11:08:02, 42.46s/it]
52
  0%| | 3/946 [02:07<11:08:46, 42.55s/it]
53
  0%| | 4/946 [02:49<11:08:05, 42.55s/it]
54
  1%| | 5/946 [03:32<11:05:36, 42.44s/it]
55
  1%| | 6/946 [04:14<11:04:02, 42.39s/it]
56
  1%| | 7/946 [04:57<11:04:53, 42.49s/it]
57
  1%| | 8/946 [05:39<11:03:06, 42.42s/it]
rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-800/README.md ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: /mnt/share01/sqk/models/ChatTime-1-7B-Chat
3
+ library_name: peft
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
200
+ ### Framework versions
201
+
202
+ - PEFT 0.14.0
rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-800/adapter_config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "/mnt/share01/sqk/models/ChatTime-1-7B-Chat",
5
+ "bias": "none",
6
+ "eva_config": null,
7
+ "exclude_modules": null,
8
+ "fan_in_fan_out": false,
9
+ "inference_mode": true,
10
+ "init_lora_weights": true,
11
+ "layer_replication": null,
12
+ "layers_pattern": null,
13
+ "layers_to_transform": null,
14
+ "loftq_config": {},
15
+ "lora_alpha": 32,
16
+ "lora_bias": false,
17
+ "lora_dropout": 0.05,
18
+ "megatron_config": null,
19
+ "megatron_core": "megatron.core",
20
+ "modules_to_save": null,
21
+ "peft_type": "LORA",
22
+ "r": 16,
23
+ "rank_pattern": {},
24
+ "revision": null,
25
+ "target_modules": [
26
+ "gate_proj",
27
+ "o_proj",
28
+ "v_proj",
29
+ "up_proj",
30
+ "q_proj",
31
+ "k_proj",
32
+ "down_proj"
33
+ ],
34
+ "task_type": "CAUSAL_LM",
35
+ "use_dora": false,
36
+ "use_rslora": false
37
+ }
rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-800/added_tokens.json ADDED
The diff for this file is too large to render. See raw diff
 
rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-800/special_tokens_map.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "unk_token": {
24
+ "content": "<unk>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ }
30
+ }
rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-800/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-800/tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff
 
rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-800/trainer_state.json ADDED
@@ -0,0 +1,594 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 1.6914232853178275,
6
+ "eval_steps": 500,
7
+ "global_step": 800,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 0.021144442976080348,
14
+ "grad_norm": 6.2254319190979,
15
+ "learning_rate": 3.3333333333333335e-05,
16
+ "loss": 3.0149,
17
+ "step": 10
18
+ },
19
+ {
20
+ "epoch": 0.042288885952160696,
21
+ "grad_norm": 0.7327573895454407,
22
+ "learning_rate": 7.500000000000001e-05,
23
+ "loss": 1.623,
24
+ "step": 20
25
+ },
26
+ {
27
+ "epoch": 0.06343332892824105,
28
+ "grad_norm": 0.5618261098861694,
29
+ "learning_rate": 0.00011250000000000001,
30
+ "loss": 1.1099,
31
+ "step": 30
32
+ },
33
+ {
34
+ "epoch": 0.08457777190432139,
35
+ "grad_norm": 0.48980122804641724,
36
+ "learning_rate": 0.00015416666666666668,
37
+ "loss": 0.9131,
38
+ "step": 40
39
+ },
40
+ {
41
+ "epoch": 0.10572221488040175,
42
+ "grad_norm": 0.488565593957901,
43
+ "learning_rate": 0.00019583333333333334,
44
+ "loss": 0.7716,
45
+ "step": 50
46
+ },
47
+ {
48
+ "epoch": 0.1268666578564821,
49
+ "grad_norm": 0.4297373592853546,
50
+ "learning_rate": 0.0001979955456570156,
51
+ "loss": 0.723,
52
+ "step": 60
53
+ },
54
+ {
55
+ "epoch": 0.14801110083256244,
56
+ "grad_norm": 0.4536869525909424,
57
+ "learning_rate": 0.0001957683741648107,
58
+ "loss": 0.6879,
59
+ "step": 70
60
+ },
61
+ {
62
+ "epoch": 0.16915554380864278,
63
+ "grad_norm": 0.41550788283348083,
64
+ "learning_rate": 0.0001935412026726058,
65
+ "loss": 0.6586,
66
+ "step": 80
67
+ },
68
+ {
69
+ "epoch": 0.19029998678472315,
70
+ "grad_norm": 0.38494592905044556,
71
+ "learning_rate": 0.0001913140311804009,
72
+ "loss": 0.6324,
73
+ "step": 90
74
+ },
75
+ {
76
+ "epoch": 0.2114444297608035,
77
+ "grad_norm": 0.3633956015110016,
78
+ "learning_rate": 0.000189086859688196,
79
+ "loss": 0.631,
80
+ "step": 100
81
+ },
82
+ {
83
+ "epoch": 0.23258887273688383,
84
+ "grad_norm": 0.3775959312915802,
85
+ "learning_rate": 0.0001868596881959911,
86
+ "loss": 0.6103,
87
+ "step": 110
88
+ },
89
+ {
90
+ "epoch": 0.2537333157129642,
91
+ "grad_norm": 0.35080480575561523,
92
+ "learning_rate": 0.0001846325167037862,
93
+ "loss": 0.6159,
94
+ "step": 120
95
+ },
96
+ {
97
+ "epoch": 0.2748777586890445,
98
+ "grad_norm": 0.4399946928024292,
99
+ "learning_rate": 0.0001824053452115813,
100
+ "loss": 0.5983,
101
+ "step": 130
102
+ },
103
+ {
104
+ "epoch": 0.2960222016651249,
105
+ "grad_norm": 0.4049876928329468,
106
+ "learning_rate": 0.0001801781737193764,
107
+ "loss": 0.5881,
108
+ "step": 140
109
+ },
110
+ {
111
+ "epoch": 0.31716664464120525,
112
+ "grad_norm": 0.3834834396839142,
113
+ "learning_rate": 0.0001779510022271715,
114
+ "loss": 0.5703,
115
+ "step": 150
116
+ },
117
+ {
118
+ "epoch": 0.33831108761728557,
119
+ "grad_norm": 0.3201199471950531,
120
+ "learning_rate": 0.0001757238307349666,
121
+ "loss": 0.5777,
122
+ "step": 160
123
+ },
124
+ {
125
+ "epoch": 0.35945553059336594,
126
+ "grad_norm": 0.3475135564804077,
127
+ "learning_rate": 0.0001734966592427617,
128
+ "loss": 0.5627,
129
+ "step": 170
130
+ },
131
+ {
132
+ "epoch": 0.3805999735694463,
133
+ "grad_norm": 0.3944849371910095,
134
+ "learning_rate": 0.0001712694877505568,
135
+ "loss": 0.569,
136
+ "step": 180
137
+ },
138
+ {
139
+ "epoch": 0.4017444165455266,
140
+ "grad_norm": 0.3674592673778534,
141
+ "learning_rate": 0.0001690423162583519,
142
+ "loss": 0.5621,
143
+ "step": 190
144
+ },
145
+ {
146
+ "epoch": 0.422888859521607,
147
+ "grad_norm": 0.3651335835456848,
148
+ "learning_rate": 0.000166815144766147,
149
+ "loss": 0.5597,
150
+ "step": 200
151
+ },
152
+ {
153
+ "epoch": 0.4440333024976873,
154
+ "grad_norm": 0.3435162901878357,
155
+ "learning_rate": 0.0001645879732739421,
156
+ "loss": 0.5538,
157
+ "step": 210
158
+ },
159
+ {
160
+ "epoch": 0.46517774547376767,
161
+ "grad_norm": 0.3870578408241272,
162
+ "learning_rate": 0.0001623608017817372,
163
+ "loss": 0.5574,
164
+ "step": 220
165
+ },
166
+ {
167
+ "epoch": 0.48632218844984804,
168
+ "grad_norm": 0.40335071086883545,
169
+ "learning_rate": 0.0001601336302895323,
170
+ "loss": 0.5394,
171
+ "step": 230
172
+ },
173
+ {
174
+ "epoch": 0.5074666314259284,
175
+ "grad_norm": 0.3105282187461853,
176
+ "learning_rate": 0.0001579064587973274,
177
+ "loss": 0.5403,
178
+ "step": 240
179
+ },
180
+ {
181
+ "epoch": 0.5286110744020087,
182
+ "grad_norm": 0.3729188144207001,
183
+ "learning_rate": 0.00015567928730512252,
184
+ "loss": 0.5466,
185
+ "step": 250
186
+ },
187
+ {
188
+ "epoch": 0.549755517378089,
189
+ "grad_norm": 0.3619287312030792,
190
+ "learning_rate": 0.0001534521158129176,
191
+ "loss": 0.5305,
192
+ "step": 260
193
+ },
194
+ {
195
+ "epoch": 0.5708999603541695,
196
+ "grad_norm": 0.34232136607170105,
197
+ "learning_rate": 0.0001512249443207127,
198
+ "loss": 0.5319,
199
+ "step": 270
200
+ },
201
+ {
202
+ "epoch": 0.5920444033302498,
203
+ "grad_norm": 0.38660332560539246,
204
+ "learning_rate": 0.0001489977728285078,
205
+ "loss": 0.5242,
206
+ "step": 280
207
+ },
208
+ {
209
+ "epoch": 0.6131888463063301,
210
+ "grad_norm": 0.35314109921455383,
211
+ "learning_rate": 0.0001467706013363029,
212
+ "loss": 0.5255,
213
+ "step": 290
214
+ },
215
+ {
216
+ "epoch": 0.6343332892824105,
217
+ "grad_norm": 0.3418401777744293,
218
+ "learning_rate": 0.00014454342984409802,
219
+ "loss": 0.5357,
220
+ "step": 300
221
+ },
222
+ {
223
+ "epoch": 0.6554777322584908,
224
+ "grad_norm": 0.357149213552475,
225
+ "learning_rate": 0.0001423162583518931,
226
+ "loss": 0.5131,
227
+ "step": 310
228
+ },
229
+ {
230
+ "epoch": 0.6766221752345711,
231
+ "grad_norm": 0.3720100224018097,
232
+ "learning_rate": 0.0001400890868596882,
233
+ "loss": 0.5072,
234
+ "step": 320
235
+ },
236
+ {
237
+ "epoch": 0.6977666182106516,
238
+ "grad_norm": 0.342650443315506,
239
+ "learning_rate": 0.0001378619153674833,
240
+ "loss": 0.5194,
241
+ "step": 330
242
+ },
243
+ {
244
+ "epoch": 0.7189110611867319,
245
+ "grad_norm": 0.34781211614608765,
246
+ "learning_rate": 0.00013563474387527841,
247
+ "loss": 0.5094,
248
+ "step": 340
249
+ },
250
+ {
251
+ "epoch": 0.7400555041628122,
252
+ "grad_norm": 0.3401576280593872,
253
+ "learning_rate": 0.00013340757238307352,
254
+ "loss": 0.5192,
255
+ "step": 350
256
+ },
257
+ {
258
+ "epoch": 0.7611999471388926,
259
+ "grad_norm": 0.3490856885910034,
260
+ "learning_rate": 0.0001311804008908686,
261
+ "loss": 0.5045,
262
+ "step": 360
263
+ },
264
+ {
265
+ "epoch": 0.7823443901149729,
266
+ "grad_norm": 0.3488720655441284,
267
+ "learning_rate": 0.0001289532293986637,
268
+ "loss": 0.502,
269
+ "step": 370
270
+ },
271
+ {
272
+ "epoch": 0.8034888330910532,
273
+ "grad_norm": 0.37278613448143005,
274
+ "learning_rate": 0.00012672605790645878,
275
+ "loss": 0.5038,
276
+ "step": 380
277
+ },
278
+ {
279
+ "epoch": 0.8246332760671337,
280
+ "grad_norm": 0.3677748441696167,
281
+ "learning_rate": 0.00012449888641425391,
282
+ "loss": 0.505,
283
+ "step": 390
284
+ },
285
+ {
286
+ "epoch": 0.845777719043214,
287
+ "grad_norm": 0.3815574049949646,
288
+ "learning_rate": 0.00012227171492204902,
289
+ "loss": 0.4997,
290
+ "step": 400
291
+ },
292
+ {
293
+ "epoch": 0.8669221620192943,
294
+ "grad_norm": 0.37245893478393555,
295
+ "learning_rate": 0.0001200445434298441,
296
+ "loss": 0.4989,
297
+ "step": 410
298
+ },
299
+ {
300
+ "epoch": 0.8880666049953746,
301
+ "grad_norm": 0.3642374277114868,
302
+ "learning_rate": 0.0001178173719376392,
303
+ "loss": 0.4992,
304
+ "step": 420
305
+ },
306
+ {
307
+ "epoch": 0.909211047971455,
308
+ "grad_norm": 0.32838189601898193,
309
+ "learning_rate": 0.0001155902004454343,
310
+ "loss": 0.4947,
311
+ "step": 430
312
+ },
313
+ {
314
+ "epoch": 0.9303554909475353,
315
+ "grad_norm": 0.36527854204177856,
316
+ "learning_rate": 0.00011336302895322941,
317
+ "loss": 0.4952,
318
+ "step": 440
319
+ },
320
+ {
321
+ "epoch": 0.9514999339236156,
322
+ "grad_norm": 0.3686304986476898,
323
+ "learning_rate": 0.0001111358574610245,
324
+ "loss": 0.4964,
325
+ "step": 450
326
+ },
327
+ {
328
+ "epoch": 0.9726443768996961,
329
+ "grad_norm": 0.3496793210506439,
330
+ "learning_rate": 0.0001089086859688196,
331
+ "loss": 0.4827,
332
+ "step": 460
333
+ },
334
+ {
335
+ "epoch": 0.9937888198757764,
336
+ "grad_norm": 0.3722958266735077,
337
+ "learning_rate": 0.0001066815144766147,
338
+ "loss": 0.4838,
339
+ "step": 470
340
+ },
341
+ {
342
+ "epoch": 1.0148011100832564,
343
+ "grad_norm": 0.3902372717857361,
344
+ "learning_rate": 0.00010445434298440981,
345
+ "loss": 0.4696,
346
+ "step": 480
347
+ },
348
+ {
349
+ "epoch": 1.0359455530593367,
350
+ "grad_norm": 0.3780229687690735,
351
+ "learning_rate": 0.00010222717149220491,
352
+ "loss": 0.4686,
353
+ "step": 490
354
+ },
355
+ {
356
+ "epoch": 1.057089996035417,
357
+ "grad_norm": 0.3552299737930298,
358
+ "learning_rate": 0.0001,
359
+ "loss": 0.457,
360
+ "step": 500
361
+ },
362
+ {
363
+ "epoch": 1.0782344390114973,
364
+ "grad_norm": 0.3887428045272827,
365
+ "learning_rate": 9.77728285077951e-05,
366
+ "loss": 0.4735,
367
+ "step": 510
368
+ },
369
+ {
370
+ "epoch": 1.0993788819875776,
371
+ "grad_norm": 0.3928622603416443,
372
+ "learning_rate": 9.55456570155902e-05,
373
+ "loss": 0.4675,
374
+ "step": 520
375
+ },
376
+ {
377
+ "epoch": 1.120523324963658,
378
+ "grad_norm": 0.3686327636241913,
379
+ "learning_rate": 9.331848552338531e-05,
380
+ "loss": 0.4804,
381
+ "step": 530
382
+ },
383
+ {
384
+ "epoch": 1.1416677679397385,
385
+ "grad_norm": 0.35772374272346497,
386
+ "learning_rate": 9.109131403118041e-05,
387
+ "loss": 0.4609,
388
+ "step": 540
389
+ },
390
+ {
391
+ "epoch": 1.1628122109158188,
392
+ "grad_norm": 0.35283800959587097,
393
+ "learning_rate": 8.88641425389755e-05,
394
+ "loss": 0.4693,
395
+ "step": 550
396
+ },
397
+ {
398
+ "epoch": 1.183956653891899,
399
+ "grad_norm": 0.37653160095214844,
400
+ "learning_rate": 8.663697104677061e-05,
401
+ "loss": 0.4551,
402
+ "step": 560
403
+ },
404
+ {
405
+ "epoch": 1.2051010968679794,
406
+ "grad_norm": 0.35314637422561646,
407
+ "learning_rate": 8.44097995545657e-05,
408
+ "loss": 0.4539,
409
+ "step": 570
410
+ },
411
+ {
412
+ "epoch": 1.2262455398440597,
413
+ "grad_norm": 0.35260340571403503,
414
+ "learning_rate": 8.21826280623608e-05,
415
+ "loss": 0.4531,
416
+ "step": 580
417
+ },
418
+ {
419
+ "epoch": 1.24738998282014,
420
+ "grad_norm": 0.3616096079349518,
421
+ "learning_rate": 7.995545657015591e-05,
422
+ "loss": 0.4645,
423
+ "step": 590
424
+ },
425
+ {
426
+ "epoch": 1.2685344257962203,
427
+ "grad_norm": 0.3933924436569214,
428
+ "learning_rate": 7.7728285077951e-05,
429
+ "loss": 0.4469,
430
+ "step": 600
431
+ },
432
+ {
433
+ "epoch": 1.2896788687723006,
434
+ "grad_norm": 0.3878353536128998,
435
+ "learning_rate": 7.550111358574611e-05,
436
+ "loss": 0.467,
437
+ "step": 610
438
+ },
439
+ {
440
+ "epoch": 1.3108233117483812,
441
+ "grad_norm": 0.41165846586227417,
442
+ "learning_rate": 7.32739420935412e-05,
443
+ "loss": 0.4504,
444
+ "step": 620
445
+ },
446
+ {
447
+ "epoch": 1.3319677547244615,
448
+ "grad_norm": 0.36190614104270935,
449
+ "learning_rate": 7.10467706013363e-05,
450
+ "loss": 0.4517,
451
+ "step": 630
452
+ },
453
+ {
454
+ "epoch": 1.3531121977005418,
455
+ "grad_norm": 0.3983185887336731,
456
+ "learning_rate": 6.881959910913141e-05,
457
+ "loss": 0.444,
458
+ "step": 640
459
+ },
460
+ {
461
+ "epoch": 1.3742566406766221,
462
+ "grad_norm": 0.38672661781311035,
463
+ "learning_rate": 6.659242761692652e-05,
464
+ "loss": 0.4488,
465
+ "step": 650
466
+ },
467
+ {
468
+ "epoch": 1.3954010836527027,
469
+ "grad_norm": 0.36232879757881165,
470
+ "learning_rate": 6.436525612472161e-05,
471
+ "loss": 0.4371,
472
+ "step": 660
473
+ },
474
+ {
475
+ "epoch": 1.416545526628783,
476
+ "grad_norm": 0.40571126341819763,
477
+ "learning_rate": 6.21380846325167e-05,
478
+ "loss": 0.4427,
479
+ "step": 670
480
+ },
481
+ {
482
+ "epoch": 1.4376899696048633,
483
+ "grad_norm": 0.36234796047210693,
484
+ "learning_rate": 5.9910913140311805e-05,
485
+ "loss": 0.4439,
486
+ "step": 680
487
+ },
488
+ {
489
+ "epoch": 1.4588344125809436,
490
+ "grad_norm": 0.4014786183834076,
491
+ "learning_rate": 5.7683741648106904e-05,
492
+ "loss": 0.4548,
493
+ "step": 690
494
+ },
495
+ {
496
+ "epoch": 1.479978855557024,
497
+ "grad_norm": 0.3884125053882599,
498
+ "learning_rate": 5.545657015590201e-05,
499
+ "loss": 0.4531,
500
+ "step": 700
501
+ },
502
+ {
503
+ "epoch": 1.5011232985331042,
504
+ "grad_norm": 0.3621061146259308,
505
+ "learning_rate": 5.322939866369711e-05,
506
+ "loss": 0.4407,
507
+ "step": 710
508
+ },
509
+ {
510
+ "epoch": 1.5222677415091845,
511
+ "grad_norm": 0.3601549565792084,
512
+ "learning_rate": 5.100222717149221e-05,
513
+ "loss": 0.439,
514
+ "step": 720
515
+ },
516
+ {
517
+ "epoch": 1.5434121844852648,
518
+ "grad_norm": 0.37766754627227783,
519
+ "learning_rate": 4.8775055679287305e-05,
520
+ "loss": 0.4397,
521
+ "step": 730
522
+ },
523
+ {
524
+ "epoch": 1.5645566274613452,
525
+ "grad_norm": 0.38728606700897217,
526
+ "learning_rate": 4.654788418708241e-05,
527
+ "loss": 0.4455,
528
+ "step": 740
529
+ },
530
+ {
531
+ "epoch": 1.5857010704374257,
532
+ "grad_norm": 0.3532933294773102,
533
+ "learning_rate": 4.432071269487751e-05,
534
+ "loss": 0.4375,
535
+ "step": 750
536
+ },
537
+ {
538
+ "epoch": 1.606845513413506,
539
+ "grad_norm": 0.37484633922576904,
540
+ "learning_rate": 4.209354120267261e-05,
541
+ "loss": 0.4386,
542
+ "step": 760
543
+ },
544
+ {
545
+ "epoch": 1.6279899563895863,
546
+ "grad_norm": 0.40252485871315,
547
+ "learning_rate": 3.986636971046771e-05,
548
+ "loss": 0.4394,
549
+ "step": 770
550
+ },
551
+ {
552
+ "epoch": 1.6491343993656669,
553
+ "grad_norm": 0.3895283043384552,
554
+ "learning_rate": 3.7639198218262804e-05,
555
+ "loss": 0.4356,
556
+ "step": 780
557
+ },
558
+ {
559
+ "epoch": 1.6702788423417472,
560
+ "grad_norm": 0.4058088958263397,
561
+ "learning_rate": 3.541202672605791e-05,
562
+ "loss": 0.4461,
563
+ "step": 790
564
+ },
565
+ {
566
+ "epoch": 1.6914232853178275,
567
+ "grad_norm": 0.40314358472824097,
568
+ "learning_rate": 3.318485523385301e-05,
569
+ "loss": 0.4311,
570
+ "step": 800
571
+ }
572
+ ],
573
+ "logging_steps": 10,
574
+ "max_steps": 946,
575
+ "num_input_tokens_seen": 0,
576
+ "num_train_epochs": 2,
577
+ "save_steps": 200,
578
+ "stateful_callbacks": {
579
+ "TrainerControl": {
580
+ "args": {
581
+ "should_epoch_stop": false,
582
+ "should_evaluate": false,
583
+ "should_log": false,
584
+ "should_save": true,
585
+ "should_training_stop": false
586
+ },
587
+ "attributes": {}
588
+ }
589
+ },
590
+ "total_flos": 5.815045548784222e+18,
591
+ "train_batch_size": 1,
592
+ "trial_name": null,
593
+ "trial_params": null
594
+ }
rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-946/README.md ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: /mnt/share01/sqk/models/ChatTime-1-7B-Chat
3
+ library_name: peft
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
200
+ ### Framework versions
201
+
202
+ - PEFT 0.14.0
rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-946/adapter_config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "/mnt/share01/sqk/models/ChatTime-1-7B-Chat",
5
+ "bias": "none",
6
+ "eva_config": null,
7
+ "exclude_modules": null,
8
+ "fan_in_fan_out": false,
9
+ "inference_mode": true,
10
+ "init_lora_weights": true,
11
+ "layer_replication": null,
12
+ "layers_pattern": null,
13
+ "layers_to_transform": null,
14
+ "loftq_config": {},
15
+ "lora_alpha": 32,
16
+ "lora_bias": false,
17
+ "lora_dropout": 0.05,
18
+ "megatron_config": null,
19
+ "megatron_core": "megatron.core",
20
+ "modules_to_save": null,
21
+ "peft_type": "LORA",
22
+ "r": 16,
23
+ "rank_pattern": {},
24
+ "revision": null,
25
+ "target_modules": [
26
+ "gate_proj",
27
+ "o_proj",
28
+ "v_proj",
29
+ "up_proj",
30
+ "q_proj",
31
+ "k_proj",
32
+ "down_proj"
33
+ ],
34
+ "task_type": "CAUSAL_LM",
35
+ "use_dora": false,
36
+ "use_rslora": false
37
+ }
rats40k_adapter/outputs/pipeline_20260608_175250/sft/adapter/checkpoint-946/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
requirements.md ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hardware
2
+
3
+ - CPU: `AMD Ryzen 9 7950X 16-Core Processor`
4
+ - GPU: `NVIDIA GeForce RTX 4090 24GB`
5
+
6
+ # System
7
+
8
+ - Kernel: `Linux-5.15.0-102-generic-x86_64-with-glibc2.35`
9
+ - Distribution: `Ubuntu 22.04.3 LTS`
10
+ - Python: `3.12.11`
11
+
12
+ # Requirements
13
+
14
+ ```
15
+ accelerate==1.8.1
16
+ aiohappyeyeballs==2.6.1
17
+ aiohttp==3.12.13
18
+ aiosignal==1.3.2
19
+ annotated-types==0.7.0
20
+ anyio==4.9.0
21
+ argon2-cffi==25.1.0
22
+ argon2-cffi-bindings==21.2.0
23
+ arrow==1.3.0
24
+ asttokens==3.0.0
25
+ async-lru==2.0.5
26
+ attrs==25.3.0
27
+ babel==2.17.0
28
+ beautifulsoup4==4.13.4
29
+ bleach==6.2.0
30
+ boto3==1.38.46
31
+ botocore==1.38.46
32
+ brotlicffi==1.0.9.2
33
+ certifi==2025.6.15
34
+ cffi==1.17.1
35
+ charset-normalizer==3.1.0
36
+ click==8.2.1
37
+ comm==0.2.2
38
+ contourpy==1.3.2
39
+ cycler==0.12.1
40
+ datasets==3.6.0
41
+ debugpy==1.8.14
42
+ decorator==5.2.1
43
+ defusedxml==0.7.1
44
+ dill==0.3.8
45
+ distro==1.9.0
46
+ einops==0.8.1
47
+ et_xmlfile==2.0.0
48
+ executing==2.2.0
49
+ fastjsonschema==2.21.1
50
+ filelock==3.13.1
51
+ fonttools==4.58.4
52
+ fqdn==1.5.1
53
+ frozenlist==1.7.0
54
+ fsspec==2024.6.1
55
+ h11==0.16.0
56
+ hf-xet==1.1.5
57
+ holidays==0.75
58
+ httpcore==1.0.9
59
+ httpx==0.28.1
60
+ huggingface-hub==0.33.1
61
+ idna==3.10
62
+ ipykernel==6.29.5
63
+ ipython==9.3.0
64
+ ipython_pygments_lexers==1.1.1
65
+ ipywidgets==8.1.7
66
+ isoduration==20.11.0
67
+ jedi==0.19.2
68
+ Jinja2==3.1.4
69
+ jiter==0.10.0
70
+ jmespath==1.0.1
71
+ joblib==1.5.1
72
+ json5==0.12.0
73
+ jsonpointer==3.0.0
74
+ jsonschema==4.24.0
75
+ jsonschema-specifications==2025.4.1
76
+ jupyter==1.1.1
77
+ jupyter_client==8.6.3
78
+ jupyter-console==6.6.3
79
+ jupyter_core==5.8.1
80
+ jupyter-events==0.12.0
81
+ jupyter-lsp==2.2.5
82
+ jupyter_server==2.16.0
83
+ jupyter_server_terminals==0.5.3
84
+ jupyterlab==4.4.4
85
+ jupyterlab_pygments==0.3.0
86
+ jupyterlab_server==2.27.3
87
+ jupyterlab_widgets==3.0.15
88
+ kiwisolver==1.4.8
89
+ MarkupSafe==2.1.5
90
+ matplotlib==3.9.0
91
+ matplotlib-inline==0.1.7
92
+ mistune==3.1.3
93
+ mpmath==1.3.0
94
+ multidict==6.6.2
95
+ multiprocess==0.70.16
96
+ nbclient==0.10.2
97
+ nbconvert==7.16.6
98
+ nbformat==5.10.4
99
+ nest-asyncio==1.6.0
100
+ networkx==3.3
101
+ notebook==7.4.4
102
+ notebook_shim==0.2.4
103
+ numpy==2.1.2
104
+ nvidia-cublas-cu11==11.11.3.6
105
+ nvidia-cuda-cupti-cu11==11.8.87
106
+ nvidia-cuda-nvrtc-cu11==11.8.89
107
+ nvidia-cuda-runtime-cu11==11.8.89
108
+ nvidia-cudnn-cu11==9.1.0.70
109
+ nvidia-cufft-cu11==10.9.0.58
110
+ nvidia-curand-cu11==10.3.0.86
111
+ nvidia-cusolver-cu11==11.4.1.48
112
+ nvidia-cusparse-cu11==11.7.5.86
113
+ nvidia-ml-py==12.575.51
114
+ nvidia-nccl-cu11==2.21.5
115
+ nvidia-nvtx-cu11==11.8.86
116
+ openai==1.93.0
117
+ openpyxl==3.1.5
118
+ overrides==7.7.0
119
+ packaging==25.0
120
+ pandas==2.3.0
121
+ pandocfilters==1.5.1
122
+ parso==0.8.4
123
+ patsy==1.0.1
124
+ peft==0.15.2
125
+ pexpect==4.9.0
126
+ pillow==11.0.0
127
+ pip==25.1
128
+ platformdirs==4.3.8
129
+ prettytable==3.16.0
130
+ prometheus_client==0.22.1
131
+ prompt_toolkit==3.0.51
132
+ propcache==0.3.2
133
+ protobuf==6.31.1
134
+ psutil==7.0.0
135
+ ptyprocess==0.7.0
136
+ pure_eval==0.2.3
137
+ pyarrow==20.0.0
138
+ pycparser==2.21
139
+ pydantic==2.11.7
140
+ pydantic_core==2.33.2
141
+ pyecharts==2.0.8
142
+ Pygments==2.19.2
143
+ pynvml==12.0.0
144
+ pyparsing==3.2.3
145
+ PySocks==1.7.1
146
+ python-dateutil==2.9.0.post0
147
+ python-json-logger==3.3.0
148
+ pytz==2025.2
149
+ PyYAML==6.0.2
150
+ pyzmq==27.0.0
151
+ referencing==0.36.2
152
+ regex==2024.11.6
153
+ requests==2.32.4
154
+ rfc3339-validator==0.1.4
155
+ rfc3986-validator==0.1.1
156
+ rpds-py==0.25.1
157
+ s3transfer==0.13.0
158
+ safetensors==0.5.3
159
+ scikit-learn==1.7.0
160
+ scipy==1.16.0
161
+ seaborn==0.13.2
162
+ Send2Trash==1.8.3
163
+ sentencepiece==0.2.0
164
+ setuptools==78.1.1
165
+ simplejson==3.20.1
166
+ six==1.17.0
167
+ sniffio==1.3.1
168
+ soupsieve==2.7
169
+ stack-data==0.6.3
170
+ statsmodels==0.14.4
171
+ swankit==0.2.4
172
+ swanlab==0.6.4
173
+ sympy==1.13.3
174
+ terminado==0.18.1
175
+ threadpoolctl==3.6.0
176
+ tinycss2==1.4.0
177
+ tokenizers==0.21.2
178
+ torch==2.7.1+cu118
179
+ torchaudio==2.7.1+cu118
180
+ torchvision==0.22.1+cu118
181
+ tornado==6.5.1
182
+ tqdm==4.67.1
183
+ traitlets==5.14.3
184
+ transformers==4.53.0
185
+ triton==3.3.1
186
+ types-python-dateutil==2.9.0.20250516
187
+ typing_extensions==4.12.2
188
+ typing-inspection==0.4.1
189
+ tzdata==2025.2
190
+ uri-template==1.3.0
191
+ urllib3==2.5.0
192
+ wcwidth==0.2.13
193
+ webcolors==24.11.1
194
+ webencodings==0.5.1
195
+ websocket-client==1.8.0
196
+ wheel==0.45.1
197
+ widgetsnbextension==4.0.14
198
+ wrapt==1.17.2
199
+ xxhash==3.5.0
200
+ yarl==1.20.1
201
+ ```
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ accelerate==1.8.1
2
+ datasets==3.6.0
3
+ huggingface-hub==0.33.1
4
+ numpy==2.1.2
5
+ pandas==2.3.0
6
+ scikit-learn==1.7.0
7
+ torch==2.7.1+cu118
8
+ transformers==4.53.0
tsqa_adapter/README.md ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TSQA Adapter for ChatTime
2
+
3
+ This folder adapts ChatTime to the **Time-MQA TSQA** multi-task time-series QA
4
+ benchmark (`/mnt/share01/sqk/datasets/Time-MQA_TSQA/tmp`). It is the TSQA analog
5
+ of `rats40k_adapter` and is meant to fill in the **ChatTime TSQA baseline**.
6
+
7
+ The dataset has four source groups with free-text answers:
8
+ `anomaly_detection`, `classification`, `forecasting`, `open_ended` (the
9
+ `open_ended` group mixes `multiple_choice`, `true_false` and open questions).
10
+
11
+ ## How ChatTime is fed
12
+
13
+ ChatTime has no chat template, so prompts use ChatTime's native analysis
14
+ template (`utils.prompt.getPrompt`):
15
+
16
+ * `### Instruction` = the TSQA `question`, kept **verbatim** (including any
17
+ numbers embedded in the text, so forecasting keeps its absolute scale).
18
+ * `### Input` = the `time_series` field discretised + serialised into ChatTime's
19
+ native time-series tokens (`###value###`).
20
+ * `### Response` = the free-text `answer` (the SFT target).
21
+
22
+ Some context-enhanced forecasting questions are much longer than ChatTime's
23
+ 4096-token context (e.g. an earnings-call transcript with a tiny series).
24
+ Prompts are therefore **left-truncated** — keeping the serialized series, the
25
+ trailing ask and (in training) the full response — instead of failing.
26
+
27
+ ## Metrics
28
+
29
+ Evaluation reuses the **canonical Time-MQA evaluator**
30
+ (`MQA/data_utils.compute_group_metrics`), so the numbers are directly comparable
31
+ to the other TSQA baselines (MQA / ITFormer). Per group:
32
+
33
+ * `anomaly_detection`: accuracy (normal vs anomaly label parsing)
34
+ * `classification`: accuracy (class-label parsing)
35
+ * `forecasting`: MSE / MAE over parsed forecast values
36
+ * `open_ended`: accuracy (multiple-choice / true-false / semantic / numeric)
37
+
38
+ `eval_tsqa.py` writes `predictions.jsonl` and `metrics.json` (with a `by_group`
39
+ block) under the eval output directory.
40
+
41
+ ## Required inputs
42
+
43
+ - `MODEL_PATH`: local ChatTime model dir. Default
44
+ `/mnt/share01/sqk/models/ChatTime-1-7B-Chat`.
45
+ - `PYTHON_BIN`: Python executable. Defaults to
46
+ `/dev/shm/suiqk/conda_envs/scalerag-ts-v4/bin/python` (override if your env
47
+ lives elsewhere, e.g. `/home/suiqk/anaconda3/envs/scalerag-ts-v4/bin/python`).
48
+ - `MQA_DIR`: defaults to `/mnt/share01/sqk/MQA` (provides the shared evaluator).
49
+ - `DATA_ROOT`: defaults to `/mnt/share01/sqk/datasets/Time-MQA_TSQA/tmp`.
50
+
51
+ The defaults target the **4× V100** machine: FP16 LoRA with `LOAD_IN_4BIT=0`,
52
+ `PER_DEVICE_TRAIN_BATCH_SIZE=1`, `GRADIENT_ACCUMULATION_STEPS=16`, the 4-GPU
53
+ accelerate config at `/mnt/share01/sqk/ITFormer/accelerate_config.yaml`.
54
+ Generation defaults: `MAX_NEW_TOKENS=256`, `MAX_INPUT_TOKENS=3840`,
55
+ `MAX_SEQ_LENGTH=4096`.
56
+
57
+ ## SFT + Eval
58
+
59
+ ```bash
60
+ cd /mnt/share01/sqk/ChatTime
61
+ MODEL_PATH=/mnt/share01/sqk/models/ChatTime-1-7B-Chat \
62
+ bash tsqa_adapter/run_sft_4gpu.sh
63
+ ```
64
+
65
+ ## Smoke test
66
+
67
+ ```bash
68
+ cd /mnt/share01/sqk/ChatTime
69
+ MAX_TRAIN_SAMPLES=128 MAX_EVAL_SAMPLES=64 bash tsqa_adapter/run_sft_4gpu.sh
70
+ ```
71
+
72
+ Outputs land in `tsqa_adapter/outputs/sft_<RUN_ID>/{adapter,eval}` and logs in
73
+ `tsqa_adapter/logs/`.
tsqa_adapter/eval_tsqa.py ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Evaluate ChatTime on the Time-MQA TSQA benchmark.
2
+
3
+ Adapted from ``rats40k_adapter/eval_rats40k.py``. Generation is sharded across
4
+ ranks; each rank writes a JSONL shard, then rank 0 merges, computes per-group
5
+ metrics with the canonical Time-MQA evaluator and writes ``predictions.jsonl``
6
+ plus ``metrics.json``.
7
+
8
+ Over-long prompts are LEFT-truncated to ``--max_input_tokens`` so the series and
9
+ the trailing ask survive (ChatTime's context is only 4096 tokens while some
10
+ context-enhanced forecasting questions are much longer).
11
+ """
12
+
13
+ import argparse
14
+ import copy
15
+ import json
16
+ import os
17
+ from pathlib import Path
18
+
19
+ import torch
20
+ import torch.distributed as dist
21
+ from tqdm import tqdm
22
+ from transformers import AutoModelForCausalLM, AutoTokenizer
23
+
24
+ from tsqa_common import (
25
+ atomic_write_json,
26
+ balanced_limit,
27
+ build_prompt,
28
+ build_result_row,
29
+ compute_tsqa_metrics,
30
+ load_tsqa_records,
31
+ resolve_data_file,
32
+ write_jsonl,
33
+ )
34
+
35
+
36
+ def parse_args():
37
+ parser = argparse.ArgumentParser(description="Evaluate ChatTime on Time-MQA TSQA.")
38
+ parser.add_argument("--model_path", required=True)
39
+ parser.add_argument("--adapter_path", default=None)
40
+ parser.add_argument("--data_root", default="/mnt/share01/sqk/datasets/Time-MQA_TSQA/tmp")
41
+ parser.add_argument("--eval_file", default="eval.jsonl")
42
+ parser.add_argument("--output_dir", required=True)
43
+ parser.add_argument("--max_eval_samples", type=int, default=None)
44
+ parser.add_argument("--eval_batch_size", type=int, default=4)
45
+ parser.add_argument("--max_input_tokens", type=int, default=3840)
46
+ parser.add_argument("--max_new_tokens", type=int, default=256)
47
+ parser.add_argument("--temperature", type=float, default=0.0)
48
+ parser.add_argument("--top_p", type=float, default=1.0)
49
+ parser.add_argument("--top_k", type=int, default=50)
50
+ parser.add_argument("--repetition_penalty", type=float, default=1.0)
51
+ parser.add_argument("--torch_dtype", choices=["auto", "bf16", "fp16", "fp32"], default="fp16")
52
+ parser.add_argument("--allow_hf_download", action="store_true")
53
+ return parser.parse_args()
54
+
55
+
56
+ def init_distributed():
57
+ world_size = int(os.environ.get("WORLD_SIZE", "1"))
58
+ rank = int(os.environ.get("RANK", "0"))
59
+ local_rank = int(os.environ.get("LOCAL_RANK", "0"))
60
+ if torch.cuda.is_available():
61
+ torch.cuda.set_device(local_rank)
62
+ if world_size > 1 and not dist.is_initialized():
63
+ dist.init_process_group(backend="nccl")
64
+ return rank, local_rank, world_size
65
+
66
+
67
+ def dtype_from_arg(value):
68
+ if value == "auto":
69
+ return "auto"
70
+ if value == "bf16":
71
+ return torch.bfloat16
72
+ if value == "fp16":
73
+ return torch.float16
74
+ return torch.float32
75
+
76
+
77
+ def load_model_and_tokenizer(args, local_rank):
78
+ local_files_only = not args.allow_hf_download
79
+ tokenizer = AutoTokenizer.from_pretrained(
80
+ args.model_path,
81
+ trust_remote_code=True,
82
+ local_files_only=local_files_only,
83
+ )
84
+ if tokenizer.pad_token is None:
85
+ tokenizer.pad_token = tokenizer.eos_token
86
+ tokenizer.padding_side = "left"
87
+ # Keep the series and the trailing ask when a prompt is too long.
88
+ tokenizer.truncation_side = "left"
89
+
90
+ device = f"cuda:{local_rank}" if torch.cuda.is_available() else "cpu"
91
+ model = AutoModelForCausalLM.from_pretrained(
92
+ args.model_path,
93
+ trust_remote_code=True,
94
+ torch_dtype=dtype_from_arg(args.torch_dtype),
95
+ low_cpu_mem_usage=True,
96
+ device_map={"": device} if torch.cuda.is_available() else None,
97
+ local_files_only=local_files_only,
98
+ )
99
+
100
+ if args.adapter_path:
101
+ from peft import PeftModel
102
+
103
+ model = PeftModel.from_pretrained(
104
+ model,
105
+ args.adapter_path,
106
+ local_files_only=local_files_only,
107
+ )
108
+
109
+ model.eval()
110
+ return model, tokenizer, device
111
+
112
+
113
+ def generate_responses(model, tokenizer, device, prompts, args):
114
+ model_context = getattr(model.config, "max_position_embeddings", None)
115
+ max_input_tokens = args.max_input_tokens
116
+ if model_context and max_input_tokens + args.max_new_tokens > model_context:
117
+ max_input_tokens = max(1, model_context - args.max_new_tokens)
118
+
119
+ inputs = tokenizer(
120
+ prompts,
121
+ return_tensors="pt",
122
+ padding=True,
123
+ truncation=True,
124
+ max_length=max_input_tokens,
125
+ )
126
+ inputs = {key: value.to(device) for key, value in inputs.items()}
127
+
128
+ do_sample = args.temperature > 0
129
+ generation_config = copy.deepcopy(model.generation_config)
130
+ generation_config.do_sample = do_sample
131
+ generation_config.pad_token_id = tokenizer.pad_token_id
132
+ generation_config.eos_token_id = tokenizer.eos_token_id
133
+ if do_sample:
134
+ generation_config.temperature = args.temperature
135
+ generation_config.top_p = args.top_p
136
+ generation_config.top_k = args.top_k
137
+ else:
138
+ generation_config.temperature = None
139
+ generation_config.top_p = None
140
+ generation_config.top_k = None
141
+
142
+ with torch.inference_mode():
143
+ output = model.generate(
144
+ **inputs,
145
+ generation_config=generation_config,
146
+ max_new_tokens=args.max_new_tokens,
147
+ repetition_penalty=args.repetition_penalty,
148
+ )
149
+ new_tokens = output[:, inputs["input_ids"].shape[-1]:]
150
+ return [
151
+ response.strip()
152
+ for response in tokenizer.batch_decode(new_tokens, skip_special_tokens=True)
153
+ ]
154
+
155
+
156
+ def main():
157
+ args = parse_args()
158
+ rank, local_rank, world_size = init_distributed()
159
+ output_dir = Path(args.output_dir)
160
+ shard_dir = output_dir / "shards"
161
+ shard_dir.mkdir(parents=True, exist_ok=True)
162
+
163
+ data_path = resolve_data_file(args.data_root, args.eval_file)
164
+ records = load_tsqa_records(data_path)
165
+ records = balanced_limit(records, args.max_eval_samples)
166
+ shard_records = records[rank::world_size]
167
+
168
+ if rank == 0:
169
+ print(f"Dataset: {data_path}")
170
+ print(f"Total samples: {len(records)}")
171
+ print(f"World size: {world_size}")
172
+ print(f"Per-device eval batch size: {args.eval_batch_size}")
173
+ print(f"Maximum global eval batch size: {args.eval_batch_size * world_size}")
174
+ print(f"Output dir: {output_dir}")
175
+
176
+ model, tokenizer, device = load_model_and_tokenizer(args, local_rank)
177
+
178
+ results = []
179
+ batch_size = max(1, args.eval_batch_size)
180
+ batch_starts = range(0, len(shard_records), batch_size)
181
+ for start in tqdm(
182
+ batch_starts,
183
+ total=(len(shard_records) + batch_size - 1) // batch_size,
184
+ desc=f"rank {rank}",
185
+ disable=rank != 0,
186
+ ):
187
+ batch = shard_records[start:start + batch_size]
188
+ prompts = [
189
+ build_prompt(record["question"], record.get("time_series") or [])
190
+ for record in batch
191
+ ]
192
+ responses = generate_responses(model, tokenizer, device, prompts, args)
193
+ for record, response in zip(batch, responses):
194
+ results.append(build_result_row(record, response))
195
+
196
+ shard_path = shard_dir / f"predictions.rank{rank}.jsonl"
197
+ write_jsonl(results, shard_path)
198
+
199
+ if world_size > 1:
200
+ dist.barrier()
201
+
202
+ if rank == 0:
203
+ merged = []
204
+ for shard_rank in range(world_size):
205
+ path = shard_dir / f"predictions.rank{shard_rank}.jsonl"
206
+ with open(path, "r", encoding="utf-8") as handle:
207
+ for line in handle:
208
+ line = line.strip()
209
+ if line:
210
+ merged.append(json.loads(line))
211
+ merged.sort(key=lambda row: str(row.get("id")))
212
+
213
+ predictions_path = output_dir / "predictions.jsonl"
214
+ metrics_path = output_dir / "metrics.json"
215
+ write_jsonl(merged, predictions_path)
216
+ metrics = compute_tsqa_metrics(merged)
217
+ atomic_write_json(metrics, metrics_path)
218
+ print(json.dumps(metrics, ensure_ascii=False, indent=2))
219
+ print(f"Saved predictions: {predictions_path}")
220
+ print(f"Saved metrics: {metrics_path}")
221
+
222
+ if world_size > 1:
223
+ dist.barrier()
224
+ dist.destroy_process_group()
225
+
226
+
227
+ if __name__ == "__main__":
228
+ main()
tsqa_adapter/finetune_tsqa_lora.py ADDED
@@ -0,0 +1,351 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """LoRA SFT for ChatTime on the Time-MQA TSQA multi-task QA benchmark.
2
+
3
+ Adapted from ``rats40k_adapter/finetune_rats40k_lora.py``. The main differences:
4
+
5
+ * Data comes from TSQA JSONL (``train.jsonl``) with free-text answers.
6
+ * Prompts use ChatTime's native analysis template with the question in
7
+ ``### Instruction`` and the serialised series in ``### Input``.
8
+ * Over-long rows (prompt+response beyond ``max_seq_length``) are SKIPPED by
9
+ default (``--skip_overlong``) so they never reach the GPU -- this prevents OOM
10
+ and avoids training on truncated junk, since some context-enhanced forecasting
11
+ questions exceed ChatTime's 4096-token context. Pass ``--no_skip_overlong`` to
12
+ fall back to left-truncation (keeping the series, the trailing ask and the full
13
+ response) instead.
14
+ """
15
+
16
+ import argparse
17
+ import inspect
18
+ import os
19
+ from pathlib import Path
20
+
21
+ import torch
22
+ from torch.utils.data import Dataset
23
+ from transformers import AutoModelForCausalLM, AutoTokenizer, Trainer, TrainingArguments
24
+
25
+ from tsqa_common import (
26
+ balanced_limit,
27
+ build_prompt,
28
+ load_tsqa_records,
29
+ resolve_data_file,
30
+ )
31
+
32
+
33
+ def patch_accelerate_compatibility():
34
+ from accelerate import Accelerator
35
+
36
+ signature = inspect.signature(Accelerator.unwrap_model)
37
+ if "keep_torch_compile" in signature.parameters:
38
+ return
39
+
40
+ original_unwrap_model = Accelerator.unwrap_model
41
+
42
+ def unwrap_model_compat(self, model, keep_fp32_wrapper=True, keep_torch_compile=True):
43
+ del keep_torch_compile
44
+ return original_unwrap_model(self, model, keep_fp32_wrapper=keep_fp32_wrapper)
45
+
46
+ Accelerator.unwrap_model = unwrap_model_compat
47
+ print(
48
+ "Applied accelerate compatibility patch: "
49
+ "Accelerator.unwrap_model accepts keep_torch_compile."
50
+ )
51
+
52
+
53
+ class PromptResponseDataset(Dataset):
54
+ def __init__(self, rows, tokenizer, max_seq_length, skip_overlong=True):
55
+ self.tokenizer = tokenizer
56
+ self.max_seq_length = max_seq_length
57
+ self.skip_overlong = skip_overlong
58
+ # Filtering is deterministic (same rows, tokenizer and threshold on every
59
+ # rank), so all DDP ranks agree on the kept set and dataset length.
60
+ self.rows = self._prepare_rows(rows)
61
+
62
+ def __len__(self):
63
+ return len(self.rows)
64
+
65
+ def _raw_encode(self, prompt, response):
66
+ prompt_ids = self.tokenizer(
67
+ prompt,
68
+ add_special_tokens=True,
69
+ truncation=False,
70
+ )["input_ids"]
71
+ response_ids = self.tokenizer(
72
+ response + self.tokenizer.eos_token,
73
+ add_special_tokens=False,
74
+ truncation=False,
75
+ )["input_ids"]
76
+ return prompt_ids, response_ids
77
+
78
+ def _fit(self, prompt_ids, response_ids):
79
+ # Always keep the full response; left-truncate the prompt to fit so the
80
+ # series, the trailing ask and the ### Response marker survive.
81
+ max_prompt = self.max_seq_length - len(response_ids)
82
+ truncated = False
83
+ if max_prompt < 1:
84
+ # Pathological: response alone exceeds the budget. Keep the response
85
+ # tail and a single prompt token so the example stays well-formed.
86
+ response_ids = response_ids[-(self.max_seq_length - 1):]
87
+ prompt_ids = prompt_ids[-1:]
88
+ truncated = True
89
+ elif len(prompt_ids) > max_prompt:
90
+ prompt_ids = prompt_ids[-max_prompt:]
91
+ truncated = True
92
+ return prompt_ids, response_ids, truncated
93
+
94
+ def _prepare_rows(self, rows):
95
+ kept = []
96
+ skipped = 0
97
+ truncated = 0
98
+ max_prompt_len = 0
99
+ max_total_len = 0
100
+ for row in rows:
101
+ _, prompt, response = row
102
+ prompt_ids, response_ids = self._raw_encode(prompt, response)
103
+ total = len(prompt_ids) + len(response_ids)
104
+ if total > self.max_seq_length:
105
+ if self.skip_overlong:
106
+ # Drop over-long examples outright so they never reach the
107
+ # GPU (prevents OOM and avoids training on truncated junk).
108
+ skipped += 1
109
+ continue
110
+ prompt_ids, response_ids, _ = self._fit(prompt_ids, response_ids)
111
+ total = len(prompt_ids) + len(response_ids)
112
+ truncated += 1
113
+ max_prompt_len = max(max_prompt_len, len(prompt_ids))
114
+ max_total_len = max(max_total_len, total)
115
+ kept.append(row)
116
+ print(
117
+ "SFT token length check: "
118
+ f"input_rows={len(rows)}, "
119
+ f"kept_rows={len(kept)}, "
120
+ f"skipped_overlong={skipped}, "
121
+ f"left_truncated_rows={truncated}, "
122
+ f"max_prompt_len={max_prompt_len}, "
123
+ f"max_total_len={max_total_len}, "
124
+ f"max_seq_length={self.max_seq_length}, "
125
+ f"skip_overlong={self.skip_overlong}"
126
+ )
127
+ return kept
128
+
129
+ def __getitem__(self, index):
130
+ _, prompt, response = self.rows[index]
131
+ prompt_ids, response_ids = self._raw_encode(prompt, response)
132
+ # Safety net: kept rows already fit when skip_overlong is on, but clamp
133
+ # anyway so a stray over-long row can never blow up the batch.
134
+ prompt_ids, response_ids, _ = self._fit(prompt_ids, response_ids)
135
+ input_ids = prompt_ids + response_ids
136
+ labels = [-100] * len(prompt_ids) + response_ids
137
+ attention_mask = [1] * len(input_ids)
138
+ return {
139
+ "input_ids": input_ids,
140
+ "attention_mask": attention_mask,
141
+ "labels": labels,
142
+ }
143
+
144
+
145
+ class CausalLMCollator:
146
+ def __init__(self, tokenizer):
147
+ self.tokenizer = tokenizer
148
+
149
+ def __call__(self, features):
150
+ max_len = max(len(feature["input_ids"]) for feature in features)
151
+ input_ids = []
152
+ attention_mask = []
153
+ labels = []
154
+ for feature in features:
155
+ pad_len = max_len - len(feature["input_ids"])
156
+ input_ids.append(feature["input_ids"] + [self.tokenizer.pad_token_id] * pad_len)
157
+ attention_mask.append(feature["attention_mask"] + [0] * pad_len)
158
+ labels.append(feature["labels"] + [-100] * pad_len)
159
+ return {
160
+ "input_ids": torch.tensor(input_ids, dtype=torch.long),
161
+ "attention_mask": torch.tensor(attention_mask, dtype=torch.long),
162
+ "labels": torch.tensor(labels, dtype=torch.long),
163
+ }
164
+
165
+
166
+ def parse_args():
167
+ parser = argparse.ArgumentParser(
168
+ description="LoRA SFT for ChatTime on Time-MQA TSQA multi-task QA."
169
+ )
170
+ parser.add_argument("--model_path", required=True)
171
+ parser.add_argument("--data_root", default="/mnt/share01/sqk/datasets/Time-MQA_TSQA/tmp")
172
+ parser.add_argument("--train_file", default="train.jsonl")
173
+ parser.add_argument("--output_dir", required=True)
174
+ parser.add_argument("--max_train_samples", type=int, default=None)
175
+ parser.add_argument("--max_seq_length", type=int, default=4096)
176
+ parser.add_argument(
177
+ "--skip_overlong",
178
+ dest="skip_overlong",
179
+ action="store_true",
180
+ default=True,
181
+ help="Skip training rows whose prompt+response exceeds max_seq_length (default).",
182
+ )
183
+ parser.add_argument(
184
+ "--no_skip_overlong",
185
+ dest="skip_overlong",
186
+ action="store_false",
187
+ help="Left-truncate over-long rows instead of skipping them.",
188
+ )
189
+ parser.add_argument("--per_device_train_batch_size", type=int, default=2)
190
+ parser.add_argument("--gradient_accumulation_steps", type=int, default=8)
191
+ parser.add_argument("--num_train_epochs", type=float, default=2.0)
192
+ parser.add_argument("--learning_rate", type=float, default=2e-4)
193
+ parser.add_argument("--warmup_ratio", type=float, default=0.05)
194
+ parser.add_argument("--weight_decay", type=float, default=0.01)
195
+ parser.add_argument("--logging_steps", type=int, default=10)
196
+ parser.add_argument("--save_steps", type=int, default=200)
197
+ parser.add_argument("--save_total_limit", type=int, default=2)
198
+ parser.add_argument("--dataloader_num_workers", type=int, default=4)
199
+ parser.add_argument("--lora_rank", type=int, default=16)
200
+ parser.add_argument("--lora_alpha", type=int, default=32)
201
+ parser.add_argument("--lora_dropout", type=float, default=0.05)
202
+ parser.add_argument("--load_in_4bit", action="store_true")
203
+ parser.add_argument("--gradient_checkpointing", action="store_true")
204
+ parser.add_argument("--torch_dtype", choices=["bf16", "fp16", "fp32"], default="fp16")
205
+ parser.add_argument("--allow_hf_download", action="store_true")
206
+ return parser.parse_args()
207
+
208
+
209
+ def dtype_from_arg(value):
210
+ if value == "bf16":
211
+ return torch.bfloat16
212
+ if value == "fp16":
213
+ return torch.float16
214
+ return torch.float32
215
+
216
+
217
+ def local_rank():
218
+ return int(os.environ.get("LOCAL_RANK", "0"))
219
+
220
+
221
+ def build_rows(data_root, train_file, max_samples):
222
+ path = resolve_data_file(data_root, train_file)
223
+ records = load_tsqa_records(path)
224
+ records = balanced_limit(records, max_samples)
225
+ rows = []
226
+ for index, record in enumerate(records):
227
+ prompt = build_prompt(record["question"], record.get("time_series") or [])
228
+ response = str(record["answer"]).strip()
229
+ row_id = str(record.get("id") or index)
230
+ rows.append((row_id, prompt, response))
231
+ return rows
232
+
233
+
234
+ def load_model(args):
235
+ try:
236
+ from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training
237
+ except Exception as exc:
238
+ raise RuntimeError(
239
+ "peft is required for SFT. Install peft in the selected Python environment."
240
+ ) from exc
241
+
242
+ dtype = dtype_from_arg(args.torch_dtype)
243
+ local_files_only = not args.allow_hf_download
244
+ device = f"cuda:{local_rank()}" if torch.cuda.is_available() else "cpu"
245
+
246
+ quantization_config = None
247
+ if args.load_in_4bit:
248
+ from transformers import BitsAndBytesConfig
249
+
250
+ quantization_config = BitsAndBytesConfig(
251
+ load_in_4bit=True,
252
+ bnb_4bit_compute_dtype=dtype,
253
+ bnb_4bit_quant_type="nf4",
254
+ bnb_4bit_use_double_quant=True,
255
+ )
256
+
257
+ model = AutoModelForCausalLM.from_pretrained(
258
+ args.model_path,
259
+ trust_remote_code=True,
260
+ torch_dtype=dtype,
261
+ low_cpu_mem_usage=True,
262
+ quantization_config=quantization_config,
263
+ device_map={"": device} if torch.cuda.is_available() and args.load_in_4bit else None,
264
+ local_files_only=local_files_only,
265
+ )
266
+ if not args.load_in_4bit and torch.cuda.is_available():
267
+ model.to(device)
268
+ if args.load_in_4bit:
269
+ model = prepare_model_for_kbit_training(
270
+ model,
271
+ use_gradient_checkpointing=args.gradient_checkpointing,
272
+ )
273
+ elif args.gradient_checkpointing:
274
+ model.gradient_checkpointing_enable()
275
+
276
+ lora_config = LoraConfig(
277
+ r=args.lora_rank,
278
+ lora_alpha=args.lora_alpha,
279
+ lora_dropout=args.lora_dropout,
280
+ bias="none",
281
+ task_type="CAUSAL_LM",
282
+ target_modules=[
283
+ "q_proj",
284
+ "k_proj",
285
+ "v_proj",
286
+ "o_proj",
287
+ "gate_proj",
288
+ "up_proj",
289
+ "down_proj",
290
+ ],
291
+ )
292
+ model = get_peft_model(model, lora_config)
293
+ model.print_trainable_parameters()
294
+ return model
295
+
296
+
297
+ def main():
298
+ args = parse_args()
299
+ patch_accelerate_compatibility()
300
+ if torch.cuda.is_available():
301
+ torch.cuda.set_device(local_rank())
302
+
303
+ local_files_only = not args.allow_hf_download
304
+ tokenizer = AutoTokenizer.from_pretrained(
305
+ args.model_path,
306
+ trust_remote_code=True,
307
+ local_files_only=local_files_only,
308
+ )
309
+ if tokenizer.pad_token is None:
310
+ tokenizer.pad_token = tokenizer.eos_token
311
+ tokenizer.padding_side = "right"
312
+
313
+ rows = build_rows(args.data_root, args.train_file, args.max_train_samples)
314
+ train_dataset = PromptResponseDataset(
315
+ rows, tokenizer, args.max_seq_length, skip_overlong=args.skip_overlong
316
+ )
317
+ model = load_model(args)
318
+
319
+ bf16 = args.torch_dtype == "bf16"
320
+ fp16 = args.torch_dtype == "fp16"
321
+ training_args = TrainingArguments(
322
+ output_dir=args.output_dir,
323
+ per_device_train_batch_size=args.per_device_train_batch_size,
324
+ gradient_accumulation_steps=args.gradient_accumulation_steps,
325
+ num_train_epochs=args.num_train_epochs,
326
+ learning_rate=args.learning_rate,
327
+ warmup_ratio=args.warmup_ratio,
328
+ weight_decay=args.weight_decay,
329
+ logging_steps=args.logging_steps,
330
+ save_steps=args.save_steps,
331
+ save_total_limit=args.save_total_limit,
332
+ dataloader_num_workers=args.dataloader_num_workers,
333
+ bf16=bf16,
334
+ fp16=fp16,
335
+ report_to="none",
336
+ remove_unused_columns=False,
337
+ ddp_find_unused_parameters=False,
338
+ )
339
+ trainer = Trainer(
340
+ model=model,
341
+ args=training_args,
342
+ train_dataset=train_dataset,
343
+ data_collator=CausalLMCollator(tokenizer),
344
+ )
345
+ trainer.train()
346
+ trainer.save_model(args.output_dir)
347
+ tokenizer.save_pretrained(args.output_dir)
348
+
349
+
350
+ if __name__ == "__main__":
351
+ main()
tsqa_adapter/outputs/sft_20260615_141604/adapter/README.md ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: /mnt/share01/sqk/models/ChatTime-1-7B-Chat
3
+ library_name: peft
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
200
+ ### Framework versions
201
+
202
+ - PEFT 0.14.0
tsqa_adapter/outputs/sft_20260615_141604/adapter/adapter_config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "/mnt/share01/sqk/models/ChatTime-1-7B-Chat",
5
+ "bias": "none",
6
+ "eva_config": null,
7
+ "exclude_modules": null,
8
+ "fan_in_fan_out": false,
9
+ "inference_mode": true,
10
+ "init_lora_weights": true,
11
+ "layer_replication": null,
12
+ "layers_pattern": null,
13
+ "layers_to_transform": null,
14
+ "loftq_config": {},
15
+ "lora_alpha": 32,
16
+ "lora_bias": false,
17
+ "lora_dropout": 0.05,
18
+ "megatron_config": null,
19
+ "megatron_core": "megatron.core",
20
+ "modules_to_save": null,
21
+ "peft_type": "LORA",
22
+ "r": 16,
23
+ "rank_pattern": {},
24
+ "revision": null,
25
+ "target_modules": [
26
+ "gate_proj",
27
+ "q_proj",
28
+ "o_proj",
29
+ "down_proj",
30
+ "v_proj",
31
+ "k_proj",
32
+ "up_proj"
33
+ ],
34
+ "task_type": "CAUSAL_LM",
35
+ "use_dora": false,
36
+ "use_rslora": false
37
+ }
tsqa_adapter/outputs/sft_20260615_141604/adapter/added_tokens.json ADDED
The diff for this file is too large to render. See raw diff
 
tsqa_adapter/outputs/sft_20260615_141604/adapter/checkpoint-250/README.md ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: /mnt/share01/sqk/models/ChatTime-1-7B-Chat
3
+ library_name: peft
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
200
+ ### Framework versions
201
+
202
+ - PEFT 0.14.0
tsqa_adapter/outputs/sft_20260615_141604/adapter/checkpoint-250/adapter_config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "/mnt/share01/sqk/models/ChatTime-1-7B-Chat",
5
+ "bias": "none",
6
+ "eva_config": null,
7
+ "exclude_modules": null,
8
+ "fan_in_fan_out": false,
9
+ "inference_mode": true,
10
+ "init_lora_weights": true,
11
+ "layer_replication": null,
12
+ "layers_pattern": null,
13
+ "layers_to_transform": null,
14
+ "loftq_config": {},
15
+ "lora_alpha": 32,
16
+ "lora_bias": false,
17
+ "lora_dropout": 0.05,
18
+ "megatron_config": null,
19
+ "megatron_core": "megatron.core",
20
+ "modules_to_save": null,
21
+ "peft_type": "LORA",
22
+ "r": 16,
23
+ "rank_pattern": {},
24
+ "revision": null,
25
+ "target_modules": [
26
+ "gate_proj",
27
+ "q_proj",
28
+ "o_proj",
29
+ "down_proj",
30
+ "v_proj",
31
+ "k_proj",
32
+ "up_proj"
33
+ ],
34
+ "task_type": "CAUSAL_LM",
35
+ "use_dora": false,
36
+ "use_rslora": false
37
+ }
tsqa_adapter/outputs/sft_20260615_141604/adapter/checkpoint-250/added_tokens.json ADDED
The diff for this file is too large to render. See raw diff
 
tsqa_adapter/outputs/sft_20260615_141604/adapter/checkpoint-250/special_tokens_map.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "unk_token": {
24
+ "content": "<unk>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ }
30
+ }
tsqa_adapter/outputs/sft_20260615_141604/adapter/checkpoint-250/tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff
 
tsqa_adapter/outputs/sft_20260615_141604/adapter/checkpoint-250/trainer_state.json ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 2.0,
6
+ "eval_steps": 500,
7
+ "global_step": 250,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 0.08012018027040561,
14
+ "grad_norm": 0.9694206714630127,
15
+ "learning_rate": 0.0001230769230769231,
16
+ "loss": 2.1733,
17
+ "step": 10
18
+ },
19
+ {
20
+ "epoch": 0.16024036054081123,
21
+ "grad_norm": 0.4126811921596527,
22
+ "learning_rate": 0.0001957805907172996,
23
+ "loss": 0.9926,
24
+ "step": 20
25
+ },
26
+ {
27
+ "epoch": 0.24036054081121683,
28
+ "grad_norm": 0.3288513422012329,
29
+ "learning_rate": 0.00018734177215189873,
30
+ "loss": 0.8508,
31
+ "step": 30
32
+ },
33
+ {
34
+ "epoch": 0.32048072108162245,
35
+ "grad_norm": 0.33170658349990845,
36
+ "learning_rate": 0.0001789029535864979,
37
+ "loss": 0.7701,
38
+ "step": 40
39
+ },
40
+ {
41
+ "epoch": 0.400600901352028,
42
+ "grad_norm": 0.2883685231208801,
43
+ "learning_rate": 0.00017046413502109706,
44
+ "loss": 0.7776,
45
+ "step": 50
46
+ },
47
+ {
48
+ "epoch": 0.48072108162243365,
49
+ "grad_norm": 0.22634504735469818,
50
+ "learning_rate": 0.0001620253164556962,
51
+ "loss": 0.7121,
52
+ "step": 60
53
+ },
54
+ {
55
+ "epoch": 0.5608412618928392,
56
+ "grad_norm": 0.22475452721118927,
57
+ "learning_rate": 0.00015358649789029536,
58
+ "loss": 0.7793,
59
+ "step": 70
60
+ },
61
+ {
62
+ "epoch": 0.6409614421632449,
63
+ "grad_norm": 0.3640509843826294,
64
+ "learning_rate": 0.00014514767932489453,
65
+ "loss": 0.757,
66
+ "step": 80
67
+ },
68
+ {
69
+ "epoch": 0.7210816224336505,
70
+ "grad_norm": 0.2446712851524353,
71
+ "learning_rate": 0.00013670886075949366,
72
+ "loss": 0.7813,
73
+ "step": 90
74
+ },
75
+ {
76
+ "epoch": 0.801201802704056,
77
+ "grad_norm": 0.21602191030979156,
78
+ "learning_rate": 0.00012827004219409285,
79
+ "loss": 0.7259,
80
+ "step": 100
81
+ },
82
+ {
83
+ "epoch": 0.8813219829744617,
84
+ "grad_norm": 0.2295820116996765,
85
+ "learning_rate": 0.00011983122362869199,
86
+ "loss": 0.7549,
87
+ "step": 110
88
+ },
89
+ {
90
+ "epoch": 0.9614421632448673,
91
+ "grad_norm": 0.2932703495025635,
92
+ "learning_rate": 0.00011139240506329114,
93
+ "loss": 0.7469,
94
+ "step": 120
95
+ },
96
+ {
97
+ "epoch": 1.0400600901352028,
98
+ "grad_norm": 0.24934373795986176,
99
+ "learning_rate": 0.00010295358649789031,
100
+ "loss": 0.7391,
101
+ "step": 130
102
+ },
103
+ {
104
+ "epoch": 1.1201802704056085,
105
+ "grad_norm": 0.19357512891292572,
106
+ "learning_rate": 9.451476793248946e-05,
107
+ "loss": 0.6932,
108
+ "step": 140
109
+ },
110
+ {
111
+ "epoch": 1.200300450676014,
112
+ "grad_norm": 0.20672819018363953,
113
+ "learning_rate": 8.607594936708861e-05,
114
+ "loss": 0.707,
115
+ "step": 150
116
+ },
117
+ {
118
+ "epoch": 1.2804206309464197,
119
+ "grad_norm": 0.40644571185112,
120
+ "learning_rate": 7.763713080168776e-05,
121
+ "loss": 0.6962,
122
+ "step": 160
123
+ },
124
+ {
125
+ "epoch": 1.3605408112168251,
126
+ "grad_norm": 0.2238582968711853,
127
+ "learning_rate": 6.919831223628693e-05,
128
+ "loss": 0.6914,
129
+ "step": 170
130
+ },
131
+ {
132
+ "epoch": 1.4406609914872308,
133
+ "grad_norm": 0.24433942139148712,
134
+ "learning_rate": 6.0759493670886084e-05,
135
+ "loss": 0.7065,
136
+ "step": 180
137
+ },
138
+ {
139
+ "epoch": 1.5207811717576365,
140
+ "grad_norm": 0.29082414507865906,
141
+ "learning_rate": 5.232067510548524e-05,
142
+ "loss": 0.708,
143
+ "step": 190
144
+ },
145
+ {
146
+ "epoch": 1.6009013520280422,
147
+ "grad_norm": 0.3576412796974182,
148
+ "learning_rate": 4.388185654008439e-05,
149
+ "loss": 0.6934,
150
+ "step": 200
151
+ },
152
+ {
153
+ "epoch": 1.6810215322984476,
154
+ "grad_norm": 0.2905654013156891,
155
+ "learning_rate": 3.5443037974683544e-05,
156
+ "loss": 0.6848,
157
+ "step": 210
158
+ },
159
+ {
160
+ "epoch": 1.7611417125688533,
161
+ "grad_norm": 0.2700088620185852,
162
+ "learning_rate": 2.7004219409282698e-05,
163
+ "loss": 0.6854,
164
+ "step": 220
165
+ },
166
+ {
167
+ "epoch": 1.8412618928392588,
168
+ "grad_norm": 0.220729798078537,
169
+ "learning_rate": 1.856540084388186e-05,
170
+ "loss": 0.7243,
171
+ "step": 230
172
+ },
173
+ {
174
+ "epoch": 1.9213820731096645,
175
+ "grad_norm": 0.23472554981708527,
176
+ "learning_rate": 1.0126582278481012e-05,
177
+ "loss": 0.7209,
178
+ "step": 240
179
+ },
180
+ {
181
+ "epoch": 2.0,
182
+ "grad_norm": 0.2952578067779541,
183
+ "learning_rate": 1.6877637130801686e-06,
184
+ "loss": 0.7225,
185
+ "step": 250
186
+ }
187
+ ],
188
+ "logging_steps": 10,
189
+ "max_steps": 250,
190
+ "num_input_tokens_seen": 0,
191
+ "num_train_epochs": 2,
192
+ "save_steps": 200,
193
+ "stateful_callbacks": {
194
+ "TrainerControl": {
195
+ "args": {
196
+ "should_epoch_stop": false,
197
+ "should_evaluate": false,
198
+ "should_log": false,
199
+ "should_save": true,
200
+ "should_training_stop": true
201
+ },
202
+ "attributes": {}
203
+ }
204
+ },
205
+ "total_flos": 4.489394280737014e+17,
206
+ "train_batch_size": 1,
207
+ "trial_name": null,
208
+ "trial_params": null
209
+ }
tsqa_adapter/outputs/sft_20260615_141604/adapter/special_tokens_map.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "unk_token": {
24
+ "content": "<unk>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ }
30
+ }
tsqa_adapter/outputs/sft_20260615_141604/adapter/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tsqa_adapter/outputs/sft_20260615_141604/adapter/tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff
 
tsqa_adapter/outputs/sft_20260615_141604/eval/metrics.json ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "by_group": {
3
+ "anomaly_detection": {
4
+ "count": 200,
5
+ "accuracy": 0.82,
6
+ "correct": 164,
7
+ "parsed": 200
8
+ },
9
+ "classification": {
10
+ "count": 200,
11
+ "accuracy": 0.74,
12
+ "correct": 148,
13
+ "parsed": 200
14
+ },
15
+ "forecasting": {
16
+ "count": 200,
17
+ "valid_samples": 170,
18
+ "valid_points": 3164,
19
+ "mse": 825899.547396054,
20
+ "mae": 151.69107746555417
21
+ },
22
+ "open_ended": {
23
+ "count": 200,
24
+ "accuracy": 0.45,
25
+ "parsed_accuracy": 0.45685279187817257,
26
+ "parse_rate": 0.985,
27
+ "correct": 90,
28
+ "parsed": 197,
29
+ "unparsed": 3,
30
+ "by_format": {
31
+ "multiple_choice": {
32
+ "count": 67,
33
+ "accuracy": 0.2835820895522388,
34
+ "parsed_accuracy": 0.2878787878787879,
35
+ "correct": 19,
36
+ "parsed": 66,
37
+ "unparsed": 1
38
+ },
39
+ "open_ended_question": {
40
+ "count": 67,
41
+ "accuracy": 0.417910447761194,
42
+ "parsed_accuracy": 0.4307692307692308,
43
+ "correct": 28,
44
+ "parsed": 65,
45
+ "unparsed": 2
46
+ },
47
+ "true_false": {
48
+ "count": 66,
49
+ "accuracy": 0.6515151515151515,
50
+ "parsed_accuracy": 0.6515151515151515,
51
+ "correct": 43,
52
+ "parsed": 66,
53
+ "unparsed": 0
54
+ }
55
+ },
56
+ "by_method": {
57
+ "anomaly": {
58
+ "count": 1,
59
+ "accuracy": 1.0,
60
+ "correct": 1
61
+ },
62
+ "cyclical": {
63
+ "count": 4,
64
+ "accuracy": 0.75,
65
+ "correct": 3
66
+ },
67
+ "multiple_choice": {
68
+ "count": 64,
69
+ "accuracy": 0.296875,
70
+ "correct": 19
71
+ },
72
+ "numeric_scalar": {
73
+ "count": 31,
74
+ "accuracy": 0.25806451612903225,
75
+ "correct": 8
76
+ },
77
+ "numeric_sequence": {
78
+ "count": 1,
79
+ "accuracy": 0.0,
80
+ "correct": 0
81
+ },
82
+ "seasonality": {
83
+ "count": 3,
84
+ "accuracy": 1.0,
85
+ "correct": 3
86
+ },
87
+ "trend": {
88
+ "count": 20,
89
+ "accuracy": 0.45,
90
+ "correct": 9
91
+ },
92
+ "true_false": {
93
+ "count": 65,
94
+ "accuracy": 0.6461538461538462,
95
+ "correct": 42
96
+ },
97
+ "volatility": {
98
+ "count": 8,
99
+ "accuracy": 0.625,
100
+ "correct": 5
101
+ }
102
+ }
103
+ }
104
+ },
105
+ "text_overall": {
106
+ "count": 800,
107
+ "exact_match": 0.39,
108
+ "normalized_exact_match": 0.39,
109
+ "token_f1": 0.6366794082162608
110
+ },
111
+ "num_samples": 800,
112
+ "counts_by_group": {
113
+ "anomaly_detection": 200,
114
+ "classification": 200,
115
+ "forecasting": 200,
116
+ "open_ended": 200
117
+ }
118
+ }
tsqa_adapter/outputs/sft_20260615_141604/eval/predictions.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
tsqa_adapter/outputs/sft_20260615_141604/eval/shards/predictions.rank0.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
tsqa_adapter/outputs/sft_20260615_141604/eval/shards/predictions.rank1.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
tsqa_adapter/outputs/sft_20260615_141604/eval/shards/predictions.rank2.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
tsqa_adapter/outputs/sft_20260615_141604/eval/shards/predictions.rank3.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
tsqa_adapter/run_sft_4gpu.sh ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ PROJECT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
6
+ cd "$PROJECT_DIR"
7
+
8
+ RUN_ID="${RUN_ID:-$(date +%Y%m%d_%H%M%S)}"
9
+ PYTHON_BIN="${PYTHON_BIN:-/dev/shm/suiqk/conda_envs/scalerag-ts-v4/bin/python}"
10
+ ACCELERATE_CONFIG="${ACCELERATE_CONFIG:-/mnt/share01/sqk/ITFormer/accelerate_config.yaml}"
11
+ CUDA_VISIBLE_DEVICES="${CUDA_VISIBLE_DEVICES:-0,1,2,3}"
12
+ MODEL_PATH="${MODEL_PATH:-/mnt/share01/sqk/models/ChatTime-1-7B-Chat}"
13
+ ALLOW_HF_DOWNLOAD="${ALLOW_HF_DOWNLOAD:-0}"
14
+ MQA_DIR="${MQA_DIR:-/mnt/share01/sqk/MQA}"
15
+ DATA_ROOT="${DATA_ROOT:-/mnt/share01/sqk/datasets/Time-MQA_TSQA/tmp}"
16
+ TRAIN_FILE="${TRAIN_FILE:-train.jsonl}"
17
+ EVAL_FILE="${EVAL_FILE:-eval.jsonl}"
18
+ OUTPUT_ROOT="${OUTPUT_ROOT:-${PROJECT_DIR}/tsqa_adapter/outputs/sft_${RUN_ID}}"
19
+ ADAPTER_OUTPUT_DIR="${ADAPTER_OUTPUT_DIR:-${OUTPUT_ROOT}/adapter}"
20
+ EVAL_OUTPUT_DIR="${EVAL_OUTPUT_DIR:-${OUTPUT_ROOT}/eval}"
21
+ RUN_EVAL_AFTER_SFT="${RUN_EVAL_AFTER_SFT:-1}"
22
+ MAX_TRAIN_SAMPLES="${MAX_TRAIN_SAMPLES:-}"
23
+ MAX_EVAL_SAMPLES="${MAX_EVAL_SAMPLES:-}"
24
+ EVAL_BATCH_SIZE="${EVAL_BATCH_SIZE:-4}"
25
+ MAX_SEQ_LENGTH="${MAX_SEQ_LENGTH:-4096}"
26
+ SKIP_OVERLONG="${SKIP_OVERLONG:-1}"
27
+ PER_DEVICE_TRAIN_BATCH_SIZE="${PER_DEVICE_TRAIN_BATCH_SIZE:-1}"
28
+ GRADIENT_ACCUMULATION_STEPS="${GRADIENT_ACCUMULATION_STEPS:-16}"
29
+ NUM_TRAIN_EPOCHS="${NUM_TRAIN_EPOCHS:-2}"
30
+ LEARNING_RATE="${LEARNING_RATE:-2e-4}"
31
+ LORA_RANK="${LORA_RANK:-16}"
32
+ LORA_ALPHA="${LORA_ALPHA:-32}"
33
+ LORA_DROPOUT="${LORA_DROPOUT:-0.05}"
34
+ SAVE_STEPS="${SAVE_STEPS:-200}"
35
+ LOGGING_STEPS="${LOGGING_STEPS:-10}"
36
+ SAVE_TOTAL_LIMIT="${SAVE_TOTAL_LIMIT:-2}"
37
+ DATALOADER_NUM_WORKERS="${DATALOADER_NUM_WORKERS:-4}"
38
+ LOAD_IN_4BIT="${LOAD_IN_4BIT:-0}"
39
+ GRADIENT_CHECKPOINTING="${GRADIENT_CHECKPOINTING:-1}"
40
+ TORCH_DTYPE="${TORCH_DTYPE:-fp16}"
41
+ MAX_NEW_TOKENS="${MAX_NEW_TOKENS:-256}"
42
+ MAX_INPUT_TOKENS="${MAX_INPUT_TOKENS:-3840}"
43
+ LOG_DIR="${LOG_DIR:-${PROJECT_DIR}/tsqa_adapter/logs}"
44
+ LOG_FILE="${LOG_FILE:-${LOG_DIR}/sft_4gpu_${RUN_ID}.log}"
45
+
46
+ mkdir -p "$LOG_DIR" "$OUTPUT_ROOT"
47
+
48
+ fail() {
49
+ echo "$*" >&2
50
+ exit 1
51
+ }
52
+
53
+ exec > >(tee -a "$LOG_FILE") 2>&1
54
+
55
+ export CUDA_VISIBLE_DEVICES
56
+ export PYTHONPATH="${PROJECT_DIR}:${MQA_DIR}:${PYTHONPATH:-}"
57
+ export MQA_DIR
58
+ export TOKENIZERS_PARALLELISM=false
59
+ export PYTHONWARNINGS="ignore::FutureWarning:transformers.utils.hub"
60
+ export WANDB_MODE=offline
61
+
62
+ # Force a guaranteed-local, writable temp dir. The repo (cwd) sits on a
63
+ # shared/NFS mount; if no standard temp dir is usable Python's tempfile falls
64
+ # back to the cwd, and DataLoader workers then try to bind their AF_UNIX IPC
65
+ # sockets there -- which NFS rejects with "Operation not permitted", crashing on
66
+ # the first batch and littering the repo with tmpXXXX scratch dirs. /dev/shm is
67
+ # local RAM, world-writable and supports unix sockets.
68
+ TMPDIR="${TMPDIR:-/dev/shm/tsqa_sft_tmp_${RUN_ID}}"
69
+ mkdir -p "$TMPDIR" || fail "Cannot create local TMPDIR: $TMPDIR (set TMPDIR=/path to a writable local dir)."
70
+ export TMPDIR TMP="$TMPDIR" TEMP="$TMPDIR"
71
+ trap 'rm -rf "$TMPDIR" 2>/dev/null || true' EXIT
72
+
73
+ [ -x "$PYTHON_BIN" ] || fail "Python executable not found: $PYTHON_BIN. Set PYTHON_BIN=/path/to/bin/python."
74
+ [ -f "$ACCELERATE_CONFIG" ] || fail "Accelerate config not found: $ACCELERATE_CONFIG"
75
+ [ -f "${DATA_ROOT}/${TRAIN_FILE}" ] || fail "TSQA train file not found: ${DATA_ROOT}/${TRAIN_FILE}"
76
+ [ -f "${DATA_ROOT}/${EVAL_FILE}" ] || fail "TSQA eval file not found: ${DATA_ROOT}/${EVAL_FILE}"
77
+ [ -n "$MODEL_PATH" ] || fail "MODEL_PATH is required. Use a local ChatTime model path, or set ALLOW_HF_DOWNLOAD=1 with a HuggingFace model id."
78
+
79
+ if [ ! -d "$MODEL_PATH" ] && [ "$ALLOW_HF_DOWNLOAD" != "1" ]; then
80
+ fail "MODEL_PATH is not a local directory: $MODEL_PATH. Set ALLOW_HF_DOWNLOAD=1 if you intentionally want HuggingFace downloads."
81
+ fi
82
+
83
+ "$PYTHON_BIN" -c "import accelerate; print('accelerate:', accelerate.__version__)" || \
84
+ fail "The selected Python cannot import accelerate: $PYTHON_BIN"
85
+ ACCELERATE_CMD=("$PYTHON_BIN" -m accelerate.commands.accelerate_cli)
86
+
87
+ if [ "$LOAD_IN_4BIT" = "1" ]; then
88
+ "$PYTHON_BIN" -c "import importlib.metadata as m; print('bitsandbytes:', m.version('bitsandbytes'))" || \
89
+ fail "LOAD_IN_4BIT=1 requires bitsandbytes in $PYTHON_BIN."
90
+ fi
91
+
92
+ TRAIN_EXTRA_ARGS=()
93
+ if [ -n "$MAX_TRAIN_SAMPLES" ]; then
94
+ TRAIN_EXTRA_ARGS+=(--max_train_samples "$MAX_TRAIN_SAMPLES")
95
+ fi
96
+ if [ "$ALLOW_HF_DOWNLOAD" = "1" ]; then
97
+ TRAIN_EXTRA_ARGS+=(--allow_hf_download)
98
+ fi
99
+ if [ "$LOAD_IN_4BIT" = "1" ]; then
100
+ TRAIN_EXTRA_ARGS+=(--load_in_4bit)
101
+ fi
102
+ if [ "$GRADIENT_CHECKPOINTING" = "1" ]; then
103
+ TRAIN_EXTRA_ARGS+=(--gradient_checkpointing)
104
+ fi
105
+ if [ "$SKIP_OVERLONG" = "1" ]; then
106
+ TRAIN_EXTRA_ARGS+=(--skip_overlong)
107
+ else
108
+ TRAIN_EXTRA_ARGS+=(--no_skip_overlong)
109
+ fi
110
+
111
+ echo "Run id: $RUN_ID"
112
+ echo "Python: $PYTHON_BIN"
113
+ echo "Accelerate: ${ACCELERATE_CMD[*]}"
114
+ echo "CUDA_VISIBLE_DEVICES: $CUDA_VISIBLE_DEVICES"
115
+ echo "Model path: $MODEL_PATH"
116
+ echo "Data root: $DATA_ROOT (train=$TRAIN_FILE eval=$EVAL_FILE)"
117
+ echo "Adapter output dir: $ADAPTER_OUTPUT_DIR"
118
+ echo "Eval output dir: $EVAL_OUTPUT_DIR"
119
+ echo "Log file: $LOG_FILE"
120
+
121
+ "${ACCELERATE_CMD[@]}" launch --config_file "$ACCELERATE_CONFIG" \
122
+ tsqa_adapter/finetune_tsqa_lora.py \
123
+ --model_path "$MODEL_PATH" \
124
+ --data_root "$DATA_ROOT" \
125
+ --train_file "$TRAIN_FILE" \
126
+ --output_dir "$ADAPTER_OUTPUT_DIR" \
127
+ --max_seq_length "$MAX_SEQ_LENGTH" \
128
+ --per_device_train_batch_size "$PER_DEVICE_TRAIN_BATCH_SIZE" \
129
+ --gradient_accumulation_steps "$GRADIENT_ACCUMULATION_STEPS" \
130
+ --num_train_epochs "$NUM_TRAIN_EPOCHS" \
131
+ --learning_rate "$LEARNING_RATE" \
132
+ --lora_rank "$LORA_RANK" \
133
+ --lora_alpha "$LORA_ALPHA" \
134
+ --lora_dropout "$LORA_DROPOUT" \
135
+ --save_steps "$SAVE_STEPS" \
136
+ --logging_steps "$LOGGING_STEPS" \
137
+ --save_total_limit "$SAVE_TOTAL_LIMIT" \
138
+ --dataloader_num_workers "$DATALOADER_NUM_WORKERS" \
139
+ --torch_dtype "$TORCH_DTYPE" \
140
+ "${TRAIN_EXTRA_ARGS[@]}"
141
+
142
+ if [ "$RUN_EVAL_AFTER_SFT" = "1" ]; then
143
+ EVAL_EXTRA_ARGS=()
144
+ if [ -n "$MAX_EVAL_SAMPLES" ]; then
145
+ EVAL_EXTRA_ARGS+=(--max_eval_samples "$MAX_EVAL_SAMPLES")
146
+ fi
147
+ if [ "$ALLOW_HF_DOWNLOAD" = "1" ]; then
148
+ EVAL_EXTRA_ARGS+=(--allow_hf_download)
149
+ fi
150
+
151
+ "${ACCELERATE_CMD[@]}" launch --config_file "$ACCELERATE_CONFIG" \
152
+ tsqa_adapter/eval_tsqa.py \
153
+ --model_path "$MODEL_PATH" \
154
+ --adapter_path "$ADAPTER_OUTPUT_DIR" \
155
+ --data_root "$DATA_ROOT" \
156
+ --eval_file "$EVAL_FILE" \
157
+ --output_dir "$EVAL_OUTPUT_DIR" \
158
+ --eval_batch_size "$EVAL_BATCH_SIZE" \
159
+ --max_new_tokens "$MAX_NEW_TOKENS" \
160
+ --max_input_tokens "$MAX_INPUT_TOKENS" \
161
+ --torch_dtype "$TORCH_DTYPE" \
162
+ "${EVAL_EXTRA_ARGS[@]}"
163
+ fi
tsqa_adapter/tsqa_common.py ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Time-MQA TSQA dataset adapter for ChatTime.
2
+
3
+ This mirrors ``rats40k_adapter`` but targets the multi-task Time-MQA TSQA
4
+ benchmark (``/mnt/share01/sqk/datasets/Time-MQA_TSQA/tmp``), which contains four
5
+ source groups -- anomaly_detection, classification, forecasting and open_ended
6
+ -- with free-text answers.
7
+
8
+ Design choices:
9
+
10
+ * ChatTime has no chat template, so prompts use ChatTime's native analysis
11
+ template (``utils.prompt.getPrompt``): the natural-language ``question`` goes
12
+ into ``### Instruction`` (kept verbatim, including any embedded numbers so
13
+ forecasting keeps its absolute scale) and the ChatTime-serialised series goes
14
+ into ``### Input`` so the model still receives its native time-series tokens.
15
+ * The free-text ``answer`` is the ``### Response`` target.
16
+ * Some context-enhanced forecasting questions are far longer than ChatTime's
17
+ 4096-token context. Callers left-truncate the prompt (keeping the series, the
18
+ trailing ask and the full response) rather than failing.
19
+ * Evaluation reuses the canonical Time-MQA evaluator
20
+ (``MQA/data_utils.compute_group_metrics``) so ChatTime numbers are directly
21
+ comparable to the other TSQA baselines.
22
+ """
23
+
24
+ import json
25
+ import os
26
+ import sys
27
+ from collections import defaultdict
28
+ from pathlib import Path
29
+
30
+ import numpy as np
31
+
32
+
33
+ CHAT_TIME_DIR = Path(__file__).resolve().parents[1]
34
+ MQA_DIR = Path(os.environ.get("MQA_DIR", "/mnt/share01/sqk/MQA"))
35
+ if str(CHAT_TIME_DIR) not in sys.path:
36
+ sys.path.insert(0, str(CHAT_TIME_DIR))
37
+
38
+ from utils.prompt import getPrompt # noqa: E402
39
+ from utils.tools import Discretizer, Serializer # noqa: E402
40
+
41
+
42
+ DEFAULT_DATA_ROOT = "/mnt/share01/sqk/datasets/Time-MQA_TSQA/tmp"
43
+ SOURCE_ORDER = ("anomaly_detection", "classification", "forecasting", "open_ended")
44
+
45
+ # Fields carried into the saved prediction rows so the Time-MQA evaluator and
46
+ # manual inspection have everything they need.
47
+ RESULT_FIELDS = (
48
+ "id",
49
+ "figure_path",
50
+ "application_domain",
51
+ "task_type",
52
+ "source_type",
53
+ "question_format",
54
+ )
55
+
56
+
57
+ def resolve_data_file(data_root, data_file):
58
+ """Resolve a split file: absolute override, or relative to ``data_root``."""
59
+ path = Path(data_file)
60
+ if not path.is_absolute():
61
+ path = Path(data_root) / path
62
+ if not path.is_file():
63
+ raise FileNotFoundError(f"TSQA JSONL not found: {path}")
64
+ return str(path)
65
+
66
+
67
+ def load_tsqa_records(path):
68
+ """Load TSQA JSONL records, dropping rows without both a question and answer."""
69
+ records = []
70
+ with open(path, "r", encoding="utf-8") as handle:
71
+ for line in handle:
72
+ line = line.strip()
73
+ if not line:
74
+ continue
75
+ record = json.loads(line)
76
+ if not str(record.get("question") or "").strip():
77
+ continue
78
+ if not str(record.get("answer") or "").strip():
79
+ continue
80
+ records.append(record)
81
+ return records
82
+
83
+
84
+ def balanced_limit(records, max_samples):
85
+ """Round-robin a balanced subset across source groups (for smoke tests)."""
86
+ if not max_samples or max_samples <= 0 or len(records) <= max_samples:
87
+ return records
88
+
89
+ grouped = defaultdict(list)
90
+ for record in records:
91
+ grouped[str(record.get("source_type") or "unknown")].append(record)
92
+
93
+ names = [name for name in SOURCE_ORDER if grouped.get(name)]
94
+ names.extend(sorted(name for name in grouped if name not in names))
95
+
96
+ selected = []
97
+ offsets = defaultdict(int)
98
+ while len(selected) < max_samples:
99
+ added = False
100
+ for name in names:
101
+ offset = offsets[name]
102
+ if offset < len(grouped[name]):
103
+ selected.append(grouped[name][offset])
104
+ offsets[name] += 1
105
+ added = True
106
+ if len(selected) == max_samples:
107
+ break
108
+ if not added:
109
+ break
110
+ return selected
111
+
112
+
113
+ def _to_float_array(series):
114
+ arr = np.asarray(series, dtype=float).reshape(-1)
115
+ if arr.size == 0:
116
+ return arr
117
+ if not np.isfinite(arr).all():
118
+ finite = np.isfinite(arr)
119
+ fill = float(np.median(arr[finite])) if finite.any() else 0.0
120
+ arr = np.where(np.isfinite(arr), arr, fill)
121
+ return arr
122
+
123
+
124
+ def serialize_series(series):
125
+ """Discretise + serialise a univariate series into ChatTime time tokens."""
126
+ arr = _to_float_array(series)
127
+ if arr.size == 0:
128
+ return ""
129
+ discretizer = Discretizer()
130
+ serializer = Serializer()
131
+ return serializer.serialize(discretizer.discretize(arr))
132
+
133
+
134
+ def build_prompt(question, series, response=None):
135
+ """Build a ChatTime prompt: question -> Instruction, series -> Input."""
136
+ question = str(question or "").strip()
137
+ response = "" if response is None else str(response)
138
+ serialized = serialize_series(series)
139
+ if serialized:
140
+ return getPrompt(
141
+ flag="analysis",
142
+ instruction=question,
143
+ input=serialized,
144
+ response=response,
145
+ )
146
+ # No usable series: fall back to a plain instruction prompt.
147
+ return getPrompt(
148
+ flag="general",
149
+ instruction=question,
150
+ input="",
151
+ response=response,
152
+ )
153
+
154
+
155
+ def build_result_row(record, prediction):
156
+ """Assemble a prediction row in the Time-MQA evaluator schema."""
157
+ row = {field: str(record.get(field) or "") for field in RESULT_FIELDS}
158
+ row["question"] = str(record.get("question") or "")
159
+ row["answer"] = str(record.get("answer") or "")
160
+ row["prediction"] = "" if prediction is None else str(prediction).strip()
161
+ return row
162
+
163
+
164
+ def compute_tsqa_metrics(rows):
165
+ """Per-group TSQA metrics, reusing the canonical Time-MQA evaluator."""
166
+ if str(MQA_DIR) not in sys.path:
167
+ sys.path.insert(0, str(MQA_DIR))
168
+ from data_utils import compute_group_metrics, compute_text_metrics
169
+
170
+ rows = list(rows)
171
+ metrics = {"by_group": compute_group_metrics(rows)}
172
+ metrics["text_overall"] = compute_text_metrics(rows)
173
+ counts = defaultdict(int)
174
+ for row in rows:
175
+ counts[str(row.get("source_type") or "unknown")] += 1
176
+ metrics["num_samples"] = len(rows)
177
+ metrics["counts_by_group"] = dict(counts)
178
+ return metrics
179
+
180
+
181
+ def atomic_write_json(obj, path):
182
+ path = Path(path)
183
+ path.parent.mkdir(parents=True, exist_ok=True)
184
+ tmp = path.with_suffix(path.suffix + f".tmp.{os.getpid()}")
185
+ with open(tmp, "w", encoding="utf-8") as handle:
186
+ json.dump(obj, handle, indent=2, ensure_ascii=False)
187
+ os.replace(tmp, path)
188
+
189
+
190
+ def write_jsonl(rows, path):
191
+ path = Path(path)
192
+ path.parent.mkdir(parents=True, exist_ok=True)
193
+ tmp = path.with_suffix(path.suffix + f".tmp.{os.getpid()}")
194
+ with open(tmp, "w", encoding="utf-8") as handle:
195
+ for row in rows:
196
+ handle.write(json.dumps(row, ensure_ascii=False) + "\n")
197
+ os.replace(tmp, path)
utils/__init__.py ADDED
File without changes
utils/prompt.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GEN_SYS_PROMPT = "Below is an instruction that describes a task. Write a response that appropriately completes the request."
2
+ PRE_SYS_PROMPT = "You are a helpful assistant that performs time series prediction. The user will provide a sequence and you will predict the sequence."
3
+ ANA_SYS_PROMPT = "You are a helpful assistant that performs time series analysis. The user will provide a sequence and you will respond to the questions based on this sequence."
4
+
5
+ PRE_INST_PROMPT = "Please predict the following sequence carefully."
6
+ PRE_INST_PROMPT_TEXT = "Please predict the following sequence carefully. Context knowledge you may consider: {}"
7
+ ANA_INST_PROMPT_TEXT = "Please answer the following question carefully after analyzing the sequence: {}"
8
+
9
+ TEMPLATE = """{}
10
+
11
+ ### Instruction:
12
+ {}
13
+
14
+ ### Input:
15
+ {}
16
+
17
+ ### Response:
18
+ {}"""
19
+
20
+
21
+ def getPrompt(flag, instruction=None, input=None, response=None, context=None):
22
+ if flag == "general": # instruction, [input], [response]
23
+ system = GEN_SYS_PROMPT
24
+ if instruction is None:
25
+ raise ValueError("Instruction must be provided for general tasks.")
26
+ else:
27
+ instruction = instruction
28
+ input = "" if input is None else input
29
+ response = "" if response is None else response
30
+
31
+ elif flag == "prediction": # [context], input, [response]
32
+ system = PRE_SYS_PROMPT
33
+ instruction = PRE_INST_PROMPT if context is None else PRE_INST_PROMPT_TEXT.format(context)
34
+ if input is None:
35
+ raise ValueError("Input must be provided for prediction tasks.")
36
+ else:
37
+ input = input
38
+ response = "" if response is None else response
39
+
40
+ elif flag == "analysis": # instruction, input, [response]
41
+ system = ANA_SYS_PROMPT
42
+ if instruction is None:
43
+ raise ValueError("Instruction must be provided for analysis tasks.")
44
+ else:
45
+ instruction = ANA_INST_PROMPT_TEXT.format(instruction)
46
+ if input is None:
47
+ raise ValueError("Input must be provided for analysis tasks.")
48
+ else:
49
+ input = input
50
+ response = "" if response is None else response
51
+
52
+ else:
53
+ raise ValueError("Flag must be one of 'general', 'prediction', or 'analysis'.")
54
+
55
+ prompt = TEMPLATE.format(system, instruction, input, response)
56
+
57
+ return prompt
utils/tools.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+
3
+ import numpy as np
4
+ from sklearn.preprocessing import MinMaxScaler
5
+
6
+
7
+ class Discretizer:
8
+ def __init__(self, low_limit=-1, high_limit=1, n_tokens=10002):
9
+ self.scaler = MinMaxScaler()
10
+
11
+ self.boundaries = np.linspace(low_limit, high_limit, n_tokens - 1)
12
+ self.centers = (self.boundaries[1:] + self.boundaries[:-1]) / 2
13
+ self.centers = np.concatenate((self.centers[:1], self.centers, self.centers[-1:]))
14
+
15
+ def get_centers(self):
16
+ return self.centers
17
+
18
+ def discretize(self, context, fit_length=None):
19
+ fit_length = len(context) if fit_length is None else fit_length
20
+ self.scaler.fit(context[:fit_length].reshape(-1, 1))
21
+ scaled_context = self.scaler.transform(context.reshape(-1, 1)).reshape(-1) - 0.5
22
+
23
+ bin_ids = np.digitize(x=scaled_context, bins=self.boundaries, right=True)
24
+ dispersed_context = self.centers[bin_ids]
25
+
26
+ dispersed_context[np.isnan(context)] = np.nan
27
+
28
+ return dispersed_context
29
+
30
+ def inverse_discretize(self, scaled_context):
31
+ context = self.scaler.inverse_transform(scaled_context.reshape(-1, 1) + 0.5).reshape(-1)
32
+
33
+ return context
34
+
35
+
36
+ class Serializer:
37
+ def __init__(self, prec=4, time_sep=" ", time_flag="###", nan_flag="Nan"):
38
+ self.prec = prec
39
+ self.time_sep = time_sep
40
+ self.time_flag = time_flag
41
+ self.nan_flag = nan_flag
42
+
43
+ def serialize(self, context):
44
+ serialized_context = np.array([f"{self.time_flag}{i:.{self.prec}f}{self.time_flag}" for i in context])
45
+ serialized_context[np.isnan(context)] = f"{self.time_flag}{self.nan_flag}{self.time_flag}"
46
+ serialized_context = self.time_sep.join(serialized_context)
47
+
48
+ return serialized_context
49
+
50
+ def inverse_serialize(self, serialized_context):
51
+ pattern = rf"{self.time_flag}(.*?){self.time_flag}"
52
+ matches = re.findall(pattern, serialized_context)
53
+
54
+ context = []
55
+ for num in matches:
56
+ try:
57
+ context.append(float(num))
58
+ except ValueError as e:
59
+ print(e)
60
+ context.append(np.NaN)
61
+
62
+ context = np.array(context)
63
+
64
+ return context