monet9736 commited on
Commit
12b011c
1 Parent(s): a943f0d

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags:
4
+ - alignment-handbook
5
+ - generated_from_trainer
6
+ datasets:
7
+ - HuggingFaceTB/Magpie-Pro-300K-Filtered-H4
8
+ - HuggingFaceTB/self-oss-instruct-sc2-H4
9
+ - HuggingFaceTB/OpenHermes-2.5-H4
10
+ - HuggingFaceTB/everyday-conversations-llama3.1-2k
11
+ - HuggingFaceTB/instruct-data-basics-smollm-H4
12
+ model-index:
13
+ - name: monet-vd-1.4B-100BT-chat-hf
14
+ results: []
15
+ ---
16
+
17
+ <!-- This model card has been generated automatically according to the information the Trainer had access to. You
18
+ should probably proofread and complete it, then remove this comment. -->
19
+
20
+ # monet-vd-1.4B-100BT-chat-hf
21
+
22
+ This model is a fine-tuned version of [monet-vd-1.4B-100BT-hf](https://huggingface.co/MonetLLM/monet-vd-1.4B-100BT-hf) on the HuggingFaceTB/Magpie-Pro-300K-Filtered-H4, the HuggingFaceTB/self-oss-instruct-sc2-H4, the HuggingFaceTB/OpenHermes-2.5-H4, the HuggingFaceTB/everyday-conversations-llama3.1-2k and the HuggingFaceTB/instruct-data-basics-smollm-H4 datasets.
23
+ It achieves the following results on the evaluation set:
24
+ - Loss: 1.1664
25
+
26
+ ## Model description
27
+
28
+ More information needed
29
+
30
+ ## Intended uses & limitations
31
+
32
+ More information needed
33
+
34
+ ## Training and evaluation data
35
+
36
+ More information needed
37
+
38
+ ## Training procedure
39
+
40
+ ### Training hyperparameters
41
+
42
+ The following hyperparameters were used during training:
43
+ - learning_rate: 0.0003
44
+ - train_batch_size: 4
45
+ - eval_batch_size: 4
46
+ - seed: 42
47
+ - distributed_type: multi-GPU
48
+ - num_devices: 4
49
+ - gradient_accumulation_steps: 8
50
+ - total_train_batch_size: 128
51
+ - total_eval_batch_size: 16
52
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
53
+ - lr_scheduler_type: cosine
54
+ - lr_scheduler_warmup_ratio: 0.1
55
+ - num_epochs: 1
56
+
57
+ ### Training results
58
+
59
+ | Training Loss | Epoch | Step | Validation Loss |
60
+ |:-------------:|:------:|:----:|:---------------:|
61
+ | 0.8032 | 0.9988 | 502 | 1.1664 |
62
+
63
+
64
+ ### Framework versions
65
+
66
+ - Transformers 4.44.2
67
+ - Pytorch 2.4.1
68
+ - Datasets 2.21.0
69
+ - Tokenizers 0.19.1
all_results.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "epoch": 0.9987565282268093,
3
+ "eval_loss": 1.1664291620254517,
4
+ "eval_runtime": 1405.1859,
5
+ "eval_samples": 82730,
6
+ "eval_samples_per_second": 16.588,
7
+ "eval_steps_per_second": 1.037,
8
+ "total_flos": 234414617395200.0,
9
+ "train_loss": 0.8937448220423968,
10
+ "train_runtime": 13768.4166,
11
+ "train_samples": 186330,
12
+ "train_samples_per_second": 4.672,
13
+ "train_steps_per_second": 0.036
14
+ }
config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": ["MonetForCausalLM"],
3
+ "attention_bias": false,
4
+ "attention_dropout": 0.0,
5
+ "auto_map": {
6
+ "AutoConfig": "modeling_monet.MonetConfig",
7
+ "AutoModelForCausalLM": "modeling_monet.MonetForCausalLM"
8
+ },
9
+ "bos_token_id": 1,
10
+ "eos_token_id": 2,
11
+ "hidden_act": "relu2",
12
+ "hidden_size": 2048,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": null,
15
+ "max_position_embeddings": 2048,
16
+ "mlp_bias": null,
17
+ "model_type": "monet",
18
+ "moe_decompose": "vertical",
19
+ "moe_dim": 16,
20
+ "moe_experts": 512,
21
+ "moe_groups": 4,
22
+ "moe_heads": 8,
23
+ "moe_topk": 8,
24
+ "num_attention_heads": 16,
25
+ "num_hidden_layers": 24,
26
+ "num_key_value_heads": 16,
27
+ "output_router_probs": false,
28
+ "pretraining_tp": 1,
29
+ "rms_norm_eps": 1e-6,
30
+ "rope_scaling": null,
31
+ "rope_theta": 10000.0,
32
+ "tie_word_embeddings": false,
33
+ "torch_dtype": "bfloat16",
34
+ "transformers_version": "4.44.2",
35
+ "use_cache": true,
36
+ "vocab_size": 32000
37
+ }
eval_results.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "epoch": 0.9987565282268093,
3
+ "eval_loss": 1.1664291620254517,
4
+ "eval_runtime": 1405.1859,
5
+ "eval_samples": 82730,
6
+ "eval_samples_per_second": 16.588,
7
+ "eval_steps_per_second": 1.037
8
+ }
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.44.2"
6
+ }
interpretation/embeddings-0.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:74554360419b088909efae4ae09e38735b002c9cae03f32228ff86145d3f8136
3
+ size 1073743029
interpretation/embeddings-1.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:86dcae4c950c033905c99d0443b514cd2760d2e53e36620023a9f67e8ca5eb90
3
+ size 1073743029
interpretation/embeddings-2.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d5d87a75cbf5748380f810f673474602027a6fd858a2d435739976270e9b574a
3
+ size 1073743029
interpretation/embeddings-3.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c76e17add23fe8a1cce5827e5b53cd59c46cc1771e932fd635bc60b3961540e
3
+ size 1073743029
interpretation/embeddings-4.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5a6373ddea12b56129c67b26c10db4cdf96e1ea1f3e9c4b6c1efb9754ada634b
3
+ size 1073743029
interpretation/embeddings-5.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8c8c8de2fde422690d361cf7a59abc5f863442ec223e62ec7029f16db3f59d48
3
+ size 1073743029
interpretation/examples-0.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:71750857dbf288e52c6de4faf6e9808ae787f3db93b09b81263e0e22adafd615
3
+ size 99785078
interpretation/examples-1.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:236966ff9a822d27f38a408a13dd2b7fa948fccdaefa25c4f7746d90750a8b55
3
+ size 186844896
interpretation/examples-2.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ba38c6b4fc4c97794704c33646aeec55643c4f9bba0b86378882b0fad1b866a
3
+ size 151744447
interpretation/examples-3.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18151accfdec95f236eb3ccbe0b4418b7f30ec027dffc38a2df139a6de076bba
3
+ size 196289141
interpretation/examples-4.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5587d6bcf1562be1bbe006b522849542ba7c126d31ab67435e0f975ac5d58f4a
3
+ size 244767190
interpretation/examples-5.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:450696857c0c06a630f70b512fd047f1436f9d775842bfceba4d33f5c502d101
3
+ size 247488639
interpretation/inputs.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c6d9e5feaca0db26368a82f6151c276638d910f2efaf5f313d3822ad1379f9c
3
+ size 157615191
interpretation/routings-0.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a014eb363ab2fae5d2d08c351b8f0dc81fa4c848216f797ab85dbe50556484b
3
+ size 2715152823
interpretation/routings-1.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a46dfea287041d4121c3a68e3b0109b629bf31fce2f66e296075ba25fefb7ec
3
+ size 2713393723
interpretation/routings-2.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:62e6267a5ed8852d20259789276ad3bb5eb1e14b273ddd740de3296bce97b164
3
+ size 1681898562
interpretation/routings-3.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cd7fdf3a3ab31346bdffa781b1d9b80a510015bd1b0afbeb164a3ed27a358b5e
3
+ size 1622189972
interpretation/routings-4.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:22f6cbee6cc421193e91fe3b0e1ce6d8c5fb4abcdf9551ca48b7069d3b70f954
3
+ size 2007108077
interpretation/routings-5.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:28446ce8d4f29127499ff503d01ed15a9bf2f71d20ddd7095c81470036203733
3
+ size 2680546231
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab36abbc22160db50fef82a4d24a03151172abcfa6a4a4256b475475d7524f99
3
+ size 2930363080
modeling_monet.py ADDED
@@ -0,0 +1,663 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # fmt: off
2
+ from __future__ import annotations
3
+
4
+ from dataclasses import dataclass
5
+
6
+ import torch
7
+ import torch.utils.checkpoint
8
+ from scipy.stats import norm
9
+ from torch import nn
10
+ from torch.nn import CrossEntropyLoss
11
+ from transformers.activations import ACT2FN
12
+ from transformers.cache_utils import Cache, DynamicCache, StaticCache
13
+ from transformers.modeling_attn_mask_utils import AttentionMaskConverter
14
+ from transformers.modeling_utils import PreTrainedModel
15
+ from transformers.models.llama.configuration_llama import LlamaConfig
16
+ from transformers.models.llama.modeling_llama import (
17
+ LLAMA_ATTENTION_CLASSES,
18
+ LlamaRMSNorm,
19
+ )
20
+ from transformers.utils import ModelOutput, logging
21
+
22
+ logger = logging.get_logger(__name__)
23
+
24
+
25
+ @dataclass
26
+ class MonetModelOutputWithPast(ModelOutput):
27
+ last_hidden_state: torch.FloatTensor = None
28
+ past_key_values: tuple[tuple[torch.FloatTensor]] | None = None
29
+ hidden_states: tuple[torch.FloatTensor, ...] | None = None
30
+ attentions: tuple[torch.FloatTensor, ...] | None = None
31
+ router_probs: tuple[tuple[torch.FloatTensor, ...], ...] | None = None
32
+
33
+
34
+ @dataclass
35
+ class MonetCausalLMOutputWithPast(ModelOutput):
36
+ loss: torch.FloatTensor | None = None
37
+ aux_loss: torch.FloatTensor | None = None
38
+ logits: torch.FloatTensor = None
39
+ past_key_values: tuple[tuple[torch.FloatTensor]] | None = None
40
+ hidden_states: tuple[torch.FloatTensor, ...] | None = None
41
+ attentions: tuple[torch.FloatTensor, ...] | None = None
42
+ router_probs: tuple[tuple[torch.FloatTensor, ...], ...] | None = None
43
+
44
+
45
+ class MonetConfig(LlamaConfig):
46
+ model_type = "monet"
47
+ keys_to_ignore_at_inference = ["past_key_values"]
48
+
49
+ def __init__(
50
+ self,
51
+ vocab_size=32000,
52
+ hidden_size=4096,
53
+ intermediate_size=None,
54
+ num_hidden_layers=32,
55
+ num_attention_heads=32,
56
+ num_key_value_heads=None,
57
+ hidden_act="relu2",
58
+ max_position_embeddings=2048,
59
+ initializer_range=0.02,
60
+ rms_norm_eps=1e-6,
61
+ use_cache=True,
62
+ pad_token_id=None,
63
+ bos_token_id=1,
64
+ eos_token_id=2,
65
+ pretraining_tp=1,
66
+ tie_word_embeddings=False,
67
+ rope_theta=10000.0,
68
+ rope_scaling=None,
69
+ attention_bias=False,
70
+ attention_dropout=0.0,
71
+ mlp_bias=None,
72
+ moe_dim=8,
73
+ moe_heads=8,
74
+ moe_experts=512,
75
+ moe_topk=32,
76
+ moe_groups=4,
77
+ moe_decompose="vertical",
78
+ output_router_probs=False,
79
+ **kwargs,
80
+ ):
81
+ self.moe_dim = moe_dim
82
+ self.moe_heads = moe_heads
83
+ self.moe_experts = moe_experts
84
+ self.moe_topk = moe_topk
85
+ self.moe_groups = moe_groups
86
+ self.moe_decompose = moe_decompose
87
+ self.output_router_probs = output_router_probs
88
+
89
+ super().__init__(
90
+ vocab_size=vocab_size,
91
+ hidden_size=hidden_size,
92
+ intermediate_size=intermediate_size,
93
+ num_hidden_layers=num_hidden_layers,
94
+ num_attention_heads=num_attention_heads,
95
+ num_key_value_heads=num_key_value_heads,
96
+ hidden_act=hidden_act,
97
+ max_position_embeddings=max_position_embeddings,
98
+ initializer_range=initializer_range,
99
+ rms_norm_eps=rms_norm_eps,
100
+ use_cache=use_cache,
101
+ pad_token_id=pad_token_id,
102
+ bos_token_id=bos_token_id,
103
+ eos_token_id=eos_token_id,
104
+ pretraining_tp=pretraining_tp,
105
+ tie_word_embeddings=tie_word_embeddings,
106
+ rope_theta=rope_theta,
107
+ rope_scaling=rope_scaling,
108
+ attention_bias=attention_bias,
109
+ attention_dropout=attention_dropout,
110
+ mlp_bias=mlp_bias,
111
+ **kwargs,
112
+ )
113
+
114
+
115
+ class MonetRouter(nn.Module):
116
+ def __init__(self, config: MonetConfig):
117
+ super().__init__()
118
+ self.config = config
119
+ flatten_shape = config.moe_heads * config.moe_experts
120
+
121
+ self.w1 = nn.Linear(config.hidden_size, flatten_shape, bias=False)
122
+ self.w2 = nn.Linear(config.hidden_size, flatten_shape, bias=False)
123
+ self.norm1 = nn.BatchNorm1d(config.moe_heads, affine=False)
124
+ self.norm2 = nn.BatchNorm1d(config.moe_heads, affine=False)
125
+
126
+ def forward(self, x: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
127
+ g1z = self.w1(x).unflatten(-1, (self.config.moe_heads, -1)).float()
128
+ g2z = self.w2(x).unflatten(-1, (self.config.moe_heads, -1)).float()
129
+
130
+ g1n = self.norm1(g1z.transpose(2, 3).flatten(0, -2))
131
+ g2n = self.norm2(g2z.transpose(2, 3).flatten(0, -2))
132
+ g1n = g1n.view(g1z.size(0), g1z.size(1), g1z.size(3), -1).transpose(2, 3)
133
+ g2n = g2n.view(g2z.size(0), g2z.size(1), g2z.size(3), -1).transpose(2, 3)
134
+
135
+ sigma = float(norm.ppf(1 - self.config.moe_topk / self.config.moe_experts))
136
+ g1s = g1n.amax(-1, keepdim=True).clamp_max_(sigma)
137
+ g2s = g2n.amax(-1, keepdim=True).clamp_max_(sigma)
138
+
139
+ g1 = nn.functional.softmax(torch.where(g1n >= g1s, g1z, -1e10), dim=-1)
140
+ g2 = nn.functional.softmax(torch.where(g2n >= g2s, g2z, -1e10), dim=-1)
141
+ return g1, g2
142
+
143
+
144
+ class MonetMoVDE(nn.Module):
145
+ def __init__(self, config: MonetConfig):
146
+ super().__init__()
147
+ self.config = config
148
+ self.act_fn = ACT2FN[config.hidden_act]
149
+ flatten_shape = config.moe_experts * config.moe_dim // 2
150
+
151
+ self.u1 = nn.Linear(config.hidden_size, flatten_shape)
152
+ self.u2 = nn.Linear(config.hidden_size, flatten_shape)
153
+
154
+ self.v11 = nn.Linear(flatten_shape, config.hidden_size // 2, bias=False)
155
+ self.v12 = nn.Linear(flatten_shape, config.hidden_size // 2, bias=False)
156
+ self.v21 = nn.Linear(flatten_shape, config.hidden_size // 2, bias=False)
157
+ self.v22 = nn.Linear(flatten_shape, config.hidden_size // 2, bias=False)
158
+
159
+ self.b1 = nn.Parameter(torch.zeros(config.moe_experts, config.hidden_size // 2))
160
+ self.b2 = nn.Parameter(torch.zeros(config.moe_experts, config.hidden_size // 2))
161
+
162
+ def forward(
163
+ self, x: torch.Tensor, g1: torch.Tensor, g2: torch.Tensor
164
+ ) -> torch.Tensor:
165
+ g1, g2 = g1.type_as(x), g2.type_as(x)
166
+ x1 = self.act_fn(self.u1(x).unflatten(-1, (self.config.moe_experts, -1)))
167
+ x2 = self.act_fn(self.u2(x).unflatten(-1, (self.config.moe_experts, -1)))
168
+
169
+ x11 = self.v11(torch.einsum("btim,bthi->btim", x1, g1).flatten(-2))
170
+ x12 = self.v12(torch.einsum("btjm,bthj,bthi->btim", x2, g2, g1).flatten(-2))
171
+ x13 = torch.einsum("bthi,id->btd", g1, self.b1.type_as(x))
172
+
173
+ x21 = self.v21(torch.einsum("btim,bthi,bthj->btjm", x1, g1, g2).flatten(-2))
174
+ x22 = self.v22(torch.einsum("btjm,bthj->btjm", x2, g2).flatten(-2))
175
+ x23 = torch.einsum("bthj,jd->btd", g2, self.b2.type_as(x))
176
+
177
+ return torch.cat((x11 + x12 + x13, x21 + x22 + x23), dim=-1)
178
+
179
+
180
+ class MonetMoHDE(nn.Module):
181
+ def __init__(self, config: MonetConfig):
182
+ super().__init__()
183
+ self.config = config
184
+ self.act_fn = ACT2FN[config.hidden_act]
185
+ flatten_shape = config.moe_experts * config.moe_dim
186
+
187
+ self.u = nn.Linear(config.hidden_size, flatten_shape)
188
+ self.v = nn.Linear(flatten_shape, config.hidden_size, bias=False)
189
+ self.b = nn.Parameter(torch.zeros(config.moe_experts, config.hidden_size))
190
+
191
+ def forward(
192
+ self, x: torch.Tensor, g1: torch.Tensor, g2: torch.Tensor
193
+ ) -> torch.Tensor:
194
+ g1, g2 = g1.type_as(x), g2.type_as(x)
195
+ x = self.act_fn(self.u(x).unflatten(-1, (self.config.moe_experts, -1)))
196
+ x = self.v(torch.einsum("btim,bthi,bthj->btjm", x, g1, g2).flatten(-2))
197
+ return x + torch.einsum("bthj,jd->btd", g2, self.b)
198
+
199
+
200
+ class MonetDecoderLayer(nn.Module):
201
+ def __init__(self, config: MonetConfig, layer_idx: int):
202
+ super().__init__()
203
+ self.hidden_size = config.hidden_size
204
+ self.self_attn = LLAMA_ATTENTION_CLASSES[config._attn_implementation](
205
+ config=config, layer_idx=layer_idx
206
+ )
207
+ self.input_layernorm = LlamaRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
208
+ self.post_attention_layernorm = LlamaRMSNorm(
209
+ config.hidden_size, eps=config.rms_norm_eps
210
+ )
211
+
212
+ if config.moe_decompose == "vertical":
213
+ self.moe = MonetMoVDE(config)
214
+ elif config.moe_decompose == "horizontal":
215
+ self.moe = MonetMoHDE(config)
216
+ if layer_idx % config.moe_groups == 0:
217
+ self.router = MonetRouter(config).requires_grad_(False)
218
+
219
+ def forward(
220
+ self,
221
+ hidden_states: torch.Tensor,
222
+ attention_mask: torch.Tensor | None = None,
223
+ position_ids: torch.LongTensor | None = None,
224
+ past_key_value: Cache | None = None,
225
+ previous_router_probs: tuple[torch.Tensor, torch.Tensor] | None = None,
226
+ output_attentions: bool | None = False,
227
+ use_cache: bool | None = False,
228
+ cache_position: torch.LongTensor | None = None,
229
+ **kwargs,
230
+ ) -> tuple[torch.FloatTensor, ...]:
231
+ residual = hidden_states
232
+
233
+ hidden_states = self.input_layernorm(hidden_states)
234
+
235
+ # Self Attention
236
+ hidden_states, self_attn_weights, present_key_value = self.self_attn(
237
+ hidden_states=hidden_states,
238
+ attention_mask=attention_mask,
239
+ position_ids=position_ids,
240
+ past_key_value=past_key_value,
241
+ output_attentions=output_attentions,
242
+ use_cache=use_cache,
243
+ cache_position=cache_position,
244
+ )
245
+ hidden_states = residual + hidden_states
246
+
247
+ # Fully Connected
248
+ residual = hidden_states
249
+ hidden_states = self.post_attention_layernorm(hidden_states)
250
+ g1, g2 = (
251
+ self.router(hidden_states)
252
+ if hasattr(self, "router")
253
+ else previous_router_probs
254
+ )
255
+ hidden_states = self.moe(hidden_states, g1, g2)
256
+ hidden_states = residual + hidden_states
257
+
258
+ outputs = (hidden_states,)
259
+
260
+ if output_attentions:
261
+ outputs += (self_attn_weights,)
262
+
263
+ if use_cache:
264
+ outputs += (present_key_value,)
265
+
266
+ return outputs + ((g1, g2) if hasattr(self, "router") else None,)
267
+
268
+
269
+ class MonetPreTrainedModel(PreTrainedModel):
270
+ config_class = MonetConfig
271
+ base_model_prefix = "model"
272
+ supports_gradient_checkpointing = True
273
+ _no_split_modules = ["MonetDecoderLayer"]
274
+ _skip_keys_device_placement = ["past_key_values"]
275
+ _supports_flash_attn_2 = True
276
+ _supports_sdpa = True
277
+ _supports_cache_class = True
278
+ _supports_quantized_cache = True
279
+ _supports_static_cache = True
280
+
281
+ def _init_weights(self, module):
282
+ std = self.config.initializer_range
283
+ if isinstance(module, nn.Linear):
284
+ module.weight.data.normal_(mean=0.0, std=std)
285
+ if module.bias is not None:
286
+ module.bias.data.zero_()
287
+ elif isinstance(module, nn.Embedding):
288
+ module.weight.data.normal_(mean=0.0, std=std)
289
+ if module.padding_idx is not None:
290
+ module.weight.data[module.padding_idx].zero_()
291
+
292
+
293
+ class MonetModel(MonetPreTrainedModel):
294
+ def __init__(self, config: MonetConfig):
295
+ super().__init__(config)
296
+ self.padding_idx = config.pad_token_id
297
+ self.vocab_size = config.vocab_size
298
+
299
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx) # noqa
300
+ self.layers = nn.ModuleList([MonetDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]) # noqa
301
+ self.norm = LlamaRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
302
+ self.gradient_checkpointing = False
303
+
304
+ # Initialize weights and apply final processing
305
+ self.post_init()
306
+
307
+ def get_input_embeddings(self):
308
+ return self.embed_tokens
309
+
310
+ def set_input_embeddings(self, value):
311
+ self.embed_tokens = value
312
+
313
+ def forward(
314
+ self,
315
+ input_ids: torch.LongTensor = None,
316
+ attention_mask: torch.Tensor | None = None,
317
+ position_ids: torch.LongTensor | None = None,
318
+ past_key_values: Cache | list[torch.FloatTensor] | None = None,
319
+ inputs_embeds: torch.FloatTensor | None = None,
320
+ use_cache: bool | None = None,
321
+ output_attentions: bool | None = None,
322
+ output_hidden_states: bool | None = None,
323
+ output_router_probs: bool | None = None,
324
+ return_dict: bool | None = None,
325
+ cache_position: torch.LongTensor | None = None,
326
+ ) -> tuple[torch.Tensor, ...] | MonetModelOutputWithPast:
327
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions # noqa
328
+ output_hidden_states = output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states # noqa
329
+ output_router_probs = output_router_probs if output_router_probs is not None else self.config.output_router_probs # noqa
330
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
331
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict # noqa
332
+
333
+ if (input_ids is None) ^ (inputs_embeds is not None):
334
+ raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one") # noqa
335
+
336
+ if self.gradient_checkpointing and self.training and use_cache:
337
+ logger.warning_once("`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`.") # noqa
338
+ use_cache = False
339
+
340
+ if inputs_embeds is None:
341
+ inputs_embeds = self.embed_tokens(input_ids)
342
+
343
+ return_legacy_cache = False
344
+ if use_cache and not isinstance(past_key_values, Cache): # kept for BC (non `Cache` `past_key_values` inputs) # noqa
345
+ return_legacy_cache = True
346
+ past_key_values = DynamicCache.from_legacy_cache(past_key_values)
347
+ logger.warning_once(
348
+ "We detected that you are passing `past_key_values` as a tuple and this is deprecated and will be removed in v4.43. " # noqa
349
+ "Please use an appropriate `Cache` class (https://huggingface.co/docs/transformers/v4.41.3/en/internal/generation_utils#transformers.Cache)" # noqa
350
+ )
351
+
352
+ if cache_position is None:
353
+ past_seen_tokens = (
354
+ past_key_values.get_seq_length() if past_key_values is not None else 0
355
+ )
356
+ cache_position = torch.arange(past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device) # noqa
357
+ if position_ids is None:
358
+ position_ids = cache_position.unsqueeze(0)
359
+ causal_mask = self._update_causal_mask(attention_mask, inputs_embeds, cache_position, past_key_values, output_attentions) # noqa
360
+
361
+ # embed positions
362
+ hidden_states = inputs_embeds
363
+
364
+ # decoder layers
365
+ all_hidden_states = () if output_hidden_states else None
366
+ all_self_attns = () if output_attentions else None
367
+ all_router_probs = () if output_router_probs else None
368
+ previous_router_probs, next_decoder_cache = None, None
369
+
370
+ for decoder_layer in self.layers:
371
+ if output_hidden_states:
372
+ all_hidden_states += (hidden_states,)
373
+
374
+ if self.gradient_checkpointing and self.training:
375
+ layer_outputs = self._gradient_checkpointing_func(
376
+ decoder_layer.__call__,
377
+ hidden_states,
378
+ causal_mask,
379
+ position_ids,
380
+ past_key_values,
381
+ previous_router_probs,
382
+ output_attentions,
383
+ use_cache,
384
+ cache_position,
385
+ )
386
+ else:
387
+ layer_outputs = decoder_layer(
388
+ hidden_states,
389
+ attention_mask=causal_mask,
390
+ position_ids=position_ids,
391
+ past_key_value=past_key_values,
392
+ previous_router_probs=previous_router_probs,
393
+ output_attentions=output_attentions,
394
+ use_cache=use_cache,
395
+ cache_position=cache_position,
396
+ )
397
+
398
+ hidden_states = layer_outputs[0]
399
+ if use_cache:
400
+ next_decoder_cache = layer_outputs[2 if output_attentions else 1]
401
+ if output_attentions:
402
+ all_self_attns += (layer_outputs[1],)
403
+ if output_router_probs:
404
+ all_router_probs += (layer_outputs[-1],)
405
+ previous_router_probs = (
406
+ layer_outputs[-1]
407
+ if layer_outputs[-1] is not None
408
+ else previous_router_probs
409
+ )
410
+
411
+ hidden_states = self.norm(hidden_states)
412
+
413
+ # add hidden states from the last decoder layer
414
+ if output_hidden_states:
415
+ all_hidden_states += (hidden_states,)
416
+
417
+ next_cache = next_decoder_cache if use_cache else None
418
+ if return_legacy_cache:
419
+ next_cache = next_cache.to_legacy_cache()
420
+
421
+ if not return_dict:
422
+ return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns, all_router_probs] if v is not None) # noqa
423
+ return MonetModelOutputWithPast(
424
+ last_hidden_state=hidden_states,
425
+ past_key_values=next_cache,
426
+ hidden_states=all_hidden_states,
427
+ attentions=all_self_attns,
428
+ router_probs=all_router_probs,
429
+ )
430
+
431
+ def _update_causal_mask(
432
+ self,
433
+ attention_mask: torch.Tensor,
434
+ input_tensor: torch.Tensor,
435
+ cache_position: torch.Tensor,
436
+ past_key_values: Cache,
437
+ output_attentions: bool,
438
+ ):
439
+ if self.config._attn_implementation == "flash_attention_2":
440
+ if attention_mask is not None and 0.0 in attention_mask:
441
+ return attention_mask
442
+ return None
443
+
444
+ past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0 # noqa
445
+ using_static_cache = isinstance(past_key_values, StaticCache)
446
+
447
+ if self.config._attn_implementation == "sdpa" and not using_static_cache and not output_attentions: # noqa
448
+ if AttentionMaskConverter._ignore_causal_mask_sdpa(
449
+ attention_mask,
450
+ inputs_embeds=input_tensor,
451
+ past_key_values_length=past_seen_tokens,
452
+ is_training=self.training,
453
+ ):
454
+ return None
455
+
456
+ dtype, device = input_tensor.dtype, input_tensor.device
457
+ min_dtype = torch.finfo(dtype).min
458
+ sequence_length = input_tensor.shape[1]
459
+ if using_static_cache:
460
+ target_length = past_key_values.get_max_length()
461
+ else:
462
+ target_length = (
463
+ attention_mask.shape[-1]
464
+ if isinstance(attention_mask, torch.Tensor)
465
+ else past_seen_tokens + sequence_length + 1
466
+ )
467
+
468
+ if attention_mask is not None and attention_mask.dim() == 4:
469
+ if attention_mask.max() != 0:
470
+ raise ValueError("Custom 4D attention mask should be passed in inverted form with max==0`") # noqa
471
+ causal_mask = attention_mask
472
+ else:
473
+ causal_mask = torch.full(
474
+ (sequence_length, target_length), fill_value=min_dtype, dtype=dtype, device=device # noqa
475
+ )
476
+ if sequence_length != 1:
477
+ causal_mask = torch.triu(causal_mask, diagonal=1)
478
+ causal_mask *= torch.arange(target_length, device=device) > cache_position.reshape(-1, 1) # noqa
479
+ causal_mask = causal_mask[None, None, :, :].expand(input_tensor.shape[0], 1, -1, -1) # noqa
480
+ if attention_mask is not None:
481
+ causal_mask = causal_mask.clone() # copy to contiguous memory for in-place edit # noqa
482
+ mask_length = attention_mask.shape[-1]
483
+ padding_mask = causal_mask[:, :, :, :mask_length] + attention_mask[:, None, None, :] # noqa
484
+ padding_mask = padding_mask == 0
485
+ causal_mask[:, :, :, :mask_length] = causal_mask[:, :, :, :mask_length].masked_fill(padding_mask, min_dtype) # noqa
486
+ if (
487
+ self.config._attn_implementation == "sdpa"
488
+ and attention_mask is not None
489
+ and attention_mask.device.type == "cuda"
490
+ and not output_attentions
491
+ ):
492
+ causal_mask = AttentionMaskConverter._unmask_unattended(causal_mask, min_dtype) # noqa
493
+
494
+ return causal_mask
495
+
496
+
497
+ class MonetForCausalLM(MonetPreTrainedModel):
498
+ _tied_weights_keys = ["lm_head.weight"]
499
+
500
+ def __init__(self, config):
501
+ super().__init__(config)
502
+ self.model = MonetModel(config)
503
+ self.vocab_size = config.vocab_size
504
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
505
+
506
+ # Initialize weights and apply final processing
507
+ self.post_init()
508
+
509
+ def get_input_embeddings(self):
510
+ return self.model.embed_tokens
511
+
512
+ def set_input_embeddings(self, value):
513
+ self.model.embed_tokens = value
514
+
515
+ def get_output_embeddings(self):
516
+ return self.lm_head
517
+
518
+ def set_output_embeddings(self, new_embeddings):
519
+ self.lm_head = new_embeddings
520
+
521
+ def set_decoder(self, decoder):
522
+ self.model = decoder
523
+
524
+ def get_decoder(self):
525
+ return self.model
526
+
527
+ def forward(
528
+ self,
529
+ input_ids: torch.LongTensor = None,
530
+ attention_mask: torch.Tensor | None = None,
531
+ position_ids: torch.LongTensor | None = None,
532
+ past_key_values: Cache | list[torch.FloatTensor] | None = None,
533
+ inputs_embeds: torch.FloatTensor | None = None,
534
+ labels: torch.LongTensor | None = None,
535
+ use_cache: bool | None = None,
536
+ output_attentions: bool | None = None,
537
+ output_hidden_states: bool | None = None,
538
+ output_router_probs: bool | None = None,
539
+ return_dict: bool | None = None,
540
+ cache_position: torch.LongTensor | None = None,
541
+ ) -> tuple[torch.Tensor, ...] | MonetCausalLMOutputWithPast:
542
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions # noqa
543
+ output_hidden_states = output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states # noqa
544
+ output_router_probs = output_router_probs if output_router_probs is not None else self.config.output_router_probs # noqa
545
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict # noqa
546
+
547
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
548
+ outputs = self.model(
549
+ input_ids=input_ids,
550
+ attention_mask=attention_mask,
551
+ position_ids=position_ids,
552
+ past_key_values=past_key_values,
553
+ inputs_embeds=inputs_embeds,
554
+ use_cache=use_cache,
555
+ output_attentions=output_attentions,
556
+ output_hidden_states=output_hidden_states,
557
+ output_router_probs=output_router_probs,
558
+ return_dict=return_dict,
559
+ cache_position=cache_position,
560
+ )
561
+
562
+ hidden_states = outputs[0]
563
+ logits = self.lm_head(hidden_states)
564
+ logits = logits.float()
565
+
566
+ loss = None
567
+ if labels is not None:
568
+ # Shift so that tokens < n predict n
569
+ shift_logits = logits[..., :-1, :].contiguous()
570
+ shift_labels = labels[..., 1:].contiguous()
571
+ # Flatten the tokens
572
+ loss_fct = CrossEntropyLoss()
573
+ shift_logits = shift_logits.view(-1, self.config.vocab_size)
574
+ shift_labels = shift_labels.view(-1)
575
+ # Enable model parallelism
576
+ shift_labels = shift_labels.to(shift_logits.device)
577
+ loss = loss_fct(shift_logits, shift_labels)
578
+
579
+ if not return_dict:
580
+ output = (logits,) + outputs[1:]
581
+ return (loss,) + output if loss is not None else output
582
+
583
+ return MonetCausalLMOutputWithPast(
584
+ loss=loss,
585
+ logits=logits,
586
+ past_key_values=outputs.past_key_values,
587
+ hidden_states=outputs.hidden_states,
588
+ attentions=outputs.attentions,
589
+ router_probs=outputs.router_probs,
590
+ )
591
+
592
+ def prepare_inputs_for_generation(
593
+ self,
594
+ input_ids,
595
+ past_key_values=None,
596
+ attention_mask=None,
597
+ inputs_embeds=None,
598
+ cache_position=None,
599
+ use_cache=True,
600
+ **kwargs,
601
+ ):
602
+ past_length = 0
603
+ if past_key_values is not None:
604
+ past_length = cache_position[0] if cache_position is not None else past_key_values.get_seq_length() # noqa
605
+ max_cache_length = (
606
+ torch.tensor(past_key_values.get_max_length(), device=input_ids.device)
607
+ if past_key_values.get_max_length() is not None
608
+ else None
609
+ )
610
+ cache_length = past_length if max_cache_length is None else torch.min(max_cache_length, past_length) # noqa
611
+
612
+ # Keep only the unprocessed tokens:
613
+ if attention_mask is not None and attention_mask.shape[1] > input_ids.shape[1]: # noqa
614
+ input_ids = input_ids[:, -(attention_mask.shape[1] - past_length) :]
615
+ # input_ids based on the past_length.
616
+ elif past_length < input_ids.shape[1]:
617
+ input_ids = input_ids[:, past_length:]
618
+
619
+ if (
620
+ max_cache_length is not None
621
+ and attention_mask is not None
622
+ and cache_length + input_ids.shape[1] > max_cache_length
623
+ ):
624
+ attention_mask = attention_mask[:, -max_cache_length:]
625
+
626
+ position_ids = kwargs.get("position_ids", None)
627
+ if attention_mask is not None and position_ids is None:
628
+ # create position_ids on the fly for batch generation
629
+ position_ids = attention_mask.long().cumsum(-1) - 1
630
+ position_ids.masked_fill_(attention_mask == 0, 1)
631
+ if past_key_values:
632
+ position_ids = position_ids[:, -input_ids.shape[1] :]
633
+
634
+ if inputs_embeds is not None and past_length == 0:
635
+ model_inputs = {"inputs_embeds": inputs_embeds}
636
+ else:
637
+ model_inputs = {"input_ids": input_ids.contiguous()}
638
+
639
+ input_length = position_ids.shape[-1] if position_ids is not None else input_ids.shape[-1] # noqa
640
+ if cache_position is None:
641
+ cache_position = torch.arange(past_length, past_length + input_length, device=input_ids.device) # noqa
642
+ elif use_cache:
643
+ cache_position = cache_position[-input_length:]
644
+
645
+ model_inputs.update(
646
+ {
647
+ "position_ids": position_ids,
648
+ "cache_position": cache_position,
649
+ "past_key_values": past_key_values,
650
+ "use_cache": use_cache,
651
+ "attention_mask": attention_mask,
652
+ }
653
+ )
654
+ return model_inputs
655
+
656
+ @staticmethod
657
+ def _reorder_cache(past_key_values, beam_idx):
658
+ reordered_past = ()
659
+ for layer_past in past_key_values:
660
+ reordered_past += (
661
+ tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past), # noqa
662
+ )
663
+ return reordered_past
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.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e556afd44213b6bd1be2b850ebbbd98f5481437a8021afaf58ee7fb1818d347
3
+ size 499723
tokenizer_config.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": true,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<unk>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "</s>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ }
30
+ },
31
+ "bos_token": "<s>",
32
+ "chat_template": "{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% set system_message = false %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 and system_message != false %}{% set content = '<<SYS>>\\n' + system_message + '\\n<</SYS>>\\n\\n' + message['content'] %}{% else %}{% set content = message['content'] %}{% endif %}{% if message['role'] == 'user' %}{{ bos_token + '[INST] ' + content.strip() + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ ' ' + content.strip() + ' ' + eos_token }}{% endif %}{% endfor %}",
33
+ "clean_up_tokenization_spaces": false,
34
+ "eos_token": "</s>",
35
+ "legacy": false,
36
+ "model_max_length": 2048,
37
+ "pad_token": "</s>",
38
+ "padding_side": "right",
39
+ "sp_model_kwargs": {},
40
+ "spaces_between_special_tokens": false,
41
+ "tokenizer_class": "LlamaTokenizer",
42
+ "unk_token": "<unk>",
43
+ "use_default_system_prompt": false
44
+ }
train_results.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "epoch": 0.9987565282268093,
3
+ "total_flos": 234414617395200.0,
4
+ "train_loss": 0.8937448220423968,
5
+ "train_runtime": 13768.4166,
6
+ "train_samples": 186330,
7
+ "train_samples_per_second": 4.672,
8
+ "train_steps_per_second": 0.036
9
+ }
trainer_state.json ADDED
@@ -0,0 +1,757 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_metric": null,
3
+ "best_model_checkpoint": null,
4
+ "epoch": 0.9987565282268093,
5
+ "eval_steps": 500,
6
+ "global_step": 502,
7
+ "is_hyper_param_search": false,
8
+ "is_local_process_zero": true,
9
+ "is_world_process_zero": true,
10
+ "log_history": [
11
+ {
12
+ "epoch": 0.001989554837105198,
13
+ "grad_norm": 2.019071375807948,
14
+ "learning_rate": 5.88235294117647e-06,
15
+ "loss": 1.4931,
16
+ "step": 1
17
+ },
18
+ {
19
+ "epoch": 0.009947774185525988,
20
+ "grad_norm": 1.5423217337624162,
21
+ "learning_rate": 2.941176470588235e-05,
22
+ "loss": 1.4424,
23
+ "step": 5
24
+ },
25
+ {
26
+ "epoch": 0.019895548371051976,
27
+ "grad_norm": 0.8308012142463063,
28
+ "learning_rate": 5.88235294117647e-05,
29
+ "loss": 1.2728,
30
+ "step": 10
31
+ },
32
+ {
33
+ "epoch": 0.029843322556577966,
34
+ "grad_norm": 0.5145126949446309,
35
+ "learning_rate": 8.823529411764705e-05,
36
+ "loss": 1.1614,
37
+ "step": 15
38
+ },
39
+ {
40
+ "epoch": 0.03979109674210395,
41
+ "grad_norm": 0.36488357130003074,
42
+ "learning_rate": 0.0001176470588235294,
43
+ "loss": 1.1138,
44
+ "step": 20
45
+ },
46
+ {
47
+ "epoch": 0.04973887092762994,
48
+ "grad_norm": 0.45152250150726514,
49
+ "learning_rate": 0.00014705882352941175,
50
+ "loss": 1.07,
51
+ "step": 25
52
+ },
53
+ {
54
+ "epoch": 0.05968664511315593,
55
+ "grad_norm": 0.3640886200970852,
56
+ "learning_rate": 0.0001764705882352941,
57
+ "loss": 1.0509,
58
+ "step": 30
59
+ },
60
+ {
61
+ "epoch": 0.06963441929868192,
62
+ "grad_norm": 1.7718021462555353,
63
+ "learning_rate": 0.00020588235294117645,
64
+ "loss": 1.0168,
65
+ "step": 35
66
+ },
67
+ {
68
+ "epoch": 0.0795821934842079,
69
+ "grad_norm": 0.3768307338988579,
70
+ "learning_rate": 0.0002352941176470588,
71
+ "loss": 1.0086,
72
+ "step": 40
73
+ },
74
+ {
75
+ "epoch": 0.0895299676697339,
76
+ "grad_norm": 0.33093766782578965,
77
+ "learning_rate": 0.00026470588235294115,
78
+ "loss": 1.0008,
79
+ "step": 45
80
+ },
81
+ {
82
+ "epoch": 0.09947774185525989,
83
+ "grad_norm": 0.37314906796958397,
84
+ "learning_rate": 0.0002941176470588235,
85
+ "loss": 0.9975,
86
+ "step": 50
87
+ },
88
+ {
89
+ "epoch": 0.10942551604078588,
90
+ "grad_norm": 0.39939561360809905,
91
+ "learning_rate": 0.00029994177629874796,
92
+ "loss": 0.9884,
93
+ "step": 55
94
+ },
95
+ {
96
+ "epoch": 0.11937329022631187,
97
+ "grad_norm": 0.3919443406321306,
98
+ "learning_rate": 0.00029970531997706437,
99
+ "loss": 0.9843,
100
+ "step": 60
101
+ },
102
+ {
103
+ "epoch": 0.12932106441183785,
104
+ "grad_norm": 0.3915947062044229,
105
+ "learning_rate": 0.00029928727864250395,
106
+ "loss": 0.9913,
107
+ "step": 65
108
+ },
109
+ {
110
+ "epoch": 0.13926883859736383,
111
+ "grad_norm": 0.3534055778790222,
112
+ "learning_rate": 0.00029868815935814996,
113
+ "loss": 0.9893,
114
+ "step": 70
115
+ },
116
+ {
117
+ "epoch": 0.14921661278288983,
118
+ "grad_norm": 0.36735315351449394,
119
+ "learning_rate": 0.0002979086888255182,
120
+ "loss": 0.9775,
121
+ "step": 75
122
+ },
123
+ {
124
+ "epoch": 0.1591643869684158,
125
+ "grad_norm": 0.3088341190569696,
126
+ "learning_rate": 0.00029694981250310496,
127
+ "loss": 0.981,
128
+ "step": 80
129
+ },
130
+ {
131
+ "epoch": 0.16911216115394181,
132
+ "grad_norm": 0.325839880040256,
133
+ "learning_rate": 0.0002958126934595933,
134
+ "loss": 0.9659,
135
+ "step": 85
136
+ },
137
+ {
138
+ "epoch": 0.1790599353394678,
139
+ "grad_norm": 1.4788476638739554,
140
+ "learning_rate": 0.0002944987109631094,
141
+ "loss": 0.9681,
142
+ "step": 90
143
+ },
144
+ {
145
+ "epoch": 0.1890077095249938,
146
+ "grad_norm": 0.3505592753718136,
147
+ "learning_rate": 0.00029300945880823956,
148
+ "loss": 0.9653,
149
+ "step": 95
150
+ },
151
+ {
152
+ "epoch": 0.19895548371051977,
153
+ "grad_norm": 0.28451648461527196,
154
+ "learning_rate": 0.0002913467433828382,
155
+ "loss": 0.9511,
156
+ "step": 100
157
+ },
158
+ {
159
+ "epoch": 0.20890325789604575,
160
+ "grad_norm": 0.3138636289880952,
161
+ "learning_rate": 0.00028951258147696967,
162
+ "loss": 0.9572,
163
+ "step": 105
164
+ },
165
+ {
166
+ "epoch": 0.21885103208157175,
167
+ "grad_norm": 0.2732249403521582,
168
+ "learning_rate": 0.00028750919783664407,
169
+ "loss": 0.9617,
170
+ "step": 110
171
+ },
172
+ {
173
+ "epoch": 0.22879880626709773,
174
+ "grad_norm": 0.311679721602736,
175
+ "learning_rate": 0.000285339022465312,
176
+ "loss": 0.9484,
177
+ "step": 115
178
+ },
179
+ {
180
+ "epoch": 0.23874658045262373,
181
+ "grad_norm": 0.2676711284506792,
182
+ "learning_rate": 0.00028300468767639305,
183
+ "loss": 0.9397,
184
+ "step": 120
185
+ },
186
+ {
187
+ "epoch": 0.2486943546381497,
188
+ "grad_norm": 0.25074023315013144,
189
+ "learning_rate": 0.00028050902490041194,
190
+ "loss": 0.9457,
191
+ "step": 125
192
+ },
193
+ {
194
+ "epoch": 0.2586421288236757,
195
+ "grad_norm": 0.27129765694428115,
196
+ "learning_rate": 0.00027785506125061604,
197
+ "loss": 0.9268,
198
+ "step": 130
199
+ },
200
+ {
201
+ "epoch": 0.2685899030092017,
202
+ "grad_norm": 2.105526076305897,
203
+ "learning_rate": 0.00027504601585123963,
204
+ "loss": 0.9459,
205
+ "step": 135
206
+ },
207
+ {
208
+ "epoch": 0.27853767719472766,
209
+ "grad_norm": 0.27202583577769746,
210
+ "learning_rate": 0.00027208529593286804,
211
+ "loss": 0.9395,
212
+ "step": 140
213
+ },
214
+ {
215
+ "epoch": 0.28848545138025367,
216
+ "grad_norm": 0.26240068306380243,
217
+ "learning_rate": 0.00026897649269963866,
218
+ "loss": 0.9166,
219
+ "step": 145
220
+ },
221
+ {
222
+ "epoch": 0.29843322556577967,
223
+ "grad_norm": 0.2631437322326041,
224
+ "learning_rate": 0.00026572337697329144,
225
+ "loss": 0.92,
226
+ "step": 150
227
+ },
228
+ {
229
+ "epoch": 0.3083809997513056,
230
+ "grad_norm": 0.2780992526939389,
231
+ "learning_rate": 0.00026232989461935164,
232
+ "loss": 0.929,
233
+ "step": 155
234
+ },
235
+ {
236
+ "epoch": 0.3183287739368316,
237
+ "grad_norm": 0.2644307921832001,
238
+ "learning_rate": 0.000258800161760994,
239
+ "loss": 0.9119,
240
+ "step": 160
241
+ },
242
+ {
243
+ "epoch": 0.3282765481223576,
244
+ "grad_norm": 0.27009906970951136,
245
+ "learning_rate": 0.0002551384597863925,
246
+ "loss": 0.9141,
247
+ "step": 165
248
+ },
249
+ {
250
+ "epoch": 0.33822432230788363,
251
+ "grad_norm": 0.24907417369935828,
252
+ "learning_rate": 0.0002513492301556124,
253
+ "loss": 0.9045,
254
+ "step": 170
255
+ },
256
+ {
257
+ "epoch": 0.3481720964934096,
258
+ "grad_norm": 0.4637150153647203,
259
+ "learning_rate": 0.0002474370690133423,
260
+ "loss": 0.9185,
261
+ "step": 175
262
+ },
263
+ {
264
+ "epoch": 0.3581198706789356,
265
+ "grad_norm": 0.28404376319877433,
266
+ "learning_rate": 0.00024340672161400278,
267
+ "loss": 0.9224,
268
+ "step": 180
269
+ },
270
+ {
271
+ "epoch": 0.3680676448644616,
272
+ "grad_norm": 0.2633604383062445,
273
+ "learning_rate": 0.00023926307656599145,
274
+ "loss": 0.9049,
275
+ "step": 185
276
+ },
277
+ {
278
+ "epoch": 0.3780154190499876,
279
+ "grad_norm": 0.3089691505145177,
280
+ "learning_rate": 0.00023501115990204728,
281
+ "loss": 0.906,
282
+ "step": 190
283
+ },
284
+ {
285
+ "epoch": 0.38796319323551354,
286
+ "grad_norm": 0.2712113108379062,
287
+ "learning_rate": 0.00023065612898292607,
288
+ "loss": 0.9033,
289
+ "step": 195
290
+ },
291
+ {
292
+ "epoch": 0.39791096742103954,
293
+ "grad_norm": 0.2759532883918752,
294
+ "learning_rate": 0.00022620326624178135,
295
+ "loss": 0.9047,
296
+ "step": 200
297
+ },
298
+ {
299
+ "epoch": 0.40785874160656554,
300
+ "grad_norm": 0.25413106263769636,
301
+ "learning_rate": 0.0002216579727768394,
302
+ "loss": 0.8884,
303
+ "step": 205
304
+ },
305
+ {
306
+ "epoch": 0.4178065157920915,
307
+ "grad_norm": 0.2679789855086274,
308
+ "learning_rate": 0.00021702576180013906,
309
+ "loss": 0.892,
310
+ "step": 210
311
+ },
312
+ {
313
+ "epoch": 0.4277542899776175,
314
+ "grad_norm": 0.2531713028754476,
315
+ "learning_rate": 0.00021231225195028297,
316
+ "loss": 0.8907,
317
+ "step": 215
318
+ },
319
+ {
320
+ "epoch": 0.4377020641631435,
321
+ "grad_norm": 0.24842966918028864,
322
+ "learning_rate": 0.00020752316047731214,
323
+ "loss": 0.882,
324
+ "step": 220
325
+ },
326
+ {
327
+ "epoch": 0.4476498383486695,
328
+ "grad_norm": 0.23591143252036872,
329
+ "learning_rate": 0.00020266429630796956,
330
+ "loss": 0.8846,
331
+ "step": 225
332
+ },
333
+ {
334
+ "epoch": 0.45759761253419545,
335
+ "grad_norm": 0.23767648270009806,
336
+ "learning_rate": 0.00019774155299976477,
337
+ "loss": 0.8793,
338
+ "step": 230
339
+ },
340
+ {
341
+ "epoch": 0.46754538671972146,
342
+ "grad_norm": 0.2271591056583853,
343
+ "learning_rate": 0.00019276090159238524,
344
+ "loss": 0.8741,
345
+ "step": 235
346
+ },
347
+ {
348
+ "epoch": 0.47749316090524746,
349
+ "grad_norm": 0.22901636532179012,
350
+ "learning_rate": 0.000187728383365126,
351
+ "loss": 0.8837,
352
+ "step": 240
353
+ },
354
+ {
355
+ "epoch": 0.48744093509077346,
356
+ "grad_norm": 0.22668623781094616,
357
+ "learning_rate": 0.0001826501025091223,
358
+ "loss": 0.8735,
359
+ "step": 245
360
+ },
361
+ {
362
+ "epoch": 0.4973887092762994,
363
+ "grad_norm": 0.23947671322760095,
364
+ "learning_rate": 0.00017753221872327318,
365
+ "loss": 0.8692,
366
+ "step": 250
367
+ },
368
+ {
369
+ "epoch": 0.5073364834618255,
370
+ "grad_norm": 0.26156533719751,
371
+ "learning_rate": 0.00017238093974283674,
372
+ "loss": 0.8625,
373
+ "step": 255
374
+ },
375
+ {
376
+ "epoch": 0.5172842576473514,
377
+ "grad_norm": 0.25671509792902836,
378
+ "learning_rate": 0.00016720251380976007,
379
+ "loss": 0.8604,
380
+ "step": 260
381
+ },
382
+ {
383
+ "epoch": 0.5272320318328774,
384
+ "grad_norm": 0.24704965941321674,
385
+ "learning_rate": 0.00016200322209387663,
386
+ "loss": 0.8626,
387
+ "step": 265
388
+ },
389
+ {
390
+ "epoch": 0.5371798060184034,
391
+ "grad_norm": 0.2514007967545614,
392
+ "learning_rate": 0.00015678937107416343,
393
+ "loss": 0.8528,
394
+ "step": 270
395
+ },
396
+ {
397
+ "epoch": 0.5471275802039294,
398
+ "grad_norm": 0.24028475499604857,
399
+ "learning_rate": 0.00015156728488929967,
400
+ "loss": 0.8574,
401
+ "step": 275
402
+ },
403
+ {
404
+ "epoch": 0.5570753543894553,
405
+ "grad_norm": 0.23213673166180135,
406
+ "learning_rate": 0.0001463432976668051,
407
+ "loss": 0.86,
408
+ "step": 280
409
+ },
410
+ {
411
+ "epoch": 0.5670231285749814,
412
+ "grad_norm": 0.23102662796096035,
413
+ "learning_rate": 0.00014112374584006253,
414
+ "loss": 0.8617,
415
+ "step": 285
416
+ },
417
+ {
418
+ "epoch": 0.5769709027605073,
419
+ "grad_norm": 0.23635078987821154,
420
+ "learning_rate": 0.00013591496046254278,
421
+ "loss": 0.8468,
422
+ "step": 290
423
+ },
424
+ {
425
+ "epoch": 0.5869186769460333,
426
+ "grad_norm": 0.2473298815208931,
427
+ "learning_rate": 0.00013072325952855624,
428
+ "loss": 0.8465,
429
+ "step": 295
430
+ },
431
+ {
432
+ "epoch": 0.5968664511315593,
433
+ "grad_norm": 0.22199589321301555,
434
+ "learning_rate": 0.00012555494030984393,
435
+ "loss": 0.8474,
436
+ "step": 300
437
+ },
438
+ {
439
+ "epoch": 0.6068142253170853,
440
+ "grad_norm": 0.224149793992071,
441
+ "learning_rate": 0.00012041627171730368,
442
+ "loss": 0.8523,
443
+ "step": 305
444
+ },
445
+ {
446
+ "epoch": 0.6167619995026112,
447
+ "grad_norm": 0.2216854964579631,
448
+ "learning_rate": 0.00011531348669711734,
449
+ "loss": 0.8296,
450
+ "step": 310
451
+ },
452
+ {
453
+ "epoch": 0.6267097736881373,
454
+ "grad_norm": 0.25823608221836053,
455
+ "learning_rate": 0.00011025277467050076,
456
+ "loss": 0.8275,
457
+ "step": 315
458
+ },
459
+ {
460
+ "epoch": 0.6366575478736632,
461
+ "grad_norm": 0.25511921593962283,
462
+ "learning_rate": 0.00010524027402624775,
463
+ "loss": 0.8379,
464
+ "step": 320
465
+ },
466
+ {
467
+ "epoch": 0.6466053220591893,
468
+ "grad_norm": 0.2169176240841302,
469
+ "learning_rate": 0.00010028206467517357,
470
+ "loss": 0.842,
471
+ "step": 325
472
+ },
473
+ {
474
+ "epoch": 0.6565530962447153,
475
+ "grad_norm": 0.23684621611339568,
476
+ "learning_rate": 9.538416067548939e-05,
477
+ "loss": 0.8363,
478
+ "step": 330
479
+ },
480
+ {
481
+ "epoch": 0.6665008704302412,
482
+ "grad_norm": 0.21588755800082085,
483
+ "learning_rate": 9.055250293805247e-05,
484
+ "loss": 0.8257,
485
+ "step": 335
486
+ },
487
+ {
488
+ "epoch": 0.6764486446157673,
489
+ "grad_norm": 0.22987884680681675,
490
+ "learning_rate": 8.579295202034084e-05,
491
+ "loss": 0.8434,
492
+ "step": 340
493
+ },
494
+ {
495
+ "epoch": 0.6863964188012932,
496
+ "grad_norm": 0.23044188787166803,
497
+ "learning_rate": 8.111128101789177e-05,
498
+ "loss": 0.8368,
499
+ "step": 345
500
+ },
501
+ {
502
+ "epoch": 0.6963441929868192,
503
+ "grad_norm": 0.20871504598447846,
504
+ "learning_rate": 7.651316856182797e-05,
505
+ "loss": 0.8235,
506
+ "step": 350
507
+ },
508
+ {
509
+ "epoch": 0.7062919671723452,
510
+ "grad_norm": 0.21764586591268964,
511
+ "learning_rate": 7.200419193096416e-05,
512
+ "loss": 0.8366,
513
+ "step": 355
514
+ },
515
+ {
516
+ "epoch": 0.7162397413578712,
517
+ "grad_norm": 0.20093905811705248,
518
+ "learning_rate": 6.758982028684842e-05,
519
+ "loss": 0.8212,
520
+ "step": 360
521
+ },
522
+ {
523
+ "epoch": 0.7261875155433971,
524
+ "grad_norm": 0.20201151370456955,
525
+ "learning_rate": 6.327540803994507e-05,
526
+ "loss": 0.8132,
527
+ "step": 365
528
+ },
529
+ {
530
+ "epoch": 0.7361352897289232,
531
+ "grad_norm": 0.20205806825962228,
532
+ "learning_rate": 5.9066188355004337e-05,
533
+ "loss": 0.8115,
534
+ "step": 370
535
+ },
536
+ {
537
+ "epoch": 0.7460830639144491,
538
+ "grad_norm": 0.4492212407917222,
539
+ "learning_rate": 5.4967266803496726e-05,
540
+ "loss": 0.8178,
541
+ "step": 375
542
+ },
543
+ {
544
+ "epoch": 0.7560308380999752,
545
+ "grad_norm": 0.20165879598033634,
546
+ "learning_rate": 5.0983615170812656e-05,
547
+ "loss": 0.8202,
548
+ "step": 380
549
+ },
550
+ {
551
+ "epoch": 0.7659786122855011,
552
+ "grad_norm": 0.20731013148125454,
553
+ "learning_rate": 4.7120065425736744e-05,
554
+ "loss": 0.8224,
555
+ "step": 385
556
+ },
557
+ {
558
+ "epoch": 0.7759263864710271,
559
+ "grad_norm": 0.19813282037840257,
560
+ "learning_rate": 4.3381303859513076e-05,
561
+ "loss": 0.8031,
562
+ "step": 390
563
+ },
564
+ {
565
+ "epoch": 0.7858741606565531,
566
+ "grad_norm": 0.19914236210141723,
567
+ "learning_rate": 3.977186540161016e-05,
568
+ "loss": 0.8146,
569
+ "step": 395
570
+ },
571
+ {
572
+ "epoch": 0.7958219348420791,
573
+ "grad_norm": 0.20390757189890973,
574
+ "learning_rate": 3.629612811907965e-05,
575
+ "loss": 0.8132,
576
+ "step": 400
577
+ },
578
+ {
579
+ "epoch": 0.805769709027605,
580
+ "grad_norm": 0.19393901917008016,
581
+ "learning_rate": 3.295830790618167e-05,
582
+ "loss": 0.8142,
583
+ "step": 405
584
+ },
585
+ {
586
+ "epoch": 0.8157174832131311,
587
+ "grad_norm": 0.1907323400363912,
588
+ "learning_rate": 2.976245337071748e-05,
589
+ "loss": 0.8129,
590
+ "step": 410
591
+ },
592
+ {
593
+ "epoch": 0.825665257398657,
594
+ "grad_norm": 0.199622342411806,
595
+ "learning_rate": 2.671244092327191e-05,
596
+ "loss": 0.7951,
597
+ "step": 415
598
+ },
599
+ {
600
+ "epoch": 0.835613031584183,
601
+ "grad_norm": 0.20412611674653627,
602
+ "learning_rate": 2.38119700753228e-05,
603
+ "loss": 0.8143,
604
+ "step": 420
605
+ },
606
+ {
607
+ "epoch": 0.845560805769709,
608
+ "grad_norm": 0.19936335181674378,
609
+ "learning_rate": 2.106455895191985e-05,
610
+ "loss": 0.802,
611
+ "step": 425
612
+ },
613
+ {
614
+ "epoch": 0.855508579955235,
615
+ "grad_norm": 0.19669632646100263,
616
+ "learning_rate": 1.847354002437588e-05,
617
+ "loss": 0.7948,
618
+ "step": 430
619
+ },
620
+ {
621
+ "epoch": 0.865456354140761,
622
+ "grad_norm": 0.19474265071015343,
623
+ "learning_rate": 1.6042056068147402e-05,
624
+ "loss": 0.8078,
625
+ "step": 435
626
+ },
627
+ {
628
+ "epoch": 0.875404128326287,
629
+ "grad_norm": 0.19134910562287546,
630
+ "learning_rate": 1.3773056350806022e-05,
631
+ "loss": 0.8067,
632
+ "step": 440
633
+ },
634
+ {
635
+ "epoch": 0.885351902511813,
636
+ "grad_norm": 0.18803806717884775,
637
+ "learning_rate": 1.1669293054725392e-05,
638
+ "loss": 0.7952,
639
+ "step": 445
640
+ },
641
+ {
642
+ "epoch": 0.895299676697339,
643
+ "grad_norm": 0.18932335388504165,
644
+ "learning_rate": 9.7333179388228e-06,
645
+ "loss": 0.8102,
646
+ "step": 450
647
+ },
648
+ {
649
+ "epoch": 0.905247450882865,
650
+ "grad_norm": 0.19773216218571474,
651
+ "learning_rate": 7.967479243403913e-06,
652
+ "loss": 0.8015,
653
+ "step": 455
654
+ },
655
+ {
656
+ "epoch": 0.9151952250683909,
657
+ "grad_norm": 0.18837812375636145,
658
+ "learning_rate": 6.373918841865727e-06,
659
+ "loss": 0.7997,
660
+ "step": 460
661
+ },
662
+ {
663
+ "epoch": 0.925142999253917,
664
+ "grad_norm": 0.18803298571004357,
665
+ "learning_rate": 4.954569642711964e-06,
666
+ "loss": 0.8068,
667
+ "step": 465
668
+ },
669
+ {
670
+ "epoch": 0.9350907734394429,
671
+ "grad_norm": 0.1810703612957102,
672
+ "learning_rate": 3.711153245032361e-06,
673
+ "loss": 0.7992,
674
+ "step": 470
675
+ },
676
+ {
677
+ "epoch": 0.9450385476249689,
678
+ "grad_norm": 0.18601132727527311,
679
+ "learning_rate": 2.645177850289787e-06,
680
+ "loss": 0.8039,
681
+ "step": 475
682
+ },
683
+ {
684
+ "epoch": 0.9549863218104949,
685
+ "grad_norm": 0.18789475936900635,
686
+ "learning_rate": 1.7579364329477375e-06,
687
+ "loss": 0.8024,
688
+ "step": 480
689
+ },
690
+ {
691
+ "epoch": 0.9649340959960209,
692
+ "grad_norm": 0.7153792725698854,
693
+ "learning_rate": 1.0505051721574398e-06,
694
+ "loss": 0.8047,
695
+ "step": 485
696
+ },
697
+ {
698
+ "epoch": 0.9748818701815469,
699
+ "grad_norm": 0.19016384162520752,
700
+ "learning_rate": 5.23742146406858e-07,
701
+ "loss": 0.8004,
702
+ "step": 490
703
+ },
704
+ {
705
+ "epoch": 0.9848296443670729,
706
+ "grad_norm": 0.19392554346569527,
707
+ "learning_rate": 1.7828629271456894e-07,
708
+ "loss": 0.7991,
709
+ "step": 495
710
+ },
711
+ {
712
+ "epoch": 0.9947774185525988,
713
+ "grad_norm": 0.19065289345162353,
714
+ "learning_rate": 1.4556631631429393e-08,
715
+ "loss": 0.8032,
716
+ "step": 500
717
+ },
718
+ {
719
+ "epoch": 0.9987565282268093,
720
+ "eval_loss": 1.1664291620254517,
721
+ "eval_runtime": 1405.6452,
722
+ "eval_samples_per_second": 16.582,
723
+ "eval_steps_per_second": 1.037,
724
+ "step": 502
725
+ },
726
+ {
727
+ "epoch": 0.9987565282268093,
728
+ "step": 502,
729
+ "total_flos": 234414617395200.0,
730
+ "train_loss": 0.8937448220423968,
731
+ "train_runtime": 13768.4166,
732
+ "train_samples_per_second": 4.672,
733
+ "train_steps_per_second": 0.036
734
+ }
735
+ ],
736
+ "logging_steps": 5,
737
+ "max_steps": 502,
738
+ "num_input_tokens_seen": 0,
739
+ "num_train_epochs": 1,
740
+ "save_steps": 500,
741
+ "stateful_callbacks": {
742
+ "TrainerControl": {
743
+ "args": {
744
+ "should_epoch_stop": false,
745
+ "should_evaluate": false,
746
+ "should_log": false,
747
+ "should_save": false,
748
+ "should_training_stop": false
749
+ },
750
+ "attributes": {}
751
+ }
752
+ },
753
+ "total_flos": 234414617395200.0,
754
+ "train_batch_size": 4,
755
+ "trial_name": null,
756
+ "trial_params": null
757
+ }