lukeleeai commited on
Commit
f993ec6
1 Parent(s): 62de1a5

End of training

Browse files
README.md ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - generated_from_trainer
4
+ model-index:
5
+ - name: Mistral_Sparse_refined_web_graceful_reg_90p_debugging_2024-03-13
6
+ results: []
7
+ ---
8
+
9
+ <!-- This model card has been generated automatically according to the information the Trainer had access to. You
10
+ should probably proofread and complete it, then remove this comment. -->
11
+
12
+ # Mistral_Sparse_refined_web_graceful_reg_90p_debugging_2024-03-13
13
+
14
+ This model is a fine-tuned version of [](https://huggingface.co/) on the None dataset.
15
+ It achieves the following results on the evaluation set:
16
+ - Loss: 10.3880
17
+
18
+ ## Model description
19
+
20
+ More information needed
21
+
22
+ ## Intended uses & limitations
23
+
24
+ More information needed
25
+
26
+ ## Training and evaluation data
27
+
28
+ More information needed
29
+
30
+ ## Training procedure
31
+
32
+ ### Training hyperparameters
33
+
34
+ The following hyperparameters were used during training:
35
+ - learning_rate: 1e-05
36
+ - train_batch_size: 1
37
+ - eval_batch_size: 1
38
+ - seed: 0
39
+ - distributed_type: multi-GPU
40
+ - num_devices: 2
41
+ - gradient_accumulation_steps: 8
42
+ - total_train_batch_size: 16
43
+ - total_eval_batch_size: 2
44
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
45
+ - lr_scheduler_type: linear
46
+ - training_steps: 10
47
+
48
+ ### Training results
49
+
50
+ | Training Loss | Epoch | Step | Validation Loss |
51
+ |:-------------:|:-----:|:----:|:---------------:|
52
+ | 10.3894 | 0.0 | 10 | 10.3875 |
53
+
54
+
55
+ ### Framework versions
56
+
57
+ - Transformers 4.37.2
58
+ - Pytorch 2.1.1+cu121
59
+ - Datasets 2.15.0
60
+ - Tokenizers 0.15.0
config.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SparseMistralforCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "auto_map": {
7
+ "AutoConfig": "sparsification_sftt.SparseMistralConfig",
8
+ "AutoModelForCausalLM": "sparsification_sftt.SparseMistralforCausalLM"
9
+ },
10
+ "bos_token_id": 1,
11
+ "eos_token_id": 2,
12
+ "hidden_act": "silu",
13
+ "hidden_size": 64,
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 64,
16
+ "max_position_embeddings": 131072,
17
+ "model_type": "sparse_mistral",
18
+ "num_attention_heads": 32,
19
+ "num_hidden_layers": 4,
20
+ "num_key_value_heads": 8,
21
+ "rms_norm_eps": 1e-06,
22
+ "rope_theta": 10000.0,
23
+ "sliding_window": 4096,
24
+ "thresholds": [
25
+ 0.0,
26
+ 0.0,
27
+ 0.0,
28
+ 0.0
29
+ ],
30
+ "tie_word_embeddings": false,
31
+ "torch_dtype": "float32",
32
+ "transformers_version": "4.37.2",
33
+ "use_cache": false,
34
+ "use_graceful_regularization": true,
35
+ "use_relu": false,
36
+ "use_sparse_model": true,
37
+ "use_sparse_predictor": false,
38
+ "use_sparse_regularization": false,
39
+ "vocab_size": 32000
40
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "transformers_version": "4.37.2"
6
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:213a0affb7f77f6289d9cc229c964a959c760d539fff4c7ecd7d1f3c83a4a339
3
+ size 16750904
sparsification_sftt.py ADDED
@@ -0,0 +1,890 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import TrainerCallback, Trainer
2
+ from trl import SFTTrainer, DataCollatorForCompletionOnlyLM
3
+ from peft import PeftModel
4
+ from datasets import Dataset
5
+ from transformers.utils import is_sagemaker_mp_enabled, is_sagemaker_dp_enabled
6
+ from typing import Any, Dict, Union, Optional, Tuple
7
+ from torch.nn import MSELoss
8
+
9
+ import warnings
10
+ import torch
11
+ import torch.nn as nn
12
+ import torch.nn.functional as F
13
+ import matplotlib.pyplot as plt
14
+ import numpy as np
15
+ import time
16
+ import os
17
+ import copy
18
+
19
+ from transformers.models.mistral.modeling_mistral import (
20
+ MistralMLP,
21
+ MistralAttention,
22
+ MistralModel,
23
+ MistralDecoderLayer,
24
+ MistralConfig,
25
+ MISTRAL_ATTENTION_CLASSES,
26
+ MistralRMSNorm,
27
+ MistralForCausalLM,
28
+ )
29
+ from experiments.models.sparse_mistral.svd_router import (
30
+ low_rank_approximation,
31
+ SparsePredictor,
32
+ )
33
+ from utils.utils import (
34
+ print_size_of_model,
35
+ is_running_deepspeed,
36
+ is_mainprocess,
37
+ get_datetime,
38
+ ds_print,
39
+ )
40
+
41
+
42
+ class SparseSFTTTrainer(SFTTrainer):
43
+ def __init__(self, *args, **kwargs):
44
+ self.regularization_coefficient = kwargs.pop("regularization_coefficient", 10)
45
+ self.use_sparse_regularization = kwargs.pop("use_sparse_regularization", False)
46
+ self.use_spm_loss = False
47
+ self.freeze_original_weights = False
48
+ self.regularization_type = kwargs.pop("regularization_type", "L1 positive activation")
49
+ assert self.regularization_type in [
50
+ "L2 activation",
51
+ "L1 positive activation",
52
+ ], f"Invalid regularization type: {self.regularization_type}"
53
+ self.sparse_layers = []
54
+ self.sparse_decoder_layers = []
55
+ super(SparseSFTTTrainer, self).__init__(*args, **kwargs)
56
+
57
+ def initialize_sparse_silu_layers(self, model):
58
+ self.sparse_layers = [m for m in model.modules() if isinstance(m, MistralSparseSiluMLP)]
59
+
60
+ def initialize_sparse_decoder_layers(self, model):
61
+ self.sparse_decoder_layers = [m for m in model.modules() if isinstance(m, SparseMistralDecoderLayer)]
62
+
63
+ def training_step(self, model: nn.Module, inputs: Dict[str, Union[torch.Tensor, Any]]) -> torch.Tensor:
64
+ """
65
+ Override the huggingface's training_step function to add a regularization term.
66
+ A regularization term is computed with intermediate values, which are freed after "backward()."
67
+ You need to set `retain_graph=True` inside `backward` function to keep the values.
68
+ """
69
+ model.train()
70
+ inputs = self._prepare_inputs(inputs)
71
+
72
+ with self.compute_loss_context_manager():
73
+ loss = self.compute_loss(model, inputs)
74
+
75
+ if self.args.n_gpu > 1:
76
+ loss = loss.mean() # mean() to average on multi-gpu parallel training
77
+ if not self.freeze_original_weights:
78
+ if loss is not None:
79
+ self.accelerator.backward(loss, retain_graph=False)
80
+
81
+ if self.use_sparse_regularization:
82
+ regularization_loss = self.compute_regularization(model)
83
+ if self.args.n_gpu > 1:
84
+ regularization_loss = regularization_loss.mean()
85
+ if regularization_loss is not None:
86
+ self.accelerator.backward(regularization_loss, retain_graph=True)
87
+ loss += regularization_loss
88
+
89
+ if self.use_spm_loss:
90
+ spm_loss = self.compute_spm_loss(model)
91
+ if self.args.n_gpu > 1:
92
+ spm_loss = spm_loss.mean()
93
+ if spm_loss is not None:
94
+ self.accelerator.backward(spm_loss, retain_graph=False)
95
+ loss += spm_loss
96
+
97
+ return loss.detach() / self.args.gradient_accumulation_steps
98
+
99
+ def compute_regularization(self, model):
100
+ """
101
+ Compute a sparse regularization loss for SiLU
102
+ """
103
+ loss = 0
104
+ if len(self.sparse_layers) == 0:
105
+ self.initialize_sparse_silu_layers(model)
106
+ num_layers = len(self.sparse_layers)
107
+
108
+ for module in self.sparse_layers:
109
+ if module.activation_norm is not None:
110
+ loss += module.activation_norm
111
+
112
+ loss /= num_layers
113
+ loss *= self.regularization_coefficient
114
+
115
+ if self.state.global_step % 20 == 0 and loss != 0:
116
+ print("Negative relularizer loss: ", loss.item())
117
+ return loss
118
+
119
+ def compute_spm_loss(self, model):
120
+ loss = 0
121
+ if len(self.sparse_decoder_layers) == 0:
122
+ self.initialize_sparse_decoder_layers(model)
123
+ for module in self.sparse_decoder_layers:
124
+ if module.distill_loss != None:
125
+ loss += module.distill_loss
126
+ if self.state.global_step % 20 == 0 and loss != 0:
127
+ print("Sparse Predictor Distillation loss: ", loss.item())
128
+ return loss
129
+
130
+ # def compute_loss(self, model, inputs, return_outputs=False):
131
+ # loss = super().compute_loss(model, inputs, return_outputs)
132
+ #
133
+ # if is_sagemaker_mp_enabled():
134
+ # import smdistributed.modelparallel.torch as smp
135
+ # @smp.step()
136
+ # def smp_forward_backward(model, inputs, gradient_accumulation_steps=1):
137
+ # outputs = model(**inputs)
138
+ # loss = outputs["loss"] if isinstance(outputs, dict) else outputs[0]
139
+ # loss /= gradient_accumulation_steps
140
+ # model.backward(loss)
141
+ # return loss
142
+ #
143
+ # loss_mb = smp_forward_backward(
144
+ # model, inputs, self.args.gradient_accumulation_steps
145
+ # )
146
+ # if self.use_sparse_regularization:
147
+ # return loss_mb.reduce_mean().detach().to(
148
+ # self.args.device
149
+ # ) + self.regularization_coefficient * self.compute_regularization(model)
150
+ # else:
151
+ # return loss_mb.reduce_mean().detach().to(self)
152
+ #
153
+ # if return_outputs:
154
+ # classification_loss, outputs = loss
155
+ # else:
156
+ # classification_loss = loss
157
+ #
158
+ # loss = classification_loss
159
+ # if self.use_sparse_regularization:
160
+ # regularization_loss = self.compute_regularization(model)
161
+ # loss += self.regularization_coefficient * regularization_loss
162
+ #
163
+ # return (loss, outputs) if return_outputs else loss
164
+
165
+
166
+ class SparseTrainer(Trainer):
167
+ def __init__(self, *args, **kwargs):
168
+ self.regularization_coefficient = kwargs.pop("regularization_coefficient", 10)
169
+ self.use_sparse_regularization = kwargs.pop("use_sparse_regularization", False)
170
+ self.use_spm_loss = False
171
+ self.freeze_original_weights = False
172
+ self.regularization_type = kwargs.pop("regularization_type", "L1 positive activation")
173
+ assert self.regularization_type in [
174
+ "L2 activation",
175
+ "L1 positive activation",
176
+ ], f"Invalid regularization type: {self.regularization_type}"
177
+ self.sparse_layers = []
178
+ self.sparse_decoder_layers = []
179
+ super(SparseTrainer, self).__init__(*args, **kwargs)
180
+
181
+ def initialize_sparse_silu_layers(self, model):
182
+ self.sparse_layers = [m for m in model.modules() if isinstance(m, MistralSparseSiluMLP)]
183
+
184
+ def initialize_sparse_decoder_layers(self, model):
185
+ self.sparse_decoder_layers = [m for m in model.modules() if isinstance(m, SparseMistralDecoderLayer)]
186
+
187
+ def training_step(self, model: nn.Module, inputs: Dict[str, Union[torch.Tensor, Any]]) -> torch.Tensor:
188
+ """
189
+ Override the huggingface's training_step function to add a regularization term.
190
+ A regularization term is computed with intermediate values, which are freed after "backward()."
191
+ You need to set `retain_graph=True` inside `backward` function to keep the values.
192
+ """
193
+ model.train()
194
+ inputs = self._prepare_inputs(inputs)
195
+
196
+ with self.compute_loss_context_manager():
197
+ loss = self.compute_loss(model, inputs)
198
+
199
+ if self.args.n_gpu > 1:
200
+ loss = loss.mean() # mean() to average on multi-gpu parallel training
201
+ if not self.freeze_original_weights:
202
+ if loss is not None:
203
+ self.accelerator.backward(loss, retain_graph=False)
204
+
205
+ if self.use_sparse_regularization:
206
+ regularization_loss = self.compute_regularization(model)
207
+ if self.args.n_gpu > 1:
208
+ regularization_loss = regularization_loss.mean()
209
+ if regularization_loss is not None:
210
+ self.accelerator.backward(regularization_loss, retain_graph=True)
211
+ loss += regularization_loss
212
+
213
+ if self.use_spm_loss:
214
+ spm_loss = self.compute_spm_loss(model)
215
+ if self.args.n_gpu > 1:
216
+ spm_loss = spm_loss.mean()
217
+ if spm_loss is not None:
218
+ self.accelerator.backward(spm_loss, retain_graph=False)
219
+ loss += spm_loss
220
+
221
+ return loss.detach() / self.args.gradient_accumulation_steps
222
+
223
+ def compute_regularization(self, model):
224
+ """
225
+ Compute a sparse regularization loss for SiLU
226
+ """
227
+ loss = 0
228
+ if len(self.sparse_layers) == 0:
229
+ self.initialize_sparse_silu_layers(model)
230
+ num_layers = len(self.sparse_layers)
231
+
232
+ for module in self.sparse_layers:
233
+ if module.activation_norm is not None:
234
+ loss += module.activation_norm
235
+
236
+ loss /= num_layers
237
+ loss *= self.regularization_coefficient
238
+
239
+ if self.state.global_step % 20 == 0 and loss != 0:
240
+ print("Negative relularizer loss: ", loss.item())
241
+ return loss
242
+
243
+ def compute_spm_loss(self, model):
244
+ loss = 0
245
+ if len(self.sparse_decoder_layers) == 0:
246
+ self.initialize_sparse_decoder_layers(model)
247
+ for module in self.sparse_decoder_layers:
248
+ if module.distill_loss != None:
249
+ loss += module.distill_loss
250
+ if self.state.global_step % 20 == 0 and loss != 0:
251
+ print("Sparse Predictor Distillation loss: ", loss.item())
252
+ return loss
253
+
254
+
255
+ class SparseSiLU(nn.SiLU):
256
+ def __init__(self, threshold):
257
+ super(SparseSiLU, self).__init__()
258
+ self.threshold = threshold
259
+ self.m = nn.Threshold(self.threshold, 0)
260
+
261
+ def set_new_threshold(self, threshold):
262
+ self.threshold = threshold
263
+ self.m = nn.Threshold(threshold, 0)
264
+
265
+ def forward(self, x):
266
+ act = super(SparseSiLU, self).forward(x)
267
+ return self.m(act) - self.m(-act)
268
+
269
+
270
+ class MistralSparseSiluMLP(MistralMLP):
271
+ def __init__(self, config, *args, **kwargs):
272
+ super().__init__(config)
273
+ self.swish_outputs = None
274
+ self.relu = nn.ReLU()
275
+
276
+ self.kill_sparse_swish_outputs = False
277
+ self.dead_percentage = 0
278
+ self.is_stats = False
279
+ self.visit_counts = 0
280
+
281
+ # Hyperparameters to tune
282
+ self.dead_threshold = kwargs.pop("dead_threshold", 0)
283
+ self.use_sparse_regularization = kwargs.pop("use_sparse_regularization", True)
284
+ self.regularization_type = kwargs.pop("regularization_type", "L1 regularization")
285
+ self.regularization_threshold = kwargs.pop("regularization_threshold", 0.5)
286
+ self.use_relu = kwargs.pop("use_relu", False)
287
+ self.activation_norm = None
288
+
289
+ # Activation Histograms
290
+ self.is_collect_histogram = False
291
+ num_bins = 1000
292
+ self.histogram_bins = torch.linspace(-1, 1, num_bins - 2)
293
+ self.histogram_bins = torch.cat([torch.tensor([-torch.inf]), self.histogram_bins, torch.tensor([torch.inf])])
294
+ self.pre_act_hist_counts = torch.zeros(num_bins - 1)
295
+ self.post_act_hist_counts = torch.zeros(num_bins - 1)
296
+ self.t = 0
297
+ self.count = 0
298
+ self.agg_sparsity = 0
299
+
300
+ # Sparse activation function
301
+ self.sparse_act_fn = SparseSiLU(threshold=self.dead_threshold)
302
+
303
+ def activate_stats(self, is_collect_histogram: bool = True):
304
+ self.is_stats = True
305
+ self.dead_percentage = 0
306
+ self.visit_counts = 0
307
+ self.is_collect_histogram = is_collect_histogram
308
+ self.histogram_counts = torch.zeros(2000) # .to(self.down_proj.weight.device)
309
+
310
+ def deactivate_stats(self):
311
+ self.is_stats = False
312
+
313
+ def collect_stats(self, pre_activation, post_activation):
314
+ start_time = time.time()
315
+ pre_activation = pre_activation.float().cpu().detach()
316
+ post_activation = post_activation.float().cpu().detach()
317
+ # self.histogram_bins=self.histogram_bins.to(pre_activation.device).type(pre_activation.dtype)
318
+ self.pre_act_hist_counts += torch.histogram(pre_activation, bins=self.histogram_bins)[0]
319
+ self.post_act_hist_counts += torch.histogram(torch.abs(post_activation), bins=self.histogram_bins)[0]
320
+ self.t += time.time() - start_time
321
+ if self.visit_counts % 30 == 0:
322
+ print(f"Time taken to collect stats: {self.t}s.")
323
+
324
+ def forward(
325
+ self,
326
+ x,
327
+ sp_mask: torch.tensor = None,
328
+ ):
329
+ """
330
+ If kill_sparse_swish_outputs is set to False, this layer functions exactly like a normal MLP layer.
331
+ """
332
+ if sp_mask != None: # When sparse mask is given
333
+ return self.down_proj(
334
+ self.sparse_act_fn(self.gate_proj(x) * sp_mask) * self.up_proj(x)
335
+ ) # Todo: This doesn't accelerate runtime (instead slowing down)
336
+
337
+ elif self.use_relu:
338
+ post_act = self.relu(self.gate_proj(x))
339
+ self.count += 1
340
+ if self.count <= 1:
341
+ print("USING RELU!!!!")
342
+
343
+ if self.is_stats:
344
+ dead_neurons = post_act == 0
345
+ dead_percentage = dead_neurons.float().mean()
346
+ agg_sparsity = dead_neurons.all(dim=0).float().mean()
347
+
348
+ self.dead_percentage = (self.dead_percentage * self.visit_counts + dead_percentage) / (self.visit_counts + 1)
349
+ self.agg_sparsity = (self.agg_sparsity * self.visit_counts + agg_sparsity) / (self.visit_counts + 1)
350
+ self.visit_counts += 1
351
+
352
+ return self.down_proj(post_act * self.up_proj(x))
353
+
354
+ else:
355
+ self.count += 1
356
+ if self.count <= 1:
357
+ print("USING SparseSILU!!!!")
358
+ pre_act = self.gate_proj(x)
359
+ post_act = self.act_fn(pre_act)
360
+ if self.kill_sparse_swish_outputs:
361
+ dead_neurons = post_act.abs() <= self.dead_threshold
362
+ # print("pre act sparsity: ", (pre_act==0).float().mean())
363
+
364
+ dead_percentage = dead_neurons.float().mean()
365
+ agg_sparsity = dead_neurons.all(dim=0).float().mean()
366
+
367
+ if self.is_stats:
368
+ self.dead_percentage = (self.dead_percentage * self.visit_counts + dead_percentage) / (self.visit_counts + 1)
369
+ self.agg_sparsity = (self.agg_sparsity * self.visit_counts + agg_sparsity) / (self.visit_counts + 1)
370
+ self.visit_counts += 1
371
+
372
+ self.a = dead_percentage
373
+
374
+ # print(self.agg_sparsity)
375
+
376
+ # Collect histogram stats
377
+ if self.is_collect_histogram and pre_act.eq(0).float().mean() < 0.99: # Padded dataset
378
+ self.collect_stats(pre_act, post_act)
379
+
380
+ post_act[dead_neurons] = 0
381
+
382
+ out = self.down_proj(post_act * self.up_proj(x))
383
+ if self.use_sparse_regularization:
384
+ if self.regularization_type == "L1 regularization":
385
+ self.activation_norm = torch.abs(post_act)[torch.abs(post_act) < self.regularization_threshold].mean()
386
+ elif self.regularization_type == "L2 regularization":
387
+ self.activation_norm = torch.sqrt(torch.square(post_act)[torch.abs(post_act) < self.regularization_threshold]).mean()
388
+
389
+ return out
390
+
391
+
392
+ class SparseMistralDecoderLayer(MistralDecoderLayer):
393
+ def __init__(
394
+ self,
395
+ config: MistralConfig,
396
+ layer_idx: int,
397
+ decoder_layer: MistralDecoderLayer,
398
+ init_svd: bool = True,
399
+ *args,
400
+ **kwargs,
401
+ ):
402
+ assert isinstance(decoder_layer.mlp, MistralSparseSiluMLP), f"{type(decoder_layer.mlp)} should MistralSparseSiluMLP."
403
+
404
+ super().__init__(config, layer_idx)
405
+ self.hidden_size = config.hidden_size
406
+ self.intermediate_size = config.intermediate_size
407
+
408
+ self.init_svd = init_svd
409
+ self.self_attn = decoder_layer.self_attn
410
+
411
+ self.mlp = decoder_layer.mlp
412
+ self.input_layernorm = decoder_layer.input_layernorm
413
+ self.post_attention_layernorm = decoder_layer.post_attention_layernorm
414
+
415
+ # Sparse predictor for mlp (initialized with SVD decomposed matrix)
416
+ self.low_rank = kwargs.pop("low_rank", 64)
417
+ self.sparse_act_func = decoder_layer.mlp.sparse_act_fn
418
+
419
+ print(f"Setting {layer_idx}th mlp layer's sparse predictor... svd init: {init_svd}")
420
+ self.sp_mlp = low_rank_approximation(
421
+ decoder_layer.mlp.gate_proj,
422
+ act_func=self.sparse_act_func,
423
+ init_svd=init_svd,
424
+ )
425
+ self.use_async = kwargs.pop("use_async", False)
426
+ self.use_sparse_predictor = False
427
+ self.distill_loss = None
428
+
429
+ def forward(
430
+ self,
431
+ hidden_states: torch.Tensor,
432
+ attention_mask: Optional[torch.Tensor] = None,
433
+ position_ids: Optional[torch.LongTensor] = None,
434
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
435
+ output_attentions: Optional[bool] = False,
436
+ use_cache: Optional[bool] = False,
437
+ **kwargs,
438
+ ) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
439
+ print("hidden_states shape: ", hidden_states.shape)
440
+ if "padding_mask" in kwargs:
441
+ warnings.warn(
442
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
443
+ )
444
+
445
+ residual = hidden_states
446
+ sp_mask = None
447
+
448
+ if self.use_async:
449
+ sp_mask = self.sp_mlp(hidden_states)
450
+
451
+ hidden_states = self.input_layernorm(hidden_states)
452
+
453
+ # Self Attention
454
+ hidden_states, self_attn_weights, present_key_value = self.self_attn(
455
+ hidden_states=hidden_states,
456
+ attention_mask=attention_mask,
457
+ position_ids=position_ids,
458
+ past_key_value=past_key_value,
459
+ output_attentions=output_attentions,
460
+ use_cache=use_cache,
461
+ )
462
+ hidden_states = residual + hidden_states
463
+
464
+ # Fully Connected
465
+ residual = hidden_states
466
+ hidden_states = self.post_attention_layernorm(hidden_states)
467
+
468
+ if not self.use_async:
469
+ sp_mask = self.sp_mlp(hidden_states)
470
+
471
+ # Compute distillation loss
472
+ gating_output = self.mlp.sparse_act_fn(self.mlp.gate_proj(hidden_states))
473
+ loss_func = MSELoss()
474
+ self.distill_loss = loss_func(sp_mask, gating_output)
475
+
476
+ # Convert sp mask into binary form
477
+ sp_mask = sp_mask > 0
478
+
479
+ if self.training:
480
+ sp_mask = None
481
+ # if not self.use_sparse_predictor:
482
+ # sp_mask = None
483
+
484
+ hidden_states = self.mlp(hidden_states, sp_mask)
485
+ hidden_states = residual + hidden_states
486
+
487
+ outputs = (hidden_states,)
488
+
489
+ if output_attentions:
490
+ outputs += (self_attn_weights,)
491
+
492
+ if use_cache:
493
+ outputs += (present_key_value,)
494
+
495
+ return outputs
496
+
497
+
498
+ class SparseMistralConfig(MistralConfig):
499
+ model_type = "sparse_mistral"
500
+
501
+ def __init__(self, **kwargs):
502
+ super().__init__(**kwargs)
503
+
504
+
505
+ class SparseMistralforCausalLM(MistralForCausalLM):
506
+ config_class = SparseMistralConfig
507
+
508
+ def __init__(self, config):
509
+ super().__init__(config)
510
+ self.config = config
511
+ if config.use_sparse_model:
512
+ self.apply_sparse_mlp()
513
+ if config.thresholds is not None:
514
+ for idx, m in enumerate(self.model.layers):
515
+ if isinstance(m.mlp, MistralSparseSiluMLP):
516
+ m.mlp.dead_threshold = config.thresholds[idx]
517
+ m.mlp.sparse_act_fn.set_new_threshold(m.mlp.dead_threshold)
518
+ m.mlp.kill_sparse_swish_outputs = True
519
+ m.mlp.use_relu = config.use_relu
520
+ if config.use_sparse_predictor:
521
+ self.apply_sparse_predictor(init_svd=config.init_svd)
522
+
523
+ def apply_sparse_mlp(self):
524
+ apply_mistral_sparse_silu_mlp(
525
+ self,
526
+ config=self.config,
527
+ use_sparse_regularization=self.config.use_sparse_regularization,
528
+ )
529
+
530
+ def apply_sparse_predictor(self, init_svd: bool = True):
531
+ apply_mistral_sparse_decoder_layer(self, config=self.config, init_svd=init_svd)
532
+
533
+
534
+ class GracefulRegularizationScheduler(TrainerCallback):
535
+ def __init__(
536
+ self,
537
+ num_warmup_steps=40,
538
+ is_enabled: bool = False,
539
+ model_name: str = "mistral",
540
+ test_dataset: Dataset = None,
541
+ targeted_sparsity: float = 0.5,
542
+ keep_regularization_with_kill: bool = False,
543
+ ):
544
+ """Scheduler for regularizing the model first before applying the dead threshold.
545
+
546
+ :param num_warmup_steps: number of training steps required to reach the dead threshold, defaults to 40
547
+ :param increment_ratio: by how much to increase the dead threshold.
548
+ For example, 0.5 means "increase the threshold by 0.5 * desired threshold
549
+ """
550
+ self.num_warmup_steps = num_warmup_steps
551
+ self.is_enabled = is_enabled
552
+ self.model_name = model_name
553
+ self.test_dataset = test_dataset
554
+ self.targeted_sparsity = targeted_sparsity
555
+ self.keep_regularization_with_kill = keep_regularization_with_kill
556
+ self.act_hist_path = f"/scr/lukeai/histograms/warm_up_reg_{targeted_sparsity}/act_hist.pt"
557
+ if self.is_enabled:
558
+ print("GracefulRegularizationScheduler is enabled.")
559
+ self.trainer = None
560
+
561
+ def set_trainer(self, trainer):
562
+ self.trainer = trainer
563
+
564
+ def on_step_end(self, args, state, control, **kwargs):
565
+ if not self.is_enabled:
566
+ return
567
+
568
+ model = kwargs["model"]
569
+ if isinstance(model, PeftModel):
570
+ base_model = model.get_base_model()
571
+ else:
572
+ base_model = model
573
+
574
+ if state.global_step == 1:
575
+ ds_print("Setting an initial reg threshold to 0.1")
576
+ set_regularization_threshold(base_model, 0.1)
577
+
578
+ if state.global_step == self.num_warmup_steps:
579
+ activate_stats(base_model)
580
+ enable_sparse_silu(base_model)
581
+ self.trainer.evaluate()
582
+ save_act_hist(base_model, self.act_hist_path)
583
+ set_sparse_threshold(base_model, self.targeted_sparsity, True)
584
+ deactivate_stats(base_model)
585
+ self.trainer.use_sparse_regularization = self.keep_regularization_with_kill
586
+ # set_layer_specific_regularization(model.get_base_model())
587
+ print_dead_neuron_stats(model.get_base_model())
588
+
589
+
590
+ class GradualSparsificationScheduler(TrainerCallback):
591
+ def __init__(
592
+ self,
593
+ num_warmup_steps=40,
594
+ increment_ratio=0.5,
595
+ is_enabled: bool = False,
596
+ model_name: str = "mistral",
597
+ ):
598
+ """Scheduler for gradually increasing a dead threshold until it reaches the desired threshold.
599
+
600
+ :param num_warmup_steps: number of training steps required to reach the dead threshold, defaults to 40
601
+ :param increment_ratio: by how much to increase the dead threshold.
602
+ For example, 0.5 means "increase the threshold by 0.5 * desired threshold
603
+ """
604
+ self.num_warmup_steps = num_warmup_steps
605
+ self.increment_ratio = increment_ratio
606
+ self.step_size = int(num_warmup_steps * increment_ratio)
607
+ self.is_enabled = is_enabled
608
+ self.model_name = model_name
609
+
610
+ def on_step_end(self, args, state, control, **kwargs):
611
+ model = kwargs["model"]
612
+
613
+ if not self.is_enabled:
614
+ if state.global_step <= 10:
615
+ for module in model.modules():
616
+ if isinstance(module, MistralSparseSiluMLP):
617
+ module.current_dead_threshold = module.dead_threshold
618
+ return
619
+
620
+ current_dead_threshold = 0
621
+ desired_dead_threshold = 0
622
+
623
+ if is_mainprocess():
624
+ ds_print(state.global_step)
625
+
626
+ if state.global_step % self.step_size == 2:
627
+ for module in model.modules():
628
+ if isinstance(module, MistralSparseSiluMLP):
629
+ desired_dead_threshold = copy.deepcopy(module.dead_threshold)
630
+ current_dead_threshold = module.current_dead_threshold
631
+ current_dead_threshold += self.increment_ratio * desired_dead_threshold
632
+ module.current_dead_threshold = min(desired_dead_threshold, current_dead_threshold)
633
+
634
+ if is_running_deepspeed and is_mainprocess():
635
+ ds_print(
636
+ state.global_step,
637
+ current_dead_threshold,
638
+ desired_dead_threshold,
639
+ )
640
+
641
+ if state.global_step % 2000 == 0:
642
+ if is_running_deepspeed and is_mainprocess():
643
+ ds_print(
644
+ f"Saving to /matx/u/lukeai/{self.model_name}_{state.global_step - 2}.pt",
645
+ )
646
+ torch.save(
647
+ model.state_dict(),
648
+ f"/matx/u/lukeai/{self.model_name}_{state.global_step - 2}.pt",
649
+ )
650
+
651
+
652
+ def get_sparse_mistral_config(
653
+ config: MistralConfig,
654
+ use_sparse_model=False,
655
+ use_sparse_predictor=False,
656
+ use_sparse_regularization=False,
657
+ use_graceful_regularization=False,
658
+ thresholds=None,
659
+ ):
660
+ new_config = SparseMistralConfig()
661
+ new_config.__dict__.update(config.__dict__)
662
+ config = new_config
663
+ config.use_sparse_model = use_sparse_model
664
+ config.use_sparse_predictor = use_sparse_predictor
665
+ config.use_sparse_regularization = use_sparse_regularization
666
+ config.use_graceful_regularization = use_graceful_regularization
667
+ config.thresholds = thresholds
668
+
669
+ return config
670
+
671
+
672
+ def apply_mistral_sparse_silu_mlp(
673
+ model,
674
+ config,
675
+ use_sparse_regularization: bool = False,
676
+ ):
677
+ # counts = 0
678
+ for layer in model.model.layers:
679
+ # counts += 1
680
+ # if counts < 4:
681
+ # continue
682
+ original_mlp = layer.mlp
683
+ new_mlp = MistralSparseSiluMLP(config, use_sparse_regularization=use_sparse_regularization)
684
+ new_mlp.gate_proj = original_mlp.gate_proj
685
+ new_mlp.up_proj = original_mlp.up_proj
686
+ new_mlp.down_proj = original_mlp.down_proj
687
+ layer.mlp = new_mlp
688
+
689
+
690
+ def apply_mistral_sparse_decoder_layer(
691
+ model,
692
+ config,
693
+ init_svd: bool = True,
694
+ ):
695
+ assert isinstance(model.model, MistralModel), "model.model must be a MistralModel."
696
+ new_layers = []
697
+ for layer_idx, layer in enumerate(model.model.layers):
698
+ if isinstance(layer.mlp, MistralSparseSiluMLP):
699
+ new_layers.append(
700
+ SparseMistralDecoderLayer(
701
+ config=config,
702
+ layer_idx=layer_idx,
703
+ decoder_layer=layer,
704
+ init_svd=init_svd,
705
+ )
706
+ )
707
+ print(f"{layer_idx}th mlp layer activation: {layer.mlp.sparse_act_fn}")
708
+ else:
709
+ new_layers.append(layer)
710
+ model.model.layers = nn.ModuleList(new_layers)
711
+
712
+
713
+ def enable_sparse_predictor(
714
+ model,
715
+ ):
716
+ for layer_idx, layer in enumerate(model.model.layers):
717
+ if isinstance(layer, MistralDecoderLayer):
718
+ layer.use_sparse_predictor = True
719
+
720
+
721
+ def disable_sparse_predictor(
722
+ model,
723
+ ):
724
+ for layer_idx, layer in enumerate(model.model.layers):
725
+ if isinstance(layer, MistralDecoderLayer):
726
+ layer.use_sparse_predictor = False
727
+
728
+
729
+ def activate_stats(model, is_collect_histogram: bool = True):
730
+ for layer in model.model.layers:
731
+ if isinstance(layer.mlp, MistralSparseSiluMLP):
732
+ layer.mlp.activate_stats(is_collect_histogram=is_collect_histogram)
733
+
734
+
735
+ def deactivate_stats(model):
736
+ for layer in model.model.layers:
737
+ if isinstance(layer.mlp, MistralSparseSiluMLP):
738
+ layer.mlp.deactivate_stats()
739
+
740
+
741
+ def enable_sparse_silu(model):
742
+ print("Enabling SparseSilu")
743
+ for i, layer in enumerate(model.model.layers):
744
+ if isinstance(layer.mlp, MistralSparseSiluMLP):
745
+ layer.mlp.kill_sparse_swish_outputs = True
746
+
747
+
748
+ def print_dead_neuron_stats(model):
749
+ total_sparsity = 0
750
+ counts = 0
751
+ for i, layer in enumerate(model.model.layers):
752
+ if isinstance(layer.mlp, MistralSparseSiluMLP):
753
+ dead_percentage = layer.mlp.dead_percentage * 100
754
+ agg_sparsity = layer.mlp.agg_sparsity * 100
755
+ print(f"layer {i} sparsity: {dead_percentage:.3f}%")
756
+ print(f"layer {i} agg sparsity: {agg_sparsity:.3f}%")
757
+ total_sparsity += dead_percentage
758
+ counts += 1
759
+
760
+ print(f"Total sparsity: {total_sparsity/counts: .3f}%")
761
+ return total_sparsity / counts
762
+
763
+
764
+ def get_sparse_layers(model: MistralModel):
765
+ sparse_layers = [m.mlp for m in model.layers() if isinstance(m.mlp, MistralSparseSiluMLP)]
766
+ return sparse_layers
767
+
768
+
769
+ def get_threshold(bin_edges: torch.tensor, histogram_counts: torch.tensor, sparsity_level: float): # Only for L1 Regularization
770
+ assert len(bin_edges.shape) == len(histogram_counts.shape) == 1, "bin_edges and histogram are expected to be 1-dimensional."
771
+ histogram_counts /= histogram_counts.sum()
772
+ threshold_idx = torch.searchsorted(histogram_counts.cumsum(0), sparsity_level, side="right")
773
+
774
+ return bin_edges[threshold_idx]
775
+
776
+
777
+ def set_regularization_threshold(model, threshold: float = 0.1):
778
+ for i, layer in enumerate(model.model.layers):
779
+ if (
780
+ isinstance(layer.mlp, MistralSparseSiluMLP) and layer.mlp.is_stats
781
+ ): # Can set the threshold only the relevant statistics is collected.
782
+ layer.mlp.regularization_threshold = threshold # TODO: find better param
783
+
784
+
785
+ def set_sparse_threshold(model, sparsity_level: float, use_relu: bool = False):
786
+ for i, layer in enumerate(model.model.layers):
787
+ if (
788
+ isinstance(layer.mlp, MistralSparseSiluMLP) and layer.mlp.is_stats
789
+ ): # Can set the threshold only the relevant statistics is collected.
790
+ if use_relu:
791
+ layer.mlp.sparse_act_fn = nn.ReLU()
792
+ layer.mlp.use_relu = True
793
+ else:
794
+ layer.mlp.dead_threshold = get_threshold(
795
+ layer.mlp.histogram_bins,
796
+ layer.mlp.post_act_hist_counts,
797
+ sparsity_level,
798
+ )
799
+ layer.mlp.sparse_act_fn.set_new_threshold(layer.mlp.dead_threshold)
800
+ layer.mlp.regularization_threshold = layer.mlp.dead_threshold * 1.2 # TODO: find better param
801
+
802
+
803
+ def plot_histogram(
804
+ bin_edges,
805
+ histogram_counts: torch.tensor,
806
+ title: str = "Activation Distribution",
807
+ fig_dir: str = "figures",
808
+ ):
809
+ plt.bar(bin_edges[:-1], histogram_counts, width=np.diff(bin_edges), edgecolor="black")
810
+ plt.title(title)
811
+ plt.xlabel("Activation Value")
812
+ plt.ylabel("Frequency")
813
+ os.makedirs(fig_dir, exist_ok=True)
814
+ plt.savefig(f"{fig_dir}/{title}.png")
815
+ # plt.show()
816
+ plt.clf()
817
+
818
+
819
+ def plot_act(model, fig_dir: str = "figures"):
820
+ for i, layer in enumerate(model.model.layers):
821
+ if (
822
+ isinstance(layer.mlp, MistralSparseSiluMLP) and layer.mlp.is_stats
823
+ ): # Can set the threshold only the relevant statistics is collected.
824
+ plot_title = f"Layer: {i} Pre-Activation Distribution"
825
+ plot_histogram(layer.mlp.histogram_bins, layer.mlp.pre_act_hist_counts, plot_title)
826
+
827
+ plot_title = f"Layer: {i} Post-Activation Absolute Distribution"
828
+ plot_histogram(layer.mlp.histogram_bins, layer.mlp.post_act_hist_counts, plot_title)
829
+
830
+
831
+ def save_act_hist(model, filename="/scr/jay/models/mistral/pre_finetune/cola_act_hist.pt"):
832
+ os.makedirs(os.path.dirname(filename), exist_ok=True)
833
+ act_dict = {}
834
+ for i, layer in enumerate(model.model.layers):
835
+ if (
836
+ isinstance(layer.mlp, MistralSparseSiluMLP) and layer.mlp.is_stats
837
+ ): # Can set the threshold only the relevant statistics is collected.
838
+ act_dict[i] = (
839
+ layer.mlp.histogram_bins,
840
+ layer.mlp.pre_act_hist_counts,
841
+ layer.mlp.post_act_hist_counts,
842
+ )
843
+ print("Saving activation histograms...\n\n\n")
844
+ torch.save(act_dict, filename)
845
+
846
+
847
+ def load_act_hist(model, filename="/scr/jay/models/mistral/pre_finetune/cola_act_hist.pt"):
848
+ assert os.path.exists(filename), f"{filename} does not exist when loading pre/post-activation histogram of SparseMistralSiluMLP."
849
+ print("Loading activation histograms...\n\n\n")
850
+
851
+ act_dict = torch.load(filename)
852
+ for i, layer in enumerate(model.model.layers):
853
+ if (
854
+ isinstance(layer.mlp, MistralSparseSiluMLP) and layer.mlp.is_stats
855
+ ): # Can set the threshold only the relevant statistics is collected.
856
+ (
857
+ layer.mlp.histogram_bins,
858
+ layer.mlp.pre_act_hist_counts,
859
+ layer.mlp.post_act_hist_counts,
860
+ ) = act_dict[i]
861
+
862
+
863
+ def enable_last_k_modules(model, start_module_idx: int):
864
+ assert 32 > start_module_idx >= 0
865
+ new_modules = []
866
+ new_idx = 0
867
+ for idx in range(start_module_idx, len(model.model.original_layers)):
868
+ module = model.model.original_layers[idx]
869
+ module.layer_idx = new_idx
870
+ module.self_attn.layer_idx = new_idx
871
+ new_modules.append(module)
872
+ new_idx += 1
873
+ print(module.layer_idx)
874
+
875
+ model.model.layers = nn.ModuleList(new_modules)
876
+
877
+
878
+ def enable_first_k_modules(model, end_module_idx: int):
879
+ assert 32 > end_module_idx >= 0
880
+ new_modules = []
881
+ new_idx = 0
882
+ for idx in range(0, end_module_idx + 1):
883
+ module = model.model.original_layers[idx]
884
+ module.layer_idx = new_idx
885
+ module.self_attn.layer_idx = new_idx
886
+ new_modules.append(module)
887
+ new_idx += 1
888
+ print(module.layer_idx)
889
+
890
+ model.model.layers = nn.ModuleList(new_modules)
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": "</s>",
17
+ "unk_token": {
18
+ "content": "<unk>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "added_tokens_decoder": {
5
+ "0": {
6
+ "content": "<unk>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "1": {
14
+ "content": "<s>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "2": {
22
+ "content": "</s>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ }
29
+ },
30
+ "additional_special_tokens": [],
31
+ "bos_token": "<s>",
32
+ "clean_up_tokenization_spaces": false,
33
+ "eos_token": "</s>",
34
+ "legacy": true,
35
+ "model_max_length": 1000000000000000019884624838656,
36
+ "pad_token": "</s>",
37
+ "sp_model_kwargs": {},
38
+ "spaces_between_special_tokens": false,
39
+ "tokenizer_class": "LlamaTokenizer",
40
+ "unk_token": "<unk>",
41
+ "use_default_system_prompt": false
42
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a60d5c2620a22e93efd5fcbd504b269cd97b3e419ecab1ba16b46f01f1e4420
3
+ size 4728