Text Generation
Transformers
PyTorch
RefinedWeb
falcon-40b
rlhf
falcon
custom_code
text-generation-inference
Inference Endpoints
ohallstrom commited on
Commit
6ee1b99
1 Parent(s): bfb4999

Upload RWForCausalLM

Browse files
config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alibi": false,
3
+ "apply_residual_connection_post_layernorm": false,
4
+ "architectures": [
5
+ "RWForCausalLM"
6
+ ],
7
+ "attention_dropout": 0.0,
8
+ "auto_map": {
9
+ "AutoConfig": "configuration_RW.RWConfig",
10
+ "AutoModelForCausalLM": "modeling_RW.RWForCausalLM"
11
+ },
12
+ "bias": false,
13
+ "bos_token_id": 11,
14
+ "eos_token_id": 11,
15
+ "hidden_dropout": 0.0,
16
+ "hidden_size": 8192,
17
+ "initializer_range": 0.02,
18
+ "layer_norm_epsilon": 1e-05,
19
+ "model_type": "RefinedWeb",
20
+ "multi_query": true,
21
+ "n_head": 128,
22
+ "n_head_kv": 8,
23
+ "n_layer": 60,
24
+ "parallel_attn": true,
25
+ "single_ln": false,
26
+ "torch_dtype": "bfloat16",
27
+ "transformers_version": "4.31.0",
28
+ "use_cache": true,
29
+ "vocab_size": 65024
30
+ }
configuration_RW.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 the Big Science Workshop and 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
+ """ Bloom configuration"""
16
+ from transformers.configuration_utils import PretrainedConfig
17
+ from transformers.utils import logging
18
+
19
+
20
+ logger = logging.get_logger(__name__)
21
+
22
+
23
+ class RWConfig(PretrainedConfig):
24
+ model_type = "RefinedWeb"
25
+ keys_to_ignore_at_inference = ["past_key_values"]
26
+ attribute_map = {
27
+ "num_hidden_layers": "n_layer",
28
+ "num_attention_heads": "n_head",
29
+ }
30
+
31
+ def __init__(
32
+ self,
33
+ vocab_size=250880,
34
+ hidden_size=64,
35
+ n_layer=2,
36
+ n_head=8,
37
+ layer_norm_epsilon=1e-5,
38
+ initializer_range=0.02,
39
+ use_cache=True,
40
+ bos_token_id=1,
41
+ eos_token_id=2,
42
+ apply_residual_connection_post_layernorm=False,
43
+ hidden_dropout=0.0,
44
+ attention_dropout=0.0,
45
+ multi_query=False,
46
+ alibi=False,
47
+ bias=False,
48
+ parallel_attn=False,
49
+ single_ln=False,
50
+ n_head_kv=1,
51
+ **kwargs,
52
+ ):
53
+ self.vocab_size = vocab_size
54
+ # Backward compatibility with n_embed kwarg
55
+ n_embed = kwargs.pop("n_embed", None)
56
+ self.hidden_size = hidden_size if n_embed is None else n_embed
57
+ self.n_layer = n_layer
58
+ self.n_head = n_head
59
+ self.layer_norm_epsilon = layer_norm_epsilon
60
+ self.initializer_range = initializer_range
61
+ self.use_cache = use_cache
62
+ self.apply_residual_connection_post_layernorm = apply_residual_connection_post_layernorm
63
+ self.hidden_dropout = hidden_dropout
64
+ self.attention_dropout = attention_dropout
65
+
66
+ self.bos_token_id = bos_token_id
67
+ self.eos_token_id = eos_token_id
68
+ self.multi_query = multi_query
69
+ self.alibi = alibi
70
+ self.bias = bias
71
+ self.parallel_attn = parallel_attn
72
+ self.single_ln = single_ln
73
+ self.n_head_kv = n_head_kv
74
+
75
+ assert not alibi, "Function of alibi has not been verified yet"
76
+
77
+ super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)
78
+
79
+ @property
80
+ def head_dim(self):
81
+ return self.hidden_size // self.n_head
82
+
83
+ @property
84
+ def rotary(self):
85
+ return not self.alibi
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 11,
4
+ "eos_token_id": 11,
5
+ "transformers_version": "4.31.0"
6
+ }
modeling_RW.py ADDED
@@ -0,0 +1,1121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # port of models described in RW
2
+ # We use the bloom model as a starting point for these model.
3
+ # Please refer to the bloom models for usage instructions.
4
+
5
+ import math
6
+ import warnings
7
+ from typing import Optional, Tuple, Union
8
+
9
+ import torch
10
+ import torch.utils.checkpoint
11
+ from torch import nn
12
+ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, LayerNorm, MSELoss
13
+ from torch.nn import functional as F
14
+
15
+ from transformers.modeling_outputs import (
16
+ BaseModelOutputWithPastAndCrossAttentions,
17
+ CausalLMOutputWithCrossAttentions,
18
+ QuestionAnsweringModelOutput,
19
+ SequenceClassifierOutputWithPast,
20
+ TokenClassifierOutput,
21
+ )
22
+ from transformers.modeling_utils import PreTrainedModel
23
+ from transformers.utils import logging
24
+ from configuration_RW import RWConfig
25
+
26
+ logger = logging.get_logger(__name__)
27
+
28
+ # NOTE: Unfortunately we did not fuse matmul and bias during training, this means that there's one additional quantization to bfloat16 between the operations.
29
+ # In order not to degrade the quality of our HF-port, we keep these characteristics in the final model.
30
+ class Linear(nn.Linear):
31
+ def forward(self, input: torch.Tensor) -> torch.Tensor:
32
+ ret = input @ self.weight.T
33
+ if self.bias is None:
34
+ return ret
35
+ else:
36
+ return ret + self.bias
37
+
38
+
39
+ from einops import rearrange
40
+
41
+ # rotary pos emb helpers (torch.jit.script does not seem to support staticmethod...)
42
+ def rotate_half(x):
43
+ x1, x2 = x[..., : x.shape[-1] // 2], x[..., x.shape[-1] // 2 :]
44
+ return torch.cat((-x2, x1), dim=x1.ndim - 1) # dim=-1 triggers a bug in torch < 1.8.0
45
+
46
+
47
+ class RotaryEmbedding(torch.nn.Module):
48
+ """Implementation of RotaryEmbedding from GPT-NeoX.
49
+ This implementation is design to operate on queries and keys that are compatible with
50
+ [batch_size, n_heads_per_partition, seq_len, head_dim] (e.g. MinGPTAttention format).
51
+ """
52
+
53
+ def __init__(
54
+ self,
55
+ head_dim: int,
56
+ base=10000,
57
+ ):
58
+ super().__init__()
59
+ inv_freq = 1.0 / (base ** (torch.arange(0, head_dim, 2).float() / head_dim))
60
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
61
+ self.head_dim = head_dim
62
+ self.seq_len_cached = None
63
+ self.batch_size_cached = None
64
+ self.cos_cached: torch.Tensor | None = None
65
+ self.sin_cached: torch.Tensor | None = None
66
+
67
+ def cos_sin(
68
+ self,
69
+ seq_len: int,
70
+ device="cuda",
71
+ dtype=torch.bfloat16,
72
+ ) -> torch.Tensor:
73
+ if seq_len != self.seq_len_cached:
74
+ self.seq_len_cached = seq_len
75
+ t = torch.arange(seq_len, device=device).type_as(self.inv_freq)
76
+ freqs = torch.einsum("i,j->ij", t, self.inv_freq)
77
+ emb = torch.cat((freqs, freqs), dim=-1).to(device)
78
+
79
+ if dtype in [torch.float16, torch.bfloat16]:
80
+ emb = emb.float()
81
+
82
+ self.cos_cached = emb.cos()[None, :, :]
83
+ self.sin_cached = emb.sin()[None, :, :]
84
+
85
+ self.cos_cached = self.cos_cached.type(dtype)
86
+ self.sin_cached = self.sin_cached.type(dtype)
87
+
88
+ return self.cos_cached, self.sin_cached
89
+
90
+ def forward(self, q, k):
91
+ batch, seq_len, head_dim = q.shape
92
+ cos, sin = self.cos_sin(seq_len, q.device, q.dtype)
93
+ return (q * cos) + (rotate_half(q) * sin), (k * cos) + (rotate_half(k) * sin)
94
+
95
+
96
+ def _make_causal_mask(
97
+ input_ids_shape: torch.Size, device: torch.device, past_key_values_length: int
98
+ ) -> torch.BoolTensor:
99
+ batch_size, target_length = input_ids_shape
100
+ mask = torch.empty((target_length, target_length + past_key_values_length), dtype=torch.bool, device=device)
101
+ # ONNX doesn't support `torch.Tensor.triu` properly, thus we use this workaround
102
+ seq_ids = torch.arange(target_length, device=device)
103
+ mask[:, past_key_values_length:] = seq_ids[:, None] < seq_ids[None, :]
104
+
105
+ if past_key_values_length > 0:
106
+ mask[:, :past_key_values_length] = False
107
+
108
+ expanded_mask = mask[None, None, :, :].expand(batch_size, 1, target_length, target_length + past_key_values_length)
109
+ return expanded_mask
110
+
111
+
112
+ def _expand_mask(mask: torch.Tensor, tgt_length: int) -> torch.BoolTensor:
113
+ batch_size, src_length = mask.shape
114
+ tgt_length = tgt_length if tgt_length is not None else src_length
115
+
116
+ expanded_mask = ~(mask[:, None, None, :].to(torch.bool))
117
+ return expanded_mask.expand(batch_size, 1, tgt_length, src_length)
118
+
119
+
120
+ def build_alibi_tensor(attention_mask: torch.Tensor, num_heads: int, dtype: torch.dtype) -> torch.Tensor:
121
+ batch_size, seq_length = attention_mask.shape
122
+ closest_power_of_2 = 2 ** math.floor(math.log2(num_heads))
123
+ base = torch.tensor(
124
+ 2 ** (-(2 ** -(math.log2(closest_power_of_2) - 3))), device=attention_mask.device, dtype=torch.float32
125
+ )
126
+ powers = torch.arange(1, 1 + closest_power_of_2, device=attention_mask.device, dtype=torch.int32)
127
+ slopes = torch.pow(base, powers)
128
+
129
+ if closest_power_of_2 != num_heads:
130
+ extra_base = torch.tensor(
131
+ 2 ** (-(2 ** -(math.log2(2 * closest_power_of_2) - 3))), device=attention_mask.device, dtype=torch.float32
132
+ )
133
+ num_remaining_heads = min(closest_power_of_2, num_heads - closest_power_of_2)
134
+ extra_powers = torch.arange(1, 1 + 2 * num_remaining_heads, 2, device=attention_mask.device, dtype=torch.int32)
135
+ slopes = torch.cat([slopes, torch.pow(extra_base, extra_powers)], dim=0)
136
+
137
+ # Note: alibi will added to the attention bias that will be applied to the query, key product of attention
138
+ # => therefore alibi will have to be of shape (batch_size, num_heads, query_length, key_length)
139
+ # => here we set (batch_size=1, num_heads=num_heads, query_length=1, key_length=max_length)
140
+ # => the query_length dimension will then be broadcasted correctly
141
+ # This is more or less identical to T5's relative position bias:
142
+ # https://github.com/huggingface/transformers/blob/f681437203baa7671de3174b0fa583c349d9d5e1/src/transformers/models/t5/modeling_t5.py#L527
143
+ arange_tensor = ((attention_mask.cumsum(dim=-1) - 1) * attention_mask)[:, None, :]
144
+ alibi = slopes[..., None].bfloat16() * arange_tensor
145
+ return alibi.reshape(batch_size * num_heads, 1, seq_length).to(dtype)
146
+
147
+
148
+ def dropout_add(x: torch.Tensor, residual: torch.Tensor, prob: float, training: bool) -> torch.Tensor:
149
+ out = F.dropout(x, p=prob, training=training)
150
+ out = residual + out
151
+ return out
152
+
153
+
154
+ class Attention(nn.Module):
155
+ def __init__(self, config: RWConfig):
156
+ super().__init__()
157
+
158
+ self.hidden_size = config.hidden_size
159
+ self.num_heads = config.n_head
160
+ self.head_dim = self.hidden_size // self.num_heads
161
+ self.split_size = self.hidden_size
162
+ self.hidden_dropout = config.hidden_dropout
163
+
164
+ if self.head_dim * self.num_heads != self.hidden_size:
165
+ raise ValueError(
166
+ f"`hidden_size` must be divisible by num_heads (got `hidden_size`: {self.hidden_size} and `num_heads`:"
167
+ f" {self.num_heads})."
168
+ )
169
+
170
+ self.maybe_rotary = RotaryEmbedding(config.head_dim) if config.rotary else lambda q, k: (q, k)
171
+
172
+ # Layer-wise attention scaling
173
+ self.inv_norm_factor = 1.0 / math.sqrt(self.head_dim)
174
+ self.beta = self.inv_norm_factor
175
+ self.num_kv = config.n_head if not config.multi_query else config.n_head_kv
176
+ self.query_key_value = Linear(
177
+ self.hidden_size,
178
+ (self.num_kv * 2 + config.n_head) * self.head_dim,
179
+ bias=config.bias,
180
+ )
181
+ self.multi_query = config.multi_query
182
+ self.dense = Linear(self.hidden_size, self.hidden_size, bias=config.bias)
183
+ self.attention_dropout = nn.Dropout(config.attention_dropout)
184
+
185
+
186
+ def _split_heads(self, fused_qkv: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
187
+ """
188
+ Split the last dimension into (num_heads, head_dim) without making any copies, results share same memory
189
+ storage as `fused_qkv`
190
+
191
+ Args:
192
+ fused_qkv (`torch.tensor`, *required*): [batch_size, seq_length, (num_heads + 2 * num_kv) * head_dim]
193
+
194
+ Returns:
195
+ query: [batch_size, seq_length, num_heads, head_dim]
196
+ key: [batch_size, seq_length, num_heads, head_dim]
197
+ value: [batch_size, seq_length, num_heads, head_dim]
198
+ """
199
+ if not self.multi_query:
200
+ batch_size, seq_length, _ = fused_qkv.shape
201
+ fused_qkv = fused_qkv.view(batch_size, seq_length, self.num_heads, 3, self.head_dim)
202
+ return fused_qkv[..., 0, :], fused_qkv[..., 1, :], fused_qkv[..., 2, :]
203
+ else:
204
+ batch, seq_len, _ = fused_qkv.shape
205
+ qkv = fused_qkv.view(batch, seq_len, -1, self.num_heads // self.num_kv + 2, 64)
206
+ q = qkv[:, :, :, :-2]
207
+ k = qkv[:, :, :, [-2]]
208
+ v = qkv[:, :, :, [-1]]
209
+ k = torch.broadcast_to(k, q.shape)
210
+ v = torch.broadcast_to(v, q.shape)
211
+
212
+
213
+ q, k, v = [
214
+ rearrange(
215
+ x,
216
+ "batch seq_len group num_heads head_dim ->\
217
+ batch seq_len (group num_heads) head_dim",
218
+ head_dim=self.head_dim,
219
+ )
220
+ for x in [q, k, v]
221
+ ]
222
+ return q, k, v
223
+
224
+ def _merge_heads(self, x: torch.Tensor) -> torch.Tensor:
225
+ """
226
+ Merge heads together over the last dimenstion
227
+
228
+ Args:
229
+ x: (`torch.tensor`, *required*): [batch_size * num_heads, seq_length, head_dim]
230
+
231
+ Returns:
232
+ torch.tensor: [batch_size, seq_length, num_heads * head_dim]
233
+ """
234
+ # What we want to achieve is:
235
+ # batch_size * num_heads, seq_length, head_dim -> batch_size, seq_length, num_heads * head_dim
236
+ batch_size_and_num_heads, seq_length, _ = x.shape
237
+ batch_size = batch_size_and_num_heads // self.num_heads
238
+
239
+ # First view to decompose the batch size
240
+ # batch_size * num_heads, seq_length, head_dim -> batch_size, num_heads, seq_length, head_dim
241
+ x = x.view(batch_size, self.num_heads, seq_length, self.head_dim)
242
+
243
+ # batch_size, num_heads, seq_length, head_dim -> batch_size, seq_length, num_heads, head_dim
244
+ x = x.permute(0, 2, 1, 3)
245
+
246
+ # batch_size, seq_length, num_heads, head_dim -> batch_size, seq_length, num_heads * head_dim
247
+ return x.reshape(batch_size, seq_length, self.num_heads * self.head_dim)
248
+
249
+ def forward(
250
+ self,
251
+ hidden_states: torch.Tensor,
252
+ alibi: torch.Tensor,
253
+ attention_mask: torch.Tensor,
254
+ layer_past: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
255
+ head_mask: Optional[torch.Tensor] = None,
256
+ use_cache: bool = False,
257
+ output_attentions: bool = False,
258
+ ):
259
+ fused_qkv = self.query_key_value(hidden_states) # [batch_size, seq_length, 3 x hidden_size]
260
+
261
+ # 3 x [batch_size, seq_length, num_heads, head_dim]
262
+ (query_layer, key_layer, value_layer) = self._split_heads(fused_qkv)
263
+
264
+ batch_size, q_length, _, _ = query_layer.shape
265
+
266
+ query_layer = query_layer.transpose(1, 2).reshape(batch_size * self.num_heads, q_length, self.head_dim)
267
+ key_layer = key_layer.transpose(1, 2).reshape(
268
+ batch_size * self.num_heads,
269
+ q_length,
270
+ self.head_dim,
271
+ )
272
+ value_layer = value_layer.transpose(1, 2).reshape(batch_size * self.num_heads, q_length, self.head_dim)
273
+
274
+ query_layer, key_layer = self.maybe_rotary(query_layer, key_layer)
275
+
276
+ if layer_past is not None:
277
+ past_key, past_value = layer_past
278
+ # concatenate along seq_length dimension:
279
+ # - key: [batch_size * self.num_heads, head_dim, kv_length]
280
+ # - value: [batch_size * self.num_heads, kv_length, head_dim]
281
+ key_layer = torch.cat((past_key, key_layer), dim=1)
282
+ value_layer = torch.cat((past_value, value_layer), dim=1)
283
+
284
+ _, kv_length, _ = key_layer.shape
285
+
286
+ if use_cache is True:
287
+ present = (key_layer, value_layer)
288
+ else:
289
+ present = None
290
+
291
+ if alibi is None:
292
+ query_layer_ = query_layer.reshape(batch_size, self.num_heads, -1, self.head_dim)
293
+ key_layer_ = key_layer.reshape(batch_size, self.num_kv, -1, self.head_dim)
294
+ value_layer_ = value_layer.reshape(batch_size, self.num_kv, -1, self.head_dim)
295
+
296
+ attn_output = F.scaled_dot_product_attention(
297
+ query_layer_, key_layer_, value_layer_, None, 0.0, is_causal=True
298
+ )
299
+
300
+ x = attn_output.view(batch_size, self.num_heads, q_length, self.head_dim)
301
+ x = x.permute(0, 2, 1, 3)
302
+ attn_output = x.reshape(batch_size, q_length, self.num_heads * self.head_dim)
303
+
304
+ output_tensor = self.dense(attn_output)
305
+
306
+ outputs = (output_tensor, present)
307
+ assert not output_attentions # not supported.
308
+ return outputs
309
+ else:
310
+ attention_mask_float = (attention_mask * 1.0).masked_fill(attention_mask, -1e9).to(torch.bfloat16)
311
+ matmul_result = query_layer @ key_layer.transpose(-1, -2)
312
+
313
+ # change view to [batch_size, num_heads, q_length, kv_length]
314
+ attention_scores = matmul_result.view(batch_size, self.num_heads, q_length, kv_length)
315
+
316
+ # cast attention scores to fp32, compute scaled softmax and cast back to initial dtype - [batch_size, num_heads, q_length, kv_length]
317
+ input_dtype = attention_scores.dtype
318
+ # `float16` has a minimum value of -65504.0, whereas `bfloat16` and `float32` have a minimum value of `-3.4e+38`
319
+ if input_dtype == torch.float16 or input_dtype == torch.bfloat16:
320
+ attention_scores = attention_scores.to(torch.float32)
321
+ # attn_weights = torch.masked_fill(attention_scores, attention_mask, torch.finfo(attention_scores.dtype).min)
322
+ attention_probs = F.softmax(
323
+ (attention_scores + alibi) * self.inv_norm_factor + attention_mask_float,
324
+ dim=-1,
325
+ dtype=hidden_states.dtype,
326
+ )
327
+ # [batch_size, num_heads, q_length, kv_length]
328
+ attention_probs = self.attention_dropout(attention_probs)
329
+
330
+ if head_mask is not None:
331
+ attention_probs = attention_probs * head_mask
332
+
333
+ # change view [batch_size x num_heads, q_length, kv_length]
334
+ attention_probs_reshaped = attention_probs.view(batch_size * self.num_heads, q_length, kv_length)
335
+
336
+ # matmul: [batch_size * num_heads, q_length, head_dim]
337
+ context_layer = attention_probs_reshaped @ value_layer
338
+
339
+ # change view [batch_size, num_heads, q_length, head_dim]
340
+ context_layer = self._merge_heads(context_layer)
341
+
342
+ output_tensor = self.dense(context_layer)
343
+
344
+ outputs = (output_tensor, present)
345
+ if output_attentions:
346
+ outputs += (attention_probs,)
347
+
348
+ return outputs
349
+
350
+
351
+ class MLP(nn.Module):
352
+ def __init__(self, config: RWConfig):
353
+ super().__init__()
354
+ hidden_size = config.hidden_size
355
+
356
+ self.dense_h_to_4h = Linear(hidden_size, 4 * hidden_size, bias=config.bias)
357
+ self.act = nn.GELU()
358
+ self.dense_4h_to_h = Linear(4 * hidden_size, hidden_size, bias=config.bias)
359
+ self.hidden_dropout = config.hidden_dropout
360
+
361
+ def forward(self, x: torch.Tensor) -> torch.Tensor:
362
+ x = self.act(self.dense_h_to_4h(x))
363
+ x = self.dense_4h_to_h(x)
364
+ return x
365
+
366
+
367
+ class DecoderLayer(nn.Module):
368
+ def __init__(self, config: RWConfig):
369
+ super().__init__()
370
+ hidden_size = config.hidden_size
371
+
372
+ self.ln_attn = LayerNorm(hidden_size, eps=config.layer_norm_epsilon)
373
+ self.num_heads = config.n_head
374
+ self.self_attention = Attention(config)
375
+
376
+ self.ln_mlp = LayerNorm(hidden_size, eps=config.layer_norm_epsilon)
377
+
378
+ self.mlp = MLP(config)
379
+
380
+ self.apply_residual_connection_post_layernorm = config.apply_residual_connection_post_layernorm
381
+ self.hidden_dropout = config.hidden_dropout
382
+
383
+ self.config = config
384
+
385
+ def forward(
386
+ self,
387
+ hidden_states: torch.Tensor,
388
+ alibi: torch.Tensor,
389
+ attention_mask: torch.Tensor,
390
+ layer_past: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
391
+ head_mask: Optional[torch.Tensor] = None,
392
+ use_cache: bool = False,
393
+ output_attentions: bool = False,
394
+ ):
395
+ # hidden_states: [batch_size, seq_length, hidden_size]
396
+
397
+ # Layer norm at the beginning of the transformer layer.
398
+ layernorm_output = self.ln_attn(hidden_states)
399
+
400
+ # Layer norm post the self attention.
401
+ residual = hidden_states
402
+
403
+ # Self attention.
404
+ attn_outputs = self.self_attention(
405
+ layernorm_output,
406
+ layer_past=layer_past,
407
+ attention_mask=attention_mask,
408
+ alibi=alibi,
409
+ head_mask=head_mask,
410
+ use_cache=use_cache,
411
+ output_attentions=output_attentions,
412
+ )
413
+
414
+ attention_output = attn_outputs[0]
415
+
416
+ if not self.config.parallel_attn:
417
+ residual = dropout_add(attention_output, residual, self.config.attention_dropout, training=self.training)
418
+ layernorm_output = self.ln_mlp(residual)
419
+ elif not self.config.single_ln:
420
+ layernorm_output = self.ln_mlp(residual)
421
+
422
+ outputs = attn_outputs[1:]
423
+
424
+ # MLP.
425
+ mlp_output = self.mlp(layernorm_output)
426
+
427
+ if self.config.parallel_attn:
428
+ mlp_output += attention_output
429
+
430
+ output = dropout_add(mlp_output, residual, self.config.hidden_dropout, training=self.training)
431
+
432
+ if use_cache:
433
+ outputs = (output,) + outputs
434
+ else:
435
+ outputs = (output,) + outputs[1:]
436
+
437
+ return outputs # hidden_states, present, attentions
438
+
439
+
440
+ class RWPreTrainedModel(PreTrainedModel):
441
+ _keys_to_ignore_on_load_missing = [r"h.*.self_attention.scale_mask_softmax.causal_mask", r"lm_head.weight"]
442
+ """
443
+ An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
444
+ models.
445
+ """
446
+
447
+ config_class = RWConfig
448
+ base_model_prefix = "transformer"
449
+ supports_gradient_checkpointing = True
450
+ _no_split_modules = ["DecoderLayer"]
451
+
452
+ def __init__(self, *inputs, **kwargs):
453
+ super().__init__(*inputs, **kwargs)
454
+
455
+ def _init_weights(self, module: nn.Module):
456
+ """Initialize the weights."""
457
+ if isinstance(module, nn.Linear) or isinstance(module, Linear):
458
+ # Slightly different from the TF version which uses truncated_normal for initialization
459
+ # cf https://github.com/pytorch/pytorch/pull/5617
460
+ module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
461
+ if module.bias is not None:
462
+ module.bias.data.zero_()
463
+ elif isinstance(module, nn.Embedding):
464
+ module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
465
+ if module.padding_idx is not None:
466
+ module.weight.data[module.padding_idx].zero_()
467
+ elif isinstance(module, LayerNorm):
468
+ module.bias.data.zero_()
469
+ module.weight.data.fill_(1.0)
470
+
471
+ def _set_gradient_checkpointing(self, module: nn.Module, value: bool = False):
472
+ if isinstance(module, RWModel):
473
+ module.gradient_checkpointing = value
474
+
475
+ @staticmethod
476
+ def _convert_to_standard_cache(
477
+ past_key_value: Tuple[Tuple[torch.Tensor, torch.Tensor]], batch_size: int
478
+ ) -> Tuple[Tuple[torch.Tensor, torch.Tensor]]:
479
+ """
480
+ Standardizes the format of the cache so as to match most implementations, i.e. to tuple(tuple([batch_size,
481
+ num_heads, ...]))
482
+ """
483
+ batch_size_times_num_heads, head_dim, seq_length = past_key_value[0][0].shape
484
+ num_heads = batch_size_times_num_heads // batch_size
485
+ # key: [batch_size * num_heads, head_dim, seq_length] -> [batch_size, num_heads, head_dim, seq_length]
486
+ # value: [batch_size * num_heads, seq_length, head_dim] -> [batch_size, num_heads, seq_length, head_dim]
487
+ return tuple(
488
+ (
489
+ layer_past[0].view(batch_size, num_heads, head_dim, seq_length),
490
+ layer_past[1].view(batch_size, num_heads, seq_length, head_dim),
491
+ )
492
+ for layer_past in past_key_value
493
+ )
494
+
495
+ @staticmethod
496
+ def _convert_to_rw_cache(
497
+ past_key_value: Tuple[Tuple[torch.Tensor, torch.Tensor]]
498
+ ) -> Tuple[Tuple[torch.Tensor, torch.Tensor]]:
499
+ batch_size, num_heads, head_dim, seq_length = past_key_value[0][0].shape
500
+ batch_size_times_num_heads = batch_size * num_heads
501
+ # key: [batch_size, num_heads, head_dim, seq_length] -> [batch_size * num_heads, head_dim, seq_length]
502
+ # value: [batch_size, num_heads, seq_length, head_dim] -> [batch_size * num_heads, seq_length, head_dim]
503
+ return tuple(
504
+ (
505
+ layer_past[0].view(batch_size_times_num_heads, head_dim, seq_length),
506
+ layer_past[1].view(batch_size_times_num_heads, seq_length, head_dim),
507
+ )
508
+ for layer_past in past_key_value
509
+ )
510
+
511
+
512
+ class RWModel(RWPreTrainedModel):
513
+ def __init__(self, config: RWConfig):
514
+ super().__init__(config)
515
+
516
+ self.embed_dim = config.hidden_size
517
+ self.num_heads = config.n_head
518
+ self.alibi = config.alibi
519
+
520
+ # Embedding + LN Embedding
521
+ self.word_embeddings = nn.Embedding(config.vocab_size, self.embed_dim)
522
+
523
+ # Transformer blocks
524
+ self.h = nn.ModuleList([DecoderLayer(config) for _ in range(config.num_hidden_layers)])
525
+
526
+ # Final Layer Norm
527
+ self.ln_f = LayerNorm(self.embed_dim, eps=config.layer_norm_epsilon)
528
+
529
+ self.gradient_checkpointing = False
530
+
531
+ # Initialize weights and apply final processing
532
+ self.post_init()
533
+
534
+ def get_input_embeddings(self):
535
+ return self.word_embeddings
536
+
537
+ def _prepare_attn_mask(
538
+ self, attention_mask: torch.Tensor, input_shape: Tuple[int, int], past_key_values_length: int
539
+ ) -> torch.BoolTensor:
540
+ # create causal mask
541
+ # [batch_size, seq_length] -> [batch_size, 1, tgt_length, src_length]
542
+ combined_attention_mask = None
543
+ device = attention_mask.device
544
+ _, src_length = input_shape
545
+
546
+ if src_length > 1:
547
+ combined_attention_mask = _make_causal_mask(
548
+ input_shape, device=device, past_key_values_length=past_key_values_length
549
+ )
550
+
551
+ # [batch_size, seq_length] -> [batch_size, 1, tgt_length, src_length]
552
+ expanded_attn_mask = _expand_mask(attention_mask, tgt_length=src_length)
553
+ combined_attention_mask = (
554
+ expanded_attn_mask if combined_attention_mask is None else expanded_attn_mask | combined_attention_mask
555
+ )
556
+
557
+ return combined_attention_mask
558
+
559
+ def set_input_embeddings(self, new_embeddings: torch.Tensor):
560
+ self.word_embeddings = new_embeddings
561
+
562
+ def forward(
563
+ self,
564
+ input_ids: Optional[torch.LongTensor] = None,
565
+ past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
566
+ attention_mask: Optional[torch.Tensor] = None,
567
+ head_mask: Optional[torch.LongTensor] = None,
568
+ inputs_embeds: Optional[torch.LongTensor] = None,
569
+ use_cache: Optional[bool] = None,
570
+ output_attentions: Optional[bool] = None,
571
+ output_hidden_states: Optional[bool] = None,
572
+ return_dict: Optional[bool] = None,
573
+ **deprecated_arguments,
574
+ ) -> Union[Tuple[torch.Tensor, ...], BaseModelOutputWithPastAndCrossAttentions]:
575
+ if deprecated_arguments.pop("position_ids", False) is not False:
576
+ # `position_ids` could have been `torch.Tensor` or `None` so defaulting pop to `False` allows to detect if users were passing explicitly `None`
577
+ warnings.warn(
578
+ "`position_ids` have no functionality in BLOOM and will be removed in v5.0.0. You can safely ignore"
579
+ " passing `position_ids`.",
580
+ FutureWarning,
581
+ )
582
+ if len(deprecated_arguments) > 0:
583
+ raise ValueError(f"Got unexpected arguments: {deprecated_arguments}")
584
+
585
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
586
+ output_hidden_states = (
587
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
588
+ )
589
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
590
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
591
+
592
+ if input_ids is not None and inputs_embeds is not None:
593
+ raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
594
+ elif input_ids is not None:
595
+ batch_size, seq_length = input_ids.shape
596
+ elif inputs_embeds is not None:
597
+ batch_size, seq_length, _ = inputs_embeds.shape
598
+ else:
599
+ raise ValueError("You have to specify either input_ids or inputs_embeds")
600
+
601
+ if past_key_values is None:
602
+ past_key_values = tuple([None] * len(self.h))
603
+
604
+ # Prepare head mask if needed
605
+ # 1.0 in head_mask indicate we keep the head
606
+ # attention_probs has shape batch_size x num_heads x N x N
607
+ # head_mask has shape n_layer x batch x num_heads x N x N
608
+ head_mask = self.get_head_mask(head_mask, self.config.n_layer)
609
+
610
+ if inputs_embeds is None:
611
+ inputs_embeds = self.word_embeddings(input_ids)
612
+
613
+ hidden_states = inputs_embeds
614
+
615
+ presents = () if use_cache else None
616
+ all_self_attentions = () if output_attentions else None
617
+ all_hidden_states = () if output_hidden_states else None
618
+
619
+ # Compute alibi tensor: check build_alibi_tensor documentation
620
+ seq_length_with_past = seq_length
621
+ past_key_values_length = 0
622
+ if past_key_values[0] is not None:
623
+ past_key_values_length = past_key_values[0][0].shape[2]
624
+ seq_length_with_past = seq_length_with_past + past_key_values_length
625
+ if attention_mask is None:
626
+ attention_mask = torch.ones((batch_size, seq_length_with_past), device=hidden_states.device)
627
+ else:
628
+ attention_mask = attention_mask.to(hidden_states.device)
629
+
630
+ if self.alibi:
631
+ alibi = build_alibi_tensor(attention_mask, self.num_heads, dtype=hidden_states.dtype)
632
+ else:
633
+ alibi = None
634
+
635
+ causal_mask = self._prepare_attn_mask(
636
+ attention_mask,
637
+ input_shape=(batch_size, seq_length),
638
+ past_key_values_length=past_key_values_length,
639
+ )
640
+
641
+ for i, (block, layer_past) in enumerate(zip(self.h, past_key_values)):
642
+
643
+ if output_hidden_states:
644
+ all_hidden_states = all_hidden_states + (hidden_states,)
645
+
646
+ if self.gradient_checkpointing and self.training:
647
+
648
+ if use_cache:
649
+ logger.warning(
650
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
651
+ )
652
+ use_cache = False
653
+
654
+ def create_custom_forward(module):
655
+ def custom_forward(*inputs):
656
+ # None for past_key_value
657
+ return module(*inputs, use_cache=use_cache, output_attentions=output_attentions)
658
+
659
+ return custom_forward
660
+
661
+ outputs = torch.utils.checkpoint.checkpoint(
662
+ create_custom_forward(block),
663
+ hidden_states,
664
+ alibi,
665
+ causal_mask,
666
+ head_mask[i],
667
+ )
668
+ else:
669
+ outputs = block(
670
+ hidden_states,
671
+ layer_past=layer_past,
672
+ attention_mask=causal_mask,
673
+ head_mask=head_mask[i],
674
+ use_cache=use_cache,
675
+ output_attentions=output_attentions,
676
+ alibi=alibi,
677
+ )
678
+
679
+ hidden_states = outputs[0]
680
+ if use_cache is True:
681
+ presents = presents + (outputs[1],)
682
+
683
+ if output_attentions:
684
+ all_self_attentions = all_self_attentions + (outputs[2 if use_cache else 1],)
685
+
686
+ # Add last hidden state
687
+ hidden_states = self.ln_f(hidden_states)
688
+
689
+ if output_hidden_states:
690
+ all_hidden_states = all_hidden_states + (hidden_states,)
691
+
692
+ if not return_dict:
693
+ return tuple(v for v in [hidden_states, presents, all_hidden_states, all_self_attentions] if v is not None)
694
+
695
+ return BaseModelOutputWithPastAndCrossAttentions(
696
+ last_hidden_state=hidden_states,
697
+ past_key_values=presents,
698
+ hidden_states=all_hidden_states,
699
+ attentions=all_self_attentions,
700
+ )
701
+
702
+
703
+ class RWForCausalLM(RWPreTrainedModel):
704
+ _keys_to_ignore_on_load_missing = [r"h.*.self_attention.scale_mask_softmax.causal_mask", r"lm_head.weight"]
705
+
706
+ def __init__(self, config: RWConfig):
707
+ super().__init__(config)
708
+ self.transformer = RWModel(config)
709
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
710
+
711
+ # Initialize weights and apply final processing
712
+ self.post_init()
713
+
714
+ def get_output_embeddings(self):
715
+ return self.lm_head
716
+
717
+ def set_output_embeddings(self, new_embeddings: torch.Tensor):
718
+ self.lm_head = new_embeddings
719
+
720
+ def prepare_inputs_for_generation(
721
+ self,
722
+ input_ids: torch.LongTensor,
723
+ past: Optional[torch.Tensor] = None,
724
+ attention_mask: Optional[torch.Tensor] = None,
725
+ **kwargs,
726
+ ) -> dict:
727
+ # only last token for input_ids if past is not None
728
+ if past:
729
+ input_ids = input_ids[:, -1].unsqueeze(-1)
730
+
731
+ # the cache may be in the stardard format (e.g. in contrastive search), convert to our's format if needed
732
+ if past[0][0].shape[0] == input_ids.shape[0]:
733
+ past = self._convert_to_rw_cache(past)
734
+
735
+ return {
736
+ "input_ids": input_ids,
737
+ "past_key_values": past,
738
+ "use_cache": kwargs.get("use_cache"),
739
+ "attention_mask": attention_mask,
740
+ }
741
+
742
+ def forward(
743
+ self,
744
+ input_ids: Optional[torch.LongTensor] = None,
745
+ past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
746
+ attention_mask: Optional[torch.Tensor] = None,
747
+ head_mask: Optional[torch.Tensor] = None,
748
+ inputs_embeds: Optional[torch.Tensor] = None,
749
+ labels: Optional[torch.Tensor] = None,
750
+ use_cache: Optional[bool] = None,
751
+ output_attentions: Optional[bool] = None,
752
+ output_hidden_states: Optional[bool] = None,
753
+ return_dict: Optional[bool] = None,
754
+ **deprecated_arguments,
755
+ ) -> Union[Tuple[torch.Tensor], CausalLMOutputWithCrossAttentions]:
756
+ r"""
757
+ labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
758
+ Labels for language modeling. Note that the labels **are shifted** inside the model, i.e. you can set
759
+ `labels = input_ids` Indices are selected in `[-100, 0, ..., config.vocab_size]` All labels set to `-100`
760
+ are ignored (masked), the loss is only computed for labels in `[0, ..., config.vocab_size]`
761
+ """
762
+ if deprecated_arguments.pop("position_ids", False) is not False:
763
+ # `position_ids` could have been `torch.Tensor` or `None` so defaulting pop to `False` allows to detect if users were passing explicitly `None`
764
+ warnings.warn(
765
+ "`position_ids` have no functionality in BLOOM and will be removed in v5.0.0. You can safely ignore"
766
+ " passing `position_ids`.",
767
+ FutureWarning,
768
+ )
769
+ if len(deprecated_arguments) > 0:
770
+ raise ValueError(f"Got unexpected arguments: {deprecated_arguments}")
771
+
772
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
773
+
774
+ transformer_outputs = self.transformer(
775
+ input_ids,
776
+ past_key_values=past_key_values,
777
+ attention_mask=attention_mask,
778
+ head_mask=head_mask,
779
+ inputs_embeds=inputs_embeds,
780
+ use_cache=use_cache,
781
+ output_attentions=output_attentions,
782
+ output_hidden_states=output_hidden_states,
783
+ return_dict=return_dict,
784
+ )
785
+ hidden_states = transformer_outputs[0]
786
+
787
+ lm_logits = self.lm_head(hidden_states)
788
+
789
+ loss = None
790
+ if labels is not None:
791
+ # Shift so that tokens < n predict n
792
+ shift_logits = lm_logits[..., :-1, :].contiguous()
793
+ shift_labels = labels[..., 1:].contiguous()
794
+ batch_size, seq_length, vocab_size = shift_logits.shape
795
+ # Flatten the tokens
796
+ loss_fct = CrossEntropyLoss()
797
+ loss = loss_fct(
798
+ shift_logits.view(batch_size * seq_length, vocab_size), shift_labels.view(batch_size * seq_length)
799
+ )
800
+
801
+ if not return_dict:
802
+ output = (lm_logits,) + transformer_outputs[1:]
803
+ return ((loss,) + output) if loss is not None else output
804
+
805
+ return CausalLMOutputWithCrossAttentions(
806
+ loss=loss,
807
+ logits=lm_logits,
808
+ past_key_values=transformer_outputs.past_key_values,
809
+ hidden_states=transformer_outputs.hidden_states,
810
+ attentions=transformer_outputs.attentions,
811
+ )
812
+
813
+ def _reorder_cache(
814
+ self, past: Tuple[Tuple[torch.Tensor, torch.Tensor], ...], beam_idx: torch.LongTensor
815
+ ) -> Tuple[Tuple[torch.Tensor, torch.Tensor], ...]:
816
+ """
817
+ This function is used to re-order the `past_key_values` cache if [`~PreTrainedModel.beam_search`] or
818
+ [`~PreTrainedModel.beam_sample`] is called. This is required to match `past_key_values` with the correct
819
+ beam_idx at every generation step.
820
+
821
+ Output shares the same memory storage as `past`.
822
+ """
823
+ standardized_past = self._convert_to_standard_cache(past, batch_size=len(beam_idx))
824
+
825
+ # Get a copy of `beam_idx` on all the devices where we need those indices.
826
+ device_to_beam_idx = {
827
+ past_state.device: beam_idx.to(past_state.device) for layer_past in past for past_state in layer_past
828
+ }
829
+ reordered_past = tuple(
830
+ (
831
+ layer_past[0].index_select(0, device_to_beam_idx[layer_past[0].device]),
832
+ layer_past[1].index_select(0, device_to_beam_idx[layer_past[0].device]),
833
+ )
834
+ for layer_past in standardized_past
835
+ )
836
+ return self._convert_to_rw_cache(reordered_past)
837
+
838
+
839
+ class RWForSequenceClassification(RWPreTrainedModel):
840
+ _keys_to_ignore_on_load_missing = [r"h.*.self_attention.scale_mask_softmax.causal_mask", r"lm_head.weight"]
841
+
842
+ def __init__(self, config: RWConfig):
843
+ super().__init__(config)
844
+ self.num_labels = config.num_labels
845
+ self.transformer = RWModel(config)
846
+ self.score = nn.Linear(config.hidden_size, config.num_labels, bias=False)
847
+
848
+ # Initialize weights and apply final processing
849
+ self.post_init()
850
+
851
+ def forward(
852
+ self,
853
+ input_ids: Optional[torch.LongTensor] = None,
854
+ past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
855
+ attention_mask: Optional[torch.Tensor] = None,
856
+ head_mask: Optional[torch.Tensor] = None,
857
+ inputs_embeds: Optional[torch.Tensor] = None,
858
+ labels: Optional[torch.Tensor] = None,
859
+ use_cache: Optional[bool] = None,
860
+ output_attentions: Optional[bool] = None,
861
+ output_hidden_states: Optional[bool] = None,
862
+ return_dict: Optional[bool] = None,
863
+ **deprecated_arguments,
864
+ ) -> Union[Tuple[torch.Tensor], SequenceClassifierOutputWithPast]:
865
+ r"""
866
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
867
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
868
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
869
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
870
+ """
871
+ if deprecated_arguments.pop("position_ids", False) is not False:
872
+ # `position_ids` could have been `torch.Tensor` or `None` so defaulting pop to `False` allows to detect if users were passing explicitly `None`
873
+ warnings.warn(
874
+ "`position_ids` have no functionality in BLOOM and will be removed in v5.0.0. You can safely ignore"
875
+ " passing `position_ids`.",
876
+ FutureWarning,
877
+ )
878
+ if len(deprecated_arguments) > 0:
879
+ raise ValueError(f"Got unexpected arguments: {deprecated_arguments}")
880
+
881
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
882
+
883
+ transformer_outputs = self.transformer(
884
+ input_ids,
885
+ past_key_values=past_key_values,
886
+ attention_mask=attention_mask,
887
+ head_mask=head_mask,
888
+ inputs_embeds=inputs_embeds,
889
+ use_cache=use_cache,
890
+ output_attentions=output_attentions,
891
+ output_hidden_states=output_hidden_states,
892
+ return_dict=return_dict,
893
+ )
894
+
895
+ hidden_states = transformer_outputs[0]
896
+ logits = self.score(hidden_states)
897
+
898
+ if input_ids is not None:
899
+ batch_size = input_ids.shape[0]
900
+ else:
901
+ batch_size = inputs_embeds.shape[0]
902
+
903
+ if self.config.pad_token_id is None and batch_size != 1:
904
+ raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
905
+ if self.config.pad_token_id is None:
906
+ sequence_lengths = -1
907
+ else:
908
+ if input_ids is not None:
909
+ sequence_lengths = torch.ne(input_ids, self.config.pad_token_id).sum(dim=-1) - 1
910
+ else:
911
+ sequence_lengths = -1
912
+ logger.warning(
913
+ f"{self.__class__.__name__} will not detect padding tokens in `inputs_embeds`. Results may be "
914
+ "unexpected if using padding tokens in conjunction with `inputs_embeds.`"
915
+ )
916
+
917
+ pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
918
+
919
+ loss = None
920
+ if labels is not None:
921
+ if self.config.problem_type is None:
922
+ if self.num_labels == 1:
923
+ self.config.problem_type = "regression"
924
+ elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
925
+ self.config.problem_type = "single_label_classification"
926
+ else:
927
+ self.config.problem_type = "multi_label_classification"
928
+
929
+ if self.config.problem_type == "regression":
930
+ loss_fct = MSELoss()
931
+ if self.num_labels == 1:
932
+ loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
933
+ else:
934
+ loss = loss_fct(pooled_logits, labels)
935
+ elif self.config.problem_type == "single_label_classification":
936
+ loss_fct = CrossEntropyLoss()
937
+ loss = loss_fct(pooled_logits, labels)
938
+ elif self.config.problem_type == "multi_label_classification":
939
+ loss_fct = BCEWithLogitsLoss()
940
+ loss = loss_fct(pooled_logits, labels)
941
+ if not return_dict:
942
+ output = (pooled_logits,) + transformer_outputs[1:]
943
+ return ((loss,) + output) if loss is not None else output
944
+
945
+ return SequenceClassifierOutputWithPast(
946
+ loss=loss,
947
+ logits=pooled_logits,
948
+ past_key_values=transformer_outputs.past_key_values,
949
+ hidden_states=transformer_outputs.hidden_states,
950
+ attentions=transformer_outputs.attentions,
951
+ )
952
+
953
+
954
+ class RWForTokenClassification(RWPreTrainedModel):
955
+ _keys_to_ignore_on_load_missing = [r"h.*.self_attention.scale_mask_softmax.causal_mask", r"lm_head.weight"]
956
+
957
+ def __init__(self, config: RWConfig):
958
+ super().__init__(config)
959
+ self.num_labels = config.num_labels
960
+
961
+ self.transformer = RWModel(config)
962
+ if hasattr(config, "classifier_dropout") and config.classifier_dropout is not None:
963
+ classifier_dropout = config.classifier_dropout
964
+ elif hasattr(config, "hidden_dropout") and config.hidden_dropout is not None:
965
+ classifier_dropout = config.hidden_dropout
966
+ else:
967
+ classifier_dropout = 0.1
968
+ self.dropout = nn.Dropout(classifier_dropout)
969
+ self.classifier = nn.Linear(config.hidden_size, config.num_labels)
970
+
971
+ # Initialize weights and apply final processing
972
+ self.post_init()
973
+
974
+ def forward(
975
+ self,
976
+ input_ids: Optional[torch.LongTensor] = None,
977
+ past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
978
+ attention_mask: Optional[torch.Tensor] = None,
979
+ head_mask: Optional[torch.Tensor] = None,
980
+ inputs_embeds: Optional[torch.Tensor] = None,
981
+ labels: Optional[torch.Tensor] = None,
982
+ use_cache: Optional[bool] = None,
983
+ output_attentions: Optional[bool] = None,
984
+ output_hidden_states: Optional[bool] = None,
985
+ return_dict: Optional[bool] = None,
986
+ **deprecated_arguments,
987
+ ) -> Union[Tuple[torch.Tensor], TokenClassifierOutput]:
988
+ r"""
989
+ labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
990
+ Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
991
+ config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
992
+ `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
993
+ """
994
+ if deprecated_arguments.pop("position_ids", False) is not False:
995
+ # `position_ids` could have been `torch.Tensor` or `None` so defaulting pop to `False` allows to detect if users were passing explicitly `None`
996
+ warnings.warn(
997
+ "`position_ids` have no functionality in BLOOM and will be removed in v5.0.0. You can safely ignore"
998
+ " passing `position_ids`.",
999
+ FutureWarning,
1000
+ )
1001
+ if len(deprecated_arguments) > 0:
1002
+ raise ValueError(f"Got unexpected arguments: {deprecated_arguments}")
1003
+
1004
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1005
+
1006
+ transformer_outputs = self.transformer(
1007
+ input_ids,
1008
+ past_key_values=past_key_values,
1009
+ attention_mask=attention_mask,
1010
+ head_mask=head_mask,
1011
+ inputs_embeds=inputs_embeds,
1012
+ use_cache=use_cache,
1013
+ output_attentions=output_attentions,
1014
+ output_hidden_states=output_hidden_states,
1015
+ return_dict=return_dict,
1016
+ )
1017
+
1018
+ hidden_states = transformer_outputs[0]
1019
+ hidden_states = self.dropout(hidden_states)
1020
+ logits = self.classifier(hidden_states)
1021
+
1022
+ loss = None
1023
+ if labels is not None:
1024
+ batch_size, seq_length = labels.shape
1025
+ loss_fct = CrossEntropyLoss()
1026
+ loss = loss_fct(logits.view(batch_size * seq_length, self.num_labels), labels.view(batch_size * seq_length))
1027
+
1028
+ if not return_dict:
1029
+ output = (logits,) + transformer_outputs[2:]
1030
+ return ((loss,) + output) if loss is not None else output
1031
+
1032
+ return TokenClassifierOutput(
1033
+ loss=loss,
1034
+ logits=logits,
1035
+ hidden_states=transformer_outputs.hidden_states,
1036
+ attentions=transformer_outputs.attentions,
1037
+ )
1038
+
1039
+
1040
+ class RWForQuestionAnswering(RWPreTrainedModel):
1041
+ _keys_to_ignore_on_load_missing = [r"h.*.self_attention.scale_mask_softmax.causal_mask", r"lm_head.weight"]
1042
+
1043
+ def __init__(self, config):
1044
+ super().__init__(config)
1045
+ self.transformer = RWModel(config)
1046
+ self.qa_outputs = nn.Linear(config.hidden_size, 2)
1047
+
1048
+ # Initialize weights and apply final processing
1049
+ self.post_init()
1050
+
1051
+ def forward(
1052
+ self,
1053
+ input_ids: Optional[torch.LongTensor] = None,
1054
+ attention_mask: Optional[torch.FloatTensor] = None,
1055
+ position_ids: Optional[torch.LongTensor] = None,
1056
+ head_mask: Optional[torch.FloatTensor] = None,
1057
+ inputs_embeds: Optional[torch.FloatTensor] = None,
1058
+ start_positions: Optional[torch.LongTensor] = None,
1059
+ end_positions: Optional[torch.LongTensor] = None,
1060
+ output_attentions: Optional[bool] = None,
1061
+ output_hidden_states: Optional[bool] = None,
1062
+ return_dict: Optional[bool] = None,
1063
+ ) -> Union[Tuple, QuestionAnsweringModelOutput]:
1064
+ r"""
1065
+ start_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1066
+ Labels for position (index) of the start of the labelled span for computing the token classification loss.
1067
+ Positions are clamped to the length of the sequence (`sequence_length`). Position outside of the sequence
1068
+ are not taken into account for computing the loss.
1069
+ end_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
1070
+ Labels for position (index) of the end of the labelled span for computing the token classification loss.
1071
+ Positions are clamped to the length of the sequence (`sequence_length`). Position outside of the sequence
1072
+ are not taken into account for computing the loss.
1073
+ """
1074
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
1075
+
1076
+ outputs = self.transformer(
1077
+ input_ids,
1078
+ attention_mask=attention_mask,
1079
+ position_ids=position_ids,
1080
+ head_mask=head_mask,
1081
+ inputs_embeds=inputs_embeds,
1082
+ output_attentions=output_attentions,
1083
+ output_hidden_states=output_hidden_states,
1084
+ return_dict=return_dict,
1085
+ )
1086
+
1087
+ sequence_output = outputs[0]
1088
+
1089
+ logits = self.qa_outputs(sequence_output)
1090
+ start_logits, end_logits = logits.split(1, dim=-1)
1091
+ start_logits = start_logits.squeeze(-1).contiguous()
1092
+ end_logits = end_logits.squeeze(-1).contiguous()
1093
+
1094
+ total_loss = None
1095
+ if start_positions is not None and end_positions is not None:
1096
+ # If we are on multi-GPU, split add a dimension
1097
+ if len(start_positions.size()) > 1:
1098
+ start_positions = start_positions.squeeze(-1)
1099
+ if len(end_positions.size()) > 1:
1100
+ end_positions = end_positions.squeeze(-1)
1101
+ # sometimes the start/end positions are outside our model inputs, we ignore these terms
1102
+ ignored_index = start_logits.size(1)
1103
+ start_positions = start_positions.clamp(0, ignored_index)
1104
+ end_positions = end_positions.clamp(0, ignored_index)
1105
+
1106
+ loss_fct = CrossEntropyLoss(ignore_index=ignored_index)
1107
+ start_loss = loss_fct(start_logits, start_positions)
1108
+ end_loss = loss_fct(end_logits, end_positions)
1109
+ total_loss = (start_loss + end_loss) / 2
1110
+
1111
+ if not return_dict:
1112
+ output = (start_logits, end_logits) + outputs[2:]
1113
+ return ((total_loss,) + output) if total_loss is not None else output
1114
+
1115
+ return QuestionAnsweringModelOutput(
1116
+ loss=total_loss,
1117
+ start_logits=start_logits,
1118
+ end_logits=end_logits,
1119
+ hidden_states=outputs.hidden_states,
1120
+ attentions=outputs.attentions,
1121
+ )
pytorch_model-00001-of-00009.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c44c2ce0d345d7d95ca97ef8ba8eac2a51d0bb2a19416ac092589642564d09ed
3
+ size 9504770141
pytorch_model-00002-of-00009.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:447d806886ff8f236ff06641320e3b094dd42ffb25d39c23278af1b35376dbdc
3
+ size 9513159151
pytorch_model-00003-of-00009.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77850eaaf7ce4826b87c24d7b7b5c3b0cc02a50a0f8d55cf8934196a28872a80
3
+ size 9513159151
pytorch_model-00004-of-00009.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ded0fa297bf28ea0fe28088f85fbd72dd1b7ed9ddb838bfd79b383b130b9d529
3
+ size 9513159151
pytorch_model-00005-of-00009.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4067f3e4fa0301b23d958b31e990b161ba4c0cfaeb2b0c290597355d32ff6a6a
3
+ size 9513159151
pytorch_model-00006-of-00009.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a46aaaa146d82ea8c7ca3ddcd8076aed0838fa8faa8aa6a831c466160632acf0
3
+ size 9513159151
pytorch_model-00007-of-00009.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2adb51a5dc32427a14f22e46f627bcbbd30678f3b76917e0a19f978b07eb2ca9
3
+ size 9513159151
pytorch_model-00008-of-00009.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c6ca09fd0b1c528ca7c213a6e96d44b49a1cffeb19610fda5424e7150b09c328
3
+ size 9513159151
pytorch_model-00009-of-00009.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:817fcda233d0f0aa84c96845d3ed95986b47de3a7fa83ec6d4762bb9ef7611fa
3
+ size 7575220277
pytorch_model.bin.index.json ADDED
@@ -0,0 +1,491 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 83671941120
4
+ },
5
+ "weight_map": {
6
+ "lm_head.weight": "pytorch_model-00009-of-00009.bin",
7
+ "transformer.h.0.ln_attn.bias": "pytorch_model-00001-of-00009.bin",
8
+ "transformer.h.0.ln_attn.weight": "pytorch_model-00001-of-00009.bin",
9
+ "transformer.h.0.ln_mlp.bias": "pytorch_model-00001-of-00009.bin",
10
+ "transformer.h.0.ln_mlp.weight": "pytorch_model-00001-of-00009.bin",
11
+ "transformer.h.0.mlp.dense_4h_to_h.weight": "pytorch_model-00001-of-00009.bin",
12
+ "transformer.h.0.mlp.dense_h_to_4h.weight": "pytorch_model-00001-of-00009.bin",
13
+ "transformer.h.0.self_attention.dense.weight": "pytorch_model-00001-of-00009.bin",
14
+ "transformer.h.0.self_attention.query_key_value.weight": "pytorch_model-00001-of-00009.bin",
15
+ "transformer.h.1.ln_attn.bias": "pytorch_model-00001-of-00009.bin",
16
+ "transformer.h.1.ln_attn.weight": "pytorch_model-00001-of-00009.bin",
17
+ "transformer.h.1.ln_mlp.bias": "pytorch_model-00001-of-00009.bin",
18
+ "transformer.h.1.ln_mlp.weight": "pytorch_model-00001-of-00009.bin",
19
+ "transformer.h.1.mlp.dense_4h_to_h.weight": "pytorch_model-00001-of-00009.bin",
20
+ "transformer.h.1.mlp.dense_h_to_4h.weight": "pytorch_model-00001-of-00009.bin",
21
+ "transformer.h.1.self_attention.dense.weight": "pytorch_model-00001-of-00009.bin",
22
+ "transformer.h.1.self_attention.query_key_value.weight": "pytorch_model-00001-of-00009.bin",
23
+ "transformer.h.10.ln_attn.bias": "pytorch_model-00002-of-00009.bin",
24
+ "transformer.h.10.ln_attn.weight": "pytorch_model-00002-of-00009.bin",
25
+ "transformer.h.10.ln_mlp.bias": "pytorch_model-00002-of-00009.bin",
26
+ "transformer.h.10.ln_mlp.weight": "pytorch_model-00002-of-00009.bin",
27
+ "transformer.h.10.mlp.dense_4h_to_h.weight": "pytorch_model-00002-of-00009.bin",
28
+ "transformer.h.10.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00009.bin",
29
+ "transformer.h.10.self_attention.dense.weight": "pytorch_model-00002-of-00009.bin",
30
+ "transformer.h.10.self_attention.query_key_value.weight": "pytorch_model-00002-of-00009.bin",
31
+ "transformer.h.11.ln_attn.bias": "pytorch_model-00002-of-00009.bin",
32
+ "transformer.h.11.ln_attn.weight": "pytorch_model-00002-of-00009.bin",
33
+ "transformer.h.11.ln_mlp.bias": "pytorch_model-00002-of-00009.bin",
34
+ "transformer.h.11.ln_mlp.weight": "pytorch_model-00002-of-00009.bin",
35
+ "transformer.h.11.mlp.dense_4h_to_h.weight": "pytorch_model-00002-of-00009.bin",
36
+ "transformer.h.11.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00009.bin",
37
+ "transformer.h.11.self_attention.dense.weight": "pytorch_model-00002-of-00009.bin",
38
+ "transformer.h.11.self_attention.query_key_value.weight": "pytorch_model-00002-of-00009.bin",
39
+ "transformer.h.12.ln_attn.bias": "pytorch_model-00002-of-00009.bin",
40
+ "transformer.h.12.ln_attn.weight": "pytorch_model-00002-of-00009.bin",
41
+ "transformer.h.12.ln_mlp.bias": "pytorch_model-00002-of-00009.bin",
42
+ "transformer.h.12.ln_mlp.weight": "pytorch_model-00002-of-00009.bin",
43
+ "transformer.h.12.mlp.dense_4h_to_h.weight": "pytorch_model-00002-of-00009.bin",
44
+ "transformer.h.12.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00009.bin",
45
+ "transformer.h.12.self_attention.dense.weight": "pytorch_model-00002-of-00009.bin",
46
+ "transformer.h.12.self_attention.query_key_value.weight": "pytorch_model-00002-of-00009.bin",
47
+ "transformer.h.13.ln_attn.bias": "pytorch_model-00002-of-00009.bin",
48
+ "transformer.h.13.ln_attn.weight": "pytorch_model-00002-of-00009.bin",
49
+ "transformer.h.13.ln_mlp.bias": "pytorch_model-00002-of-00009.bin",
50
+ "transformer.h.13.ln_mlp.weight": "pytorch_model-00002-of-00009.bin",
51
+ "transformer.h.13.mlp.dense_4h_to_h.weight": "pytorch_model-00003-of-00009.bin",
52
+ "transformer.h.13.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00009.bin",
53
+ "transformer.h.13.self_attention.dense.weight": "pytorch_model-00002-of-00009.bin",
54
+ "transformer.h.13.self_attention.query_key_value.weight": "pytorch_model-00002-of-00009.bin",
55
+ "transformer.h.14.ln_attn.bias": "pytorch_model-00003-of-00009.bin",
56
+ "transformer.h.14.ln_attn.weight": "pytorch_model-00003-of-00009.bin",
57
+ "transformer.h.14.ln_mlp.bias": "pytorch_model-00003-of-00009.bin",
58
+ "transformer.h.14.ln_mlp.weight": "pytorch_model-00003-of-00009.bin",
59
+ "transformer.h.14.mlp.dense_4h_to_h.weight": "pytorch_model-00003-of-00009.bin",
60
+ "transformer.h.14.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00009.bin",
61
+ "transformer.h.14.self_attention.dense.weight": "pytorch_model-00003-of-00009.bin",
62
+ "transformer.h.14.self_attention.query_key_value.weight": "pytorch_model-00003-of-00009.bin",
63
+ "transformer.h.15.ln_attn.bias": "pytorch_model-00003-of-00009.bin",
64
+ "transformer.h.15.ln_attn.weight": "pytorch_model-00003-of-00009.bin",
65
+ "transformer.h.15.ln_mlp.bias": "pytorch_model-00003-of-00009.bin",
66
+ "transformer.h.15.ln_mlp.weight": "pytorch_model-00003-of-00009.bin",
67
+ "transformer.h.15.mlp.dense_4h_to_h.weight": "pytorch_model-00003-of-00009.bin",
68
+ "transformer.h.15.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00009.bin",
69
+ "transformer.h.15.self_attention.dense.weight": "pytorch_model-00003-of-00009.bin",
70
+ "transformer.h.15.self_attention.query_key_value.weight": "pytorch_model-00003-of-00009.bin",
71
+ "transformer.h.16.ln_attn.bias": "pytorch_model-00003-of-00009.bin",
72
+ "transformer.h.16.ln_attn.weight": "pytorch_model-00003-of-00009.bin",
73
+ "transformer.h.16.ln_mlp.bias": "pytorch_model-00003-of-00009.bin",
74
+ "transformer.h.16.ln_mlp.weight": "pytorch_model-00003-of-00009.bin",
75
+ "transformer.h.16.mlp.dense_4h_to_h.weight": "pytorch_model-00003-of-00009.bin",
76
+ "transformer.h.16.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00009.bin",
77
+ "transformer.h.16.self_attention.dense.weight": "pytorch_model-00003-of-00009.bin",
78
+ "transformer.h.16.self_attention.query_key_value.weight": "pytorch_model-00003-of-00009.bin",
79
+ "transformer.h.17.ln_attn.bias": "pytorch_model-00003-of-00009.bin",
80
+ "transformer.h.17.ln_attn.weight": "pytorch_model-00003-of-00009.bin",
81
+ "transformer.h.17.ln_mlp.bias": "pytorch_model-00003-of-00009.bin",
82
+ "transformer.h.17.ln_mlp.weight": "pytorch_model-00003-of-00009.bin",
83
+ "transformer.h.17.mlp.dense_4h_to_h.weight": "pytorch_model-00003-of-00009.bin",
84
+ "transformer.h.17.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00009.bin",
85
+ "transformer.h.17.self_attention.dense.weight": "pytorch_model-00003-of-00009.bin",
86
+ "transformer.h.17.self_attention.query_key_value.weight": "pytorch_model-00003-of-00009.bin",
87
+ "transformer.h.18.ln_attn.bias": "pytorch_model-00003-of-00009.bin",
88
+ "transformer.h.18.ln_attn.weight": "pytorch_model-00003-of-00009.bin",
89
+ "transformer.h.18.ln_mlp.bias": "pytorch_model-00003-of-00009.bin",
90
+ "transformer.h.18.ln_mlp.weight": "pytorch_model-00003-of-00009.bin",
91
+ "transformer.h.18.mlp.dense_4h_to_h.weight": "pytorch_model-00003-of-00009.bin",
92
+ "transformer.h.18.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00009.bin",
93
+ "transformer.h.18.self_attention.dense.weight": "pytorch_model-00003-of-00009.bin",
94
+ "transformer.h.18.self_attention.query_key_value.weight": "pytorch_model-00003-of-00009.bin",
95
+ "transformer.h.19.ln_attn.bias": "pytorch_model-00003-of-00009.bin",
96
+ "transformer.h.19.ln_attn.weight": "pytorch_model-00003-of-00009.bin",
97
+ "transformer.h.19.ln_mlp.bias": "pytorch_model-00003-of-00009.bin",
98
+ "transformer.h.19.ln_mlp.weight": "pytorch_model-00003-of-00009.bin",
99
+ "transformer.h.19.mlp.dense_4h_to_h.weight": "pytorch_model-00003-of-00009.bin",
100
+ "transformer.h.19.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00009.bin",
101
+ "transformer.h.19.self_attention.dense.weight": "pytorch_model-00003-of-00009.bin",
102
+ "transformer.h.19.self_attention.query_key_value.weight": "pytorch_model-00003-of-00009.bin",
103
+ "transformer.h.2.ln_attn.bias": "pytorch_model-00001-of-00009.bin",
104
+ "transformer.h.2.ln_attn.weight": "pytorch_model-00001-of-00009.bin",
105
+ "transformer.h.2.ln_mlp.bias": "pytorch_model-00001-of-00009.bin",
106
+ "transformer.h.2.ln_mlp.weight": "pytorch_model-00001-of-00009.bin",
107
+ "transformer.h.2.mlp.dense_4h_to_h.weight": "pytorch_model-00001-of-00009.bin",
108
+ "transformer.h.2.mlp.dense_h_to_4h.weight": "pytorch_model-00001-of-00009.bin",
109
+ "transformer.h.2.self_attention.dense.weight": "pytorch_model-00001-of-00009.bin",
110
+ "transformer.h.2.self_attention.query_key_value.weight": "pytorch_model-00001-of-00009.bin",
111
+ "transformer.h.20.ln_attn.bias": "pytorch_model-00003-of-00009.bin",
112
+ "transformer.h.20.ln_attn.weight": "pytorch_model-00003-of-00009.bin",
113
+ "transformer.h.20.ln_mlp.bias": "pytorch_model-00003-of-00009.bin",
114
+ "transformer.h.20.ln_mlp.weight": "pytorch_model-00003-of-00009.bin",
115
+ "transformer.h.20.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00009.bin",
116
+ "transformer.h.20.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00009.bin",
117
+ "transformer.h.20.self_attention.dense.weight": "pytorch_model-00003-of-00009.bin",
118
+ "transformer.h.20.self_attention.query_key_value.weight": "pytorch_model-00003-of-00009.bin",
119
+ "transformer.h.21.ln_attn.bias": "pytorch_model-00004-of-00009.bin",
120
+ "transformer.h.21.ln_attn.weight": "pytorch_model-00004-of-00009.bin",
121
+ "transformer.h.21.ln_mlp.bias": "pytorch_model-00004-of-00009.bin",
122
+ "transformer.h.21.ln_mlp.weight": "pytorch_model-00004-of-00009.bin",
123
+ "transformer.h.21.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00009.bin",
124
+ "transformer.h.21.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00009.bin",
125
+ "transformer.h.21.self_attention.dense.weight": "pytorch_model-00004-of-00009.bin",
126
+ "transformer.h.21.self_attention.query_key_value.weight": "pytorch_model-00004-of-00009.bin",
127
+ "transformer.h.22.ln_attn.bias": "pytorch_model-00004-of-00009.bin",
128
+ "transformer.h.22.ln_attn.weight": "pytorch_model-00004-of-00009.bin",
129
+ "transformer.h.22.ln_mlp.bias": "pytorch_model-00004-of-00009.bin",
130
+ "transformer.h.22.ln_mlp.weight": "pytorch_model-00004-of-00009.bin",
131
+ "transformer.h.22.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00009.bin",
132
+ "transformer.h.22.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00009.bin",
133
+ "transformer.h.22.self_attention.dense.weight": "pytorch_model-00004-of-00009.bin",
134
+ "transformer.h.22.self_attention.query_key_value.weight": "pytorch_model-00004-of-00009.bin",
135
+ "transformer.h.23.ln_attn.bias": "pytorch_model-00004-of-00009.bin",
136
+ "transformer.h.23.ln_attn.weight": "pytorch_model-00004-of-00009.bin",
137
+ "transformer.h.23.ln_mlp.bias": "pytorch_model-00004-of-00009.bin",
138
+ "transformer.h.23.ln_mlp.weight": "pytorch_model-00004-of-00009.bin",
139
+ "transformer.h.23.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00009.bin",
140
+ "transformer.h.23.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00009.bin",
141
+ "transformer.h.23.self_attention.dense.weight": "pytorch_model-00004-of-00009.bin",
142
+ "transformer.h.23.self_attention.query_key_value.weight": "pytorch_model-00004-of-00009.bin",
143
+ "transformer.h.24.ln_attn.bias": "pytorch_model-00004-of-00009.bin",
144
+ "transformer.h.24.ln_attn.weight": "pytorch_model-00004-of-00009.bin",
145
+ "transformer.h.24.ln_mlp.bias": "pytorch_model-00004-of-00009.bin",
146
+ "transformer.h.24.ln_mlp.weight": "pytorch_model-00004-of-00009.bin",
147
+ "transformer.h.24.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00009.bin",
148
+ "transformer.h.24.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00009.bin",
149
+ "transformer.h.24.self_attention.dense.weight": "pytorch_model-00004-of-00009.bin",
150
+ "transformer.h.24.self_attention.query_key_value.weight": "pytorch_model-00004-of-00009.bin",
151
+ "transformer.h.25.ln_attn.bias": "pytorch_model-00004-of-00009.bin",
152
+ "transformer.h.25.ln_attn.weight": "pytorch_model-00004-of-00009.bin",
153
+ "transformer.h.25.ln_mlp.bias": "pytorch_model-00004-of-00009.bin",
154
+ "transformer.h.25.ln_mlp.weight": "pytorch_model-00004-of-00009.bin",
155
+ "transformer.h.25.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00009.bin",
156
+ "transformer.h.25.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00009.bin",
157
+ "transformer.h.25.self_attention.dense.weight": "pytorch_model-00004-of-00009.bin",
158
+ "transformer.h.25.self_attention.query_key_value.weight": "pytorch_model-00004-of-00009.bin",
159
+ "transformer.h.26.ln_attn.bias": "pytorch_model-00004-of-00009.bin",
160
+ "transformer.h.26.ln_attn.weight": "pytorch_model-00004-of-00009.bin",
161
+ "transformer.h.26.ln_mlp.bias": "pytorch_model-00004-of-00009.bin",
162
+ "transformer.h.26.ln_mlp.weight": "pytorch_model-00004-of-00009.bin",
163
+ "transformer.h.26.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00009.bin",
164
+ "transformer.h.26.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00009.bin",
165
+ "transformer.h.26.self_attention.dense.weight": "pytorch_model-00004-of-00009.bin",
166
+ "transformer.h.26.self_attention.query_key_value.weight": "pytorch_model-00004-of-00009.bin",
167
+ "transformer.h.27.ln_attn.bias": "pytorch_model-00004-of-00009.bin",
168
+ "transformer.h.27.ln_attn.weight": "pytorch_model-00004-of-00009.bin",
169
+ "transformer.h.27.ln_mlp.bias": "pytorch_model-00004-of-00009.bin",
170
+ "transformer.h.27.ln_mlp.weight": "pytorch_model-00004-of-00009.bin",
171
+ "transformer.h.27.mlp.dense_4h_to_h.weight": "pytorch_model-00005-of-00009.bin",
172
+ "transformer.h.27.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00009.bin",
173
+ "transformer.h.27.self_attention.dense.weight": "pytorch_model-00004-of-00009.bin",
174
+ "transformer.h.27.self_attention.query_key_value.weight": "pytorch_model-00004-of-00009.bin",
175
+ "transformer.h.28.ln_attn.bias": "pytorch_model-00005-of-00009.bin",
176
+ "transformer.h.28.ln_attn.weight": "pytorch_model-00005-of-00009.bin",
177
+ "transformer.h.28.ln_mlp.bias": "pytorch_model-00005-of-00009.bin",
178
+ "transformer.h.28.ln_mlp.weight": "pytorch_model-00005-of-00009.bin",
179
+ "transformer.h.28.mlp.dense_4h_to_h.weight": "pytorch_model-00005-of-00009.bin",
180
+ "transformer.h.28.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00009.bin",
181
+ "transformer.h.28.self_attention.dense.weight": "pytorch_model-00005-of-00009.bin",
182
+ "transformer.h.28.self_attention.query_key_value.weight": "pytorch_model-00005-of-00009.bin",
183
+ "transformer.h.29.ln_attn.bias": "pytorch_model-00005-of-00009.bin",
184
+ "transformer.h.29.ln_attn.weight": "pytorch_model-00005-of-00009.bin",
185
+ "transformer.h.29.ln_mlp.bias": "pytorch_model-00005-of-00009.bin",
186
+ "transformer.h.29.ln_mlp.weight": "pytorch_model-00005-of-00009.bin",
187
+ "transformer.h.29.mlp.dense_4h_to_h.weight": "pytorch_model-00005-of-00009.bin",
188
+ "transformer.h.29.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00009.bin",
189
+ "transformer.h.29.self_attention.dense.weight": "pytorch_model-00005-of-00009.bin",
190
+ "transformer.h.29.self_attention.query_key_value.weight": "pytorch_model-00005-of-00009.bin",
191
+ "transformer.h.3.ln_attn.bias": "pytorch_model-00001-of-00009.bin",
192
+ "transformer.h.3.ln_attn.weight": "pytorch_model-00001-of-00009.bin",
193
+ "transformer.h.3.ln_mlp.bias": "pytorch_model-00001-of-00009.bin",
194
+ "transformer.h.3.ln_mlp.weight": "pytorch_model-00001-of-00009.bin",
195
+ "transformer.h.3.mlp.dense_4h_to_h.weight": "pytorch_model-00001-of-00009.bin",
196
+ "transformer.h.3.mlp.dense_h_to_4h.weight": "pytorch_model-00001-of-00009.bin",
197
+ "transformer.h.3.self_attention.dense.weight": "pytorch_model-00001-of-00009.bin",
198
+ "transformer.h.3.self_attention.query_key_value.weight": "pytorch_model-00001-of-00009.bin",
199
+ "transformer.h.30.ln_attn.bias": "pytorch_model-00005-of-00009.bin",
200
+ "transformer.h.30.ln_attn.weight": "pytorch_model-00005-of-00009.bin",
201
+ "transformer.h.30.ln_mlp.bias": "pytorch_model-00005-of-00009.bin",
202
+ "transformer.h.30.ln_mlp.weight": "pytorch_model-00005-of-00009.bin",
203
+ "transformer.h.30.mlp.dense_4h_to_h.weight": "pytorch_model-00005-of-00009.bin",
204
+ "transformer.h.30.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00009.bin",
205
+ "transformer.h.30.self_attention.dense.weight": "pytorch_model-00005-of-00009.bin",
206
+ "transformer.h.30.self_attention.query_key_value.weight": "pytorch_model-00005-of-00009.bin",
207
+ "transformer.h.31.ln_attn.bias": "pytorch_model-00005-of-00009.bin",
208
+ "transformer.h.31.ln_attn.weight": "pytorch_model-00005-of-00009.bin",
209
+ "transformer.h.31.ln_mlp.bias": "pytorch_model-00005-of-00009.bin",
210
+ "transformer.h.31.ln_mlp.weight": "pytorch_model-00005-of-00009.bin",
211
+ "transformer.h.31.mlp.dense_4h_to_h.weight": "pytorch_model-00005-of-00009.bin",
212
+ "transformer.h.31.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00009.bin",
213
+ "transformer.h.31.self_attention.dense.weight": "pytorch_model-00005-of-00009.bin",
214
+ "transformer.h.31.self_attention.query_key_value.weight": "pytorch_model-00005-of-00009.bin",
215
+ "transformer.h.32.ln_attn.bias": "pytorch_model-00005-of-00009.bin",
216
+ "transformer.h.32.ln_attn.weight": "pytorch_model-00005-of-00009.bin",
217
+ "transformer.h.32.ln_mlp.bias": "pytorch_model-00005-of-00009.bin",
218
+ "transformer.h.32.ln_mlp.weight": "pytorch_model-00005-of-00009.bin",
219
+ "transformer.h.32.mlp.dense_4h_to_h.weight": "pytorch_model-00005-of-00009.bin",
220
+ "transformer.h.32.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00009.bin",
221
+ "transformer.h.32.self_attention.dense.weight": "pytorch_model-00005-of-00009.bin",
222
+ "transformer.h.32.self_attention.query_key_value.weight": "pytorch_model-00005-of-00009.bin",
223
+ "transformer.h.33.ln_attn.bias": "pytorch_model-00005-of-00009.bin",
224
+ "transformer.h.33.ln_attn.weight": "pytorch_model-00005-of-00009.bin",
225
+ "transformer.h.33.ln_mlp.bias": "pytorch_model-00005-of-00009.bin",
226
+ "transformer.h.33.ln_mlp.weight": "pytorch_model-00005-of-00009.bin",
227
+ "transformer.h.33.mlp.dense_4h_to_h.weight": "pytorch_model-00005-of-00009.bin",
228
+ "transformer.h.33.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00009.bin",
229
+ "transformer.h.33.self_attention.dense.weight": "pytorch_model-00005-of-00009.bin",
230
+ "transformer.h.33.self_attention.query_key_value.weight": "pytorch_model-00005-of-00009.bin",
231
+ "transformer.h.34.ln_attn.bias": "pytorch_model-00005-of-00009.bin",
232
+ "transformer.h.34.ln_attn.weight": "pytorch_model-00005-of-00009.bin",
233
+ "transformer.h.34.ln_mlp.bias": "pytorch_model-00005-of-00009.bin",
234
+ "transformer.h.34.ln_mlp.weight": "pytorch_model-00005-of-00009.bin",
235
+ "transformer.h.34.mlp.dense_4h_to_h.weight": "pytorch_model-00006-of-00009.bin",
236
+ "transformer.h.34.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00009.bin",
237
+ "transformer.h.34.self_attention.dense.weight": "pytorch_model-00005-of-00009.bin",
238
+ "transformer.h.34.self_attention.query_key_value.weight": "pytorch_model-00005-of-00009.bin",
239
+ "transformer.h.35.ln_attn.bias": "pytorch_model-00006-of-00009.bin",
240
+ "transformer.h.35.ln_attn.weight": "pytorch_model-00006-of-00009.bin",
241
+ "transformer.h.35.ln_mlp.bias": "pytorch_model-00006-of-00009.bin",
242
+ "transformer.h.35.ln_mlp.weight": "pytorch_model-00006-of-00009.bin",
243
+ "transformer.h.35.mlp.dense_4h_to_h.weight": "pytorch_model-00006-of-00009.bin",
244
+ "transformer.h.35.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00009.bin",
245
+ "transformer.h.35.self_attention.dense.weight": "pytorch_model-00006-of-00009.bin",
246
+ "transformer.h.35.self_attention.query_key_value.weight": "pytorch_model-00006-of-00009.bin",
247
+ "transformer.h.36.ln_attn.bias": "pytorch_model-00006-of-00009.bin",
248
+ "transformer.h.36.ln_attn.weight": "pytorch_model-00006-of-00009.bin",
249
+ "transformer.h.36.ln_mlp.bias": "pytorch_model-00006-of-00009.bin",
250
+ "transformer.h.36.ln_mlp.weight": "pytorch_model-00006-of-00009.bin",
251
+ "transformer.h.36.mlp.dense_4h_to_h.weight": "pytorch_model-00006-of-00009.bin",
252
+ "transformer.h.36.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00009.bin",
253
+ "transformer.h.36.self_attention.dense.weight": "pytorch_model-00006-of-00009.bin",
254
+ "transformer.h.36.self_attention.query_key_value.weight": "pytorch_model-00006-of-00009.bin",
255
+ "transformer.h.37.ln_attn.bias": "pytorch_model-00006-of-00009.bin",
256
+ "transformer.h.37.ln_attn.weight": "pytorch_model-00006-of-00009.bin",
257
+ "transformer.h.37.ln_mlp.bias": "pytorch_model-00006-of-00009.bin",
258
+ "transformer.h.37.ln_mlp.weight": "pytorch_model-00006-of-00009.bin",
259
+ "transformer.h.37.mlp.dense_4h_to_h.weight": "pytorch_model-00006-of-00009.bin",
260
+ "transformer.h.37.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00009.bin",
261
+ "transformer.h.37.self_attention.dense.weight": "pytorch_model-00006-of-00009.bin",
262
+ "transformer.h.37.self_attention.query_key_value.weight": "pytorch_model-00006-of-00009.bin",
263
+ "transformer.h.38.ln_attn.bias": "pytorch_model-00006-of-00009.bin",
264
+ "transformer.h.38.ln_attn.weight": "pytorch_model-00006-of-00009.bin",
265
+ "transformer.h.38.ln_mlp.bias": "pytorch_model-00006-of-00009.bin",
266
+ "transformer.h.38.ln_mlp.weight": "pytorch_model-00006-of-00009.bin",
267
+ "transformer.h.38.mlp.dense_4h_to_h.weight": "pytorch_model-00006-of-00009.bin",
268
+ "transformer.h.38.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00009.bin",
269
+ "transformer.h.38.self_attention.dense.weight": "pytorch_model-00006-of-00009.bin",
270
+ "transformer.h.38.self_attention.query_key_value.weight": "pytorch_model-00006-of-00009.bin",
271
+ "transformer.h.39.ln_attn.bias": "pytorch_model-00006-of-00009.bin",
272
+ "transformer.h.39.ln_attn.weight": "pytorch_model-00006-of-00009.bin",
273
+ "transformer.h.39.ln_mlp.bias": "pytorch_model-00006-of-00009.bin",
274
+ "transformer.h.39.ln_mlp.weight": "pytorch_model-00006-of-00009.bin",
275
+ "transformer.h.39.mlp.dense_4h_to_h.weight": "pytorch_model-00006-of-00009.bin",
276
+ "transformer.h.39.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00009.bin",
277
+ "transformer.h.39.self_attention.dense.weight": "pytorch_model-00006-of-00009.bin",
278
+ "transformer.h.39.self_attention.query_key_value.weight": "pytorch_model-00006-of-00009.bin",
279
+ "transformer.h.4.ln_attn.bias": "pytorch_model-00001-of-00009.bin",
280
+ "transformer.h.4.ln_attn.weight": "pytorch_model-00001-of-00009.bin",
281
+ "transformer.h.4.ln_mlp.bias": "pytorch_model-00001-of-00009.bin",
282
+ "transformer.h.4.ln_mlp.weight": "pytorch_model-00001-of-00009.bin",
283
+ "transformer.h.4.mlp.dense_4h_to_h.weight": "pytorch_model-00001-of-00009.bin",
284
+ "transformer.h.4.mlp.dense_h_to_4h.weight": "pytorch_model-00001-of-00009.bin",
285
+ "transformer.h.4.self_attention.dense.weight": "pytorch_model-00001-of-00009.bin",
286
+ "transformer.h.4.self_attention.query_key_value.weight": "pytorch_model-00001-of-00009.bin",
287
+ "transformer.h.40.ln_attn.bias": "pytorch_model-00006-of-00009.bin",
288
+ "transformer.h.40.ln_attn.weight": "pytorch_model-00006-of-00009.bin",
289
+ "transformer.h.40.ln_mlp.bias": "pytorch_model-00006-of-00009.bin",
290
+ "transformer.h.40.ln_mlp.weight": "pytorch_model-00006-of-00009.bin",
291
+ "transformer.h.40.mlp.dense_4h_to_h.weight": "pytorch_model-00006-of-00009.bin",
292
+ "transformer.h.40.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00009.bin",
293
+ "transformer.h.40.self_attention.dense.weight": "pytorch_model-00006-of-00009.bin",
294
+ "transformer.h.40.self_attention.query_key_value.weight": "pytorch_model-00006-of-00009.bin",
295
+ "transformer.h.41.ln_attn.bias": "pytorch_model-00006-of-00009.bin",
296
+ "transformer.h.41.ln_attn.weight": "pytorch_model-00006-of-00009.bin",
297
+ "transformer.h.41.ln_mlp.bias": "pytorch_model-00006-of-00009.bin",
298
+ "transformer.h.41.ln_mlp.weight": "pytorch_model-00006-of-00009.bin",
299
+ "transformer.h.41.mlp.dense_4h_to_h.weight": "pytorch_model-00007-of-00009.bin",
300
+ "transformer.h.41.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00009.bin",
301
+ "transformer.h.41.self_attention.dense.weight": "pytorch_model-00006-of-00009.bin",
302
+ "transformer.h.41.self_attention.query_key_value.weight": "pytorch_model-00006-of-00009.bin",
303
+ "transformer.h.42.ln_attn.bias": "pytorch_model-00007-of-00009.bin",
304
+ "transformer.h.42.ln_attn.weight": "pytorch_model-00007-of-00009.bin",
305
+ "transformer.h.42.ln_mlp.bias": "pytorch_model-00007-of-00009.bin",
306
+ "transformer.h.42.ln_mlp.weight": "pytorch_model-00007-of-00009.bin",
307
+ "transformer.h.42.mlp.dense_4h_to_h.weight": "pytorch_model-00007-of-00009.bin",
308
+ "transformer.h.42.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00009.bin",
309
+ "transformer.h.42.self_attention.dense.weight": "pytorch_model-00007-of-00009.bin",
310
+ "transformer.h.42.self_attention.query_key_value.weight": "pytorch_model-00007-of-00009.bin",
311
+ "transformer.h.43.ln_attn.bias": "pytorch_model-00007-of-00009.bin",
312
+ "transformer.h.43.ln_attn.weight": "pytorch_model-00007-of-00009.bin",
313
+ "transformer.h.43.ln_mlp.bias": "pytorch_model-00007-of-00009.bin",
314
+ "transformer.h.43.ln_mlp.weight": "pytorch_model-00007-of-00009.bin",
315
+ "transformer.h.43.mlp.dense_4h_to_h.weight": "pytorch_model-00007-of-00009.bin",
316
+ "transformer.h.43.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00009.bin",
317
+ "transformer.h.43.self_attention.dense.weight": "pytorch_model-00007-of-00009.bin",
318
+ "transformer.h.43.self_attention.query_key_value.weight": "pytorch_model-00007-of-00009.bin",
319
+ "transformer.h.44.ln_attn.bias": "pytorch_model-00007-of-00009.bin",
320
+ "transformer.h.44.ln_attn.weight": "pytorch_model-00007-of-00009.bin",
321
+ "transformer.h.44.ln_mlp.bias": "pytorch_model-00007-of-00009.bin",
322
+ "transformer.h.44.ln_mlp.weight": "pytorch_model-00007-of-00009.bin",
323
+ "transformer.h.44.mlp.dense_4h_to_h.weight": "pytorch_model-00007-of-00009.bin",
324
+ "transformer.h.44.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00009.bin",
325
+ "transformer.h.44.self_attention.dense.weight": "pytorch_model-00007-of-00009.bin",
326
+ "transformer.h.44.self_attention.query_key_value.weight": "pytorch_model-00007-of-00009.bin",
327
+ "transformer.h.45.ln_attn.bias": "pytorch_model-00007-of-00009.bin",
328
+ "transformer.h.45.ln_attn.weight": "pytorch_model-00007-of-00009.bin",
329
+ "transformer.h.45.ln_mlp.bias": "pytorch_model-00007-of-00009.bin",
330
+ "transformer.h.45.ln_mlp.weight": "pytorch_model-00007-of-00009.bin",
331
+ "transformer.h.45.mlp.dense_4h_to_h.weight": "pytorch_model-00007-of-00009.bin",
332
+ "transformer.h.45.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00009.bin",
333
+ "transformer.h.45.self_attention.dense.weight": "pytorch_model-00007-of-00009.bin",
334
+ "transformer.h.45.self_attention.query_key_value.weight": "pytorch_model-00007-of-00009.bin",
335
+ "transformer.h.46.ln_attn.bias": "pytorch_model-00007-of-00009.bin",
336
+ "transformer.h.46.ln_attn.weight": "pytorch_model-00007-of-00009.bin",
337
+ "transformer.h.46.ln_mlp.bias": "pytorch_model-00007-of-00009.bin",
338
+ "transformer.h.46.ln_mlp.weight": "pytorch_model-00007-of-00009.bin",
339
+ "transformer.h.46.mlp.dense_4h_to_h.weight": "pytorch_model-00007-of-00009.bin",
340
+ "transformer.h.46.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00009.bin",
341
+ "transformer.h.46.self_attention.dense.weight": "pytorch_model-00007-of-00009.bin",
342
+ "transformer.h.46.self_attention.query_key_value.weight": "pytorch_model-00007-of-00009.bin",
343
+ "transformer.h.47.ln_attn.bias": "pytorch_model-00007-of-00009.bin",
344
+ "transformer.h.47.ln_attn.weight": "pytorch_model-00007-of-00009.bin",
345
+ "transformer.h.47.ln_mlp.bias": "pytorch_model-00007-of-00009.bin",
346
+ "transformer.h.47.ln_mlp.weight": "pytorch_model-00007-of-00009.bin",
347
+ "transformer.h.47.mlp.dense_4h_to_h.weight": "pytorch_model-00007-of-00009.bin",
348
+ "transformer.h.47.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00009.bin",
349
+ "transformer.h.47.self_attention.dense.weight": "pytorch_model-00007-of-00009.bin",
350
+ "transformer.h.47.self_attention.query_key_value.weight": "pytorch_model-00007-of-00009.bin",
351
+ "transformer.h.48.ln_attn.bias": "pytorch_model-00007-of-00009.bin",
352
+ "transformer.h.48.ln_attn.weight": "pytorch_model-00007-of-00009.bin",
353
+ "transformer.h.48.ln_mlp.bias": "pytorch_model-00007-of-00009.bin",
354
+ "transformer.h.48.ln_mlp.weight": "pytorch_model-00007-of-00009.bin",
355
+ "transformer.h.48.mlp.dense_4h_to_h.weight": "pytorch_model-00008-of-00009.bin",
356
+ "transformer.h.48.mlp.dense_h_to_4h.weight": "pytorch_model-00008-of-00009.bin",
357
+ "transformer.h.48.self_attention.dense.weight": "pytorch_model-00007-of-00009.bin",
358
+ "transformer.h.48.self_attention.query_key_value.weight": "pytorch_model-00007-of-00009.bin",
359
+ "transformer.h.49.ln_attn.bias": "pytorch_model-00008-of-00009.bin",
360
+ "transformer.h.49.ln_attn.weight": "pytorch_model-00008-of-00009.bin",
361
+ "transformer.h.49.ln_mlp.bias": "pytorch_model-00008-of-00009.bin",
362
+ "transformer.h.49.ln_mlp.weight": "pytorch_model-00008-of-00009.bin",
363
+ "transformer.h.49.mlp.dense_4h_to_h.weight": "pytorch_model-00008-of-00009.bin",
364
+ "transformer.h.49.mlp.dense_h_to_4h.weight": "pytorch_model-00008-of-00009.bin",
365
+ "transformer.h.49.self_attention.dense.weight": "pytorch_model-00008-of-00009.bin",
366
+ "transformer.h.49.self_attention.query_key_value.weight": "pytorch_model-00008-of-00009.bin",
367
+ "transformer.h.5.ln_attn.bias": "pytorch_model-00001-of-00009.bin",
368
+ "transformer.h.5.ln_attn.weight": "pytorch_model-00001-of-00009.bin",
369
+ "transformer.h.5.ln_mlp.bias": "pytorch_model-00001-of-00009.bin",
370
+ "transformer.h.5.ln_mlp.weight": "pytorch_model-00001-of-00009.bin",
371
+ "transformer.h.5.mlp.dense_4h_to_h.weight": "pytorch_model-00001-of-00009.bin",
372
+ "transformer.h.5.mlp.dense_h_to_4h.weight": "pytorch_model-00001-of-00009.bin",
373
+ "transformer.h.5.self_attention.dense.weight": "pytorch_model-00001-of-00009.bin",
374
+ "transformer.h.5.self_attention.query_key_value.weight": "pytorch_model-00001-of-00009.bin",
375
+ "transformer.h.50.ln_attn.bias": "pytorch_model-00008-of-00009.bin",
376
+ "transformer.h.50.ln_attn.weight": "pytorch_model-00008-of-00009.bin",
377
+ "transformer.h.50.ln_mlp.bias": "pytorch_model-00008-of-00009.bin",
378
+ "transformer.h.50.ln_mlp.weight": "pytorch_model-00008-of-00009.bin",
379
+ "transformer.h.50.mlp.dense_4h_to_h.weight": "pytorch_model-00008-of-00009.bin",
380
+ "transformer.h.50.mlp.dense_h_to_4h.weight": "pytorch_model-00008-of-00009.bin",
381
+ "transformer.h.50.self_attention.dense.weight": "pytorch_model-00008-of-00009.bin",
382
+ "transformer.h.50.self_attention.query_key_value.weight": "pytorch_model-00008-of-00009.bin",
383
+ "transformer.h.51.ln_attn.bias": "pytorch_model-00008-of-00009.bin",
384
+ "transformer.h.51.ln_attn.weight": "pytorch_model-00008-of-00009.bin",
385
+ "transformer.h.51.ln_mlp.bias": "pytorch_model-00008-of-00009.bin",
386
+ "transformer.h.51.ln_mlp.weight": "pytorch_model-00008-of-00009.bin",
387
+ "transformer.h.51.mlp.dense_4h_to_h.weight": "pytorch_model-00008-of-00009.bin",
388
+ "transformer.h.51.mlp.dense_h_to_4h.weight": "pytorch_model-00008-of-00009.bin",
389
+ "transformer.h.51.self_attention.dense.weight": "pytorch_model-00008-of-00009.bin",
390
+ "transformer.h.51.self_attention.query_key_value.weight": "pytorch_model-00008-of-00009.bin",
391
+ "transformer.h.52.ln_attn.bias": "pytorch_model-00008-of-00009.bin",
392
+ "transformer.h.52.ln_attn.weight": "pytorch_model-00008-of-00009.bin",
393
+ "transformer.h.52.ln_mlp.bias": "pytorch_model-00008-of-00009.bin",
394
+ "transformer.h.52.ln_mlp.weight": "pytorch_model-00008-of-00009.bin",
395
+ "transformer.h.52.mlp.dense_4h_to_h.weight": "pytorch_model-00008-of-00009.bin",
396
+ "transformer.h.52.mlp.dense_h_to_4h.weight": "pytorch_model-00008-of-00009.bin",
397
+ "transformer.h.52.self_attention.dense.weight": "pytorch_model-00008-of-00009.bin",
398
+ "transformer.h.52.self_attention.query_key_value.weight": "pytorch_model-00008-of-00009.bin",
399
+ "transformer.h.53.ln_attn.bias": "pytorch_model-00008-of-00009.bin",
400
+ "transformer.h.53.ln_attn.weight": "pytorch_model-00008-of-00009.bin",
401
+ "transformer.h.53.ln_mlp.bias": "pytorch_model-00008-of-00009.bin",
402
+ "transformer.h.53.ln_mlp.weight": "pytorch_model-00008-of-00009.bin",
403
+ "transformer.h.53.mlp.dense_4h_to_h.weight": "pytorch_model-00008-of-00009.bin",
404
+ "transformer.h.53.mlp.dense_h_to_4h.weight": "pytorch_model-00008-of-00009.bin",
405
+ "transformer.h.53.self_attention.dense.weight": "pytorch_model-00008-of-00009.bin",
406
+ "transformer.h.53.self_attention.query_key_value.weight": "pytorch_model-00008-of-00009.bin",
407
+ "transformer.h.54.ln_attn.bias": "pytorch_model-00008-of-00009.bin",
408
+ "transformer.h.54.ln_attn.weight": "pytorch_model-00008-of-00009.bin",
409
+ "transformer.h.54.ln_mlp.bias": "pytorch_model-00008-of-00009.bin",
410
+ "transformer.h.54.ln_mlp.weight": "pytorch_model-00008-of-00009.bin",
411
+ "transformer.h.54.mlp.dense_4h_to_h.weight": "pytorch_model-00008-of-00009.bin",
412
+ "transformer.h.54.mlp.dense_h_to_4h.weight": "pytorch_model-00008-of-00009.bin",
413
+ "transformer.h.54.self_attention.dense.weight": "pytorch_model-00008-of-00009.bin",
414
+ "transformer.h.54.self_attention.query_key_value.weight": "pytorch_model-00008-of-00009.bin",
415
+ "transformer.h.55.ln_attn.bias": "pytorch_model-00008-of-00009.bin",
416
+ "transformer.h.55.ln_attn.weight": "pytorch_model-00008-of-00009.bin",
417
+ "transformer.h.55.ln_mlp.bias": "pytorch_model-00008-of-00009.bin",
418
+ "transformer.h.55.ln_mlp.weight": "pytorch_model-00008-of-00009.bin",
419
+ "transformer.h.55.mlp.dense_4h_to_h.weight": "pytorch_model-00009-of-00009.bin",
420
+ "transformer.h.55.mlp.dense_h_to_4h.weight": "pytorch_model-00009-of-00009.bin",
421
+ "transformer.h.55.self_attention.dense.weight": "pytorch_model-00008-of-00009.bin",
422
+ "transformer.h.55.self_attention.query_key_value.weight": "pytorch_model-00008-of-00009.bin",
423
+ "transformer.h.56.ln_attn.bias": "pytorch_model-00009-of-00009.bin",
424
+ "transformer.h.56.ln_attn.weight": "pytorch_model-00009-of-00009.bin",
425
+ "transformer.h.56.ln_mlp.bias": "pytorch_model-00009-of-00009.bin",
426
+ "transformer.h.56.ln_mlp.weight": "pytorch_model-00009-of-00009.bin",
427
+ "transformer.h.56.mlp.dense_4h_to_h.weight": "pytorch_model-00009-of-00009.bin",
428
+ "transformer.h.56.mlp.dense_h_to_4h.weight": "pytorch_model-00009-of-00009.bin",
429
+ "transformer.h.56.self_attention.dense.weight": "pytorch_model-00009-of-00009.bin",
430
+ "transformer.h.56.self_attention.query_key_value.weight": "pytorch_model-00009-of-00009.bin",
431
+ "transformer.h.57.ln_attn.bias": "pytorch_model-00009-of-00009.bin",
432
+ "transformer.h.57.ln_attn.weight": "pytorch_model-00009-of-00009.bin",
433
+ "transformer.h.57.ln_mlp.bias": "pytorch_model-00009-of-00009.bin",
434
+ "transformer.h.57.ln_mlp.weight": "pytorch_model-00009-of-00009.bin",
435
+ "transformer.h.57.mlp.dense_4h_to_h.weight": "pytorch_model-00009-of-00009.bin",
436
+ "transformer.h.57.mlp.dense_h_to_4h.weight": "pytorch_model-00009-of-00009.bin",
437
+ "transformer.h.57.self_attention.dense.weight": "pytorch_model-00009-of-00009.bin",
438
+ "transformer.h.57.self_attention.query_key_value.weight": "pytorch_model-00009-of-00009.bin",
439
+ "transformer.h.58.ln_attn.bias": "pytorch_model-00009-of-00009.bin",
440
+ "transformer.h.58.ln_attn.weight": "pytorch_model-00009-of-00009.bin",
441
+ "transformer.h.58.ln_mlp.bias": "pytorch_model-00009-of-00009.bin",
442
+ "transformer.h.58.ln_mlp.weight": "pytorch_model-00009-of-00009.bin",
443
+ "transformer.h.58.mlp.dense_4h_to_h.weight": "pytorch_model-00009-of-00009.bin",
444
+ "transformer.h.58.mlp.dense_h_to_4h.weight": "pytorch_model-00009-of-00009.bin",
445
+ "transformer.h.58.self_attention.dense.weight": "pytorch_model-00009-of-00009.bin",
446
+ "transformer.h.58.self_attention.query_key_value.weight": "pytorch_model-00009-of-00009.bin",
447
+ "transformer.h.59.ln_attn.bias": "pytorch_model-00009-of-00009.bin",
448
+ "transformer.h.59.ln_attn.weight": "pytorch_model-00009-of-00009.bin",
449
+ "transformer.h.59.ln_mlp.bias": "pytorch_model-00009-of-00009.bin",
450
+ "transformer.h.59.ln_mlp.weight": "pytorch_model-00009-of-00009.bin",
451
+ "transformer.h.59.mlp.dense_4h_to_h.weight": "pytorch_model-00009-of-00009.bin",
452
+ "transformer.h.59.mlp.dense_h_to_4h.weight": "pytorch_model-00009-of-00009.bin",
453
+ "transformer.h.59.self_attention.dense.weight": "pytorch_model-00009-of-00009.bin",
454
+ "transformer.h.59.self_attention.query_key_value.weight": "pytorch_model-00009-of-00009.bin",
455
+ "transformer.h.6.ln_attn.bias": "pytorch_model-00001-of-00009.bin",
456
+ "transformer.h.6.ln_attn.weight": "pytorch_model-00001-of-00009.bin",
457
+ "transformer.h.6.ln_mlp.bias": "pytorch_model-00001-of-00009.bin",
458
+ "transformer.h.6.ln_mlp.weight": "pytorch_model-00001-of-00009.bin",
459
+ "transformer.h.6.mlp.dense_4h_to_h.weight": "pytorch_model-00002-of-00009.bin",
460
+ "transformer.h.6.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00009.bin",
461
+ "transformer.h.6.self_attention.dense.weight": "pytorch_model-00001-of-00009.bin",
462
+ "transformer.h.6.self_attention.query_key_value.weight": "pytorch_model-00001-of-00009.bin",
463
+ "transformer.h.7.ln_attn.bias": "pytorch_model-00002-of-00009.bin",
464
+ "transformer.h.7.ln_attn.weight": "pytorch_model-00002-of-00009.bin",
465
+ "transformer.h.7.ln_mlp.bias": "pytorch_model-00002-of-00009.bin",
466
+ "transformer.h.7.ln_mlp.weight": "pytorch_model-00002-of-00009.bin",
467
+ "transformer.h.7.mlp.dense_4h_to_h.weight": "pytorch_model-00002-of-00009.bin",
468
+ "transformer.h.7.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00009.bin",
469
+ "transformer.h.7.self_attention.dense.weight": "pytorch_model-00002-of-00009.bin",
470
+ "transformer.h.7.self_attention.query_key_value.weight": "pytorch_model-00002-of-00009.bin",
471
+ "transformer.h.8.ln_attn.bias": "pytorch_model-00002-of-00009.bin",
472
+ "transformer.h.8.ln_attn.weight": "pytorch_model-00002-of-00009.bin",
473
+ "transformer.h.8.ln_mlp.bias": "pytorch_model-00002-of-00009.bin",
474
+ "transformer.h.8.ln_mlp.weight": "pytorch_model-00002-of-00009.bin",
475
+ "transformer.h.8.mlp.dense_4h_to_h.weight": "pytorch_model-00002-of-00009.bin",
476
+ "transformer.h.8.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00009.bin",
477
+ "transformer.h.8.self_attention.dense.weight": "pytorch_model-00002-of-00009.bin",
478
+ "transformer.h.8.self_attention.query_key_value.weight": "pytorch_model-00002-of-00009.bin",
479
+ "transformer.h.9.ln_attn.bias": "pytorch_model-00002-of-00009.bin",
480
+ "transformer.h.9.ln_attn.weight": "pytorch_model-00002-of-00009.bin",
481
+ "transformer.h.9.ln_mlp.bias": "pytorch_model-00002-of-00009.bin",
482
+ "transformer.h.9.ln_mlp.weight": "pytorch_model-00002-of-00009.bin",
483
+ "transformer.h.9.mlp.dense_4h_to_h.weight": "pytorch_model-00002-of-00009.bin",
484
+ "transformer.h.9.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00009.bin",
485
+ "transformer.h.9.self_attention.dense.weight": "pytorch_model-00002-of-00009.bin",
486
+ "transformer.h.9.self_attention.query_key_value.weight": "pytorch_model-00002-of-00009.bin",
487
+ "transformer.ln_f.bias": "pytorch_model-00009-of-00009.bin",
488
+ "transformer.ln_f.weight": "pytorch_model-00009-of-00009.bin",
489
+ "transformer.word_embeddings.weight": "pytorch_model-00001-of-00009.bin"
490
+ }
491
+ }