ArturBaranowskiAA commited on
Commit
6fdac15
1 Parent(s): f588879

Push Pharia-1-LLM-7B-control-aligned-safetensors

Browse files
LICENSE CHANGED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The following applies to all files in this repository, unless otherwise noted:
2
+
3
+ Copyright (c) 2024 IPAI Aleph Alpha Research GmbH. All rights reserved.
4
+
5
+ This project is licensed under the terms of the Open Aleph License 1.0, available at
6
+ https://github.com/Aleph-Alpha/.github/blob/main/oal.pdf
7
+
8
+ ---
9
+ Excerpt from the license text:
10
+
11
+ Subject to the terms and conditions of this License, the Licensor grants you a non-exclusive, worldwide,
12
+ non-transferable, non-sublicensable, and royalty-free limited right to use, copy, modify, distribute, make
13
+ otherwise publicly available, and reproduce the Works and Derivative Works under Licensor’s copyright,
14
+ for any Non-Commercial and Non-Administrative purpose.
15
+ You may not use, copy, modify, distribute, make otherwise publicly available, reproduce, or sublicense the
16
+ Works or Derivative Works except as expressly provided under and in accordance with this License.
17
+ Your rights granted under this License will automatically terminate if you fail to comply with any of the
18
+ terms of this License.
19
+
20
+ EXCEPT FOR DAMAGES CAUSED BY INTENT OR FRAUDULENTLY CONCEALED
21
+ DEFECTS, AND EXCEPT FOR DAMAGES RESULTING FROM BREACH OF ANY
22
+ WARRANTY OR GUARANTEE EXPRESSLY GIVEN BY LICENSOR IN THE OPEN ALEPH LICENSE,
23
+ IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY
24
+ DAMAGES ARISING OUT OF THE OPEN ALEPH LICENSE OR THE USE OF THE WORK. ANY
25
+ MANDATORY STATUTORY LIABILITY UNDER APPLICABLE LAW REMAINS
26
+ UNAFFECTED.
27
+
28
+ EXCEPT AS EXPRESSLY STATED IN THIS LICENSE OR REQUIRED BY APPLICABLE
29
+ LAW, THE WORKS ARE PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES
30
+ OF ANY KIND INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES REGARDING
31
+ THE CONTENTS, ACCURACY, OR FITNESS FOR A PARTICULAR PURPOSE.
README.md CHANGED
@@ -1,5 +1,9 @@
1
- ---
2
- license: other
3
- license_name: open-aleph-license
4
- license_link: LICENSE
5
- ---
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: open-aleph-license
4
+ license_link: LICENSE
5
+ library_name: transformers
6
+ pipeline_tag: text-generation
7
+ ---
8
+
9
+ We provide a joint model card for `Pharia-1-LLM-7B-control` and `Pharia-1-LLM-control-aligned`. Find this model card [here](https://huggingface.co/Aleph-Alpha/Pharia-1-LLM-7B-control).
config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "PhariaForCausalLM"
4
+ ],
5
+ "auto_map": {
6
+ "AutoConfig": "configuration_pharia.PhariaConfig",
7
+ "AutoModelForCausalLM": "modeling_pharia.PhariaForCausalLM"
8
+ },
9
+ "model_type": "pharia-v1",
10
+ "attention_bias": true,
11
+ "attention_dropout": 0.0,
12
+ "eos_token_id": 0,
13
+ "bos_token_id": 127179,
14
+ "pad_token_id": 1,
15
+ "hidden_act": "gelu",
16
+ "hidden_size": 4608,
17
+ "initializer_range": 0.02,
18
+ "intermediate_size": 18432,
19
+ "max_position_embeddings": 8192,
20
+ "mlp_bias": true,
21
+ "num_attention_heads": 36,
22
+ "num_hidden_layers": 27,
23
+ "num_key_value_heads": 4,
24
+ "rope_scaling": null,
25
+ "rope_theta": 1000000,
26
+ "tie_word_embeddings": false,
27
+ "torch_dtype": "float32",
28
+ "transformers_version": "4.44.2",
29
+ "use_cache": true,
30
+ "vocab_size": 128000
31
+ }
configuration_pharia.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers.configuration_utils import PretrainedConfig
2
+
3
+
4
+ class PhariaConfig(PretrainedConfig):
5
+ model_type = "pharia-v1"
6
+
7
+ def __init__(
8
+ self,
9
+ pad_token_id=None,
10
+ bos_token_id=1,
11
+ eos_token_id=2,
12
+ hidden_act="gelu",
13
+ hidden_size=512,
14
+ initializer_range=0.02,
15
+ intermediate_size=2048,
16
+ max_position_embeddings=8192,
17
+ model_type="pharia-v1",
18
+ num_attention_heads=4,
19
+ num_hidden_layers=4,
20
+ num_key_value_heads=2,
21
+ torch_dtype="bfloat16",
22
+ transformers_version="4.31.0.dev0",
23
+ use_cache=True,
24
+ vocab_size=128000,
25
+ mlp_bias=True,
26
+ attention_bias=True,
27
+ tie_word_embeddings=False,
28
+ attention_dropout=0.0,
29
+ rope_theta=1000000, # rotary_embeddingbase,
30
+ rope_scaling=None,
31
+ **kwargs,
32
+ ):
33
+ super().__init__(
34
+ pad_token_id=pad_token_id,
35
+ bos_token_id=bos_token_id,
36
+ eos_token_id=eos_token_id,
37
+ tie_word_embeddings=tie_word_embeddings,
38
+ **kwargs,
39
+ )
40
+
41
+ self.pad_token_id = pad_token_id
42
+ self.bos_token_id = bos_token_id
43
+ self.eos_token_id = eos_token_id
44
+ self.hidden_act = hidden_act
45
+ self.hidden_size = hidden_size
46
+ self.initializer_range = initializer_range
47
+ self.intermediate_size = intermediate_size
48
+ self.max_position_embeddings = max_position_embeddings
49
+ self.model_type = model_type
50
+ self.num_attention_heads = num_attention_heads
51
+ self.num_hidden_layers = num_hidden_layers
52
+ self.num_key_value_heads = num_key_value_heads
53
+ self.torch_dtype = torch_dtype
54
+ self.transformers_version = transformers_version
55
+ self.use_cache = use_cache
56
+ self.vocab_size = vocab_size
57
+ self.mlp_bias = mlp_bias
58
+ self.attention_bias = attention_bias
59
+ self.tie_word_embeddings = tie_word_embeddings
60
+ self.attention_dropout = attention_dropout
61
+ self.rope_theta = rope_theta
62
+ self.rope_scaling = rope_scaling
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "eos_token_id": 0,
4
+ "bos_token_id": 127179,
5
+ "pad_token_id": 1,
6
+ "transformers_version": "4.44.2"
7
+ }
model-00001-of-00006.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6156fc4ab958213bcd56aea3b37d6397e689fd634294248edd15e446ba5ffc07
3
+ size 4964584832
model-00002-of-00006.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5592400ca6de01a3728633f1bc3f5873ad29ed521b7a80b2f999342c4aa61fbe
3
+ size 4870745896
model-00003-of-00006.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b24b0e92a53605c73d8c21b0dfa5a1a9a293fd6b102713c1048158df9afb3a1
3
+ size 4870764856
model-00004-of-00006.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e011995281779610c39610780696f0bae1c827617ecd39b8213cbb014354460
3
+ size 4681960456
model-00005-of-00006.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2163db79ded6900292da74848a007aea2e1ca6f3a75d5af804fe2181f2374b07
3
+ size 4870764888
model-00006-of-00006.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34d3d6a9468d032587cf0b2ddff734273ea738d0032787ccebca673b10aa3d3e
3
+ size 3907406784
model.safetensors.index.json ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 28166178816
4
+ },
5
+ "weight_map": {
6
+ "lm_head.weight": "model-00006-of-00006.safetensors",
7
+ "model.embed_tokens.weight": "model-00001-of-00006.safetensors",
8
+ "model.layers.0.input_layernorm.bias": "model-00001-of-00006.safetensors",
9
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00006.safetensors",
10
+ "model.layers.0.mlp.down_proj.bias": "model-00001-of-00006.safetensors",
11
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00006.safetensors",
12
+ "model.layers.0.mlp.up_proj.bias": "model-00001-of-00006.safetensors",
13
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00006.safetensors",
14
+ "model.layers.0.post_attention_layernorm.bias": "model-00001-of-00006.safetensors",
15
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00006.safetensors",
16
+ "model.layers.0.self_attn.k_proj.bias": "model-00001-of-00006.safetensors",
17
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
18
+ "model.layers.0.self_attn.o_proj.bias": "model-00001-of-00006.safetensors",
19
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
20
+ "model.layers.0.self_attn.q_proj.bias": "model-00001-of-00006.safetensors",
21
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
22
+ "model.layers.0.self_attn.v_proj.bias": "model-00001-of-00006.safetensors",
23
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
24
+ "model.layers.1.input_layernorm.bias": "model-00001-of-00006.safetensors",
25
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00006.safetensors",
26
+ "model.layers.1.mlp.down_proj.bias": "model-00001-of-00006.safetensors",
27
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00006.safetensors",
28
+ "model.layers.1.mlp.up_proj.bias": "model-00001-of-00006.safetensors",
29
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00006.safetensors",
30
+ "model.layers.1.post_attention_layernorm.bias": "model-00001-of-00006.safetensors",
31
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00006.safetensors",
32
+ "model.layers.1.self_attn.k_proj.bias": "model-00001-of-00006.safetensors",
33
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
34
+ "model.layers.1.self_attn.o_proj.bias": "model-00001-of-00006.safetensors",
35
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
36
+ "model.layers.1.self_attn.q_proj.bias": "model-00001-of-00006.safetensors",
37
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
38
+ "model.layers.1.self_attn.v_proj.bias": "model-00001-of-00006.safetensors",
39
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
40
+ "model.layers.10.input_layernorm.bias": "model-00003-of-00006.safetensors",
41
+ "model.layers.10.input_layernorm.weight": "model-00003-of-00006.safetensors",
42
+ "model.layers.10.mlp.down_proj.bias": "model-00003-of-00006.safetensors",
43
+ "model.layers.10.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
44
+ "model.layers.10.mlp.up_proj.bias": "model-00003-of-00006.safetensors",
45
+ "model.layers.10.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
46
+ "model.layers.10.post_attention_layernorm.bias": "model-00003-of-00006.safetensors",
47
+ "model.layers.10.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
48
+ "model.layers.10.self_attn.k_proj.bias": "model-00003-of-00006.safetensors",
49
+ "model.layers.10.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
50
+ "model.layers.10.self_attn.o_proj.bias": "model-00003-of-00006.safetensors",
51
+ "model.layers.10.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
52
+ "model.layers.10.self_attn.q_proj.bias": "model-00003-of-00006.safetensors",
53
+ "model.layers.10.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
54
+ "model.layers.10.self_attn.v_proj.bias": "model-00003-of-00006.safetensors",
55
+ "model.layers.10.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
56
+ "model.layers.11.input_layernorm.bias": "model-00003-of-00006.safetensors",
57
+ "model.layers.11.input_layernorm.weight": "model-00003-of-00006.safetensors",
58
+ "model.layers.11.mlp.down_proj.bias": "model-00003-of-00006.safetensors",
59
+ "model.layers.11.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
60
+ "model.layers.11.mlp.up_proj.bias": "model-00003-of-00006.safetensors",
61
+ "model.layers.11.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
62
+ "model.layers.11.post_attention_layernorm.bias": "model-00003-of-00006.safetensors",
63
+ "model.layers.11.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
64
+ "model.layers.11.self_attn.k_proj.bias": "model-00003-of-00006.safetensors",
65
+ "model.layers.11.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
66
+ "model.layers.11.self_attn.o_proj.bias": "model-00003-of-00006.safetensors",
67
+ "model.layers.11.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
68
+ "model.layers.11.self_attn.q_proj.bias": "model-00003-of-00006.safetensors",
69
+ "model.layers.11.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
70
+ "model.layers.11.self_attn.v_proj.bias": "model-00003-of-00006.safetensors",
71
+ "model.layers.11.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
72
+ "model.layers.12.input_layernorm.bias": "model-00003-of-00006.safetensors",
73
+ "model.layers.12.input_layernorm.weight": "model-00003-of-00006.safetensors",
74
+ "model.layers.12.mlp.down_proj.bias": "model-00003-of-00006.safetensors",
75
+ "model.layers.12.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
76
+ "model.layers.12.mlp.up_proj.bias": "model-00003-of-00006.safetensors",
77
+ "model.layers.12.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
78
+ "model.layers.12.post_attention_layernorm.bias": "model-00003-of-00006.safetensors",
79
+ "model.layers.12.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
80
+ "model.layers.12.self_attn.k_proj.bias": "model-00003-of-00006.safetensors",
81
+ "model.layers.12.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
82
+ "model.layers.12.self_attn.o_proj.bias": "model-00003-of-00006.safetensors",
83
+ "model.layers.12.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
84
+ "model.layers.12.self_attn.q_proj.bias": "model-00003-of-00006.safetensors",
85
+ "model.layers.12.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
86
+ "model.layers.12.self_attn.v_proj.bias": "model-00003-of-00006.safetensors",
87
+ "model.layers.12.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
88
+ "model.layers.13.input_layernorm.bias": "model-00003-of-00006.safetensors",
89
+ "model.layers.13.input_layernorm.weight": "model-00003-of-00006.safetensors",
90
+ "model.layers.13.mlp.down_proj.bias": "model-00003-of-00006.safetensors",
91
+ "model.layers.13.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
92
+ "model.layers.13.mlp.up_proj.bias": "model-00003-of-00006.safetensors",
93
+ "model.layers.13.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
94
+ "model.layers.13.post_attention_layernorm.bias": "model-00003-of-00006.safetensors",
95
+ "model.layers.13.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
96
+ "model.layers.13.self_attn.k_proj.bias": "model-00003-of-00006.safetensors",
97
+ "model.layers.13.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
98
+ "model.layers.13.self_attn.o_proj.bias": "model-00003-of-00006.safetensors",
99
+ "model.layers.13.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
100
+ "model.layers.13.self_attn.q_proj.bias": "model-00003-of-00006.safetensors",
101
+ "model.layers.13.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
102
+ "model.layers.13.self_attn.v_proj.bias": "model-00003-of-00006.safetensors",
103
+ "model.layers.13.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
104
+ "model.layers.14.input_layernorm.bias": "model-00004-of-00006.safetensors",
105
+ "model.layers.14.input_layernorm.weight": "model-00004-of-00006.safetensors",
106
+ "model.layers.14.mlp.down_proj.bias": "model-00004-of-00006.safetensors",
107
+ "model.layers.14.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
108
+ "model.layers.14.mlp.up_proj.bias": "model-00004-of-00006.safetensors",
109
+ "model.layers.14.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
110
+ "model.layers.14.post_attention_layernorm.bias": "model-00004-of-00006.safetensors",
111
+ "model.layers.14.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
112
+ "model.layers.14.self_attn.k_proj.bias": "model-00003-of-00006.safetensors",
113
+ "model.layers.14.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
114
+ "model.layers.14.self_attn.o_proj.bias": "model-00003-of-00006.safetensors",
115
+ "model.layers.14.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
116
+ "model.layers.14.self_attn.q_proj.bias": "model-00003-of-00006.safetensors",
117
+ "model.layers.14.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
118
+ "model.layers.14.self_attn.v_proj.bias": "model-00003-of-00006.safetensors",
119
+ "model.layers.14.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
120
+ "model.layers.15.input_layernorm.bias": "model-00004-of-00006.safetensors",
121
+ "model.layers.15.input_layernorm.weight": "model-00004-of-00006.safetensors",
122
+ "model.layers.15.mlp.down_proj.bias": "model-00004-of-00006.safetensors",
123
+ "model.layers.15.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
124
+ "model.layers.15.mlp.up_proj.bias": "model-00004-of-00006.safetensors",
125
+ "model.layers.15.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
126
+ "model.layers.15.post_attention_layernorm.bias": "model-00004-of-00006.safetensors",
127
+ "model.layers.15.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
128
+ "model.layers.15.self_attn.k_proj.bias": "model-00004-of-00006.safetensors",
129
+ "model.layers.15.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
130
+ "model.layers.15.self_attn.o_proj.bias": "model-00004-of-00006.safetensors",
131
+ "model.layers.15.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
132
+ "model.layers.15.self_attn.q_proj.bias": "model-00004-of-00006.safetensors",
133
+ "model.layers.15.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
134
+ "model.layers.15.self_attn.v_proj.bias": "model-00004-of-00006.safetensors",
135
+ "model.layers.15.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
136
+ "model.layers.16.input_layernorm.bias": "model-00004-of-00006.safetensors",
137
+ "model.layers.16.input_layernorm.weight": "model-00004-of-00006.safetensors",
138
+ "model.layers.16.mlp.down_proj.bias": "model-00004-of-00006.safetensors",
139
+ "model.layers.16.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
140
+ "model.layers.16.mlp.up_proj.bias": "model-00004-of-00006.safetensors",
141
+ "model.layers.16.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
142
+ "model.layers.16.post_attention_layernorm.bias": "model-00004-of-00006.safetensors",
143
+ "model.layers.16.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
144
+ "model.layers.16.self_attn.k_proj.bias": "model-00004-of-00006.safetensors",
145
+ "model.layers.16.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
146
+ "model.layers.16.self_attn.o_proj.bias": "model-00004-of-00006.safetensors",
147
+ "model.layers.16.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
148
+ "model.layers.16.self_attn.q_proj.bias": "model-00004-of-00006.safetensors",
149
+ "model.layers.16.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
150
+ "model.layers.16.self_attn.v_proj.bias": "model-00004-of-00006.safetensors",
151
+ "model.layers.16.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
152
+ "model.layers.17.input_layernorm.bias": "model-00004-of-00006.safetensors",
153
+ "model.layers.17.input_layernorm.weight": "model-00004-of-00006.safetensors",
154
+ "model.layers.17.mlp.down_proj.bias": "model-00004-of-00006.safetensors",
155
+ "model.layers.17.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
156
+ "model.layers.17.mlp.up_proj.bias": "model-00004-of-00006.safetensors",
157
+ "model.layers.17.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
158
+ "model.layers.17.post_attention_layernorm.bias": "model-00004-of-00006.safetensors",
159
+ "model.layers.17.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
160
+ "model.layers.17.self_attn.k_proj.bias": "model-00004-of-00006.safetensors",
161
+ "model.layers.17.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
162
+ "model.layers.17.self_attn.o_proj.bias": "model-00004-of-00006.safetensors",
163
+ "model.layers.17.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
164
+ "model.layers.17.self_attn.q_proj.bias": "model-00004-of-00006.safetensors",
165
+ "model.layers.17.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
166
+ "model.layers.17.self_attn.v_proj.bias": "model-00004-of-00006.safetensors",
167
+ "model.layers.17.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
168
+ "model.layers.18.input_layernorm.bias": "model-00004-of-00006.safetensors",
169
+ "model.layers.18.input_layernorm.weight": "model-00004-of-00006.safetensors",
170
+ "model.layers.18.mlp.down_proj.bias": "model-00004-of-00006.safetensors",
171
+ "model.layers.18.mlp.down_proj.weight": "model-00004-of-00006.safetensors",
172
+ "model.layers.18.mlp.up_proj.bias": "model-00004-of-00006.safetensors",
173
+ "model.layers.18.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
174
+ "model.layers.18.post_attention_layernorm.bias": "model-00004-of-00006.safetensors",
175
+ "model.layers.18.post_attention_layernorm.weight": "model-00004-of-00006.safetensors",
176
+ "model.layers.18.self_attn.k_proj.bias": "model-00004-of-00006.safetensors",
177
+ "model.layers.18.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
178
+ "model.layers.18.self_attn.o_proj.bias": "model-00004-of-00006.safetensors",
179
+ "model.layers.18.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
180
+ "model.layers.18.self_attn.q_proj.bias": "model-00004-of-00006.safetensors",
181
+ "model.layers.18.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
182
+ "model.layers.18.self_attn.v_proj.bias": "model-00004-of-00006.safetensors",
183
+ "model.layers.18.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
184
+ "model.layers.19.input_layernorm.bias": "model-00005-of-00006.safetensors",
185
+ "model.layers.19.input_layernorm.weight": "model-00005-of-00006.safetensors",
186
+ "model.layers.19.mlp.down_proj.bias": "model-00005-of-00006.safetensors",
187
+ "model.layers.19.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
188
+ "model.layers.19.mlp.up_proj.bias": "model-00004-of-00006.safetensors",
189
+ "model.layers.19.mlp.up_proj.weight": "model-00004-of-00006.safetensors",
190
+ "model.layers.19.post_attention_layernorm.bias": "model-00005-of-00006.safetensors",
191
+ "model.layers.19.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
192
+ "model.layers.19.self_attn.k_proj.bias": "model-00004-of-00006.safetensors",
193
+ "model.layers.19.self_attn.k_proj.weight": "model-00004-of-00006.safetensors",
194
+ "model.layers.19.self_attn.o_proj.bias": "model-00004-of-00006.safetensors",
195
+ "model.layers.19.self_attn.o_proj.weight": "model-00004-of-00006.safetensors",
196
+ "model.layers.19.self_attn.q_proj.bias": "model-00004-of-00006.safetensors",
197
+ "model.layers.19.self_attn.q_proj.weight": "model-00004-of-00006.safetensors",
198
+ "model.layers.19.self_attn.v_proj.bias": "model-00004-of-00006.safetensors",
199
+ "model.layers.19.self_attn.v_proj.weight": "model-00004-of-00006.safetensors",
200
+ "model.layers.2.input_layernorm.bias": "model-00001-of-00006.safetensors",
201
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00006.safetensors",
202
+ "model.layers.2.mlp.down_proj.bias": "model-00001-of-00006.safetensors",
203
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00006.safetensors",
204
+ "model.layers.2.mlp.up_proj.bias": "model-00001-of-00006.safetensors",
205
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00006.safetensors",
206
+ "model.layers.2.post_attention_layernorm.bias": "model-00001-of-00006.safetensors",
207
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00006.safetensors",
208
+ "model.layers.2.self_attn.k_proj.bias": "model-00001-of-00006.safetensors",
209
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00006.safetensors",
210
+ "model.layers.2.self_attn.o_proj.bias": "model-00001-of-00006.safetensors",
211
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00006.safetensors",
212
+ "model.layers.2.self_attn.q_proj.bias": "model-00001-of-00006.safetensors",
213
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00006.safetensors",
214
+ "model.layers.2.self_attn.v_proj.bias": "model-00001-of-00006.safetensors",
215
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00006.safetensors",
216
+ "model.layers.20.input_layernorm.bias": "model-00005-of-00006.safetensors",
217
+ "model.layers.20.input_layernorm.weight": "model-00005-of-00006.safetensors",
218
+ "model.layers.20.mlp.down_proj.bias": "model-00005-of-00006.safetensors",
219
+ "model.layers.20.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
220
+ "model.layers.20.mlp.up_proj.bias": "model-00005-of-00006.safetensors",
221
+ "model.layers.20.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
222
+ "model.layers.20.post_attention_layernorm.bias": "model-00005-of-00006.safetensors",
223
+ "model.layers.20.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
224
+ "model.layers.20.self_attn.k_proj.bias": "model-00005-of-00006.safetensors",
225
+ "model.layers.20.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
226
+ "model.layers.20.self_attn.o_proj.bias": "model-00005-of-00006.safetensors",
227
+ "model.layers.20.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
228
+ "model.layers.20.self_attn.q_proj.bias": "model-00005-of-00006.safetensors",
229
+ "model.layers.20.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
230
+ "model.layers.20.self_attn.v_proj.bias": "model-00005-of-00006.safetensors",
231
+ "model.layers.20.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
232
+ "model.layers.21.input_layernorm.bias": "model-00005-of-00006.safetensors",
233
+ "model.layers.21.input_layernorm.weight": "model-00005-of-00006.safetensors",
234
+ "model.layers.21.mlp.down_proj.bias": "model-00005-of-00006.safetensors",
235
+ "model.layers.21.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
236
+ "model.layers.21.mlp.up_proj.bias": "model-00005-of-00006.safetensors",
237
+ "model.layers.21.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
238
+ "model.layers.21.post_attention_layernorm.bias": "model-00005-of-00006.safetensors",
239
+ "model.layers.21.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
240
+ "model.layers.21.self_attn.k_proj.bias": "model-00005-of-00006.safetensors",
241
+ "model.layers.21.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
242
+ "model.layers.21.self_attn.o_proj.bias": "model-00005-of-00006.safetensors",
243
+ "model.layers.21.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
244
+ "model.layers.21.self_attn.q_proj.bias": "model-00005-of-00006.safetensors",
245
+ "model.layers.21.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
246
+ "model.layers.21.self_attn.v_proj.bias": "model-00005-of-00006.safetensors",
247
+ "model.layers.21.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
248
+ "model.layers.22.input_layernorm.bias": "model-00005-of-00006.safetensors",
249
+ "model.layers.22.input_layernorm.weight": "model-00005-of-00006.safetensors",
250
+ "model.layers.22.mlp.down_proj.bias": "model-00005-of-00006.safetensors",
251
+ "model.layers.22.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
252
+ "model.layers.22.mlp.up_proj.bias": "model-00005-of-00006.safetensors",
253
+ "model.layers.22.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
254
+ "model.layers.22.post_attention_layernorm.bias": "model-00005-of-00006.safetensors",
255
+ "model.layers.22.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
256
+ "model.layers.22.self_attn.k_proj.bias": "model-00005-of-00006.safetensors",
257
+ "model.layers.22.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
258
+ "model.layers.22.self_attn.o_proj.bias": "model-00005-of-00006.safetensors",
259
+ "model.layers.22.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
260
+ "model.layers.22.self_attn.q_proj.bias": "model-00005-of-00006.safetensors",
261
+ "model.layers.22.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
262
+ "model.layers.22.self_attn.v_proj.bias": "model-00005-of-00006.safetensors",
263
+ "model.layers.22.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
264
+ "model.layers.23.input_layernorm.bias": "model-00005-of-00006.safetensors",
265
+ "model.layers.23.input_layernorm.weight": "model-00005-of-00006.safetensors",
266
+ "model.layers.23.mlp.down_proj.bias": "model-00005-of-00006.safetensors",
267
+ "model.layers.23.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
268
+ "model.layers.23.mlp.up_proj.bias": "model-00005-of-00006.safetensors",
269
+ "model.layers.23.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
270
+ "model.layers.23.post_attention_layernorm.bias": "model-00005-of-00006.safetensors",
271
+ "model.layers.23.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
272
+ "model.layers.23.self_attn.k_proj.bias": "model-00005-of-00006.safetensors",
273
+ "model.layers.23.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
274
+ "model.layers.23.self_attn.o_proj.bias": "model-00005-of-00006.safetensors",
275
+ "model.layers.23.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
276
+ "model.layers.23.self_attn.q_proj.bias": "model-00005-of-00006.safetensors",
277
+ "model.layers.23.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
278
+ "model.layers.23.self_attn.v_proj.bias": "model-00005-of-00006.safetensors",
279
+ "model.layers.23.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
280
+ "model.layers.24.input_layernorm.bias": "model-00005-of-00006.safetensors",
281
+ "model.layers.24.input_layernorm.weight": "model-00005-of-00006.safetensors",
282
+ "model.layers.24.mlp.down_proj.bias": "model-00005-of-00006.safetensors",
283
+ "model.layers.24.mlp.down_proj.weight": "model-00005-of-00006.safetensors",
284
+ "model.layers.24.mlp.up_proj.bias": "model-00005-of-00006.safetensors",
285
+ "model.layers.24.mlp.up_proj.weight": "model-00005-of-00006.safetensors",
286
+ "model.layers.24.post_attention_layernorm.bias": "model-00005-of-00006.safetensors",
287
+ "model.layers.24.post_attention_layernorm.weight": "model-00005-of-00006.safetensors",
288
+ "model.layers.24.self_attn.k_proj.bias": "model-00005-of-00006.safetensors",
289
+ "model.layers.24.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
290
+ "model.layers.24.self_attn.o_proj.bias": "model-00005-of-00006.safetensors",
291
+ "model.layers.24.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
292
+ "model.layers.24.self_attn.q_proj.bias": "model-00005-of-00006.safetensors",
293
+ "model.layers.24.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
294
+ "model.layers.24.self_attn.v_proj.bias": "model-00005-of-00006.safetensors",
295
+ "model.layers.24.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
296
+ "model.layers.25.input_layernorm.bias": "model-00006-of-00006.safetensors",
297
+ "model.layers.25.input_layernorm.weight": "model-00006-of-00006.safetensors",
298
+ "model.layers.25.mlp.down_proj.bias": "model-00006-of-00006.safetensors",
299
+ "model.layers.25.mlp.down_proj.weight": "model-00006-of-00006.safetensors",
300
+ "model.layers.25.mlp.up_proj.bias": "model-00006-of-00006.safetensors",
301
+ "model.layers.25.mlp.up_proj.weight": "model-00006-of-00006.safetensors",
302
+ "model.layers.25.post_attention_layernorm.bias": "model-00006-of-00006.safetensors",
303
+ "model.layers.25.post_attention_layernorm.weight": "model-00006-of-00006.safetensors",
304
+ "model.layers.25.self_attn.k_proj.bias": "model-00005-of-00006.safetensors",
305
+ "model.layers.25.self_attn.k_proj.weight": "model-00005-of-00006.safetensors",
306
+ "model.layers.25.self_attn.o_proj.bias": "model-00005-of-00006.safetensors",
307
+ "model.layers.25.self_attn.o_proj.weight": "model-00005-of-00006.safetensors",
308
+ "model.layers.25.self_attn.q_proj.bias": "model-00005-of-00006.safetensors",
309
+ "model.layers.25.self_attn.q_proj.weight": "model-00005-of-00006.safetensors",
310
+ "model.layers.25.self_attn.v_proj.bias": "model-00005-of-00006.safetensors",
311
+ "model.layers.25.self_attn.v_proj.weight": "model-00005-of-00006.safetensors",
312
+ "model.layers.26.input_layernorm.bias": "model-00006-of-00006.safetensors",
313
+ "model.layers.26.input_layernorm.weight": "model-00006-of-00006.safetensors",
314
+ "model.layers.26.mlp.down_proj.bias": "model-00006-of-00006.safetensors",
315
+ "model.layers.26.mlp.down_proj.weight": "model-00006-of-00006.safetensors",
316
+ "model.layers.26.mlp.up_proj.bias": "model-00006-of-00006.safetensors",
317
+ "model.layers.26.mlp.up_proj.weight": "model-00006-of-00006.safetensors",
318
+ "model.layers.26.post_attention_layernorm.bias": "model-00006-of-00006.safetensors",
319
+ "model.layers.26.post_attention_layernorm.weight": "model-00006-of-00006.safetensors",
320
+ "model.layers.26.self_attn.k_proj.bias": "model-00006-of-00006.safetensors",
321
+ "model.layers.26.self_attn.k_proj.weight": "model-00006-of-00006.safetensors",
322
+ "model.layers.26.self_attn.o_proj.bias": "model-00006-of-00006.safetensors",
323
+ "model.layers.26.self_attn.o_proj.weight": "model-00006-of-00006.safetensors",
324
+ "model.layers.26.self_attn.q_proj.bias": "model-00006-of-00006.safetensors",
325
+ "model.layers.26.self_attn.q_proj.weight": "model-00006-of-00006.safetensors",
326
+ "model.layers.26.self_attn.v_proj.bias": "model-00006-of-00006.safetensors",
327
+ "model.layers.26.self_attn.v_proj.weight": "model-00006-of-00006.safetensors",
328
+ "model.layers.3.input_layernorm.bias": "model-00002-of-00006.safetensors",
329
+ "model.layers.3.input_layernorm.weight": "model-00002-of-00006.safetensors",
330
+ "model.layers.3.mlp.down_proj.bias": "model-00002-of-00006.safetensors",
331
+ "model.layers.3.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
332
+ "model.layers.3.mlp.up_proj.bias": "model-00002-of-00006.safetensors",
333
+ "model.layers.3.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
334
+ "model.layers.3.post_attention_layernorm.bias": "model-00002-of-00006.safetensors",
335
+ "model.layers.3.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
336
+ "model.layers.3.self_attn.k_proj.bias": "model-00002-of-00006.safetensors",
337
+ "model.layers.3.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
338
+ "model.layers.3.self_attn.o_proj.bias": "model-00002-of-00006.safetensors",
339
+ "model.layers.3.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
340
+ "model.layers.3.self_attn.q_proj.bias": "model-00002-of-00006.safetensors",
341
+ "model.layers.3.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
342
+ "model.layers.3.self_attn.v_proj.bias": "model-00002-of-00006.safetensors",
343
+ "model.layers.3.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
344
+ "model.layers.4.input_layernorm.bias": "model-00002-of-00006.safetensors",
345
+ "model.layers.4.input_layernorm.weight": "model-00002-of-00006.safetensors",
346
+ "model.layers.4.mlp.down_proj.bias": "model-00002-of-00006.safetensors",
347
+ "model.layers.4.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
348
+ "model.layers.4.mlp.up_proj.bias": "model-00002-of-00006.safetensors",
349
+ "model.layers.4.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
350
+ "model.layers.4.post_attention_layernorm.bias": "model-00002-of-00006.safetensors",
351
+ "model.layers.4.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
352
+ "model.layers.4.self_attn.k_proj.bias": "model-00002-of-00006.safetensors",
353
+ "model.layers.4.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
354
+ "model.layers.4.self_attn.o_proj.bias": "model-00002-of-00006.safetensors",
355
+ "model.layers.4.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
356
+ "model.layers.4.self_attn.q_proj.bias": "model-00002-of-00006.safetensors",
357
+ "model.layers.4.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
358
+ "model.layers.4.self_attn.v_proj.bias": "model-00002-of-00006.safetensors",
359
+ "model.layers.4.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
360
+ "model.layers.5.input_layernorm.bias": "model-00002-of-00006.safetensors",
361
+ "model.layers.5.input_layernorm.weight": "model-00002-of-00006.safetensors",
362
+ "model.layers.5.mlp.down_proj.bias": "model-00002-of-00006.safetensors",
363
+ "model.layers.5.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
364
+ "model.layers.5.mlp.up_proj.bias": "model-00002-of-00006.safetensors",
365
+ "model.layers.5.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
366
+ "model.layers.5.post_attention_layernorm.bias": "model-00002-of-00006.safetensors",
367
+ "model.layers.5.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
368
+ "model.layers.5.self_attn.k_proj.bias": "model-00002-of-00006.safetensors",
369
+ "model.layers.5.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
370
+ "model.layers.5.self_attn.o_proj.bias": "model-00002-of-00006.safetensors",
371
+ "model.layers.5.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
372
+ "model.layers.5.self_attn.q_proj.bias": "model-00002-of-00006.safetensors",
373
+ "model.layers.5.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
374
+ "model.layers.5.self_attn.v_proj.bias": "model-00002-of-00006.safetensors",
375
+ "model.layers.5.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
376
+ "model.layers.6.input_layernorm.bias": "model-00002-of-00006.safetensors",
377
+ "model.layers.6.input_layernorm.weight": "model-00002-of-00006.safetensors",
378
+ "model.layers.6.mlp.down_proj.bias": "model-00002-of-00006.safetensors",
379
+ "model.layers.6.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
380
+ "model.layers.6.mlp.up_proj.bias": "model-00002-of-00006.safetensors",
381
+ "model.layers.6.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
382
+ "model.layers.6.post_attention_layernorm.bias": "model-00002-of-00006.safetensors",
383
+ "model.layers.6.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
384
+ "model.layers.6.self_attn.k_proj.bias": "model-00002-of-00006.safetensors",
385
+ "model.layers.6.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
386
+ "model.layers.6.self_attn.o_proj.bias": "model-00002-of-00006.safetensors",
387
+ "model.layers.6.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
388
+ "model.layers.6.self_attn.q_proj.bias": "model-00002-of-00006.safetensors",
389
+ "model.layers.6.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
390
+ "model.layers.6.self_attn.v_proj.bias": "model-00002-of-00006.safetensors",
391
+ "model.layers.6.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
392
+ "model.layers.7.input_layernorm.bias": "model-00002-of-00006.safetensors",
393
+ "model.layers.7.input_layernorm.weight": "model-00002-of-00006.safetensors",
394
+ "model.layers.7.mlp.down_proj.bias": "model-00002-of-00006.safetensors",
395
+ "model.layers.7.mlp.down_proj.weight": "model-00002-of-00006.safetensors",
396
+ "model.layers.7.mlp.up_proj.bias": "model-00002-of-00006.safetensors",
397
+ "model.layers.7.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
398
+ "model.layers.7.post_attention_layernorm.bias": "model-00002-of-00006.safetensors",
399
+ "model.layers.7.post_attention_layernorm.weight": "model-00002-of-00006.safetensors",
400
+ "model.layers.7.self_attn.k_proj.bias": "model-00002-of-00006.safetensors",
401
+ "model.layers.7.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
402
+ "model.layers.7.self_attn.o_proj.bias": "model-00002-of-00006.safetensors",
403
+ "model.layers.7.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
404
+ "model.layers.7.self_attn.q_proj.bias": "model-00002-of-00006.safetensors",
405
+ "model.layers.7.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
406
+ "model.layers.7.self_attn.v_proj.bias": "model-00002-of-00006.safetensors",
407
+ "model.layers.7.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
408
+ "model.layers.8.input_layernorm.bias": "model-00003-of-00006.safetensors",
409
+ "model.layers.8.input_layernorm.weight": "model-00003-of-00006.safetensors",
410
+ "model.layers.8.mlp.down_proj.bias": "model-00003-of-00006.safetensors",
411
+ "model.layers.8.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
412
+ "model.layers.8.mlp.up_proj.bias": "model-00002-of-00006.safetensors",
413
+ "model.layers.8.mlp.up_proj.weight": "model-00002-of-00006.safetensors",
414
+ "model.layers.8.post_attention_layernorm.bias": "model-00003-of-00006.safetensors",
415
+ "model.layers.8.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
416
+ "model.layers.8.self_attn.k_proj.bias": "model-00002-of-00006.safetensors",
417
+ "model.layers.8.self_attn.k_proj.weight": "model-00002-of-00006.safetensors",
418
+ "model.layers.8.self_attn.o_proj.bias": "model-00002-of-00006.safetensors",
419
+ "model.layers.8.self_attn.o_proj.weight": "model-00002-of-00006.safetensors",
420
+ "model.layers.8.self_attn.q_proj.bias": "model-00002-of-00006.safetensors",
421
+ "model.layers.8.self_attn.q_proj.weight": "model-00002-of-00006.safetensors",
422
+ "model.layers.8.self_attn.v_proj.bias": "model-00002-of-00006.safetensors",
423
+ "model.layers.8.self_attn.v_proj.weight": "model-00002-of-00006.safetensors",
424
+ "model.layers.9.input_layernorm.bias": "model-00003-of-00006.safetensors",
425
+ "model.layers.9.input_layernorm.weight": "model-00003-of-00006.safetensors",
426
+ "model.layers.9.mlp.down_proj.bias": "model-00003-of-00006.safetensors",
427
+ "model.layers.9.mlp.down_proj.weight": "model-00003-of-00006.safetensors",
428
+ "model.layers.9.mlp.up_proj.bias": "model-00003-of-00006.safetensors",
429
+ "model.layers.9.mlp.up_proj.weight": "model-00003-of-00006.safetensors",
430
+ "model.layers.9.post_attention_layernorm.bias": "model-00003-of-00006.safetensors",
431
+ "model.layers.9.post_attention_layernorm.weight": "model-00003-of-00006.safetensors",
432
+ "model.layers.9.self_attn.k_proj.bias": "model-00003-of-00006.safetensors",
433
+ "model.layers.9.self_attn.k_proj.weight": "model-00003-of-00006.safetensors",
434
+ "model.layers.9.self_attn.o_proj.bias": "model-00003-of-00006.safetensors",
435
+ "model.layers.9.self_attn.o_proj.weight": "model-00003-of-00006.safetensors",
436
+ "model.layers.9.self_attn.q_proj.bias": "model-00003-of-00006.safetensors",
437
+ "model.layers.9.self_attn.q_proj.weight": "model-00003-of-00006.safetensors",
438
+ "model.layers.9.self_attn.v_proj.bias": "model-00003-of-00006.safetensors",
439
+ "model.layers.9.self_attn.v_proj.weight": "model-00003-of-00006.safetensors",
440
+ "model.norm.bias": "model-00006-of-00006.safetensors",
441
+ "model.norm.weight": "model-00006-of-00006.safetensors"
442
+ }
443
+ }
modeling_pharia.py ADDED
@@ -0,0 +1,870 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # we don't want to support mypy for this file for now
2
+ # type: ignore
3
+
4
+ import math
5
+ from typing import List, Optional, Tuple, Union
6
+
7
+ import torch
8
+ from torch import nn
9
+ from transformers.activations import ACT2FN
10
+ from transformers.cache_utils import Cache, DynamicCache, StaticCache
11
+ from transformers.modeling_attn_mask_utils import AttentionMaskConverter
12
+ from transformers.modeling_outputs import (
13
+ BaseModelOutputWithPast,
14
+ CausalLMOutputWithPast,
15
+ )
16
+ from transformers.modeling_utils import PreTrainedModel
17
+
18
+ from .configuration_pharia import PhariaConfig
19
+
20
+
21
+ class PhariaRotaryEmbedding(nn.Module):
22
+ def __init__(
23
+ self,
24
+ dim,
25
+ max_position_embeddings=2048,
26
+ base=10000,
27
+ device=None,
28
+ scaling_factor=1.0,
29
+ ):
30
+ super().__init__()
31
+ self.scaling_factor = scaling_factor
32
+ self.dim = dim
33
+ self.max_position_embeddings = max_position_embeddings
34
+ self.base = base
35
+ inv_freq = 1.0 / (
36
+ self.base
37
+ ** (
38
+ torch.arange(0, self.dim, 2, dtype=torch.int64).float().to(device)
39
+ / self.dim
40
+ )
41
+ )
42
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
43
+ # For BC we register cos and sin cached
44
+ self.max_seq_len_cached = max_position_embeddings
45
+
46
+ @torch.no_grad()
47
+ def forward(self, x, position_ids):
48
+ # x: [bs, num_attention_heads, seq_len, head_size]
49
+ inv_freq_expanded = (
50
+ self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1)
51
+ )
52
+ position_ids_expanded = position_ids[:, None, :].float()
53
+ # Force float32 since bfloat16 loses precision on long contexts
54
+ # See https://github.com/huggingface/transformers/pull/29285
55
+ device_type = x.device.type
56
+ device_type = (
57
+ device_type
58
+ if isinstance(device_type, str) and device_type != "mps"
59
+ else "cpu"
60
+ )
61
+ with torch.autocast(device_type=device_type, enabled=False):
62
+ freqs = (
63
+ inv_freq_expanded.float() @ position_ids_expanded.float()
64
+ ).transpose(1, 2)
65
+ emb = freqs.repeat_interleave(2, dim=-1, output_size=self.dim)
66
+ cos = emb.cos()
67
+ sin = emb.sin()
68
+
69
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
70
+
71
+
72
+ class PhariaLinearScalingRotaryEmbedding(PhariaRotaryEmbedding):
73
+ """PhariaRotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
74
+
75
+ def forward(self, x, position_ids):
76
+ # difference to the original RoPE: a scaling factor is aplied to the position ids
77
+ position_ids = position_ids.float() / self.scaling_factor
78
+ cos, sin = super().forward(x, position_ids)
79
+ return cos, sin
80
+
81
+
82
+ class PhariaDynamicNTKScalingRotaryEmbedding(PhariaRotaryEmbedding):
83
+ """PhariaRotaryEmbedding extended with Dynamic NTK scaling. Credits to the Reddit users /u/bloc97 and /u/emozilla"""
84
+
85
+ def forward(self, x, position_ids):
86
+ # difference to the original RoPE: inv_freq is recomputed when the sequence length > original length
87
+ seq_len = torch.max(position_ids) + 1
88
+ if seq_len > self.max_position_embeddings:
89
+ base = self.base * (
90
+ (self.scaling_factor * seq_len / self.max_position_embeddings)
91
+ - (self.scaling_factor - 1)
92
+ ) ** (self.dim / (self.dim - 2))
93
+ inv_freq = 1.0 / (
94
+ base
95
+ ** (
96
+ torch.arange(0, self.dim, 2, dtype=torch.int64).float().to(x.device)
97
+ / self.dim
98
+ )
99
+ )
100
+ self.register_buffer(
101
+ "inv_freq", inv_freq, persistent=False
102
+ ) # TODO joao: this may break with compilation
103
+
104
+ cos, sin = super().forward(x, position_ids)
105
+ return cos, sin
106
+
107
+
108
+ def rotate_half(x):
109
+ """Rotates half the hidden dims of the input (interleaved)."""
110
+ y = torch.empty_like(x)
111
+ y[..., ::2] = -x[..., 1::2]
112
+ y[..., 1::2] = x[..., ::2]
113
+ return y
114
+
115
+
116
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):
117
+ """Applies Rotary Position Embedding to the query and key tensors.
118
+
119
+ Args:
120
+ q (`torch.Tensor`): The query tensor.
121
+ k (`torch.Tensor`): The key tensor.
122
+ cos (`torch.Tensor`): The cosine part of the rotary embedding.
123
+ sin (`torch.Tensor`): The sine part of the rotary embedding.
124
+ position_ids (`torch.Tensor`, *optional*):
125
+ Deprecated and unused.
126
+ unsqueeze_dim (`int`, *optional*, defaults to 1):
127
+ The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
128
+ sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
129
+ that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
130
+ k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
131
+ cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
132
+ the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
133
+ Returns:
134
+ `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
135
+ """
136
+ cos = cos.unsqueeze(unsqueeze_dim)
137
+ sin = sin.unsqueeze(unsqueeze_dim)
138
+ q_embed = (q * cos) + (rotate_half(q) * sin)
139
+ k_embed = (k * cos) + (rotate_half(k) * sin)
140
+
141
+ return q_embed, k_embed
142
+
143
+
144
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
145
+ """
146
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
147
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
148
+ """
149
+ batch, num_key_value_heads, slen, head_dim = hidden_states.shape
150
+ if n_rep == 1:
151
+ return hidden_states
152
+ hidden_states = hidden_states[:, :, None, :, :].expand(
153
+ batch, num_key_value_heads, n_rep, slen, head_dim
154
+ )
155
+ return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
156
+
157
+
158
+ class LlamaAttention(nn.Module):
159
+ """Multi-headed attention from 'Attention Is All You Need' paper"""
160
+
161
+ def __init__(self, config: PhariaConfig, layer_idx: Optional[int] = None):
162
+ super().__init__()
163
+ self.config = config
164
+ self.layer_idx = layer_idx
165
+ # if layer_idx is None:
166
+ # logger.warning_once(
167
+ # f"Instantiating {self.__class__.__name__} without passing a `layer_idx` is not recommended and will "
168
+ # "lead to errors during the forward call if caching is used. Please make sure to provide a `layer_idx` "
169
+ # "when creating this class."
170
+ # )
171
+
172
+ self.attention_dropout = config.attention_dropout
173
+ self.hidden_size = config.hidden_size
174
+ self.num_heads = config.num_attention_heads
175
+ self.head_dim = self.hidden_size // self.num_heads
176
+ self.num_key_value_heads = config.num_key_value_heads
177
+ self.num_key_value_groups = self.num_heads // self.num_key_value_heads
178
+ self.max_position_embeddings = config.max_position_embeddings
179
+ self.rope_theta = config.rope_theta
180
+ self.is_causal = True
181
+
182
+ if (self.head_dim * self.num_heads) != self.hidden_size:
183
+ raise ValueError(
184
+ f"hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}"
185
+ f" and `num_heads`: {self.num_heads})."
186
+ )
187
+
188
+ self.q_proj = nn.Linear(
189
+ self.hidden_size, self.num_heads * self.head_dim, bias=config.attention_bias
190
+ )
191
+ self.k_proj = nn.Linear(
192
+ self.hidden_size,
193
+ self.num_key_value_heads * self.head_dim,
194
+ bias=config.attention_bias,
195
+ )
196
+ self.v_proj = nn.Linear(
197
+ self.hidden_size,
198
+ self.num_key_value_heads * self.head_dim,
199
+ bias=config.attention_bias,
200
+ )
201
+ self.o_proj = nn.Linear(
202
+ self.hidden_size, self.hidden_size, bias=config.attention_bias
203
+ )
204
+ self._init_rope()
205
+
206
+ def _init_rope(self):
207
+ if self.config.rope_scaling is None:
208
+ self.rotary_emb = PhariaRotaryEmbedding(
209
+ self.head_dim,
210
+ max_position_embeddings=self.max_position_embeddings,
211
+ base=self.rope_theta,
212
+ )
213
+ else:
214
+ scaling_type = self.config.rope_scaling["type"]
215
+ scaling_factor = self.config.rope_scaling["factor"]
216
+ if scaling_type == "linear":
217
+ self.rotary_emb = PhariaLinearScalingRotaryEmbedding(
218
+ self.head_dim,
219
+ max_position_embeddings=self.max_position_embeddings,
220
+ scaling_factor=scaling_factor,
221
+ base=self.rope_theta,
222
+ )
223
+ elif scaling_type == "dynamic":
224
+ self.rotary_emb = PhariaDynamicNTKScalingRotaryEmbedding(
225
+ self.head_dim,
226
+ max_position_embeddings=self.max_position_embeddings,
227
+ scaling_factor=scaling_factor,
228
+ base=self.rope_theta,
229
+ )
230
+ else:
231
+ raise ValueError(f"Unknown RoPE scaling type {scaling_type}")
232
+
233
+ def forward(
234
+ self,
235
+ hidden_states: torch.Tensor,
236
+ attention_mask: Optional[torch.Tensor] = None,
237
+ position_ids: Optional[torch.LongTensor] = None,
238
+ past_key_value: Optional[Cache] = None,
239
+ output_attentions: bool = False,
240
+ use_cache: bool = False,
241
+ cache_position: Optional[torch.LongTensor] = None,
242
+ ) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
243
+ bsz, q_len, _ = hidden_states.size()
244
+
245
+ query_states = self.q_proj(hidden_states)
246
+ key_states = self.k_proj(hidden_states)
247
+ value_states = self.v_proj(hidden_states)
248
+
249
+ query_states = query_states.view(
250
+ bsz, q_len, self.num_heads, self.head_dim
251
+ ).transpose(1, 2)
252
+ key_states = key_states.view(
253
+ bsz, q_len, self.num_key_value_heads, self.head_dim
254
+ ).transpose(1, 2)
255
+ value_states = value_states.view(
256
+ bsz, q_len, self.num_key_value_heads, self.head_dim
257
+ ).transpose(1, 2)
258
+
259
+ cos, sin = self.rotary_emb(value_states, position_ids)
260
+ query_states, key_states = apply_rotary_pos_emb(
261
+ query_states, key_states, cos, sin
262
+ )
263
+
264
+ if past_key_value is not None:
265
+ # cache_position needed for the static cache
266
+ cache_kwargs = {"cache_position": cache_position}
267
+ key_states, value_states = past_key_value.update(
268
+ key_states, value_states, self.layer_idx, cache_kwargs
269
+ )
270
+
271
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
272
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
273
+
274
+ attn_weights = torch.matmul(
275
+ query_states, key_states.transpose(2, 3)
276
+ ) / math.sqrt(self.head_dim)
277
+
278
+ if attention_mask is not None: # no matter the length, we just slice it
279
+ causal_mask = attention_mask[:, :, :, : key_states.shape[-2]]
280
+ attn_weights = attn_weights + causal_mask
281
+
282
+ # upcast attention to fp32
283
+ attn_weights = nn.functional.softmax(
284
+ attn_weights, dim=-1, dtype=torch.float32
285
+ ).to(query_states.dtype)
286
+ attn_weights = nn.functional.dropout(
287
+ attn_weights, p=self.attention_dropout, training=self.training
288
+ )
289
+ attn_output = torch.matmul(attn_weights, value_states)
290
+
291
+ if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
292
+ raise ValueError(
293
+ f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
294
+ f" {attn_output.size()}"
295
+ )
296
+
297
+ attn_output: Optional[torch.Tensor] = attn_output.transpose(1, 2).contiguous()
298
+
299
+ attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
300
+
301
+ attn_output = self.o_proj(attn_output)
302
+
303
+ if not output_attentions:
304
+ attn_weights = None
305
+
306
+ return attn_output, attn_weights, past_key_value
307
+
308
+
309
+ class PhariaMLP(nn.Module):
310
+ def __init__(self, config, layer_idx: int):
311
+ super().__init__()
312
+ self.layer_idx = layer_idx
313
+ self.config = config
314
+ self.hidden_size = config.hidden_size
315
+ self.intermediate_size = config.intermediate_size
316
+ self.up_proj = nn.Linear(
317
+ self.hidden_size, self.intermediate_size, bias=config.mlp_bias
318
+ )
319
+ self.down_proj = nn.Linear(
320
+ self.intermediate_size, self.hidden_size, bias=config.mlp_bias
321
+ )
322
+ self.act_fn = ACT2FN[config.hidden_act]
323
+
324
+ def forward(self, x):
325
+ o = self.down_proj(self.act_fn(self.up_proj(x)))
326
+ return o
327
+
328
+
329
+ class PhariaDecoderLayer(nn.Module):
330
+ def __init__(self, config: PhariaConfig, layer_idx: int):
331
+ super().__init__()
332
+ self.hidden_size = config.hidden_size
333
+ self.self_attn = LlamaAttention(config=config, layer_idx=layer_idx)
334
+ self.mlp = PhariaMLP(config, layer_idx=layer_idx)
335
+ self.input_layernorm = nn.LayerNorm(config.hidden_size)
336
+ self.post_attention_layernorm = nn.LayerNorm(config.hidden_size)
337
+ self.layer_idx = layer_idx
338
+
339
+ def forward(
340
+ self,
341
+ hidden_states: torch.Tensor,
342
+ attention_mask: Optional[torch.Tensor] = None,
343
+ position_ids: Optional[torch.LongTensor] = None,
344
+ past_key_value: Optional[Cache] = None,
345
+ output_attentions: Optional[bool] = False,
346
+ use_cache: Optional[bool] = False,
347
+ cache_position: Optional[torch.LongTensor] = None,
348
+ ) -> Tuple[
349
+ torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]
350
+ ]:
351
+ residual = hidden_states
352
+
353
+ hidden_states = self.input_layernorm(hidden_states)
354
+
355
+ hidden_states, self_attn_weights, present_key_value = self.self_attn(
356
+ hidden_states=hidden_states,
357
+ attention_mask=attention_mask,
358
+ position_ids=position_ids,
359
+ past_key_value=past_key_value,
360
+ output_attentions=output_attentions,
361
+ use_cache=use_cache,
362
+ cache_position=cache_position,
363
+ )
364
+ hidden_states = residual + hidden_states
365
+
366
+ residual = hidden_states
367
+ hidden_states = self.post_attention_layernorm(hidden_states)
368
+
369
+ if self.layer_idx == -1:
370
+ print("Layer 0 huggingface")
371
+ print(hidden_states)
372
+ print(hidden_states.shape)
373
+
374
+ hidden_states = self.mlp(hidden_states)
375
+ hidden_states = residual + hidden_states
376
+
377
+ outputs = (hidden_states,)
378
+
379
+ if output_attentions:
380
+ outputs += (self_attn_weights,)
381
+
382
+ if use_cache:
383
+ outputs += (present_key_value,)
384
+
385
+ return outputs
386
+
387
+
388
+ class PhariaPreTrainedModel(PreTrainedModel):
389
+ config_class = PhariaConfig
390
+ base_model_prefix = "model"
391
+ supports_gradient_checkpointing = True
392
+ _no_split_modules = ["PhariaDecoderLayer"]
393
+ _skip_keys_device_placement = ["past_key_values"]
394
+ _supports_flash_attn_2 = False
395
+ _supports_sdpa = False
396
+ _supports_cache_class = True
397
+ _supports_static_cache = True
398
+
399
+ def _init_weights(self, module):
400
+ std = self.config.initializer_range
401
+ if isinstance(module, nn.Linear):
402
+ module.weight.data.normal_(mean=0.0, std=std)
403
+ if module.bias is not None:
404
+ module.bias.data.zero_()
405
+ elif isinstance(module, nn.Embedding):
406
+ module.weight.data.normal_(mean=0.0, std=std)
407
+ if module.padding_idx is not None:
408
+ module.weight.data[module.padding_idx].zero_()
409
+
410
+
411
+ class PhariaModel(PhariaPreTrainedModel):
412
+ config_class = PhariaConfig
413
+
414
+ def __init__(self, config: PhariaConfig):
415
+ super().__init__(config)
416
+ self.padding_idx = config.pad_token_id
417
+ self.vocab_size = config.vocab_size
418
+
419
+ self.embed_tokens = nn.Embedding(
420
+ config.vocab_size, config.hidden_size, self.padding_idx
421
+ )
422
+
423
+ self.layers = nn.ModuleList(
424
+ [
425
+ PhariaDecoderLayer(config, layer_idx)
426
+ for layer_idx in range(config.num_hidden_layers)
427
+ ]
428
+ )
429
+ self.norm = nn.LayerNorm(config.hidden_size)
430
+
431
+ def forward(
432
+ self,
433
+ input_ids: torch.LongTensor = None,
434
+ attention_mask: Optional[torch.Tensor] = None,
435
+ position_ids: Optional[torch.LongTensor] = None,
436
+ past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
437
+ inputs_embeds: Optional[torch.FloatTensor] = None,
438
+ use_cache: Optional[bool] = None,
439
+ output_attentions: Optional[bool] = None,
440
+ output_hidden_states: Optional[bool] = None,
441
+ return_dict: Optional[bool] = None,
442
+ cache_position: Optional[torch.LongTensor] = None,
443
+ ) -> Union[Tuple, BaseModelOutputWithPast]:
444
+ output_attentions = (
445
+ output_attentions
446
+ if output_attentions is not None
447
+ else self.config.output_attentions
448
+ )
449
+ output_hidden_states = (
450
+ output_hidden_states
451
+ if output_hidden_states is not None
452
+ else self.config.output_hidden_states
453
+ )
454
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
455
+ return_dict = (
456
+ return_dict if return_dict is not None else self.config.use_return_dict
457
+ )
458
+
459
+ if (input_ids is None) ^ (inputs_embeds is not None):
460
+ raise ValueError(
461
+ "You cannot specify both input_ids and inputs_embeds at the same time, and must specify either one"
462
+ )
463
+
464
+ # if self.gradient_checkpointing and self.training and use_cache:
465
+ # # logger.warning_once(
466
+ # # "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`."
467
+ # # )
468
+ # use_cache = False
469
+
470
+ if inputs_embeds is None:
471
+ inputs_embeds = self.embed_tokens(input_ids)
472
+
473
+ return_legacy_cache = False
474
+ if use_cache and not isinstance(
475
+ past_key_values, Cache
476
+ ): # kept for BC (non `Cache` `past_key_values` inputs)
477
+ return_legacy_cache = True
478
+ past_key_values = DynamicCache.from_legacy_cache(past_key_values)
479
+
480
+ if cache_position is None:
481
+ past_seen_tokens = (
482
+ past_key_values.get_seq_length() if past_key_values is not None else 0
483
+ )
484
+ cache_position = torch.arange(
485
+ past_seen_tokens,
486
+ past_seen_tokens + inputs_embeds.shape[1],
487
+ device=inputs_embeds.device,
488
+ )
489
+ if position_ids is None:
490
+ position_ids = cache_position.unsqueeze(0)
491
+
492
+ causal_mask = self._update_causal_mask(
493
+ attention_mask,
494
+ inputs_embeds,
495
+ cache_position,
496
+ past_key_values,
497
+ output_attentions,
498
+ )
499
+
500
+ # embed positions
501
+ hidden_states = inputs_embeds
502
+
503
+ # decoder layers
504
+ all_hidden_states = () if output_hidden_states else None
505
+ all_self_attns = () if output_attentions else None
506
+ next_decoder_cache = None
507
+
508
+ for decoder_layer in self.layers:
509
+ if output_hidden_states:
510
+ all_hidden_states += (hidden_states,)
511
+
512
+ # if self.gradient_checkpointing and self.training:
513
+ # layer_outputs = self._gradient_checkpointing_func(
514
+ # decoder_layer.__call__,
515
+ # hidden_states,
516
+ # causal_mask,
517
+ # position_ids,
518
+ # past_key_values,
519
+ # output_attentions,
520
+ # use_cache,
521
+ # cache_position,
522
+ # )
523
+ # else:
524
+ layer_outputs = decoder_layer(
525
+ hidden_states,
526
+ attention_mask=causal_mask,
527
+ position_ids=position_ids,
528
+ past_key_value=past_key_values,
529
+ output_attentions=output_attentions,
530
+ use_cache=use_cache,
531
+ cache_position=cache_position,
532
+ )
533
+
534
+ hidden_states = layer_outputs[0]
535
+
536
+ if use_cache:
537
+ next_decoder_cache = layer_outputs[2 if output_attentions else 1]
538
+
539
+ if output_attentions:
540
+ all_self_attns += (layer_outputs[1],)
541
+
542
+ hidden_states = self.norm(hidden_states)
543
+
544
+ # add hidden states from the last decoder layer
545
+ if output_hidden_states:
546
+ all_hidden_states += (hidden_states,)
547
+
548
+ next_cache = next_decoder_cache if use_cache else None
549
+ if return_legacy_cache:
550
+ next_cache = next_cache.to_legacy_cache()
551
+
552
+ if not return_dict:
553
+ return tuple(
554
+ v
555
+ for v in [hidden_states, next_cache, all_hidden_states, all_self_attns]
556
+ if v is not None
557
+ )
558
+ return BaseModelOutputWithPast(
559
+ last_hidden_state=hidden_states,
560
+ past_key_values=next_cache,
561
+ hidden_states=all_hidden_states,
562
+ attentions=all_self_attns,
563
+ )
564
+
565
+ def _update_causal_mask(
566
+ self,
567
+ attention_mask: torch.Tensor,
568
+ input_tensor: torch.Tensor,
569
+ cache_position: torch.Tensor,
570
+ past_key_values: Cache,
571
+ output_attentions: bool,
572
+ ):
573
+ # TODO: As of torch==2.2.0, the `attention_mask` passed to the model in `generate` is 2D and of dynamic length even when the static
574
+ # KV cache is used. This is an issue for torch.compile which then recaptures cudagraphs at each decode steps due to the dynamic shapes.
575
+ # (`recording cudagraph tree for symint key 13`, etc.), which is VERY slow. A workaround is `@torch.compiler.disable`, but this prevents using
576
+ # `fullgraph=True`. See more context in https://github.com/huggingface/transformers/pull/29114
577
+
578
+ if self.config._attn_implementation == "flash_attention_2":
579
+ if attention_mask is not None and 0.0 in attention_mask:
580
+ return attention_mask
581
+ return None
582
+
583
+ # For SDPA, when possible, we will rely on its `is_causal` argument instead of its `attn_mask` argument, in
584
+ # order to dispatch on Flash Attention 2. This feature is not compatible with static cache, as SDPA will fail
585
+ # to infer the attention mask.
586
+ past_seen_tokens = (
587
+ past_key_values.get_seq_length() if past_key_values is not None else 0
588
+ )
589
+ using_static_cache = isinstance(past_key_values, StaticCache)
590
+
591
+ # When output attentions is True, sdpa implementation's forward method calls the eager implementation's forward
592
+ if (
593
+ self.config._attn_implementation == "sdpa"
594
+ and not using_static_cache
595
+ and not output_attentions
596
+ ):
597
+ if AttentionMaskConverter._ignore_causal_mask_sdpa(
598
+ attention_mask,
599
+ inputs_embeds=input_tensor,
600
+ past_key_values_length=past_seen_tokens,
601
+ is_training=self.training,
602
+ ):
603
+ return None
604
+
605
+ dtype, device = input_tensor.dtype, input_tensor.device
606
+ min_dtype = torch.finfo(dtype).min
607
+ sequence_length = input_tensor.shape[1]
608
+ if using_static_cache:
609
+ target_length = past_key_values.get_max_length()
610
+ else:
611
+ target_length = (
612
+ attention_mask.shape[-1]
613
+ if isinstance(attention_mask, torch.Tensor)
614
+ else past_seen_tokens + sequence_length + 1
615
+ )
616
+
617
+ if attention_mask is not None and attention_mask.dim() == 4:
618
+ # in this case we assume that the mask comes already in inverted form and requires no inversion or slicing
619
+ if attention_mask.max() != 0:
620
+ raise ValueError(
621
+ "Custom 4D attention mask should be passed in inverted form with max==0`"
622
+ )
623
+ causal_mask = attention_mask
624
+ else:
625
+ causal_mask = torch.full(
626
+ (sequence_length, target_length),
627
+ fill_value=min_dtype,
628
+ dtype=dtype,
629
+ device=device,
630
+ )
631
+ if sequence_length != 1:
632
+ causal_mask = torch.triu(causal_mask, diagonal=1)
633
+ causal_mask *= torch.arange(
634
+ target_length, device=device
635
+ ) > cache_position.reshape(-1, 1)
636
+ causal_mask = causal_mask[None, None, :, :].expand(
637
+ input_tensor.shape[0], 1, -1, -1
638
+ )
639
+ if attention_mask is not None:
640
+ causal_mask = (
641
+ causal_mask.clone()
642
+ ) # copy to contiguous memory for in-place edit
643
+ mask_length = attention_mask.shape[-1]
644
+ padding_mask = (
645
+ causal_mask[:, :, :, :mask_length]
646
+ + attention_mask[:, None, None, :]
647
+ )
648
+ padding_mask = padding_mask == 0
649
+ causal_mask[:, :, :, :mask_length] = causal_mask[
650
+ :, :, :, :mask_length
651
+ ].masked_fill(padding_mask, min_dtype)
652
+ if (
653
+ self.config._attn_implementation == "sdpa"
654
+ and attention_mask is not None
655
+ and attention_mask.device.type == "cuda"
656
+ and not output_attentions
657
+ ):
658
+ # Attend to all tokens in fully masked rows in the causal_mask, for example the relevant first rows when
659
+ # using left padding. This is required by F.scaled_dot_product_attention memory-efficient attention path.
660
+ # Details: https://github.com/pytorch/pytorch/issues/110213
661
+ causal_mask = AttentionMaskConverter._unmask_unattended(
662
+ causal_mask, min_dtype
663
+ )
664
+
665
+ return causal_mask
666
+
667
+
668
+ class PhariaForCausalLM(PhariaPreTrainedModel):
669
+ _tied_weights_keys = ["lm_head.weight"]
670
+
671
+ def __init__(self, config):
672
+ super().__init__(config)
673
+ self.model = PhariaModel(config)
674
+ self.vocab_size = config.vocab_size
675
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
676
+
677
+ # Initialize weights and apply final processing
678
+ self.post_init()
679
+
680
+ def get_input_embeddings(self):
681
+ return self.model.embed_tokens
682
+
683
+ def set_input_embeddings(self, value):
684
+ self.model.embed_tokens = value
685
+
686
+ def get_output_embeddings(self):
687
+ return self.lm_head
688
+
689
+ def set_output_embeddings(self, new_embeddings):
690
+ self.lm_head = new_embeddings
691
+
692
+ def set_decoder(self, decoder):
693
+ self.model = decoder
694
+
695
+ def get_decoder(self):
696
+ return self.model
697
+
698
+ def forward(
699
+ self,
700
+ input_ids: torch.LongTensor = None,
701
+ attention_mask: Optional[torch.Tensor] = None,
702
+ position_ids: Optional[torch.LongTensor] = None,
703
+ past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,
704
+ inputs_embeds: Optional[torch.FloatTensor] = None,
705
+ labels: Optional[torch.LongTensor] = None,
706
+ use_cache: Optional[bool] = None,
707
+ output_attentions: Optional[bool] = None,
708
+ output_hidden_states: Optional[bool] = None,
709
+ return_dict: Optional[bool] = None,
710
+ cache_position: Optional[torch.LongTensor] = None,
711
+ ) -> Union[Tuple, CausalLMOutputWithPast]:
712
+ r"""
713
+ Args:
714
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
715
+ Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
716
+ config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
717
+ (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
718
+
719
+ Returns:
720
+
721
+ Example:
722
+
723
+ ```python
724
+ >>> from transformers import AutoTokenizer, LlamaForCausalLM
725
+
726
+ >>> model = LlamaForCausalLM.from_pretrained("meta-llama/Llama-2-7b-hf")
727
+ >>> tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf")
728
+
729
+ >>> prompt = "Hey, are you conscious? Can you talk to me?"
730
+ >>> inputs = tokenizer(prompt, return_tensors="pt")
731
+
732
+ >>> # Generate
733
+ >>> generate_ids = model.generate(inputs.input_ids, max_length=30)
734
+ >>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
735
+ "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
736
+ ```"""
737
+ output_attentions = (
738
+ output_attentions
739
+ if output_attentions is not None
740
+ else self.config.output_attentions
741
+ )
742
+ output_hidden_states = (
743
+ output_hidden_states
744
+ if output_hidden_states is not None
745
+ else self.config.output_hidden_states
746
+ )
747
+ return_dict = (
748
+ return_dict if return_dict is not None else self.config.use_return_dict
749
+ )
750
+
751
+ # decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
752
+ outputs = self.model(
753
+ input_ids=input_ids,
754
+ attention_mask=attention_mask,
755
+ position_ids=position_ids,
756
+ past_key_values=past_key_values,
757
+ inputs_embeds=inputs_embeds,
758
+ use_cache=use_cache,
759
+ output_attentions=output_attentions,
760
+ output_hidden_states=output_hidden_states,
761
+ return_dict=return_dict,
762
+ cache_position=cache_position,
763
+ )
764
+
765
+ hidden_states = outputs[0]
766
+ logits = self.lm_head(hidden_states)
767
+ logits = logits.float()
768
+
769
+ return CausalLMOutputWithPast(
770
+ loss=0.0,
771
+ logits=logits,
772
+ past_key_values=outputs.past_key_values,
773
+ hidden_states=outputs.hidden_states,
774
+ attentions=outputs.attentions,
775
+ )
776
+
777
+ def prepare_inputs_for_generation(
778
+ self,
779
+ input_ids,
780
+ past_key_values=None,
781
+ attention_mask=None,
782
+ inputs_embeds=None,
783
+ cache_position=None,
784
+ use_cache=True,
785
+ **kwargs,
786
+ ):
787
+ past_length = 0
788
+ if past_key_values is not None:
789
+ if isinstance(past_key_values, Cache):
790
+ past_length = (
791
+ cache_position[0]
792
+ if cache_position is not None
793
+ else past_key_values.get_seq_length()
794
+ )
795
+ max_cache_length = (
796
+ torch.tensor(
797
+ past_key_values.get_max_length(), device=input_ids.device
798
+ )
799
+ if past_key_values.get_max_length() is not None
800
+ else None
801
+ )
802
+ cache_length = (
803
+ past_length
804
+ if max_cache_length is None
805
+ else torch.min(max_cache_length, past_length)
806
+ )
807
+ # TODO joao: remove this `else` after `generate` prioritizes `Cache` objects
808
+ else:
809
+ cache_length = past_length = past_key_values[0][0].shape[2]
810
+ max_cache_length = None
811
+
812
+ # Keep only the unprocessed tokens:
813
+ # 1 - If the length of the attention_mask exceeds the length of input_ids, then we are in a setting where
814
+ # some of the inputs are exclusively passed as part of the cache (e.g. when passing input_embeds as input)
815
+ if (
816
+ attention_mask is not None
817
+ and attention_mask.shape[1] > input_ids.shape[1]
818
+ ):
819
+ input_ids = input_ids[:, -(attention_mask.shape[1] - past_length) :]
820
+ # 2 - If the past_length is smaller than input_ids', then input_ids holds all input tokens. We can discard
821
+ # input_ids based on the past_length.
822
+ elif past_length < input_ids.shape[1]:
823
+ input_ids = input_ids[:, past_length:]
824
+ # 3 - Otherwise (past_length >= input_ids.shape[1]), let's assume input_ids only has unprocessed tokens.
825
+
826
+ # If we are about to go beyond the maximum cache length, we need to crop the input attention mask.
827
+ if (
828
+ max_cache_length is not None
829
+ and attention_mask is not None
830
+ and cache_length + input_ids.shape[1] > max_cache_length
831
+ ):
832
+ attention_mask = attention_mask[:, -max_cache_length:]
833
+
834
+ position_ids = kwargs.get("position_ids", None)
835
+ if attention_mask is not None and position_ids is None:
836
+ # create position_ids on the fly for batch generation
837
+ position_ids = attention_mask.long().cumsum(-1) - 1
838
+ position_ids.masked_fill_(attention_mask == 0, 1)
839
+ if past_key_values:
840
+ position_ids = position_ids[:, -input_ids.shape[1] :]
841
+
842
+ # if `inputs_embeds` are passed, we only want to use them in the 1st generation step
843
+ if inputs_embeds is not None and past_key_values is None:
844
+ model_inputs = {"inputs_embeds": inputs_embeds}
845
+ else:
846
+ # The `contiguous()` here is necessary to have a static stride during decoding. torchdynamo otherwise
847
+ # recompiles graphs as the stride of the inputs is a guard. Ref: https://github.com/huggingface/transformers/pull/29114
848
+ # TODO: use `next_tokens` directly instead.
849
+ model_inputs = {"input_ids": input_ids.contiguous()}
850
+
851
+ input_length = (
852
+ position_ids.shape[-1] if position_ids is not None else input_ids.shape[-1]
853
+ )
854
+ if cache_position is None:
855
+ cache_position = torch.arange(
856
+ past_length, past_length + input_length, device=input_ids.device
857
+ )
858
+ elif use_cache:
859
+ cache_position = cache_position[-input_length:]
860
+
861
+ model_inputs.update(
862
+ {
863
+ "position_ids": position_ids,
864
+ "cache_position": cache_position,
865
+ "past_key_values": past_key_values,
866
+ "use_cache": use_cache,
867
+ "attention_mask": attention_mask,
868
+ }
869
+ )
870
+ return model_inputs
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {}
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff