euclaise commited on
Commit
c55db1a
1 Parent(s): e60f83b

Upload folder using huggingface_hub

Browse files
config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "./model3",
3
+ "architectures": [
4
+ "StableLMEpochForCausalLM"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_stablelm_epoch.StableLMEpochConfig",
9
+ "AutoModelForCausalLM": "modeling_stablelm_epoch.StableLMEpochForCausalLM"
10
+ },
11
+ "bos_token_id": 0,
12
+ "eos_token_id": 0,
13
+ "hidden_act": "silu",
14
+ "hidden_size": 2560,
15
+ "initializer_range": 0.02,
16
+ "intermediate_size": 6912,
17
+ "max_position_embeddings": 4096,
18
+ "model_type": "stablelm_epoch",
19
+ "norm_eps": 1e-05,
20
+ "num_attention_heads": 32,
21
+ "num_heads": 32,
22
+ "num_hidden_layers": 32,
23
+ "num_key_value_heads": 32,
24
+ "rope_pct": 0.25,
25
+ "rope_theta": 10000,
26
+ "rotary_scaling_factor": 1.0,
27
+ "tie_word_embeddings": false,
28
+ "torch_dtype": "bfloat16",
29
+ "transformers_version": "4.36.2",
30
+ "use_cache": false,
31
+ "vocab_size": 50304
32
+ }
configuration_stablelm_epoch.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2023 Stability and The HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """ StableLM Epoch model configuration"""
16
+ from transformers import PretrainedConfig
17
+ from transformers.utils import logging
18
+
19
+
20
+ logger = logging.get_logger(__name__)
21
+
22
+
23
+ class StableLMEpochConfig(PretrainedConfig):
24
+ r"""
25
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
26
+ documentation from [`PretrainedConfig`] for more information.
27
+
28
+ Args:
29
+ vocab_size (`int`, *optional*, defaults to 50_304):
30
+ Vocabulary size of the StableLM model. Defines the number of different tokens that
31
+ can be represented by the `inputs_ids` passed when calling [`StableLMEpochModel`].
32
+ intermediate_size (`int`, *optional*, defaults to 6912):
33
+ Dimension of the MLP representations.
34
+ hidden_size (`int`, *optional*, defaults to 2560):
35
+ Dimension of the decoder layers and the pooler layer.
36
+ num_hidden_layers (`int`, *optional*, defaults to 32):
37
+ Number of hidden layers in the Transformer decoder.
38
+ num_attention_heads (`int`, *optional*, defaults to 32):
39
+ Number of attention heads for each attention layer in the Transformer encoder.
40
+ num_key_value_heads (`int`, *optional*):
41
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
42
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
43
+ `num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
44
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
45
+ by meanpooling all the original heads within that group. For more details checkout [this
46
+ paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
47
+ `num_attention_heads`.
48
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
49
+ The non-linear activation function (function or string).
50
+ rope_pct (`float`, *optional*, defaults to 1.0):
51
+ Percentage of hidden dimensions to allocate to rotary embeddings.
52
+ rope_theta (`float`, *optional*, defaults to 10000.0):
53
+ The base period of the RoPE embeddings.
54
+ max_position_embeddings (`int`, *optional*, defaults to 2048):
55
+ The maximum sequence length that this model might ever be used with.
56
+ Typically set this to something large just in case (e.g., 512 or 1024 or 2048).
57
+ initializer_range (`float`, *optional*, defaults to 1e-5):
58
+ The standard deviation of the truncated_normal_initializer for initializing
59
+ all weight matrices.
60
+ norm_eps (`float`, *optional*, defaults to 1e-8):
61
+ The epsilon used by the normalization layers.
62
+ use_cache (`bool`, *optional*, defaults to `True`):
63
+ Whether or not the model should return the last key/values attentions
64
+ (not used by all models). Only relevant if `config.is_decoder=True`.
65
+ tie_word_embeddings(`bool`, *optional*, defaults to `False`):
66
+ Whether to tie weight embeddings
67
+ attention_dropout (`float`, *optional*, defaults to 0.0):
68
+ The dropout ratio for the attention probabilities.
69
+ """
70
+ model_type = "stablelm_epoch"
71
+ keys_to_ignore_at_inference = ["past_key_values"]
72
+
73
+ def __init__(
74
+ self,
75
+ vocab_size=50_304,
76
+ intermediate_size=6912,
77
+ hidden_size=2560,
78
+ num_hidden_layers=32,
79
+ num_attention_heads=32,
80
+ num_key_value_heads=32,
81
+ hidden_act="silu",
82
+ rope_pct=0.25,
83
+ rope_theta=10_000,
84
+ max_position_embeddings=4096,
85
+ initializer_range=0.02,
86
+ norm_eps=1.0e-5,
87
+ use_cache=True,
88
+ bos_token_id=0,
89
+ eos_token_id=2,
90
+ tie_word_embeddings=False,
91
+ attention_dropout: float = 0.0,
92
+ **kwargs,
93
+ ):
94
+ self.vocab_size = vocab_size
95
+ self.max_position_embeddings = max_position_embeddings
96
+ self.intermediate_size = intermediate_size
97
+ self.hidden_size = hidden_size
98
+ self.num_hidden_layers = num_hidden_layers
99
+ self.num_attention_heads = num_attention_heads
100
+ self.num_key_value_heads = num_key_value_heads
101
+ self.hidden_act = hidden_act
102
+ self.rope_pct = rope_pct
103
+ self.rope_theta = rope_theta
104
+ self.initializer_range = initializer_range
105
+ self.norm_eps = norm_eps
106
+ self.use_cache = use_cache
107
+ self.tie_word_embeddings = tie_word_embeddings
108
+ self.attention_dropout = attention_dropout
109
+ super().__init__(
110
+ bos_token_id=bos_token_id,
111
+ eos_token_id=eos_token_id,
112
+ tie_word_embeddings=tie_word_embeddings,
113
+ **kwargs,
114
+ )
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": 0,
5
+ "transformers_version": "4.36.2"
6
+ }
model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c975706de94e2eaa6527046a5a6ab9470a8f43ee82fa5a422acaa7c258f1ba96
3
+ size 4980712216
model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:25cdd075d7f9052f27abc2f3731a8b6a6fd1fbd4e57865d7d8a0e887615afa44
3
+ size 610215224
model.safetensors.index.json ADDED
@@ -0,0 +1,363 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 5590886400
4
+ },
5
+ "weight_map": {
6
+ "lm_head.weight": "model-00002-of-00002.safetensors",
7
+ "model.embed_tokens.weight": "model-00001-of-00002.safetensors",
8
+ "model.layers.0.input_layernorm.bias": "model-00001-of-00002.safetensors",
9
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
10
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
11
+ "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
12
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
13
+ "model.layers.0.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
14
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
15
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
16
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
17
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
18
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
19
+ "model.layers.1.input_layernorm.bias": "model-00001-of-00002.safetensors",
20
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
21
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
22
+ "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
23
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
24
+ "model.layers.1.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
25
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
26
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
27
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
28
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
29
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
30
+ "model.layers.10.input_layernorm.bias": "model-00001-of-00002.safetensors",
31
+ "model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
32
+ "model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
33
+ "model.layers.10.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
34
+ "model.layers.10.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
35
+ "model.layers.10.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
36
+ "model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
37
+ "model.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
38
+ "model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
39
+ "model.layers.10.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
40
+ "model.layers.10.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
41
+ "model.layers.11.input_layernorm.bias": "model-00001-of-00002.safetensors",
42
+ "model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
43
+ "model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
44
+ "model.layers.11.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
45
+ "model.layers.11.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
46
+ "model.layers.11.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
47
+ "model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
48
+ "model.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
49
+ "model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
50
+ "model.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
51
+ "model.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
52
+ "model.layers.12.input_layernorm.bias": "model-00001-of-00002.safetensors",
53
+ "model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
54
+ "model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
55
+ "model.layers.12.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
56
+ "model.layers.12.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
57
+ "model.layers.12.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
58
+ "model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
59
+ "model.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
60
+ "model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
61
+ "model.layers.12.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
62
+ "model.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
63
+ "model.layers.13.input_layernorm.bias": "model-00001-of-00002.safetensors",
64
+ "model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
65
+ "model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
66
+ "model.layers.13.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
67
+ "model.layers.13.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
68
+ "model.layers.13.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
69
+ "model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
70
+ "model.layers.13.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
71
+ "model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
72
+ "model.layers.13.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
73
+ "model.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
74
+ "model.layers.14.input_layernorm.bias": "model-00001-of-00002.safetensors",
75
+ "model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
76
+ "model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
77
+ "model.layers.14.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
78
+ "model.layers.14.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
79
+ "model.layers.14.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
80
+ "model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
81
+ "model.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
82
+ "model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
83
+ "model.layers.14.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
84
+ "model.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
85
+ "model.layers.15.input_layernorm.bias": "model-00001-of-00002.safetensors",
86
+ "model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
87
+ "model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
88
+ "model.layers.15.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
89
+ "model.layers.15.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
90
+ "model.layers.15.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
91
+ "model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
92
+ "model.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
93
+ "model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
94
+ "model.layers.15.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
95
+ "model.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
96
+ "model.layers.16.input_layernorm.bias": "model-00001-of-00002.safetensors",
97
+ "model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
98
+ "model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
99
+ "model.layers.16.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
100
+ "model.layers.16.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
101
+ "model.layers.16.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
102
+ "model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
103
+ "model.layers.16.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
104
+ "model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
105
+ "model.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
106
+ "model.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
107
+ "model.layers.17.input_layernorm.bias": "model-00001-of-00002.safetensors",
108
+ "model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
109
+ "model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
110
+ "model.layers.17.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
111
+ "model.layers.17.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
112
+ "model.layers.17.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
113
+ "model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
114
+ "model.layers.17.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
115
+ "model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
116
+ "model.layers.17.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
117
+ "model.layers.17.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
118
+ "model.layers.18.input_layernorm.bias": "model-00001-of-00002.safetensors",
119
+ "model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
120
+ "model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
121
+ "model.layers.18.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
122
+ "model.layers.18.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
123
+ "model.layers.18.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
124
+ "model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
125
+ "model.layers.18.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
126
+ "model.layers.18.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
127
+ "model.layers.18.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
128
+ "model.layers.18.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
129
+ "model.layers.19.input_layernorm.bias": "model-00001-of-00002.safetensors",
130
+ "model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
131
+ "model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
132
+ "model.layers.19.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
133
+ "model.layers.19.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
134
+ "model.layers.19.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
135
+ "model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
136
+ "model.layers.19.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
137
+ "model.layers.19.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
138
+ "model.layers.19.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
139
+ "model.layers.19.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
140
+ "model.layers.2.input_layernorm.bias": "model-00001-of-00002.safetensors",
141
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
142
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
143
+ "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
144
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
145
+ "model.layers.2.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
146
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
147
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
148
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
149
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
150
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
151
+ "model.layers.20.input_layernorm.bias": "model-00001-of-00002.safetensors",
152
+ "model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
153
+ "model.layers.20.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
154
+ "model.layers.20.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
155
+ "model.layers.20.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
156
+ "model.layers.20.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
157
+ "model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
158
+ "model.layers.20.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
159
+ "model.layers.20.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
160
+ "model.layers.20.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
161
+ "model.layers.20.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
162
+ "model.layers.21.input_layernorm.bias": "model-00001-of-00002.safetensors",
163
+ "model.layers.21.input_layernorm.weight": "model-00001-of-00002.safetensors",
164
+ "model.layers.21.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
165
+ "model.layers.21.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
166
+ "model.layers.21.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
167
+ "model.layers.21.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
168
+ "model.layers.21.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
169
+ "model.layers.21.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
170
+ "model.layers.21.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
171
+ "model.layers.21.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
172
+ "model.layers.21.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
173
+ "model.layers.22.input_layernorm.bias": "model-00001-of-00002.safetensors",
174
+ "model.layers.22.input_layernorm.weight": "model-00001-of-00002.safetensors",
175
+ "model.layers.22.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
176
+ "model.layers.22.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
177
+ "model.layers.22.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
178
+ "model.layers.22.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
179
+ "model.layers.22.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
180
+ "model.layers.22.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
181
+ "model.layers.22.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
182
+ "model.layers.22.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
183
+ "model.layers.22.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
184
+ "model.layers.23.input_layernorm.bias": "model-00001-of-00002.safetensors",
185
+ "model.layers.23.input_layernorm.weight": "model-00001-of-00002.safetensors",
186
+ "model.layers.23.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
187
+ "model.layers.23.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
188
+ "model.layers.23.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
189
+ "model.layers.23.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
190
+ "model.layers.23.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
191
+ "model.layers.23.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
192
+ "model.layers.23.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
193
+ "model.layers.23.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
194
+ "model.layers.23.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
195
+ "model.layers.24.input_layernorm.bias": "model-00001-of-00002.safetensors",
196
+ "model.layers.24.input_layernorm.weight": "model-00001-of-00002.safetensors",
197
+ "model.layers.24.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
198
+ "model.layers.24.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
199
+ "model.layers.24.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
200
+ "model.layers.24.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
201
+ "model.layers.24.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
202
+ "model.layers.24.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
203
+ "model.layers.24.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
204
+ "model.layers.24.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
205
+ "model.layers.24.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
206
+ "model.layers.25.input_layernorm.bias": "model-00001-of-00002.safetensors",
207
+ "model.layers.25.input_layernorm.weight": "model-00001-of-00002.safetensors",
208
+ "model.layers.25.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
209
+ "model.layers.25.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
210
+ "model.layers.25.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
211
+ "model.layers.25.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
212
+ "model.layers.25.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
213
+ "model.layers.25.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
214
+ "model.layers.25.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
215
+ "model.layers.25.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
216
+ "model.layers.25.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
217
+ "model.layers.26.input_layernorm.bias": "model-00001-of-00002.safetensors",
218
+ "model.layers.26.input_layernorm.weight": "model-00001-of-00002.safetensors",
219
+ "model.layers.26.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
220
+ "model.layers.26.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
221
+ "model.layers.26.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
222
+ "model.layers.26.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
223
+ "model.layers.26.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
224
+ "model.layers.26.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
225
+ "model.layers.26.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
226
+ "model.layers.26.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
227
+ "model.layers.26.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
228
+ "model.layers.27.input_layernorm.bias": "model-00001-of-00002.safetensors",
229
+ "model.layers.27.input_layernorm.weight": "model-00001-of-00002.safetensors",
230
+ "model.layers.27.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
231
+ "model.layers.27.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
232
+ "model.layers.27.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
233
+ "model.layers.27.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
234
+ "model.layers.27.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
235
+ "model.layers.27.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
236
+ "model.layers.27.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
237
+ "model.layers.27.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
238
+ "model.layers.27.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
239
+ "model.layers.28.input_layernorm.bias": "model-00001-of-00002.safetensors",
240
+ "model.layers.28.input_layernorm.weight": "model-00001-of-00002.safetensors",
241
+ "model.layers.28.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
242
+ "model.layers.28.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
243
+ "model.layers.28.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
244
+ "model.layers.28.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
245
+ "model.layers.28.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
246
+ "model.layers.28.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
247
+ "model.layers.28.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
248
+ "model.layers.28.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
249
+ "model.layers.28.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
250
+ "model.layers.29.input_layernorm.bias": "model-00002-of-00002.safetensors",
251
+ "model.layers.29.input_layernorm.weight": "model-00002-of-00002.safetensors",
252
+ "model.layers.29.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
253
+ "model.layers.29.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
254
+ "model.layers.29.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
255
+ "model.layers.29.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
256
+ "model.layers.29.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
257
+ "model.layers.29.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
258
+ "model.layers.29.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
259
+ "model.layers.29.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
260
+ "model.layers.29.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
261
+ "model.layers.3.input_layernorm.bias": "model-00001-of-00002.safetensors",
262
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
263
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
264
+ "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
265
+ "model.layers.3.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
266
+ "model.layers.3.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
267
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
268
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
269
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
270
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
271
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
272
+ "model.layers.30.input_layernorm.bias": "model-00002-of-00002.safetensors",
273
+ "model.layers.30.input_layernorm.weight": "model-00002-of-00002.safetensors",
274
+ "model.layers.30.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
275
+ "model.layers.30.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
276
+ "model.layers.30.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
277
+ "model.layers.30.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
278
+ "model.layers.30.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
279
+ "model.layers.30.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
280
+ "model.layers.30.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
281
+ "model.layers.30.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
282
+ "model.layers.30.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
283
+ "model.layers.31.input_layernorm.bias": "model-00002-of-00002.safetensors",
284
+ "model.layers.31.input_layernorm.weight": "model-00002-of-00002.safetensors",
285
+ "model.layers.31.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
286
+ "model.layers.31.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
287
+ "model.layers.31.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
288
+ "model.layers.31.post_attention_layernorm.bias": "model-00002-of-00002.safetensors",
289
+ "model.layers.31.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
290
+ "model.layers.31.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
291
+ "model.layers.31.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
292
+ "model.layers.31.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
293
+ "model.layers.31.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
294
+ "model.layers.4.input_layernorm.bias": "model-00001-of-00002.safetensors",
295
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
296
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
297
+ "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
298
+ "model.layers.4.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
299
+ "model.layers.4.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
300
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
301
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
302
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
303
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
304
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
305
+ "model.layers.5.input_layernorm.bias": "model-00001-of-00002.safetensors",
306
+ "model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
307
+ "model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
308
+ "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
309
+ "model.layers.5.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
310
+ "model.layers.5.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
311
+ "model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
312
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
313
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
314
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
315
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
316
+ "model.layers.6.input_layernorm.bias": "model-00001-of-00002.safetensors",
317
+ "model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
318
+ "model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
319
+ "model.layers.6.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
320
+ "model.layers.6.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
321
+ "model.layers.6.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
322
+ "model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
323
+ "model.layers.6.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
324
+ "model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
325
+ "model.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
326
+ "model.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
327
+ "model.layers.7.input_layernorm.bias": "model-00001-of-00002.safetensors",
328
+ "model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
329
+ "model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
330
+ "model.layers.7.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
331
+ "model.layers.7.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
332
+ "model.layers.7.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
333
+ "model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
334
+ "model.layers.7.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
335
+ "model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
336
+ "model.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
337
+ "model.layers.7.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
338
+ "model.layers.8.input_layernorm.bias": "model-00001-of-00002.safetensors",
339
+ "model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
340
+ "model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
341
+ "model.layers.8.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
342
+ "model.layers.8.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
343
+ "model.layers.8.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
344
+ "model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
345
+ "model.layers.8.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
346
+ "model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
347
+ "model.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
348
+ "model.layers.8.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
349
+ "model.layers.9.input_layernorm.bias": "model-00001-of-00002.safetensors",
350
+ "model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
351
+ "model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
352
+ "model.layers.9.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
353
+ "model.layers.9.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
354
+ "model.layers.9.post_attention_layernorm.bias": "model-00001-of-00002.safetensors",
355
+ "model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
356
+ "model.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
357
+ "model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
358
+ "model.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
359
+ "model.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
360
+ "model.norm.bias": "model-00002-of-00002.safetensors",
361
+ "model.norm.weight": "model-00002-of-00002.safetensors"
362
+ }
363
+ }
modeling_stablelm_epoch.py ADDED
@@ -0,0 +1,918 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2023 Stability AI, EleutherAI, and The HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ # This code is based off the following work:
17
+ # https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/modeling_llama.py
18
+ # https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt_neox/modeling_gpt_neox.py
19
+ """ PyTorch StableLM Epoch model. """
20
+ from typing import Optional, Tuple, Union
21
+ import math
22
+ import warnings
23
+
24
+ import torch
25
+ import torch.nn.functional as F
26
+ import torch.utils.checkpoint
27
+ from torch import nn
28
+ from torch.nn import CrossEntropyLoss
29
+
30
+ from transformers.cache_utils import Cache
31
+ from transformers.modeling_outputs import (
32
+ BaseModelOutputWithPast,
33
+ CausalLMOutputWithPast,
34
+ )
35
+ from transformers.modeling_utils import PreTrainedModel
36
+ from transformers.utils import logging, is_flash_attn_greater_or_equal_2_10
37
+
38
+ from .configuration_stablelm_epoch import StableLMEpochConfig
39
+
40
+ try:
41
+ from flash_attn import flash_attn_func, flash_attn_varlen_func
42
+ from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input
43
+ except:
44
+ flash_attn_func, flash_attn_varlen_func = None, None
45
+ index_first_axis, pad_input, unpad_input = None, None, None
46
+
47
+
48
+ logger = logging.get_logger(__name__)
49
+
50
+
51
+ # Copied from transformers.models.llama.modeling_llama._get_unpad_data
52
+ def _get_unpad_data(attention_mask):
53
+ seqlens_in_batch = attention_mask.sum(dim=-1, dtype=torch.int32)
54
+ indices = torch.nonzero(attention_mask.flatten(), as_tuple=False).flatten()
55
+ max_seqlen_in_batch = seqlens_in_batch.max().item()
56
+ cu_seqlens = F.pad(torch.cumsum(seqlens_in_batch, dim=0, dtype=torch.torch.int32), (1, 0))
57
+ return (
58
+ indices,
59
+ cu_seqlens,
60
+ max_seqlen_in_batch,
61
+ )
62
+
63
+
64
+ # Copied from transformers.models.bart.modeling_bart._make_causal_mask
65
+ def _make_causal_mask(
66
+ input_ids_shape: torch.Size,
67
+ dtype: torch.dtype,
68
+ device: torch.device,
69
+ past_key_values_length: int = 0,
70
+ ):
71
+ """Make causal mask used for bi-directional self-attention."""
72
+ batch_size, tgt_len = input_ids_shape
73
+ mask = torch.full((tgt_len, tgt_len), torch.finfo(torch.float16).min, device=device)
74
+ mask_cond = torch.arange(mask.size(-1), device=device)
75
+ mask.masked_fill_(mask_cond < (mask_cond + 1).view(mask.size(-1), 1), 0)
76
+ mask = mask.to(dtype)
77
+ if past_key_values_length > 0:
78
+ mask = torch.cat([torch.zeros(tgt_len, past_key_values_length, dtype=dtype, device=device), mask], dim=-1)
79
+ return mask[None, None, :, :].expand(batch_size, 1, tgt_len, tgt_len + past_key_values_length)
80
+
81
+
82
+ # Copied from transformers.models.bart.modeling_bart._expand_mask
83
+ def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None):
84
+ """Expands attention_mask from `[batch_size, seq_len]` to `[batch_size, 1, tgt_seq_len, src_seq_len]`."""
85
+ batch_size, src_len = mask.size()
86
+ tgt_len = tgt_len if tgt_len is not None else src_len
87
+
88
+ expanded_mask = mask[:, None, None, :].expand(batch_size, 1, tgt_len, src_len).to(dtype)
89
+ inverted_mask = 1.0 - expanded_mask
90
+
91
+ return inverted_mask.masked_fill(
92
+ inverted_mask.to(torch.bool), torch.finfo(dtype).min
93
+ )
94
+
95
+
96
+ class RotaryEmbedding(nn.Module):
97
+ def __init__(
98
+ self,
99
+ dim: int,
100
+ max_position_embeddings: int,
101
+ base: int = 10_000,
102
+ device: Optional[torch.device] = None,
103
+ ):
104
+ super().__init__()
105
+
106
+ self.dim = dim
107
+ self.max_position_embeddings = max_position_embeddings
108
+ self.base = base
109
+ inv_freq = 1.0 / (self.base ** (torch.arange(0, self.dim, 2, device=device, dtype=torch.float32) / self.dim))
110
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
111
+
112
+ # Build here to make `torch.jit.trace` work.
113
+ self._set_cos_sin_cache(
114
+ seq_len=max_position_embeddings, device=self.inv_freq.device, dtype=torch.get_default_dtype(),
115
+ )
116
+
117
+ def _set_cos_sin_cache(self, seq_len: int, device: torch.device, dtype: torch.dtype):
118
+ self.max_seq_len_cached = seq_len
119
+ t = torch.arange(self.max_seq_len_cached, device=device, dtype=torch.float32)
120
+
121
+ # Don't do einsum, it converts fp32 to fp16 under AMP
122
+ # freqs = torch.einsum("i,j->ij", t, self.inv_freq)
123
+ freqs = torch.outer(t, self.inv_freq)
124
+ # Different from paper, but it uses a different permutation in order to obtain the same calculation
125
+ emb = torch.cat((freqs, freqs), dim=-1)
126
+ self.register_buffer("cos_cached", emb.cos()[None, None, :, :].to(dtype), persistent=False)
127
+ self.register_buffer("sin_cached", emb.sin()[None, None, :, :].to(dtype), persistent=False)
128
+
129
+ def forward(self, x: torch.Tensor, seq_len: Optional[int] = None):
130
+ # x: [batch_size, num_heads, seq_len, head_size]
131
+ if seq_len > self.max_seq_len_cached:
132
+ self._set_cos_sin_cache(seq_len=seq_len, device=x.device, dtype=torch.get_default_dtype())
133
+ return (
134
+ self.cos_cached[:, :, :seq_len, ...].to(dtype=x.dtype),
135
+ self.sin_cached[:, :, :seq_len, ...].to(dtype=x.dtype),
136
+ )
137
+
138
+
139
+ def rotate_half(x: torch.Tensor):
140
+ """Rotates half the hidden dims of the input."""
141
+ x1, x2 = torch.chunk(x, 2, dim=-1)
142
+ return torch.cat((-x2, x1), dim=-1)
143
+
144
+
145
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids):
146
+ # The first two dimensions of cos and sin are always 1, so we can `squeeze` them.
147
+ cos = cos.squeeze(1).squeeze(0) # [seq_len, dim]
148
+ sin = sin.squeeze(1).squeeze(0) # [seq_len, dim]
149
+ cos = cos[position_ids].unsqueeze(1) # [batch_size, 1, seq_len, dim]
150
+ sin = sin[position_ids].unsqueeze(1) # [batch_size, 1, seq_len, dim]
151
+ q_embed = (q * cos) + (rotate_half(q) * sin)
152
+ k_embed = (k * cos) + (rotate_half(k) * sin)
153
+ return q_embed, k_embed
154
+
155
+
156
+ class MLP(nn.Module):
157
+ def __init__(self, config: StableLMEpochConfig):
158
+ super().__init__()
159
+ self.config = config
160
+ self.hidden_size = config.hidden_size
161
+ self.intermediate_size = config.intermediate_size
162
+ self.gate_proj = nn.Linear(config.hidden_size, config.intermediate_size, bias=False)
163
+ self.up_proj = nn.Linear(config.hidden_size, config.intermediate_size, bias=False)
164
+ self.down_proj = nn.Linear(config.intermediate_size, config.hidden_size, bias=False)
165
+ self.act_fn = nn.SiLU()
166
+
167
+ def forward(self, x: torch.Tensor) -> torch.Tensor:
168
+ return self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
169
+
170
+
171
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
172
+ """
173
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
174
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
175
+ """
176
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
177
+ if n_rep == 1:
178
+ return hidden_states
179
+ hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
180
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
181
+
182
+
183
+ class Attention(nn.Module):
184
+ def __init__(self, config: StableLMEpochConfig):
185
+ super().__init__()
186
+ self.config = config
187
+ self.hidden_size = config.hidden_size
188
+ self.num_heads = config.num_attention_heads
189
+ self.head_dim = self.hidden_size // self.num_heads
190
+ self.num_key_value_heads = config.num_key_value_heads
191
+ self.num_key_value_groups = self.num_heads // self.num_key_value_heads
192
+ self.max_position_embeddings = config.max_position_embeddings
193
+ self.is_causal = True
194
+ self.attention_dropout = config.attention_dropout
195
+
196
+ if (self.head_dim * self.num_heads) != self.hidden_size:
197
+ raise ValueError(
198
+ f"hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}"
199
+ f" and `num_heads`: {self.num_heads})."
200
+ )
201
+ self.q_proj = nn.Linear(self.hidden_size, self.num_heads * self.head_dim, bias=False)
202
+ self.k_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=False)
203
+ self.v_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=False)
204
+ self.o_proj = nn.Linear(self.hidden_size, self.hidden_size, bias=False)
205
+
206
+ self._init_rope()
207
+
208
+ def _init_rope(self):
209
+ self.rotary_ndims = int(self.head_dim * self.config.rope_pct)
210
+ self.rotary_emb = RotaryEmbedding(
211
+ self.rotary_ndims,
212
+ max_position_embeddings=self.config.max_position_embeddings,
213
+ base=self.config.rope_theta,
214
+ )
215
+
216
+ def forward(
217
+ self,
218
+ hidden_states: torch.FloatTensor,
219
+ attention_mask: torch.FloatTensor,
220
+ position_ids: torch.LongTensor,
221
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
222
+ output_attentions: Optional[bool] = False,
223
+ use_cache: Optional[bool] = False,
224
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
225
+ bsz, q_len, _ = hidden_states.size()
226
+
227
+ query_states = self.q_proj(hidden_states)
228
+ key_states = self.k_proj(hidden_states)
229
+ value_states = self.v_proj(hidden_states)
230
+
231
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
232
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
233
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
234
+
235
+ query_rot = query_states[..., : self.rotary_ndims]
236
+ query_pass = query_states[..., self.rotary_ndims :]
237
+ key_rot = key_states[..., : self.rotary_ndims]
238
+ key_pass = key_states[..., self.rotary_ndims :]
239
+
240
+ kv_seq_len = key_states.shape[-2]
241
+ if past_key_value is not None:
242
+ kv_seq_len += past_key_value[0].shape[-2]
243
+ cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
244
+ query_states, key_states = apply_rotary_pos_emb(query_rot, key_rot, cos, sin, position_ids)
245
+
246
+ # [batch_size, num_heads, seq_len, head_dim]
247
+ query_states = torch.cat((query_states, query_pass), dim=-1)
248
+ key_states = torch.cat((key_states, key_pass), dim=-1)
249
+
250
+ if past_key_value is not None:
251
+ # Reuse k, v, self_attention
252
+ key_states = torch.cat((past_key_value[0], key_states), dim=2)
253
+ value_states = torch.cat((past_key_value[1], value_states), dim=2)
254
+
255
+ past_key_value = (key_states, value_states) if use_cache else None
256
+
257
+ # Repeat k/v heads if n_kv_heads < n_heads
258
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
259
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
260
+
261
+ attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
262
+
263
+ if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
264
+ raise ValueError(
265
+ f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
266
+ f" {attn_weights.size()}"
267
+ )
268
+
269
+ if attention_mask is not None:
270
+ if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
271
+ raise ValueError(
272
+ f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
273
+ )
274
+ attn_weights = attn_weights + attention_mask
275
+
276
+ # Upcast attention to fp32
277
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
278
+ attn_weights = nn.functional.dropout(attn_weights, p=self.attention_dropout, training=self.training)
279
+ attn_output = torch.matmul(attn_weights, value_states)
280
+
281
+ if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
282
+ raise ValueError(
283
+ f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
284
+ f" {attn_output.size()}"
285
+ )
286
+
287
+ # Merge heads
288
+ attn_output = attn_output.transpose(1, 2).contiguous()
289
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
290
+
291
+ # Final linear projection
292
+ attn_output = self.o_proj(attn_output)
293
+
294
+ if not output_attentions:
295
+ attn_weights = None
296
+
297
+ return attn_output, attn_weights, past_key_value
298
+
299
+
300
+ class FlashAttention2(Attention):
301
+ """
302
+ Reference: https://github.com/huggingface/transformers/blob/5d36025ca13d05151b7a0c761e90d429c4644a30/src/transformers/models/llama/modeling_llama.py#L456
303
+ """
304
+
305
+ def __init__(self, *args, **kwargs):
306
+ super().__init__(*args, **kwargs)
307
+
308
+ # TODO: Should be removed once Flash Attention for RoCm is bumped to 2.1.
309
+ # flash_attn<2.1 generates top-left aligned causal mask, while what is needed here is bottom-right alignement, that was made default for flash_attn>=2.1. This attribute is used to handle this difference. Reference: https://github.com/Dao-AILab/flash-attention/releases/tag/v2.1.0.
310
+ # Beware that with flash_attn<2.1, using q_seqlen != k_seqlen (except for the case q_seqlen == 1) produces a wrong mask (top-left).
311
+ self._flash_attn_uses_top_left_mask = not is_flash_attn_greater_or_equal_2_10()
312
+
313
+ def forward(
314
+ self,
315
+ hidden_states: torch.Tensor,
316
+ attention_mask: Optional[torch.LongTensor] = None,
317
+ position_ids: Optional[torch.LongTensor] = None,
318
+ past_key_value: Optional[Cache] = None,
319
+ output_attentions: bool = False,
320
+ use_cache: bool = False,
321
+ **kwargs,
322
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
323
+ # FlashAttention2 attention does not support output_attentions
324
+ if "padding_mask" in kwargs:
325
+ warnings.warn(
326
+ "Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
327
+ )
328
+
329
+ # overwrite attention_mask with padding_mask
330
+ attention_mask = kwargs.pop("padding_mask")
331
+
332
+ output_attentions = False
333
+
334
+ bsz, q_len, _ = hidden_states.size()
335
+
336
+ query_states = self.q_proj(hidden_states)
337
+ key_states = self.k_proj(hidden_states)
338
+ value_states = self.v_proj(hidden_states)
339
+
340
+ # Flash attention requires the input to have the shape
341
+ # batch_size x seq_length x head_dim x hidden_dim
342
+ # therefore we just need to keep the original shape
343
+ query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
344
+ key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
345
+ value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
346
+
347
+ query_rot = query_states[..., : self.rotary_ndims]
348
+ query_pass = query_states[..., self.rotary_ndims :]
349
+ key_rot = key_states[..., : self.rotary_ndims]
350
+ key_pass = key_states[..., self.rotary_ndims :]
351
+
352
+ kv_seq_len = key_states.shape[-2]
353
+ if past_key_value is not None:
354
+ kv_seq_len += past_key_value[0].shape[-2]
355
+ cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
356
+ query_states, key_states = apply_rotary_pos_emb(query_rot, key_rot, cos, sin, position_ids)
357
+
358
+ # [batch_size, num_heads, seq_len, head_dim]
359
+ query_states = torch.cat((query_states, query_pass), dim=-1)
360
+ key_states = torch.cat((key_states, key_pass), dim=-1)
361
+
362
+ if past_key_value is not None:
363
+ # Reuse k, v, self_attention
364
+ key_states = torch.cat((past_key_value[0], key_states), dim=2)
365
+ value_states = torch.cat((past_key_value[1], value_states), dim=2)
366
+
367
+ past_key_value = (key_states, value_states) if use_cache else None
368
+
369
+ # TODO: These transpose are quite inefficient but Flash Attention requires the layout [batch_size, sequence_length, num_heads, head_dim]. We would need to refactor the KV cache
370
+ # to be able to avoid many of these transpose/reshape/view.
371
+ query_states = query_states.transpose(1, 2)
372
+ key_states = key_states.transpose(1, 2)
373
+ value_states = value_states.transpose(1, 2)
374
+
375
+ dropout_rate = self.attention_dropout if self.training else 0.0
376
+
377
+ attn_output = self._flash_attention_forward(
378
+ query_states, key_states, value_states, attention_mask, q_len, dropout=dropout_rate
379
+ )
380
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size).contiguous()
381
+ attn_output = self.o_proj(attn_output)
382
+
383
+ if not output_attentions:
384
+ attn_weights = None
385
+
386
+ return attn_output, attn_weights, past_key_value
387
+
388
+ def _flash_attention_forward(
389
+ self, query_states, key_states, value_states, attention_mask, query_length, dropout=0.0, softmax_scale=None
390
+ ):
391
+ """
392
+ Calls the forward method of Flash Attention - if the input hidden states contain at least one padding token
393
+ first unpad the input, then computes the attention scores and pad the final attention scores.
394
+
395
+ Args:
396
+ query_states (`torch.Tensor`):
397
+ Input query states to be passed to Flash Attention API
398
+ key_states (`torch.Tensor`):
399
+ Input key states to be passed to Flash Attention API
400
+ value_states (`torch.Tensor`):
401
+ Input value states to be passed to Flash Attention API
402
+ attention_mask (`torch.Tensor`):
403
+ The padding mask - corresponds to a tensor of size `(batch_size, seq_len)` where 0 stands for the
404
+ position of padding tokens and 1 for the position of non-padding tokens.
405
+ dropout (`int`, *optional*):
406
+ Attention dropout
407
+ softmax_scale (`float`, *optional*):
408
+ The scaling of QK^T before applying softmax. Default to 1 / sqrt(head_dim)
409
+ """
410
+ if not self._flash_attn_uses_top_left_mask:
411
+ causal = self.is_causal
412
+ else:
413
+ # TODO: Remove the `query_length != 1` check once Flash Attention for RoCm is bumped to 2.1. For details, please see the comment in FlashAttention2 __init__.
414
+ causal = self.is_causal and query_length != 1
415
+
416
+ # Contains at least one padding token in the sequence
417
+ if attention_mask is not None:
418
+ batch_size = query_states.shape[0]
419
+ query_states, key_states, value_states, indices_q, cu_seq_lens, max_seq_lens = self._upad_input(
420
+ query_states, key_states, value_states, attention_mask, query_length
421
+ )
422
+
423
+ cu_seqlens_q, cu_seqlens_k = cu_seq_lens
424
+ max_seqlen_in_batch_q, max_seqlen_in_batch_k = max_seq_lens
425
+
426
+ attn_output_unpad = flash_attn_varlen_func(
427
+ query_states,
428
+ key_states,
429
+ value_states,
430
+ cu_seqlens_q=cu_seqlens_q,
431
+ cu_seqlens_k=cu_seqlens_k,
432
+ max_seqlen_q=max_seqlen_in_batch_q,
433
+ max_seqlen_k=max_seqlen_in_batch_k,
434
+ dropout_p=dropout,
435
+ softmax_scale=softmax_scale,
436
+ causal=causal,
437
+ )
438
+
439
+ attn_output = pad_input(attn_output_unpad, indices_q, batch_size, query_length)
440
+ else:
441
+ attn_output = flash_attn_func(
442
+ query_states, key_states, value_states, dropout, softmax_scale=softmax_scale, causal=causal
443
+ )
444
+
445
+ return attn_output
446
+
447
+ def _upad_input(self, query_layer, key_layer, value_layer, attention_mask, query_length):
448
+ indices_k, cu_seqlens_k, max_seqlen_in_batch_k = _get_unpad_data(attention_mask)
449
+ batch_size, kv_seq_len, num_key_value_heads, head_dim = key_layer.shape
450
+
451
+ key_layer = index_first_axis(
452
+ key_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim), indices_k
453
+ )
454
+ value_layer = index_first_axis(
455
+ value_layer.reshape(batch_size * kv_seq_len, num_key_value_heads, head_dim), indices_k
456
+ )
457
+ if query_length == kv_seq_len:
458
+ query_layer = index_first_axis(
459
+ query_layer.reshape(batch_size * kv_seq_len, self.num_heads, head_dim), indices_k
460
+ )
461
+ cu_seqlens_q = cu_seqlens_k
462
+ max_seqlen_in_batch_q = max_seqlen_in_batch_k
463
+ indices_q = indices_k
464
+ elif query_length == 1:
465
+ max_seqlen_in_batch_q = 1
466
+ cu_seqlens_q = torch.arange(
467
+ batch_size + 1, dtype=torch.int32, device=query_layer.device
468
+ ) # There is a memcpy here, that is very bad.
469
+ indices_q = cu_seqlens_q[:-1]
470
+ query_layer = query_layer.squeeze(1)
471
+ else:
472
+ # The -q_len: slice assumes left padding.
473
+ attention_mask = attention_mask[:, -query_length:]
474
+ query_layer, indices_q, cu_seqlens_q, max_seqlen_in_batch_q = unpad_input(query_layer, attention_mask)
475
+
476
+ return (
477
+ query_layer,
478
+ key_layer,
479
+ value_layer,
480
+ indices_q,
481
+ (cu_seqlens_q, cu_seqlens_k),
482
+ (max_seqlen_in_batch_q, max_seqlen_in_batch_k),
483
+ )
484
+
485
+
486
+ ATTENTION_CLASSES = {
487
+ "eager": Attention,
488
+ "flash_attention_2": FlashAttention2,
489
+ }
490
+
491
+
492
+ class DecoderLayer(nn.Module):
493
+ def __init__(self, config: StableLMEpochConfig):
494
+ super().__init__()
495
+ self.self_attn = ATTENTION_CLASSES[config._attn_implementation](config=config)
496
+ self.mlp = MLP(config)
497
+ self.input_layernorm = nn.LayerNorm(config.hidden_size, eps=config.norm_eps)
498
+ self.post_attention_layernorm = nn.LayerNorm(config.hidden_size, eps=config.norm_eps)
499
+
500
+ def forward(
501
+ self,
502
+ hidden_states: Optional[torch.FloatTensor],
503
+ attention_mask: Optional[torch.FloatTensor] = None,
504
+ position_ids: Optional[torch.LongTensor] = None,
505
+ past_key_value: Optional[Tuple[torch.Tensor]] = None,
506
+ output_attentions: Optional[bool] = False,
507
+ use_cache: Optional[bool] = False,
508
+ ) -> Union[Tuple[torch.Tensor], Optional[Tuple[torch.Tensor, Tuple[torch.FloatTensor, ...]]]]:
509
+ residual = hidden_states
510
+
511
+ hidden_states = self.input_layernorm(hidden_states)
512
+
513
+ # Self Attention
514
+ hidden_states, self_attn_weights, present_key_value = self.self_attn(
515
+ hidden_states=hidden_states,
516
+ attention_mask=attention_mask,
517
+ position_ids=position_ids,
518
+ past_key_value=past_key_value,
519
+ output_attentions=output_attentions,
520
+ use_cache=use_cache,
521
+ )
522
+ hidden_states = residual + hidden_states
523
+
524
+ # Fully Connected
525
+ residual = hidden_states
526
+ hidden_states = self.post_attention_layernorm(hidden_states)
527
+ hidden_states = self.mlp(hidden_states)
528
+ hidden_states = residual + hidden_states
529
+
530
+ outputs = (hidden_states,)
531
+
532
+ if output_attentions:
533
+ outputs += (self_attn_weights,)
534
+
535
+ if use_cache:
536
+ outputs += (present_key_value,)
537
+
538
+ return outputs
539
+
540
+
541
+ class StableLMEpochPreTrainedModel(PreTrainedModel):
542
+ """An abstract class to handle weights initialization and a simple interface
543
+ for downloading and loading pretrained models.
544
+ """
545
+
546
+ config_class = StableLMEpochConfig
547
+ base_model_prefix = "transformer"
548
+ supports_gradient_checkpointing = True
549
+ _no_split_modules = ["DecoderLayer"]
550
+ _skip_keys_device_placement = "past_key_values"
551
+ _supports_flash_attn_2 = True
552
+
553
+ def _init_weights(self, module: nn.Module):
554
+ """Initialize the weights"""
555
+ if isinstance(module, nn.Linear):
556
+ module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
557
+ if module.bias is not None:
558
+ module.bias.data.zero_()
559
+ elif isinstance(module, nn.Embedding):
560
+ module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
561
+ if module.padding_idx is not None:
562
+ module.weight.data[module.padding_idx].zero_()
563
+ elif isinstance(module, nn.LayerNorm):
564
+ module.bias.data.zero_()
565
+ module.weight.data.fill_(1.0)
566
+
567
+ def _set_gradient_checkpointing(self, module: nn.Module, value=False):
568
+ if isinstance(module, StableLMEpochModel):
569
+ module.gradient_checkpointing = value
570
+
571
+
572
+ class StableLMEpochModel(StableLMEpochPreTrainedModel):
573
+ def __init__(self, config: StableLMEpochConfig):
574
+ super().__init__(config)
575
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, config.pad_token_id)
576
+ self.layers = nn.ModuleList([DecoderLayer(config) for _ in range(config.num_hidden_layers)])
577
+ self.norm = nn.LayerNorm(config.hidden_size, eps=config.norm_eps)
578
+
579
+ self._use_flash_attention_2 = config._attn_implementation == "flash_attention_2"
580
+ self.gradient_checkpointing = False
581
+ # Initialize weights and apply final processing
582
+ self.post_init()
583
+
584
+ def get_input_embeddings(self):
585
+ return self.embed_tokens
586
+
587
+ def set_input_embeddings(self, value: nn.Module):
588
+ self.embed_tokens = value
589
+
590
+ # Copied from transformers.models.bart.modeling_bart.BartDecoder._prepare_decoder_attention_mask
591
+ def _prepare_decoder_attention_mask(
592
+ self,
593
+ attention_mask: torch.Tensor,
594
+ input_shape: torch.Size,
595
+ inputs_embeds: torch.Tensor,
596
+ past_key_values_length: int,
597
+ ):
598
+ # Create causal mask
599
+ # [batch_size, seq_len] -> [batch_size, 1, tgt_seq_len, src_seq_len]
600
+ combined_attention_mask = None
601
+ if input_shape[-1] > 1:
602
+ combined_attention_mask = _make_causal_mask(
603
+ input_shape,
604
+ inputs_embeds.dtype,
605
+ device=inputs_embeds.device,
606
+ past_key_values_length=past_key_values_length,
607
+ )
608
+
609
+ if attention_mask is not None:
610
+ # [batch_size, seq_len] -> [batch_size, 1, tgt_seq_len, src_seq_len]
611
+ expanded_attn_mask = _expand_mask(
612
+ attention_mask, inputs_embeds.dtype, tgt_len=input_shape[-1]
613
+ ).to(inputs_embeds.device)
614
+ combined_attention_mask = expanded_attn_mask if combined_attention_mask is None else expanded_attn_mask + combined_attention_mask
615
+
616
+ return combined_attention_mask
617
+
618
+ def forward(
619
+ self,
620
+ input_ids: Optional[torch.LongTensor] = None,
621
+ attention_mask: Optional[torch.FloatTensor] = None,
622
+ position_ids: Optional[torch.LongTensor] = None,
623
+ past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
624
+ inputs_embeds: Optional[torch.FloatTensor] = None,
625
+ use_cache: Optional[bool] = None,
626
+ output_attentions: Optional[bool] = None,
627
+ output_hidden_states: Optional[bool] = None,
628
+ return_dict: Optional[bool] = None,
629
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
630
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
631
+ output_hidden_states = output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
632
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
633
+
634
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
635
+
636
+ # Retrieve input_ids and inputs_embeds
637
+ if input_ids is not None and inputs_embeds is not None:
638
+ raise ValueError(
639
+ "You cannot specify both decoder_input_ids and decoder_inputs_embeds at the same time"
640
+ )
641
+ elif input_ids is not None:
642
+ batch_size, seq_length = input_ids.shape
643
+ elif inputs_embeds is not None:
644
+ batch_size, seq_length, _ = inputs_embeds.shape
645
+ else:
646
+ raise ValueError(
647
+ "You have to specify either decoder_input_ids or decoder_inputs_embeds"
648
+ )
649
+
650
+ seq_length_with_past = seq_length
651
+ past_key_values_length = 0
652
+
653
+ if position_ids is None:
654
+ device = input_ids.device if input_ids is not None else inputs_embeds.device
655
+ position_ids = torch.arange(
656
+ past_key_values_length,
657
+ seq_length + past_key_values_length,
658
+ dtype=torch.long,
659
+ device=device,
660
+ )
661
+ position_ids = position_ids.unsqueeze(0).view(-1, seq_length)
662
+ else:
663
+ position_ids = position_ids.view(-1, seq_length).long()
664
+
665
+ if inputs_embeds is None:
666
+ inputs_embeds = self.embed_tokens(input_ids)
667
+ # Embed positions
668
+ if self._use_flash_attention_2:
669
+ # 2d mask is passed through the layers
670
+ attention_mask = attention_mask if (attention_mask is not None and 0 in attention_mask) else None
671
+ else:
672
+ if attention_mask is None:
673
+ attention_mask = torch.ones(
674
+ (batch_size, seq_length_with_past),
675
+ dtype=torch.bool,
676
+ device=inputs_embeds.device,
677
+ )
678
+ attention_mask = self._prepare_decoder_attention_mask(
679
+ attention_mask,
680
+ (batch_size, seq_length),
681
+ inputs_embeds,
682
+ past_key_values_length,
683
+ )
684
+
685
+ hidden_states = inputs_embeds
686
+
687
+ if self.gradient_checkpointing and self.training:
688
+ if use_cache:
689
+ logger.warning(
690
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
691
+ )
692
+ use_cache = False
693
+
694
+ # Decoder layers
695
+ all_hidden_states = () if output_hidden_states else None
696
+ all_self_attns = () if output_attentions else None
697
+ next_decoder_cache = () if use_cache else None
698
+
699
+ for idx, decoder_layer in enumerate(self.layers):
700
+ if output_hidden_states:
701
+ all_hidden_states += (hidden_states,)
702
+
703
+ past_key_value = (
704
+ past_key_values[idx] if past_key_values is not None else None
705
+ )
706
+
707
+ if self.gradient_checkpointing and self.training:
708
+
709
+ def create_custom_forward(module):
710
+ def custom_forward(*inputs):
711
+ # None for past_key_value
712
+ return module(*inputs, past_key_value, output_attentions)
713
+
714
+ return custom_forward
715
+
716
+ layer_outputs = torch.utils.checkpoint.checkpoint(
717
+ create_custom_forward(decoder_layer),
718
+ hidden_states,
719
+ attention_mask,
720
+ position_ids,
721
+ )
722
+ else:
723
+ layer_outputs = decoder_layer(
724
+ hidden_states,
725
+ attention_mask=attention_mask,
726
+ position_ids=position_ids,
727
+ past_key_value=past_key_value,
728
+ output_attentions=output_attentions,
729
+ use_cache=use_cache,
730
+ )
731
+
732
+ hidden_states = layer_outputs[0]
733
+
734
+ if use_cache:
735
+ next_decoder_cache += (layer_outputs[2 if output_attentions else 1],)
736
+
737
+ if output_attentions:
738
+ all_self_attns += (layer_outputs[1],)
739
+
740
+ hidden_states = self.norm(hidden_states)
741
+
742
+ # Add hidden states from the last decoder layer
743
+ if output_hidden_states:
744
+ all_hidden_states += (hidden_states,)
745
+
746
+ next_cache = next_decoder_cache if use_cache else None
747
+ if not return_dict:
748
+ return tuple(
749
+ v
750
+ for v in [hidden_states, next_cache, all_hidden_states, all_self_attns]
751
+ if v is not None
752
+ )
753
+ return BaseModelOutputWithPast(
754
+ last_hidden_state=hidden_states,
755
+ past_key_values=next_cache,
756
+ hidden_states=all_hidden_states,
757
+ attentions=all_self_attns,
758
+ )
759
+
760
+
761
+ class StableLMEpochForCausalLM(StableLMEpochPreTrainedModel):
762
+ _tied_weights_keys = ["lm_head.weight"]
763
+
764
+ def __init__(self, config: StableLMEpochConfig):
765
+ super().__init__(config)
766
+
767
+ self.model = StableLMEpochModel(config)
768
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
769
+
770
+ # Initialize weights and apply final processing
771
+ self.post_init()
772
+
773
+ def get_input_embeddings(self):
774
+ return self.model.embed_tokens
775
+
776
+ def set_input_embeddings(self, value):
777
+ self.model.embed_tokens = value
778
+
779
+ def get_output_embeddings(self):
780
+ return self.lm_head
781
+
782
+ def set_output_embeddings(self, new_embeddings: nn.Module):
783
+ self.lm_head = new_embeddings
784
+
785
+ def get_decoder(self):
786
+ return self.model
787
+
788
+ def set_decoder(self, decoder):
789
+ self.model = decoder
790
+
791
+ def forward(
792
+ self,
793
+ input_ids: Optional[torch.LongTensor] = None,
794
+ attention_mask: Optional[torch.FloatTensor] = None,
795
+ position_ids: Optional[torch.LongTensor] = None,
796
+ past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
797
+ inputs_embeds: Optional[torch.FloatTensor] = None,
798
+ labels: Optional[torch.LongTensor] = None,
799
+ use_cache: Optional[bool] = None,
800
+ output_attentions: Optional[bool] = None,
801
+ output_hidden_states: Optional[bool] = None,
802
+ return_dict: Optional[bool] = None,
803
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
804
+ output_attentions = (
805
+ output_attentions
806
+ if output_attentions is not None
807
+ else self.config.output_attentions
808
+ )
809
+ output_hidden_states = (
810
+ output_hidden_states
811
+ if output_hidden_states is not None
812
+ else self.config.output_hidden_states
813
+ )
814
+ return_dict = (
815
+ return_dict if return_dict is not None else self.config.use_return_dict
816
+ )
817
+
818
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
819
+ outputs = self.model(
820
+ input_ids,
821
+ attention_mask=attention_mask,
822
+ position_ids=position_ids,
823
+ past_key_values=past_key_values,
824
+ inputs_embeds=inputs_embeds,
825
+ use_cache=use_cache,
826
+ output_attentions=output_attentions,
827
+ output_hidden_states=output_hidden_states,
828
+ return_dict=return_dict,
829
+ )
830
+
831
+ hidden_states = outputs[0]
832
+ logits = self.lm_head(hidden_states).float()
833
+
834
+ loss = None
835
+ if labels is not None:
836
+ # Shift so that tokens < n predict n
837
+ shift_logits = logits[..., :-1, :].contiguous()
838
+ shift_labels = labels[..., 1:].contiguous()
839
+ # Flatten the tokens
840
+ loss_fct = CrossEntropyLoss()
841
+ shift_logits = shift_logits.view(-1, self.config.vocab_size)
842
+ shift_labels = shift_labels.view(-1)
843
+ # Enable model parallelism
844
+ shift_labels = shift_labels.to(shift_logits.device)
845
+ loss = loss_fct(shift_logits, shift_labels)
846
+
847
+ if not return_dict:
848
+ output = (logits,) + outputs[1:]
849
+ return (loss,) + output if loss is not None else output
850
+
851
+ return CausalLMOutputWithPast(
852
+ loss=loss,
853
+ logits=logits,
854
+ past_key_values=outputs.past_key_values,
855
+ hidden_states=outputs.hidden_states,
856
+ attentions=outputs.attentions,
857
+ )
858
+
859
+ def prepare_inputs_for_generation(
860
+ self,
861
+ input_ids,
862
+ past_key_values: Optional[torch.Tensor] = None,
863
+ attention_mask: Optional[torch.Tensor] = None,
864
+ inputs_embeds: Optional[torch.Tensor] = None,
865
+ **kwargs,
866
+ ):
867
+ # Trim decoder_input_ids if past is used
868
+ if past_key_values is not None:
869
+ past_length = past_key_values[0][0].shape[2]
870
+
871
+ # Some generation methods already pass only the last input ID
872
+ if input_ids.shape[1] > past_length:
873
+ remove_prefix_length = past_length
874
+ else:
875
+ # Default to old behavior: keep only final ID
876
+ remove_prefix_length = input_ids.shape[1] - 1
877
+
878
+ input_ids = input_ids[:, remove_prefix_length:]
879
+
880
+ position_ids = kwargs.get("position_ids", None)
881
+ if attention_mask is not None and position_ids is None:
882
+ # Create position_ids on the fly for batch generation
883
+ position_ids = attention_mask.long().cumsum(-1) - 1
884
+ position_ids.masked_fill_(attention_mask == 0, 1)
885
+ if past_key_values:
886
+ position_ids = position_ids[:, -1].unsqueeze(-1)
887
+
888
+ # If `inputs_embeds` are passed, we only want to use them in the 1st generation step
889
+ if inputs_embeds is not None and past_key_values is None:
890
+ model_inputs = {"inputs_embeds": inputs_embeds}
891
+ else:
892
+ model_inputs = {"input_ids": input_ids}
893
+
894
+ model_inputs.update(
895
+ {
896
+ "attention_mask": attention_mask,
897
+ "past_key_values": past_key_values,
898
+ "use_cache": kwargs.get("use_cache"),
899
+ "position_ids": position_ids,
900
+ }
901
+ )
902
+ return model_inputs
903
+
904
+ @staticmethod
905
+ def _reorder_cache(past_key_values, beam_idx):
906
+ reordered_past = ()
907
+ for layer_past in past_key_values:
908
+ reordered_past += (
909
+ tuple(
910
+ past_state.index_select(0, beam_idx.to(past_state.device))
911
+ for past_state in layer_past
912
+ ),
913
+ )
914
+ return reordered_past
915
+
916
+
917
+ StableLMEpochConfig.register_for_auto_class()
918
+ StableLMEpochForCausalLM.register_for_auto_class("AutoModelForCausalLM")
special_tokens_map.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|endoftext|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "unk_token": {
17
+ "content": "<|endoftext|>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ }
23
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<|padding|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "50254": {
21
+ "content": " ",
22
+ "lstrip": false,
23
+ "normalized": true,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": false
27
+ },
28
+ "50255": {
29
+ "content": " ",
30
+ "lstrip": false,
31
+ "normalized": true,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": false
35
+ },
36
+ "50256": {
37
+ "content": " ",
38
+ "lstrip": false,
39
+ "normalized": true,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": false
43
+ },
44
+ "50257": {
45
+ "content": " ",
46
+ "lstrip": false,
47
+ "normalized": true,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": false
51
+ },
52
+ "50258": {
53
+ "content": " ",
54
+ "lstrip": false,
55
+ "normalized": true,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": false
59
+ },
60
+ "50259": {
61
+ "content": " ",
62
+ "lstrip": false,
63
+ "normalized": true,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": false
67
+ },
68
+ "50260": {
69
+ "content": " ",
70
+ "lstrip": false,
71
+ "normalized": true,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": false
75
+ },
76
+ "50261": {
77
+ "content": " ",
78
+ "lstrip": false,
79
+ "normalized": true,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": false
83
+ },
84
+ "50262": {
85
+ "content": " ",
86
+ "lstrip": false,
87
+ "normalized": true,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": false
91
+ },
92
+ "50263": {
93
+ "content": " ",
94
+ "lstrip": false,
95
+ "normalized": true,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": false
99
+ },
100
+ "50264": {
101
+ "content": " ",
102
+ "lstrip": false,
103
+ "normalized": true,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": false
107
+ },
108
+ "50265": {
109
+ "content": " ",
110
+ "lstrip": false,
111
+ "normalized": true,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": false
115
+ },
116
+ "50266": {
117
+ "content": " ",
118
+ "lstrip": false,
119
+ "normalized": true,
120
+ "rstrip": false,
121
+ "single_word": false,
122
+ "special": false
123
+ },
124
+ "50267": {
125
+ "content": " ",
126
+ "lstrip": false,
127
+ "normalized": true,
128
+ "rstrip": false,
129
+ "single_word": false,
130
+ "special": false
131
+ },
132
+ "50268": {
133
+ "content": " ",
134
+ "lstrip": false,
135
+ "normalized": true,
136
+ "rstrip": false,
137
+ "single_word": false,
138
+ "special": false
139
+ },
140
+ "50269": {
141
+ "content": " ",
142
+ "lstrip": false,
143
+ "normalized": true,
144
+ "rstrip": false,
145
+ "single_word": false,
146
+ "special": false
147
+ },
148
+ "50270": {
149
+ "content": " ",
150
+ "lstrip": false,
151
+ "normalized": true,
152
+ "rstrip": false,
153
+ "single_word": false,
154
+ "special": false
155
+ },
156
+ "50271": {
157
+ "content": " ",
158
+ "lstrip": false,
159
+ "normalized": true,
160
+ "rstrip": false,
161
+ "single_word": false,
162
+ "special": false
163
+ },
164
+ "50272": {
165
+ "content": " ",
166
+ "lstrip": false,
167
+ "normalized": true,
168
+ "rstrip": false,
169
+ "single_word": false,
170
+ "special": false
171
+ },
172
+ "50273": {
173
+ "content": " ",
174
+ "lstrip": false,
175
+ "normalized": true,
176
+ "rstrip": false,
177
+ "single_word": false,
178
+ "special": false
179
+ },
180
+ "50274": {
181
+ "content": " ",
182
+ "lstrip": false,
183
+ "normalized": true,
184
+ "rstrip": false,
185
+ "single_word": false,
186
+ "special": false
187
+ },
188
+ "50275": {
189
+ "content": " ",
190
+ "lstrip": false,
191
+ "normalized": true,
192
+ "rstrip": false,
193
+ "single_word": false,
194
+ "special": false
195
+ },
196
+ "50276": {
197
+ "content": " ",
198
+ "lstrip": false,
199
+ "normalized": true,
200
+ "rstrip": false,
201
+ "single_word": false,
202
+ "special": false
203
+ }
204
+ },
205
+ "bos_token": "<|endoftext|>",
206
+ "clean_up_tokenization_spaces": true,
207
+ "eos_token": "<|endoftext|>",
208
+ "model_max_length": 1000000000000000019884624838656,
209
+ "tokenizer_class": "GPTNeoXTokenizer",
210
+ "unk_token": "<|endoftext|>"
211
+ }