sunzeyeah commited on
Commit
367c0d8
1 Parent(s): ae40ea2
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/root/autodl-tmp//Data/models/pangu-2.6B",
3
+ "activation_function": "gelu",
4
+ "architectures": [
5
+ "GPTPanguForCausalLM"
6
+ ],
7
+ "attn_pdrop": 0.1,
8
+ "auto_map": {
9
+ "AutoConfig": "configuration_gptpangu.GPTPanguConfig",
10
+ "AutoModelForCausalLM": "modeling_gptpangu.GPTPanguForCausalLM",
11
+ "AutoTokenizer": [
12
+ "tokenization_gptpangu.GPTPanguTokenizer",
13
+ null
14
+ ]
15
+ },
16
+ "bos_token_id": 9,
17
+ "embd_pdrop": 0.1,
18
+ "end_token_id": 9,
19
+ "eos_token_id": 9,
20
+ "hidden_size": 2560,
21
+ "initializer_range": 0.02,
22
+ "intermediate_size": null,
23
+ "layer_norm_epsilon": 1e-05,
24
+ "max_position_embeddings": 1024,
25
+ "model_type": "gpt_pangu",
26
+ "num_heads": 32,
27
+ "num_layers": 32,
28
+ "pad_token_id": 6,
29
+ "resid_pdrop": 0.1,
30
+ "scale_attn_weights": true,
31
+ "summary_activation": null,
32
+ "summary_first_dropout": 0.1,
33
+ "summary_proj_to_labels": true,
34
+ "summary_type": "cls_index",
35
+ "summary_use_proj": true,
36
+ "tokenizer_class": "GPTPanguTokenizer",
37
+ "torch_dtype": "float32",
38
+ "transformers_version": "4.26.1",
39
+ "use_cache": false,
40
+ "vocab_size": 40000
41
+ }
configuration_gptpangu.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers.configuration_utils import PretrainedConfig
2
+
3
+
4
+ class GPTPanguConfig(PretrainedConfig):
5
+ model_type = "gpt_pangu"
6
+ keys_to_ignore_at_inference = ["past_key_values"]
7
+
8
+ def __init__(
9
+ self,
10
+ vocab_size=40000,
11
+ max_position_embeddings=1024,
12
+ hidden_size=2560,
13
+ intermediate_size=None,
14
+ num_layers=32,
15
+ num_heads=32,
16
+ activation_function="gelu",
17
+ resid_pdrop=0.1,
18
+ embd_pdrop=0.1,
19
+ attn_pdrop=0.1,
20
+ layer_norm_epsilon=1e-5,
21
+ scale_attn_weights=True,
22
+ initializer_range=0.02,
23
+ summary_type="cls_index",
24
+ summary_use_proj=True,
25
+ summary_activation=None,
26
+ summary_proj_to_labels=True,
27
+ summary_first_dropout=0.1,
28
+ use_cache=True,
29
+ bos_token_id=9,
30
+ eos_token_id=9,
31
+ **kwargs,
32
+ ):
33
+ self.vocab_size = vocab_size
34
+ self.max_position_embeddings = max_position_embeddings
35
+ self.hidden_size = hidden_size
36
+ self.intermediate_size = intermediate_size
37
+ self.num_layers = num_layers
38
+ self.num_heads = num_heads
39
+ self.activation_function = activation_function
40
+ self.resid_pdrop = resid_pdrop
41
+ self.embd_pdrop = embd_pdrop
42
+ self.attn_pdrop = attn_pdrop
43
+ self.layer_norm_epsilon = layer_norm_epsilon
44
+ self.scale_attn_weights = scale_attn_weights
45
+ self.initializer_range = initializer_range
46
+ self.summary_type = summary_type
47
+ self.summary_use_proj = summary_use_proj
48
+ self.summary_activation = summary_activation
49
+ self.summary_first_dropout = summary_first_dropout
50
+ self.summary_proj_to_labels = summary_proj_to_labels
51
+ self.use_cache = use_cache
52
+
53
+ self.bos_token_id = bos_token_id
54
+ self.eos_token_id = eos_token_id
55
+
56
+ super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 9,
4
+ "eos_token_id": 9,
5
+ "transformers_version": "4.26.1",
6
+ "use_cache": false
7
+ }
modeling_gptpangu.py ADDED
@@ -0,0 +1,549 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """PyTorch PanguAlpha GPT2 Model"""
2
+ # from .configuration_gptpangu import GPTPanguConfig
3
+
4
+ from typing import Tuple
5
+ import math
6
+
7
+ import torch
8
+ from torch import nn
9
+
10
+ from transformers.activations import ACT2FN
11
+ from transformers.modeling_utils import PreTrainedModel
12
+ from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
13
+
14
+ from transformers.utils import logging
15
+
16
+ logger = logging.get_logger(__name__)
17
+
18
+
19
+ class GPTPanguAttention(nn.Module):
20
+ def __init__(self, config):
21
+ super().__init__()
22
+
23
+ max_positions = config.max_position_embeddings
24
+ self.register_buffer(
25
+ "bias",
26
+ torch.tril(torch.ones((max_positions, max_positions), dtype=torch.uint8)).view(
27
+ 1, 1, max_positions, max_positions
28
+ ),
29
+ )
30
+ self.register_buffer("masked_bias", torch.tensor(-1e4))
31
+
32
+ self.embed_dim = config.hidden_size
33
+ self.num_heads = config.num_heads
34
+ self.head_dim = self.embed_dim // self.num_heads
35
+ if self.head_dim * self.num_heads != self.embed_dim:
36
+ raise ValueError(
37
+ f"embed_dim must be divisible by num_heads (got `embed_dim`: {self.embed_dim} and `num_heads`: {self.num_heads})."
38
+ )
39
+
40
+ self.scale_attn_weights = config.scale_attn_weights
41
+
42
+ self.k_proj = nn.Linear(self.embed_dim, self.embed_dim, bias=True)
43
+ self.v_proj = nn.Linear(self.embed_dim, self.embed_dim, bias=True)
44
+ self.q_proj = nn.Linear(self.embed_dim, self.embed_dim, bias=True)
45
+ self.c_proj = nn.Linear(self.embed_dim, self.embed_dim, bias=True)
46
+
47
+ self.attn_dropout = nn.Dropout(config.attn_pdrop)
48
+ self.resid_dropout = nn.Dropout(config.resid_pdrop)
49
+
50
+
51
+ def _attn(self, query, key, value, attention_mask=None, head_mask=None):
52
+ attn_weights = torch.matmul(query, key.transpose(-1, -2))
53
+
54
+ if self.scale_attn_weights:
55
+ attn_weights = attn_weights / (float(value.size(-1)) ** 0.5)
56
+
57
+ query_length, key_length = query.size(-2), key.size(-2)
58
+ causal_mask = self.bias[:, :, key_length - query_length : key_length, :key_length].bool()
59
+ attn_weights = torch.where(causal_mask, attn_weights, self.masked_bias.to(attn_weights.dtype))
60
+
61
+ if attention_mask is not None:
62
+ # Apply the attention mask
63
+ attn_weights = attn_weights + attention_mask
64
+
65
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1)
66
+
67
+ # Downcast (if necessary) back to V's dtype (if in mixed-precision) -- No-Op otherwise
68
+ attn_weights = attn_weights.type(value.dtype)
69
+ attn_weights = self.attn_dropout(attn_weights)
70
+
71
+ # Mask heads if we want to
72
+ if head_mask is not None:
73
+ attn_weights = attn_weights * head_mask
74
+
75
+ attn_output = torch.matmul(attn_weights, value)
76
+
77
+ return attn_output, attn_weights
78
+
79
+ def _split_heads(self, tensor, num_heads, attn_head_size):
80
+ """
81
+ Splits hidden_size dim into attn_head_size and num_heads
82
+ """
83
+ new_shape = tensor.size()[:-1] + (num_heads, attn_head_size)
84
+ tensor = tensor.view(*new_shape)
85
+ return tensor.permute(0, 2, 1, 3) # (batch, head, seq_length, head_features)
86
+
87
+ def _merge_heads(self, tensor, num_heads, attn_head_size):
88
+ """
89
+ Merges attn_head_size dim and num_attn_heads dim into hidden_size
90
+ """
91
+ tensor = tensor.permute(0, 2, 1, 3).contiguous()
92
+ new_shape = tensor.size()[:-2] + (num_heads * attn_head_size,)
93
+ return tensor.view(new_shape)
94
+
95
+ def forward(
96
+ self,
97
+ hidden_states,
98
+ layer_past=None,
99
+ attention_mask=None,
100
+ head_mask=None,
101
+ custom_query=None,
102
+ use_cache=False,
103
+ output_attentions=False,
104
+ ):
105
+ query = self.q_proj(custom_query) if custom_query is not None else self.q_proj(hidden_states)
106
+ key = self.k_proj(hidden_states)
107
+ value = self.v_proj(hidden_states)
108
+
109
+ query = self._split_heads(query, self.num_heads, self.head_dim)
110
+ key = self._split_heads(key, self.num_heads, self.head_dim)
111
+ value = self._split_heads(value, self.num_heads, self.head_dim)
112
+
113
+ if layer_past is not None:
114
+ past_key, past_value = layer_past
115
+ key = torch.cat((past_key, key), dim=-2)
116
+ value = torch.cat((past_value, value), dim=-2)
117
+
118
+ if use_cache is True:
119
+ present = (key, value)
120
+ else:
121
+ present = None
122
+
123
+ attn_output, attn_weights = self._attn(query, key, value, attention_mask, head_mask)
124
+
125
+ attn_output = self._merge_heads(attn_output, self.num_heads, self.head_dim)
126
+ attn_output = self.c_proj(attn_output)
127
+ attn_output = self.resid_dropout(attn_output)
128
+
129
+ outputs = (attn_output, present)
130
+ if output_attentions:
131
+ outputs += (attn_weights,)
132
+
133
+ return outputs # a, present, (attentions)
134
+
135
+
136
+ class GPTPanguMLP(nn.Module):
137
+ def __init__(self, intermediate_size, config): # in MLP: intermediate_size= 4 * hidden_size
138
+ super().__init__()
139
+ embed_dim = config.hidden_size
140
+ self.c_fc = nn.Linear(embed_dim, intermediate_size)
141
+ self.c_proj = nn.Linear(intermediate_size, embed_dim)
142
+ self.act = ACT2FN[config.activation_function]
143
+ self.dropout = nn.Dropout(config.resid_pdrop)
144
+
145
+ def forward(self, hidden_states):
146
+ hidden_states = self.c_fc(hidden_states)
147
+ hidden_states = self.act(hidden_states)
148
+ hidden_states = self.c_proj(hidden_states)
149
+ hidden_states = self.dropout(hidden_states)
150
+ return hidden_states
151
+
152
+
153
+ class GPTPanguBlock(nn.Module):
154
+ def __init__(self, config):
155
+ super().__init__()
156
+ hidden_size = config.hidden_size
157
+ inner_dim = config.intermediate_size if config.intermediate_size is not None else 4 * hidden_size
158
+
159
+ self.ln_1 = nn.LayerNorm(hidden_size, eps=config.layer_norm_epsilon)
160
+ self.attn = GPTPanguAttention(config)
161
+ self.ln_2 = nn.LayerNorm(hidden_size, eps=config.layer_norm_epsilon)
162
+ self.mlp = GPTPanguMLP(inner_dim, config)
163
+
164
+ def forward(
165
+ self,
166
+ hidden_states,
167
+ layer_past=None,
168
+ attention_mask=None,
169
+ head_mask=None,
170
+ custom_query=None,
171
+ use_cache=False,
172
+ output_attentions=False,
173
+ ):
174
+ residual = hidden_states
175
+ hidden_states = self.ln_1(hidden_states)
176
+ attn_outputs = self.attn(
177
+ hidden_states,
178
+ layer_past=layer_past,
179
+ attention_mask=attention_mask,
180
+ head_mask=head_mask,
181
+ custom_query=custom_query,
182
+ use_cache=use_cache,
183
+ output_attentions=output_attentions,
184
+ )
185
+ attn_output = attn_outputs[0] # output_attn: a, present, (attentions)
186
+ outputs = attn_outputs[1:]
187
+ # residual connection
188
+ hidden_states = attn_output + residual
189
+
190
+ residual = hidden_states
191
+ hidden_states = self.ln_2(hidden_states)
192
+ feed_forward_hidden_states = self.mlp(hidden_states)
193
+ # residual connection
194
+ hidden_states = residual + feed_forward_hidden_states
195
+
196
+ if use_cache:
197
+ outputs = (hidden_states,) + outputs
198
+ else:
199
+ outputs = (hidden_states,) + outputs[1:]
200
+
201
+ return outputs # hidden_states, present, (attentions, cross_attentions)
202
+
203
+
204
+ class GPTPanguPreTrainedModel(PreTrainedModel):
205
+ """
206
+ An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
207
+ models.
208
+ """
209
+
210
+ # config_class = GPTPanguConfig
211
+ base_model_prefix = "transformer"
212
+ supports_gradient_checkpointing = True
213
+
214
+ def __init__(self, *inputs, **kwargs):
215
+ super().__init__(*inputs, **kwargs)
216
+
217
+ def _init_weights(self, module):
218
+ """Initialize the weights."""
219
+ if isinstance(module, (nn.Linear,)):
220
+ # Slightly different from the TF version which uses truncated_normal for initialization
221
+ # cf https://github.com/pytorch/pytorch/pull/5617
222
+ module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
223
+ if module.bias is not None:
224
+ module.bias.data.zero_()
225
+ elif isinstance(module, nn.Embedding):
226
+ module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
227
+ if module.padding_idx is not None:
228
+ module.weight.data[module.padding_idx].zero_()
229
+ elif isinstance(module, nn.LayerNorm):
230
+ module.bias.data.zero_()
231
+ module.weight.data.fill_(1.0)
232
+
233
+ # Reinitialize selected weights subject to the OpenAI GPT-2 Paper Scheme:
234
+ # > A modified initialization which accounts for the accumulation on the residual path with model depth. Scale
235
+ # > the weights of residual layers at initialization by a factor of 1/√N where N is the # of residual layers.
236
+ # > -- GPT-2 :: https://openai.com/blog/better-language-models/
237
+ #
238
+ # Reference (Megatron-LM): https://github.com/NVIDIA/Megatron-LM/blob/main/megatron/model/gpt_model.py
239
+ for name, p in module.named_parameters():
240
+ if "c_proj" in name and "weight" in name:
241
+ # Special Scaled Initialization --> There are 2 Layer Norms per Transformer Block
242
+ p.data.normal_(mean=0.0, std=(self.config.initializer_range / math.sqrt(2 * self.config.num_layers)))
243
+
244
+ def _set_gradient_checkpointing(self, module, value=False):
245
+ if isinstance(module, GPTPanguModel):
246
+ module.gradient_checkpointing = value
247
+
248
+
249
+ class GPTPanguModel(GPTPanguPreTrainedModel):
250
+ def __init__(self, config):
251
+ super().__init__(config)
252
+
253
+ self.embed_dim = config.hidden_size
254
+
255
+ self.wte = nn.Embedding(config.vocab_size, self.embed_dim)
256
+ self.wpe = nn.Embedding(config.max_position_embeddings, self.embed_dim)
257
+ self.wqe = nn.Embedding(config.max_position_embeddings, self.embed_dim)
258
+
259
+ self.drop = nn.Dropout(config.embd_pdrop)
260
+ self.h = nn.ModuleList([GPTPanguBlock(config) for _ in range(config.num_layers)])
261
+ self.ln_f = nn.LayerNorm(self.embed_dim, eps=config.layer_norm_epsilon)
262
+
263
+ self.gradient_checkpointing = False
264
+ # Initialize weights and apply final processing
265
+ self.post_init()
266
+
267
+ def get_input_embeddings(self):
268
+ return self.wte
269
+
270
+ def set_input_embeddings(self, new_embeddings):
271
+ self.wte = new_embeddings
272
+
273
+ def forward(
274
+ self,
275
+ input_ids=None,
276
+ past_key_values=None,
277
+ attention_mask=None,
278
+ token_type_ids=None,
279
+ position_ids=None,
280
+ head_mask=None,
281
+ inputs_embeds=None,
282
+ use_cache=None,
283
+ output_attentions=None,
284
+ output_hidden_states=None,
285
+ return_dict=None,
286
+ ):
287
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
288
+ output_hidden_states = (
289
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
290
+ )
291
+ use_cache = use_cache if use_cache is not None else self.config.use_cache
292
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
293
+
294
+ if input_ids is not None and inputs_embeds is not None:
295
+ raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
296
+ elif input_ids is not None:
297
+ input_shape = input_ids.size()
298
+ input_ids = input_ids.view(-1, input_shape[-1])
299
+ batch_size = input_ids.shape[0]
300
+ elif inputs_embeds is not None:
301
+ input_shape = inputs_embeds.size()[:-1]
302
+ batch_size = inputs_embeds.shape[0]
303
+ else:
304
+ raise ValueError("You have to specify either input_ids or inputs_embeds")
305
+
306
+ device = input_ids.device if input_ids is not None else inputs_embeds.device
307
+
308
+ if token_type_ids is not None:
309
+ token_type_ids = token_type_ids.view(-1, input_shape[-1])
310
+ if position_ids is not None:
311
+ position_ids = position_ids.view(-1, input_shape[-1])
312
+
313
+ if past_key_values is None:
314
+ past_length = 0
315
+ past_key_values = tuple([None] * len(self.h))
316
+ else:
317
+ past_length = past_key_values[0][0].size(-2)
318
+ if position_ids is None:
319
+ position_ids = torch.arange(past_length, input_shape[-1] + past_length, dtype=torch.long, device=device)
320
+ position_ids = position_ids.unsqueeze(0).view(-1, input_shape[-1])
321
+
322
+ # GPT2Attention mask.
323
+ if attention_mask is not None:
324
+ if batch_size <= 0:
325
+ raise ValueError("batch_size has to be defined and > 0")
326
+ attention_mask = attention_mask.view(batch_size, -1)
327
+ # We create a 3D attention mask from a 2D tensor mask.
328
+ # Sizes are [batch_size, 1, 1, to_seq_length]
329
+ # So we can broadcast to [batch_size, num_heads, from_seq_length, to_seq_length]
330
+ # this attention mask is more simple than the triangular masking of causal attention
331
+ # used in OpenAI GPT, we just need to prepare the broadcast dimension here.
332
+ attention_mask = attention_mask[:, None, None, :]
333
+
334
+ # Since attention_mask is 1.0 for positions we want to attend and 0.0 for
335
+ # masked positions, this operation will create a tensor which is 0.0 for
336
+ # positions we want to attend and -10000.0 for masked positions.
337
+ # Since we are adding it to the raw scores before the softmax, this is
338
+ # effectively the same as removing these entirely.
339
+ attention_mask = attention_mask.to(dtype=self.dtype) # fp16 compatibility
340
+ attention_mask = (1.0 - attention_mask) * -10000.0
341
+
342
+ # Prepare head mask if needed
343
+ # 1.0 in head_mask indicate we keep the head
344
+ # attention_probs has shape bsz x num_heads x N x N
345
+ # head_mask has shape n_layer x batch x num_heads x N x N
346
+ head_mask = self.get_head_mask(head_mask, self.config.num_layers)
347
+
348
+ if inputs_embeds is None:
349
+ inputs_embeds = self.wte(input_ids)
350
+ position_embeds = self.wpe(position_ids)
351
+ hidden_states = inputs_embeds + position_embeds
352
+
353
+ if token_type_ids is not None:
354
+ token_type_embeds = self.wte(token_type_ids)
355
+ hidden_states = hidden_states + token_type_embeds
356
+
357
+ hidden_states = self.drop(hidden_states)
358
+
359
+ output_shape = input_shape + (hidden_states.size(-1),)
360
+
361
+ # top attention custom query
362
+ last_layer_id = len(self.h) - 1
363
+ query_embeds = self.wqe(position_ids)
364
+
365
+ presents = () if use_cache else None
366
+ all_self_attentions = () if output_attentions else None
367
+ all_hidden_states = () if output_hidden_states else None
368
+ for i, (block, layer_past) in enumerate(zip(self.h, past_key_values)):
369
+ # Final LayerNorm before last query layer
370
+ if i == last_layer_id:
371
+ hidden_states = self.ln_f(hidden_states)
372
+
373
+ if output_hidden_states:
374
+ all_hidden_states = all_hidden_states + (hidden_states,)
375
+
376
+ if self.gradient_checkpointing and self.training:
377
+
378
+ if use_cache:
379
+ logger.warning(
380
+ "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
381
+ )
382
+ use_cache = False
383
+
384
+ def create_custom_forward(module):
385
+ def custom_forward(*inputs):
386
+ # None for past_key_value
387
+ return module(*inputs, use_cache, output_attentions)
388
+
389
+ return custom_forward
390
+
391
+ outputs = torch.utils.checkpoint.checkpoint(
392
+ create_custom_forward(block),
393
+ hidden_states=hidden_states,
394
+ layer_past=None,
395
+ attention_mask=attention_mask,
396
+ head_mask=head_mask[i],
397
+ # custom query
398
+ custom_query=query_embeds if i == last_layer_id else None,
399
+ )
400
+ else:
401
+ outputs = block(
402
+ hidden_states,
403
+ layer_past=layer_past,
404
+ attention_mask=attention_mask,
405
+ head_mask=head_mask[i],
406
+ # custom query
407
+ custom_query=query_embeds if i == last_layer_id else None,
408
+ use_cache=use_cache,
409
+ output_attentions=output_attentions,
410
+ )
411
+
412
+ hidden_states = outputs[0]
413
+ if use_cache is True:
414
+ presents = presents + (outputs[1],)
415
+
416
+ if output_attentions:
417
+ all_self_attentions = all_self_attentions + (outputs[2 if use_cache else 1],)
418
+
419
+ hidden_states = hidden_states.view(*output_shape)
420
+ # Add last hidden state
421
+ if output_hidden_states:
422
+ all_hidden_states = all_hidden_states + (hidden_states,)
423
+
424
+ if not return_dict:
425
+ return tuple(v for v in [hidden_states, presents, all_hidden_states, all_self_attentions] if v is not None)
426
+
427
+ return BaseModelOutputWithPast(
428
+ last_hidden_state=hidden_states,
429
+ past_key_values=presents,
430
+ hidden_states=all_hidden_states,
431
+ attentions=all_self_attentions,
432
+ )
433
+
434
+
435
+ class GPTPanguForCausalLM(GPTPanguPreTrainedModel):
436
+ def __init__(self, config):
437
+ super().__init__(config)
438
+ self.transformer = GPTPanguModel(config)
439
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
440
+
441
+ # Initialize weights and apply final processing
442
+ self.post_init()
443
+
444
+ def get_output_embeddings(self):
445
+ return self.lm_head
446
+
447
+ def set_output_embeddings(self, new_embeddings):
448
+ self.lm_head = new_embeddings
449
+
450
+ def prepare_inputs_for_generation(self, input_ids, past=None, **kwargs):
451
+ token_type_ids = kwargs.get("token_type_ids", None)
452
+ # only last token for inputs_ids if past is defined in kwargs
453
+ if past:
454
+ input_ids = input_ids[:, -1].unsqueeze(-1)
455
+ if token_type_ids is not None:
456
+ token_type_ids = token_type_ids[:, -1].unsqueeze(-1)
457
+
458
+ attention_mask = kwargs.get("attention_mask", None)
459
+ position_ids = kwargs.get("position_ids", None)
460
+
461
+ if attention_mask is not None and position_ids is None:
462
+ # create position_ids on the fly for batch generation
463
+ position_ids = attention_mask.long().cumsum(-1) - 1
464
+ position_ids.masked_fill_(attention_mask == 0, 1)
465
+ if past:
466
+ position_ids = position_ids[:, -1].unsqueeze(-1)
467
+ else:
468
+ position_ids = None
469
+ return {
470
+ "input_ids": input_ids,
471
+ "past_key_values": past,
472
+ "use_cache": kwargs.get("use_cache"),
473
+ "position_ids": position_ids,
474
+ "attention_mask": attention_mask,
475
+ "token_type_ids": token_type_ids,
476
+ }
477
+
478
+ def forward(
479
+ self,
480
+ input_ids=None,
481
+ past_key_values=None,
482
+ attention_mask=None,
483
+ token_type_ids=None,
484
+ position_ids=None,
485
+ head_mask=None,
486
+ inputs_embeds=None,
487
+ labels=None,
488
+ use_cache=None,
489
+ output_attentions=None,
490
+ output_hidden_states=None,
491
+ return_dict=None,
492
+ ):
493
+ r"""
494
+ labels (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`):
495
+ Labels for language modeling. Note that the labels **are shifted** inside the model, i.e. you can set
496
+ ``labels = input_ids`` Indices are selected in ``[-100, 0, ..., config.vocab_size]`` All labels set to
497
+ ``-100`` are ignored (masked), the loss is only computed for labels in ``[0, ..., config.vocab_size]``
498
+ """
499
+ return_dict = return_dict if return_dict is not None else self.config.use_return_dict
500
+
501
+ transformer_outputs = self.transformer(
502
+ input_ids,
503
+ past_key_values=past_key_values,
504
+ attention_mask=attention_mask,
505
+ token_type_ids=token_type_ids,
506
+ position_ids=position_ids,
507
+ head_mask=head_mask,
508
+ inputs_embeds=inputs_embeds,
509
+ use_cache=use_cache,
510
+ output_attentions=output_attentions,
511
+ output_hidden_states=output_hidden_states,
512
+ return_dict=return_dict,
513
+ )
514
+ hidden_states = transformer_outputs[0]
515
+
516
+ lm_logits = self.lm_head(hidden_states)
517
+
518
+ loss = None
519
+ if labels is not None:
520
+ # Shift so that tokens < n predict n
521
+ shift_logits = lm_logits[..., :-1, :].contiguous()
522
+ shift_labels = labels[..., 1:].contiguous()
523
+ # Flatten the tokens
524
+ loss_fct = nn.CrossEntropyLoss()
525
+ loss = loss_fct(shift_logits.view(-1, shift_logits.size(-1)), shift_labels.view(-1))
526
+
527
+ if not return_dict:
528
+ output = (lm_logits,) + transformer_outputs[1:]
529
+ return ((loss,) + output) if loss is not None else output
530
+
531
+ return CausalLMOutputWithPast(
532
+ loss=loss,
533
+ logits=lm_logits,
534
+ past_key_values=transformer_outputs.past_key_values,
535
+ hidden_states=transformer_outputs.hidden_states,
536
+ attentions=transformer_outputs.attentions,
537
+ )
538
+
539
+ @staticmethod
540
+ def _reorder_cache(past: Tuple[Tuple[torch.Tensor]], beam_idx: torch.Tensor) -> Tuple[Tuple[torch.Tensor]]:
541
+ """
542
+ This function is used to re-order the :obj:`past_key_values` cache if
543
+ :meth:`~transformers.PreTrainedModel.beam_search` or :meth:`~transformers.PreTrainedModel.beam_sample` is
544
+ called. This is required to match :obj:`past_key_values` with the correct beam_idx at every generation step.
545
+ """
546
+ return tuple(
547
+ tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past)
548
+ for layer_past in past
549
+ )
pytorch_model-00001-of-00002.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c7ab63ef95bc748ea9fc0cbe8a84fe6e2ab3adc9fe8594d9a1c0055d7b6df4fd
3
+ size 9983130891
pytorch_model-00002-of-00002.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:583580d5ea51421ac98f1e4364109ea654b1f8b86e14be6abf5f8514d99d0bc2
3
+ size 961394894
pytorch_model.bin.index.json ADDED
@@ -0,0 +1,589 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 10944336000
4
+ },
5
+ "weight_map": {
6
+ "lm_head.weight": "pytorch_model-00002-of-00002.bin",
7
+ "transformer.h.0.attn.bias": "pytorch_model-00001-of-00002.bin",
8
+ "transformer.h.0.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
9
+ "transformer.h.0.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
10
+ "transformer.h.0.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
11
+ "transformer.h.0.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
12
+ "transformer.h.0.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
13
+ "transformer.h.0.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
14
+ "transformer.h.0.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
15
+ "transformer.h.0.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
16
+ "transformer.h.0.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
17
+ "transformer.h.0.ln_1.bias": "pytorch_model-00001-of-00002.bin",
18
+ "transformer.h.0.ln_1.weight": "pytorch_model-00001-of-00002.bin",
19
+ "transformer.h.0.ln_2.bias": "pytorch_model-00001-of-00002.bin",
20
+ "transformer.h.0.ln_2.weight": "pytorch_model-00001-of-00002.bin",
21
+ "transformer.h.0.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
22
+ "transformer.h.0.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
23
+ "transformer.h.0.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
24
+ "transformer.h.0.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
25
+ "transformer.h.1.attn.bias": "pytorch_model-00001-of-00002.bin",
26
+ "transformer.h.1.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
27
+ "transformer.h.1.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
28
+ "transformer.h.1.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
29
+ "transformer.h.1.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
30
+ "transformer.h.1.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
31
+ "transformer.h.1.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
32
+ "transformer.h.1.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
33
+ "transformer.h.1.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
34
+ "transformer.h.1.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
35
+ "transformer.h.1.ln_1.bias": "pytorch_model-00001-of-00002.bin",
36
+ "transformer.h.1.ln_1.weight": "pytorch_model-00001-of-00002.bin",
37
+ "transformer.h.1.ln_2.bias": "pytorch_model-00001-of-00002.bin",
38
+ "transformer.h.1.ln_2.weight": "pytorch_model-00001-of-00002.bin",
39
+ "transformer.h.1.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
40
+ "transformer.h.1.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
41
+ "transformer.h.1.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
42
+ "transformer.h.1.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
43
+ "transformer.h.10.attn.bias": "pytorch_model-00001-of-00002.bin",
44
+ "transformer.h.10.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
45
+ "transformer.h.10.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
46
+ "transformer.h.10.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
47
+ "transformer.h.10.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
48
+ "transformer.h.10.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
49
+ "transformer.h.10.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
50
+ "transformer.h.10.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
51
+ "transformer.h.10.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
52
+ "transformer.h.10.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
53
+ "transformer.h.10.ln_1.bias": "pytorch_model-00001-of-00002.bin",
54
+ "transformer.h.10.ln_1.weight": "pytorch_model-00001-of-00002.bin",
55
+ "transformer.h.10.ln_2.bias": "pytorch_model-00001-of-00002.bin",
56
+ "transformer.h.10.ln_2.weight": "pytorch_model-00001-of-00002.bin",
57
+ "transformer.h.10.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
58
+ "transformer.h.10.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
59
+ "transformer.h.10.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
60
+ "transformer.h.10.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
61
+ "transformer.h.11.attn.bias": "pytorch_model-00001-of-00002.bin",
62
+ "transformer.h.11.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
63
+ "transformer.h.11.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
64
+ "transformer.h.11.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
65
+ "transformer.h.11.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
66
+ "transformer.h.11.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
67
+ "transformer.h.11.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
68
+ "transformer.h.11.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
69
+ "transformer.h.11.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
70
+ "transformer.h.11.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
71
+ "transformer.h.11.ln_1.bias": "pytorch_model-00001-of-00002.bin",
72
+ "transformer.h.11.ln_1.weight": "pytorch_model-00001-of-00002.bin",
73
+ "transformer.h.11.ln_2.bias": "pytorch_model-00001-of-00002.bin",
74
+ "transformer.h.11.ln_2.weight": "pytorch_model-00001-of-00002.bin",
75
+ "transformer.h.11.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
76
+ "transformer.h.11.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
77
+ "transformer.h.11.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
78
+ "transformer.h.11.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
79
+ "transformer.h.12.attn.bias": "pytorch_model-00001-of-00002.bin",
80
+ "transformer.h.12.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
81
+ "transformer.h.12.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
82
+ "transformer.h.12.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
83
+ "transformer.h.12.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
84
+ "transformer.h.12.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
85
+ "transformer.h.12.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
86
+ "transformer.h.12.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
87
+ "transformer.h.12.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
88
+ "transformer.h.12.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
89
+ "transformer.h.12.ln_1.bias": "pytorch_model-00001-of-00002.bin",
90
+ "transformer.h.12.ln_1.weight": "pytorch_model-00001-of-00002.bin",
91
+ "transformer.h.12.ln_2.bias": "pytorch_model-00001-of-00002.bin",
92
+ "transformer.h.12.ln_2.weight": "pytorch_model-00001-of-00002.bin",
93
+ "transformer.h.12.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
94
+ "transformer.h.12.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
95
+ "transformer.h.12.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
96
+ "transformer.h.12.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
97
+ "transformer.h.13.attn.bias": "pytorch_model-00001-of-00002.bin",
98
+ "transformer.h.13.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
99
+ "transformer.h.13.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
100
+ "transformer.h.13.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
101
+ "transformer.h.13.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
102
+ "transformer.h.13.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
103
+ "transformer.h.13.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
104
+ "transformer.h.13.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
105
+ "transformer.h.13.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
106
+ "transformer.h.13.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
107
+ "transformer.h.13.ln_1.bias": "pytorch_model-00001-of-00002.bin",
108
+ "transformer.h.13.ln_1.weight": "pytorch_model-00001-of-00002.bin",
109
+ "transformer.h.13.ln_2.bias": "pytorch_model-00001-of-00002.bin",
110
+ "transformer.h.13.ln_2.weight": "pytorch_model-00001-of-00002.bin",
111
+ "transformer.h.13.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
112
+ "transformer.h.13.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
113
+ "transformer.h.13.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
114
+ "transformer.h.13.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
115
+ "transformer.h.14.attn.bias": "pytorch_model-00001-of-00002.bin",
116
+ "transformer.h.14.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
117
+ "transformer.h.14.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
118
+ "transformer.h.14.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
119
+ "transformer.h.14.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
120
+ "transformer.h.14.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
121
+ "transformer.h.14.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
122
+ "transformer.h.14.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
123
+ "transformer.h.14.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
124
+ "transformer.h.14.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
125
+ "transformer.h.14.ln_1.bias": "pytorch_model-00001-of-00002.bin",
126
+ "transformer.h.14.ln_1.weight": "pytorch_model-00001-of-00002.bin",
127
+ "transformer.h.14.ln_2.bias": "pytorch_model-00001-of-00002.bin",
128
+ "transformer.h.14.ln_2.weight": "pytorch_model-00001-of-00002.bin",
129
+ "transformer.h.14.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
130
+ "transformer.h.14.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
131
+ "transformer.h.14.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
132
+ "transformer.h.14.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
133
+ "transformer.h.15.attn.bias": "pytorch_model-00001-of-00002.bin",
134
+ "transformer.h.15.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
135
+ "transformer.h.15.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
136
+ "transformer.h.15.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
137
+ "transformer.h.15.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
138
+ "transformer.h.15.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
139
+ "transformer.h.15.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
140
+ "transformer.h.15.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
141
+ "transformer.h.15.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
142
+ "transformer.h.15.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
143
+ "transformer.h.15.ln_1.bias": "pytorch_model-00001-of-00002.bin",
144
+ "transformer.h.15.ln_1.weight": "pytorch_model-00001-of-00002.bin",
145
+ "transformer.h.15.ln_2.bias": "pytorch_model-00001-of-00002.bin",
146
+ "transformer.h.15.ln_2.weight": "pytorch_model-00001-of-00002.bin",
147
+ "transformer.h.15.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
148
+ "transformer.h.15.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
149
+ "transformer.h.15.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
150
+ "transformer.h.15.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
151
+ "transformer.h.16.attn.bias": "pytorch_model-00001-of-00002.bin",
152
+ "transformer.h.16.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
153
+ "transformer.h.16.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
154
+ "transformer.h.16.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
155
+ "transformer.h.16.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
156
+ "transformer.h.16.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
157
+ "transformer.h.16.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
158
+ "transformer.h.16.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
159
+ "transformer.h.16.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
160
+ "transformer.h.16.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
161
+ "transformer.h.16.ln_1.bias": "pytorch_model-00001-of-00002.bin",
162
+ "transformer.h.16.ln_1.weight": "pytorch_model-00001-of-00002.bin",
163
+ "transformer.h.16.ln_2.bias": "pytorch_model-00001-of-00002.bin",
164
+ "transformer.h.16.ln_2.weight": "pytorch_model-00001-of-00002.bin",
165
+ "transformer.h.16.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
166
+ "transformer.h.16.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
167
+ "transformer.h.16.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
168
+ "transformer.h.16.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
169
+ "transformer.h.17.attn.bias": "pytorch_model-00001-of-00002.bin",
170
+ "transformer.h.17.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
171
+ "transformer.h.17.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
172
+ "transformer.h.17.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
173
+ "transformer.h.17.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
174
+ "transformer.h.17.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
175
+ "transformer.h.17.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
176
+ "transformer.h.17.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
177
+ "transformer.h.17.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
178
+ "transformer.h.17.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
179
+ "transformer.h.17.ln_1.bias": "pytorch_model-00001-of-00002.bin",
180
+ "transformer.h.17.ln_1.weight": "pytorch_model-00001-of-00002.bin",
181
+ "transformer.h.17.ln_2.bias": "pytorch_model-00001-of-00002.bin",
182
+ "transformer.h.17.ln_2.weight": "pytorch_model-00001-of-00002.bin",
183
+ "transformer.h.17.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
184
+ "transformer.h.17.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
185
+ "transformer.h.17.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
186
+ "transformer.h.17.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
187
+ "transformer.h.18.attn.bias": "pytorch_model-00001-of-00002.bin",
188
+ "transformer.h.18.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
189
+ "transformer.h.18.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
190
+ "transformer.h.18.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
191
+ "transformer.h.18.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
192
+ "transformer.h.18.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
193
+ "transformer.h.18.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
194
+ "transformer.h.18.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
195
+ "transformer.h.18.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
196
+ "transformer.h.18.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
197
+ "transformer.h.18.ln_1.bias": "pytorch_model-00001-of-00002.bin",
198
+ "transformer.h.18.ln_1.weight": "pytorch_model-00001-of-00002.bin",
199
+ "transformer.h.18.ln_2.bias": "pytorch_model-00001-of-00002.bin",
200
+ "transformer.h.18.ln_2.weight": "pytorch_model-00001-of-00002.bin",
201
+ "transformer.h.18.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
202
+ "transformer.h.18.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
203
+ "transformer.h.18.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
204
+ "transformer.h.18.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
205
+ "transformer.h.19.attn.bias": "pytorch_model-00001-of-00002.bin",
206
+ "transformer.h.19.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
207
+ "transformer.h.19.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
208
+ "transformer.h.19.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
209
+ "transformer.h.19.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
210
+ "transformer.h.19.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
211
+ "transformer.h.19.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
212
+ "transformer.h.19.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
213
+ "transformer.h.19.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
214
+ "transformer.h.19.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
215
+ "transformer.h.19.ln_1.bias": "pytorch_model-00001-of-00002.bin",
216
+ "transformer.h.19.ln_1.weight": "pytorch_model-00001-of-00002.bin",
217
+ "transformer.h.19.ln_2.bias": "pytorch_model-00001-of-00002.bin",
218
+ "transformer.h.19.ln_2.weight": "pytorch_model-00001-of-00002.bin",
219
+ "transformer.h.19.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
220
+ "transformer.h.19.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
221
+ "transformer.h.19.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
222
+ "transformer.h.19.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
223
+ "transformer.h.2.attn.bias": "pytorch_model-00001-of-00002.bin",
224
+ "transformer.h.2.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
225
+ "transformer.h.2.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
226
+ "transformer.h.2.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
227
+ "transformer.h.2.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
228
+ "transformer.h.2.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
229
+ "transformer.h.2.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
230
+ "transformer.h.2.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
231
+ "transformer.h.2.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
232
+ "transformer.h.2.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
233
+ "transformer.h.2.ln_1.bias": "pytorch_model-00001-of-00002.bin",
234
+ "transformer.h.2.ln_1.weight": "pytorch_model-00001-of-00002.bin",
235
+ "transformer.h.2.ln_2.bias": "pytorch_model-00001-of-00002.bin",
236
+ "transformer.h.2.ln_2.weight": "pytorch_model-00001-of-00002.bin",
237
+ "transformer.h.2.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
238
+ "transformer.h.2.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
239
+ "transformer.h.2.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
240
+ "transformer.h.2.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
241
+ "transformer.h.20.attn.bias": "pytorch_model-00001-of-00002.bin",
242
+ "transformer.h.20.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
243
+ "transformer.h.20.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
244
+ "transformer.h.20.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
245
+ "transformer.h.20.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
246
+ "transformer.h.20.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
247
+ "transformer.h.20.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
248
+ "transformer.h.20.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
249
+ "transformer.h.20.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
250
+ "transformer.h.20.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
251
+ "transformer.h.20.ln_1.bias": "pytorch_model-00001-of-00002.bin",
252
+ "transformer.h.20.ln_1.weight": "pytorch_model-00001-of-00002.bin",
253
+ "transformer.h.20.ln_2.bias": "pytorch_model-00001-of-00002.bin",
254
+ "transformer.h.20.ln_2.weight": "pytorch_model-00001-of-00002.bin",
255
+ "transformer.h.20.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
256
+ "transformer.h.20.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
257
+ "transformer.h.20.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
258
+ "transformer.h.20.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
259
+ "transformer.h.21.attn.bias": "pytorch_model-00001-of-00002.bin",
260
+ "transformer.h.21.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
261
+ "transformer.h.21.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
262
+ "transformer.h.21.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
263
+ "transformer.h.21.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
264
+ "transformer.h.21.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
265
+ "transformer.h.21.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
266
+ "transformer.h.21.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
267
+ "transformer.h.21.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
268
+ "transformer.h.21.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
269
+ "transformer.h.21.ln_1.bias": "pytorch_model-00001-of-00002.bin",
270
+ "transformer.h.21.ln_1.weight": "pytorch_model-00001-of-00002.bin",
271
+ "transformer.h.21.ln_2.bias": "pytorch_model-00001-of-00002.bin",
272
+ "transformer.h.21.ln_2.weight": "pytorch_model-00001-of-00002.bin",
273
+ "transformer.h.21.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
274
+ "transformer.h.21.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
275
+ "transformer.h.21.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
276
+ "transformer.h.21.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
277
+ "transformer.h.22.attn.bias": "pytorch_model-00001-of-00002.bin",
278
+ "transformer.h.22.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
279
+ "transformer.h.22.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
280
+ "transformer.h.22.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
281
+ "transformer.h.22.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
282
+ "transformer.h.22.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
283
+ "transformer.h.22.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
284
+ "transformer.h.22.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
285
+ "transformer.h.22.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
286
+ "transformer.h.22.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
287
+ "transformer.h.22.ln_1.bias": "pytorch_model-00001-of-00002.bin",
288
+ "transformer.h.22.ln_1.weight": "pytorch_model-00001-of-00002.bin",
289
+ "transformer.h.22.ln_2.bias": "pytorch_model-00001-of-00002.bin",
290
+ "transformer.h.22.ln_2.weight": "pytorch_model-00001-of-00002.bin",
291
+ "transformer.h.22.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
292
+ "transformer.h.22.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
293
+ "transformer.h.22.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
294
+ "transformer.h.22.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
295
+ "transformer.h.23.attn.bias": "pytorch_model-00001-of-00002.bin",
296
+ "transformer.h.23.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
297
+ "transformer.h.23.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
298
+ "transformer.h.23.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
299
+ "transformer.h.23.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
300
+ "transformer.h.23.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
301
+ "transformer.h.23.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
302
+ "transformer.h.23.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
303
+ "transformer.h.23.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
304
+ "transformer.h.23.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
305
+ "transformer.h.23.ln_1.bias": "pytorch_model-00001-of-00002.bin",
306
+ "transformer.h.23.ln_1.weight": "pytorch_model-00001-of-00002.bin",
307
+ "transformer.h.23.ln_2.bias": "pytorch_model-00001-of-00002.bin",
308
+ "transformer.h.23.ln_2.weight": "pytorch_model-00001-of-00002.bin",
309
+ "transformer.h.23.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
310
+ "transformer.h.23.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
311
+ "transformer.h.23.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
312
+ "transformer.h.23.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
313
+ "transformer.h.24.attn.bias": "pytorch_model-00001-of-00002.bin",
314
+ "transformer.h.24.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
315
+ "transformer.h.24.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
316
+ "transformer.h.24.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
317
+ "transformer.h.24.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
318
+ "transformer.h.24.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
319
+ "transformer.h.24.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
320
+ "transformer.h.24.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
321
+ "transformer.h.24.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
322
+ "transformer.h.24.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
323
+ "transformer.h.24.ln_1.bias": "pytorch_model-00001-of-00002.bin",
324
+ "transformer.h.24.ln_1.weight": "pytorch_model-00001-of-00002.bin",
325
+ "transformer.h.24.ln_2.bias": "pytorch_model-00001-of-00002.bin",
326
+ "transformer.h.24.ln_2.weight": "pytorch_model-00001-of-00002.bin",
327
+ "transformer.h.24.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
328
+ "transformer.h.24.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
329
+ "transformer.h.24.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
330
+ "transformer.h.24.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
331
+ "transformer.h.25.attn.bias": "pytorch_model-00001-of-00002.bin",
332
+ "transformer.h.25.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
333
+ "transformer.h.25.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
334
+ "transformer.h.25.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
335
+ "transformer.h.25.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
336
+ "transformer.h.25.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
337
+ "transformer.h.25.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
338
+ "transformer.h.25.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
339
+ "transformer.h.25.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
340
+ "transformer.h.25.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
341
+ "transformer.h.25.ln_1.bias": "pytorch_model-00001-of-00002.bin",
342
+ "transformer.h.25.ln_1.weight": "pytorch_model-00001-of-00002.bin",
343
+ "transformer.h.25.ln_2.bias": "pytorch_model-00001-of-00002.bin",
344
+ "transformer.h.25.ln_2.weight": "pytorch_model-00001-of-00002.bin",
345
+ "transformer.h.25.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
346
+ "transformer.h.25.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
347
+ "transformer.h.25.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
348
+ "transformer.h.25.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
349
+ "transformer.h.26.attn.bias": "pytorch_model-00001-of-00002.bin",
350
+ "transformer.h.26.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
351
+ "transformer.h.26.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
352
+ "transformer.h.26.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
353
+ "transformer.h.26.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
354
+ "transformer.h.26.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
355
+ "transformer.h.26.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
356
+ "transformer.h.26.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
357
+ "transformer.h.26.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
358
+ "transformer.h.26.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
359
+ "transformer.h.26.ln_1.bias": "pytorch_model-00001-of-00002.bin",
360
+ "transformer.h.26.ln_1.weight": "pytorch_model-00001-of-00002.bin",
361
+ "transformer.h.26.ln_2.bias": "pytorch_model-00001-of-00002.bin",
362
+ "transformer.h.26.ln_2.weight": "pytorch_model-00001-of-00002.bin",
363
+ "transformer.h.26.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
364
+ "transformer.h.26.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
365
+ "transformer.h.26.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
366
+ "transformer.h.26.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
367
+ "transformer.h.27.attn.bias": "pytorch_model-00001-of-00002.bin",
368
+ "transformer.h.27.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
369
+ "transformer.h.27.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
370
+ "transformer.h.27.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
371
+ "transformer.h.27.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
372
+ "transformer.h.27.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
373
+ "transformer.h.27.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
374
+ "transformer.h.27.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
375
+ "transformer.h.27.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
376
+ "transformer.h.27.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
377
+ "transformer.h.27.ln_1.bias": "pytorch_model-00001-of-00002.bin",
378
+ "transformer.h.27.ln_1.weight": "pytorch_model-00001-of-00002.bin",
379
+ "transformer.h.27.ln_2.bias": "pytorch_model-00001-of-00002.bin",
380
+ "transformer.h.27.ln_2.weight": "pytorch_model-00001-of-00002.bin",
381
+ "transformer.h.27.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
382
+ "transformer.h.27.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
383
+ "transformer.h.27.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
384
+ "transformer.h.27.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
385
+ "transformer.h.28.attn.bias": "pytorch_model-00001-of-00002.bin",
386
+ "transformer.h.28.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
387
+ "transformer.h.28.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
388
+ "transformer.h.28.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
389
+ "transformer.h.28.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
390
+ "transformer.h.28.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
391
+ "transformer.h.28.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
392
+ "transformer.h.28.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
393
+ "transformer.h.28.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
394
+ "transformer.h.28.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
395
+ "transformer.h.28.ln_1.bias": "pytorch_model-00001-of-00002.bin",
396
+ "transformer.h.28.ln_1.weight": "pytorch_model-00001-of-00002.bin",
397
+ "transformer.h.28.ln_2.bias": "pytorch_model-00001-of-00002.bin",
398
+ "transformer.h.28.ln_2.weight": "pytorch_model-00001-of-00002.bin",
399
+ "transformer.h.28.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
400
+ "transformer.h.28.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
401
+ "transformer.h.28.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
402
+ "transformer.h.28.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
403
+ "transformer.h.29.attn.bias": "pytorch_model-00001-of-00002.bin",
404
+ "transformer.h.29.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
405
+ "transformer.h.29.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
406
+ "transformer.h.29.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
407
+ "transformer.h.29.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
408
+ "transformer.h.29.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
409
+ "transformer.h.29.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
410
+ "transformer.h.29.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
411
+ "transformer.h.29.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
412
+ "transformer.h.29.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
413
+ "transformer.h.29.ln_1.bias": "pytorch_model-00001-of-00002.bin",
414
+ "transformer.h.29.ln_1.weight": "pytorch_model-00001-of-00002.bin",
415
+ "transformer.h.29.ln_2.bias": "pytorch_model-00001-of-00002.bin",
416
+ "transformer.h.29.ln_2.weight": "pytorch_model-00001-of-00002.bin",
417
+ "transformer.h.29.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
418
+ "transformer.h.29.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
419
+ "transformer.h.29.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
420
+ "transformer.h.29.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
421
+ "transformer.h.3.attn.bias": "pytorch_model-00001-of-00002.bin",
422
+ "transformer.h.3.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
423
+ "transformer.h.3.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
424
+ "transformer.h.3.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
425
+ "transformer.h.3.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
426
+ "transformer.h.3.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
427
+ "transformer.h.3.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
428
+ "transformer.h.3.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
429
+ "transformer.h.3.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
430
+ "transformer.h.3.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
431
+ "transformer.h.3.ln_1.bias": "pytorch_model-00001-of-00002.bin",
432
+ "transformer.h.3.ln_1.weight": "pytorch_model-00001-of-00002.bin",
433
+ "transformer.h.3.ln_2.bias": "pytorch_model-00001-of-00002.bin",
434
+ "transformer.h.3.ln_2.weight": "pytorch_model-00001-of-00002.bin",
435
+ "transformer.h.3.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
436
+ "transformer.h.3.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
437
+ "transformer.h.3.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
438
+ "transformer.h.3.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
439
+ "transformer.h.30.attn.bias": "pytorch_model-00001-of-00002.bin",
440
+ "transformer.h.30.attn.c_proj.bias": "pytorch_model-00002-of-00002.bin",
441
+ "transformer.h.30.attn.c_proj.weight": "pytorch_model-00002-of-00002.bin",
442
+ "transformer.h.30.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
443
+ "transformer.h.30.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
444
+ "transformer.h.30.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
445
+ "transformer.h.30.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
446
+ "transformer.h.30.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
447
+ "transformer.h.30.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
448
+ "transformer.h.30.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
449
+ "transformer.h.30.ln_1.bias": "pytorch_model-00001-of-00002.bin",
450
+ "transformer.h.30.ln_1.weight": "pytorch_model-00001-of-00002.bin",
451
+ "transformer.h.30.ln_2.bias": "pytorch_model-00002-of-00002.bin",
452
+ "transformer.h.30.ln_2.weight": "pytorch_model-00002-of-00002.bin",
453
+ "transformer.h.30.mlp.c_fc.bias": "pytorch_model-00002-of-00002.bin",
454
+ "transformer.h.30.mlp.c_fc.weight": "pytorch_model-00002-of-00002.bin",
455
+ "transformer.h.30.mlp.c_proj.bias": "pytorch_model-00002-of-00002.bin",
456
+ "transformer.h.30.mlp.c_proj.weight": "pytorch_model-00002-of-00002.bin",
457
+ "transformer.h.31.attn.bias": "pytorch_model-00002-of-00002.bin",
458
+ "transformer.h.31.attn.c_proj.bias": "pytorch_model-00002-of-00002.bin",
459
+ "transformer.h.31.attn.c_proj.weight": "pytorch_model-00002-of-00002.bin",
460
+ "transformer.h.31.attn.k_proj.bias": "pytorch_model-00002-of-00002.bin",
461
+ "transformer.h.31.attn.k_proj.weight": "pytorch_model-00002-of-00002.bin",
462
+ "transformer.h.31.attn.masked_bias": "pytorch_model-00002-of-00002.bin",
463
+ "transformer.h.31.attn.q_proj.bias": "pytorch_model-00002-of-00002.bin",
464
+ "transformer.h.31.attn.q_proj.weight": "pytorch_model-00002-of-00002.bin",
465
+ "transformer.h.31.attn.v_proj.bias": "pytorch_model-00002-of-00002.bin",
466
+ "transformer.h.31.attn.v_proj.weight": "pytorch_model-00002-of-00002.bin",
467
+ "transformer.h.31.ln_1.bias": "pytorch_model-00002-of-00002.bin",
468
+ "transformer.h.31.ln_1.weight": "pytorch_model-00002-of-00002.bin",
469
+ "transformer.h.31.ln_2.bias": "pytorch_model-00002-of-00002.bin",
470
+ "transformer.h.31.ln_2.weight": "pytorch_model-00002-of-00002.bin",
471
+ "transformer.h.31.mlp.c_fc.bias": "pytorch_model-00002-of-00002.bin",
472
+ "transformer.h.31.mlp.c_fc.weight": "pytorch_model-00002-of-00002.bin",
473
+ "transformer.h.31.mlp.c_proj.bias": "pytorch_model-00002-of-00002.bin",
474
+ "transformer.h.31.mlp.c_proj.weight": "pytorch_model-00002-of-00002.bin",
475
+ "transformer.h.4.attn.bias": "pytorch_model-00001-of-00002.bin",
476
+ "transformer.h.4.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
477
+ "transformer.h.4.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
478
+ "transformer.h.4.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
479
+ "transformer.h.4.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
480
+ "transformer.h.4.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
481
+ "transformer.h.4.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
482
+ "transformer.h.4.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
483
+ "transformer.h.4.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
484
+ "transformer.h.4.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
485
+ "transformer.h.4.ln_1.bias": "pytorch_model-00001-of-00002.bin",
486
+ "transformer.h.4.ln_1.weight": "pytorch_model-00001-of-00002.bin",
487
+ "transformer.h.4.ln_2.bias": "pytorch_model-00001-of-00002.bin",
488
+ "transformer.h.4.ln_2.weight": "pytorch_model-00001-of-00002.bin",
489
+ "transformer.h.4.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
490
+ "transformer.h.4.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
491
+ "transformer.h.4.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
492
+ "transformer.h.4.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
493
+ "transformer.h.5.attn.bias": "pytorch_model-00001-of-00002.bin",
494
+ "transformer.h.5.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
495
+ "transformer.h.5.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
496
+ "transformer.h.5.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
497
+ "transformer.h.5.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
498
+ "transformer.h.5.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
499
+ "transformer.h.5.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
500
+ "transformer.h.5.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
501
+ "transformer.h.5.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
502
+ "transformer.h.5.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
503
+ "transformer.h.5.ln_1.bias": "pytorch_model-00001-of-00002.bin",
504
+ "transformer.h.5.ln_1.weight": "pytorch_model-00001-of-00002.bin",
505
+ "transformer.h.5.ln_2.bias": "pytorch_model-00001-of-00002.bin",
506
+ "transformer.h.5.ln_2.weight": "pytorch_model-00001-of-00002.bin",
507
+ "transformer.h.5.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
508
+ "transformer.h.5.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
509
+ "transformer.h.5.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
510
+ "transformer.h.5.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
511
+ "transformer.h.6.attn.bias": "pytorch_model-00001-of-00002.bin",
512
+ "transformer.h.6.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
513
+ "transformer.h.6.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
514
+ "transformer.h.6.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
515
+ "transformer.h.6.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
516
+ "transformer.h.6.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
517
+ "transformer.h.6.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
518
+ "transformer.h.6.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
519
+ "transformer.h.6.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
520
+ "transformer.h.6.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
521
+ "transformer.h.6.ln_1.bias": "pytorch_model-00001-of-00002.bin",
522
+ "transformer.h.6.ln_1.weight": "pytorch_model-00001-of-00002.bin",
523
+ "transformer.h.6.ln_2.bias": "pytorch_model-00001-of-00002.bin",
524
+ "transformer.h.6.ln_2.weight": "pytorch_model-00001-of-00002.bin",
525
+ "transformer.h.6.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
526
+ "transformer.h.6.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
527
+ "transformer.h.6.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
528
+ "transformer.h.6.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
529
+ "transformer.h.7.attn.bias": "pytorch_model-00001-of-00002.bin",
530
+ "transformer.h.7.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
531
+ "transformer.h.7.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
532
+ "transformer.h.7.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
533
+ "transformer.h.7.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
534
+ "transformer.h.7.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
535
+ "transformer.h.7.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
536
+ "transformer.h.7.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
537
+ "transformer.h.7.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
538
+ "transformer.h.7.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
539
+ "transformer.h.7.ln_1.bias": "pytorch_model-00001-of-00002.bin",
540
+ "transformer.h.7.ln_1.weight": "pytorch_model-00001-of-00002.bin",
541
+ "transformer.h.7.ln_2.bias": "pytorch_model-00001-of-00002.bin",
542
+ "transformer.h.7.ln_2.weight": "pytorch_model-00001-of-00002.bin",
543
+ "transformer.h.7.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
544
+ "transformer.h.7.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
545
+ "transformer.h.7.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
546
+ "transformer.h.7.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
547
+ "transformer.h.8.attn.bias": "pytorch_model-00001-of-00002.bin",
548
+ "transformer.h.8.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
549
+ "transformer.h.8.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
550
+ "transformer.h.8.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
551
+ "transformer.h.8.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
552
+ "transformer.h.8.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
553
+ "transformer.h.8.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
554
+ "transformer.h.8.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
555
+ "transformer.h.8.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
556
+ "transformer.h.8.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
557
+ "transformer.h.8.ln_1.bias": "pytorch_model-00001-of-00002.bin",
558
+ "transformer.h.8.ln_1.weight": "pytorch_model-00001-of-00002.bin",
559
+ "transformer.h.8.ln_2.bias": "pytorch_model-00001-of-00002.bin",
560
+ "transformer.h.8.ln_2.weight": "pytorch_model-00001-of-00002.bin",
561
+ "transformer.h.8.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
562
+ "transformer.h.8.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
563
+ "transformer.h.8.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
564
+ "transformer.h.8.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
565
+ "transformer.h.9.attn.bias": "pytorch_model-00001-of-00002.bin",
566
+ "transformer.h.9.attn.c_proj.bias": "pytorch_model-00001-of-00002.bin",
567
+ "transformer.h.9.attn.c_proj.weight": "pytorch_model-00001-of-00002.bin",
568
+ "transformer.h.9.attn.k_proj.bias": "pytorch_model-00001-of-00002.bin",
569
+ "transformer.h.9.attn.k_proj.weight": "pytorch_model-00001-of-00002.bin",
570
+ "transformer.h.9.attn.masked_bias": "pytorch_model-00001-of-00002.bin",
571
+ "transformer.h.9.attn.q_proj.bias": "pytorch_model-00001-of-00002.bin",
572
+ "transformer.h.9.attn.q_proj.weight": "pytorch_model-00001-of-00002.bin",
573
+ "transformer.h.9.attn.v_proj.bias": "pytorch_model-00001-of-00002.bin",
574
+ "transformer.h.9.attn.v_proj.weight": "pytorch_model-00001-of-00002.bin",
575
+ "transformer.h.9.ln_1.bias": "pytorch_model-00001-of-00002.bin",
576
+ "transformer.h.9.ln_1.weight": "pytorch_model-00001-of-00002.bin",
577
+ "transformer.h.9.ln_2.bias": "pytorch_model-00001-of-00002.bin",
578
+ "transformer.h.9.ln_2.weight": "pytorch_model-00001-of-00002.bin",
579
+ "transformer.h.9.mlp.c_fc.bias": "pytorch_model-00001-of-00002.bin",
580
+ "transformer.h.9.mlp.c_fc.weight": "pytorch_model-00001-of-00002.bin",
581
+ "transformer.h.9.mlp.c_proj.bias": "pytorch_model-00001-of-00002.bin",
582
+ "transformer.h.9.mlp.c_proj.weight": "pytorch_model-00001-of-00002.bin",
583
+ "transformer.ln_f.bias": "pytorch_model-00002-of-00002.bin",
584
+ "transformer.ln_f.weight": "pytorch_model-00002-of-00002.bin",
585
+ "transformer.wpe.weight": "pytorch_model-00001-of-00002.bin",
586
+ "transformer.wqe.weight": "pytorch_model-00001-of-00002.bin",
587
+ "transformer.wte.weight": "pytorch_model-00001-of-00002.bin"
588
+ }
589
+ }
tokenization_gptpangu.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import torch
3
+ import sentencepiece
4
+ import jieba
5
+ import numpy as np
6
+
7
+ from transformers.tokenization_utils import PreTrainedTokenizer
8
+
9
+
10
+ class GPTPanguTokenizer(PreTrainedTokenizer):
11
+ # Ref: https://git.openi.org.cn/PCL-Platform.Intelligence/PanGu-Alpha/src/branch/master/tokenization_jieba.py
12
+ vocab_files_names = {
13
+ "model_file": "vocab.model"
14
+ }
15
+
16
+ def __init__(
17
+ self,
18
+ model_file,
19
+ **kwargs
20
+ ):
21
+ super().__init__(**kwargs)
22
+
23
+ self.sp = sentencepiece.SentencePieceProcessor()
24
+ self.sp.Load(model_file=model_file)
25
+ self.translator = str.maketrans(" \n", "\u2582\u2583")
26
+
27
+ # special token ids
28
+ # self.eos_token_id = self.sp.piece_to_id("<eot>")
29
+
30
+ def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None):
31
+ """
32
+ Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
33
+ adding special tokens. A BERT sequence has the following format:
34
+
35
+ - single sequence: `[CLS] X [SEP]`
36
+ - pair of sequences: `[CLS] A [SEP] B [SEP]`
37
+
38
+ Args:
39
+ token_ids_0 (`List[int]`):
40
+ List of IDs to which the special tokens will be added.
41
+ token_ids_1 (`List[int]`, *optional*):
42
+ Optional second list of IDs for sequence pairs.
43
+
44
+ Returns:
45
+ `List[int]`: List of [input IDs](../glossary#input-ids) with the appropriate special tokens.
46
+ """
47
+ if self.bos_token_id is not None:
48
+ if token_ids_1 is None:
49
+ return [self.bos_token_id] + token_ids_0 + [self.eos_token_id]
50
+ bos = [self.bos_token_id]
51
+ sep = [self.sep_token_id]
52
+ eos = [self.eos_token_id]
53
+ return bos + token_ids_0 + sep + token_ids_1 + eos
54
+ else:
55
+ if token_ids_1 is None:
56
+ return token_ids_0 + [self.eos_token_id]
57
+ sep = [self.sep_token_id]
58
+ eos = [self.eos_token_id]
59
+ return token_ids_0 + sep + token_ids_1 + eos
60
+
61
+ def tokenize(self, text, **kwargs):
62
+ """ Tokenize a string. """
63
+ seg_list = [x.translate(self.translator) for x in jieba.cut(text, cut_all=False)]
64
+ return seg_list
65
+
66
+ def convert_tokens_to_ids(self, tokens):
67
+ if tokens is None:
68
+ return None
69
+
70
+ if isinstance(tokens, str):
71
+ return self._convert_token_to_id_with_added_voc(tokens)
72
+
73
+ new_seg = " ".join(tokens)
74
+ return self.sp.encode(new_seg)
75
+ # return tokens
76
+
77
+ def _convert_token_to_id(self, token):
78
+ return self.sp.piece_to_id(token)
79
+
80
+ def _convert_id_to_token(self, index):
81
+ return self.sp.id_to_piece(index)
82
+
83
+ def convert_ids_to_tokens(self, ids):
84
+ return self.decode(ids)
85
+
86
+ def decode(self, tokens, **kwargs):
87
+ if isinstance(tokens, torch.Tensor) or isinstance(tokens, np.ndarray):
88
+ tokens = tokens.tolist()
89
+
90
+ if kwargs.get('skip_special_tokens', None) is True:
91
+ tokens = [token for token in tokens if token not in self.all_special_ids]
92
+ text = self.sp.decode(tokens)
93
+ if isinstance(text, list):
94
+ text = text[0]
95
+ text = text.replace(' ', '').replace('\u2582', ' ').replace('\u2583', '\n')
96
+ return text
97
+
98
+ @property
99
+ def vocab_size(self) -> int:
100
+ """
101
+ `int`: Size of the base vocabulary (without the added tokens).
102
+ """
103
+ return len(self.sp)
tokenizer_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "eos_token": "<eot>",
3
+ "pad_token": "<pad>",
4
+ "unk_token": "<unk>",
5
+ "sep_token": "<sep>",
6
+ "bos_token": "<s>",
7
+ "add_prefix_space": false,
8
+ "tokenizer_class": "GPTPanguTokenizer",
9
+ "use_fast": false,
10
+ "auto_map": {
11
+ "AutoTokenizer": [
12
+ "tokenization_gptpangu.GPTPanguTokenizer",
13
+ null
14
+ ]
15
+ }
16
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4983ff967339ef40821aa4c7a300af08a3f3bab294245ce2d61e93c9b9b2873
3
+ size 3567
vocab.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18857e86783e50cfcaa0bc3c043fb4e9b5f240b885d2870ea593ee69b44f7a3a
3
+ size 879697