Commit
•
fbc057c
1
Parent(s):
547e12b
start point
Browse files- README.md +1 -3
- config.json +40 -0
- configuration_cc_bloom.py +127 -0
- generation_config.json +7 -0
- modeling_cc_bloom.py +1552 -0
- pytorch_model-00001-of-00014.bin +3 -0
- pytorch_model-00002-of-00014.bin +3 -0
- pytorch_model-00003-of-00014.bin +3 -0
- pytorch_model-00004-of-00014.bin +3 -0
- pytorch_model-00005-of-00014.bin +3 -0
- pytorch_model-00006-of-00014.bin +3 -0
- pytorch_model-00007-of-00014.bin +3 -0
- pytorch_model-00008-of-00014.bin +3 -0
- pytorch_model-00009-of-00014.bin +3 -0
- pytorch_model-00010-of-00014.bin +3 -0
- pytorch_model-00011-of-00014.bin +3 -0
- pytorch_model-00012-of-00014.bin +3 -0
- pytorch_model-00013-of-00014.bin +3 -0
- pytorch_model-00014-of-00014.bin +3 -0
- pytorch_model.bin.index.json +373 -0
- special_tokens_map.json +30 -0
- tokenizer.json +0 -0
- tokenizer.model +3 -0
- tokenizer_config.json +42 -0
README.md
CHANGED
@@ -1,3 +1 @@
|
|
1 |
-
|
2 |
-
license: apache-2.0
|
3 |
-
---
|
|
|
1 |
+
https://github.com/CoinCheung/gdGPT
|
|
|
|
config.json
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "coincheung/cc-bloomz-7b",
|
3 |
+
"apply_residual_connection_post_layernorm": false,
|
4 |
+
"architectures": [
|
5 |
+
"CCBloomForCausalLM"
|
6 |
+
],
|
7 |
+
"attention_dropout": 0.0,
|
8 |
+
"attention_softmax_in_fp32": true,
|
9 |
+
"auto_map": {
|
10 |
+
"AutoConfig": "configuration_cc_bloom.CCBloomConfig",
|
11 |
+
"AutoModel": "modeling_cc_bloom.CCBloomForCausalLM",
|
12 |
+
"AutoModelForCausalLM": "modeling_cc_bloom.CCBloomForCausalLM"
|
13 |
+
},
|
14 |
+
"bias_dropout_fusion": true,
|
15 |
+
"bos_token_id": 1,
|
16 |
+
"eos_token_id": 2,
|
17 |
+
"hidden_dropout": 0.0,
|
18 |
+
"hidden_size": 4096,
|
19 |
+
"initializer_range": 0.02,
|
20 |
+
"layer_norm_epsilon": 1e-05,
|
21 |
+
"masked_softmax_fusion": true,
|
22 |
+
"model_type": "ccbloom",
|
23 |
+
"n_head": 32,
|
24 |
+
"n_inner": null,
|
25 |
+
"n_layer": 30,
|
26 |
+
"pad_token_id": 0,
|
27 |
+
"pretraining_tp": 1,
|
28 |
+
"rope_scaling": null,
|
29 |
+
"seq_length": 2048,
|
30 |
+
"skip_bias_add": true,
|
31 |
+
"skip_bias_add_qkv": false,
|
32 |
+
"slow_but_exact": false,
|
33 |
+
"tie_word_embeddings": false,
|
34 |
+
"torch_dtype": "float32",
|
35 |
+
"transformers_version": "4.31.0",
|
36 |
+
"unk_token_id": 0,
|
37 |
+
"use_cache": true,
|
38 |
+
"use_flash_attn": false,
|
39 |
+
"vocab_size": 64000
|
40 |
+
}
|
configuration_cc_bloom.py
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 collections import OrderedDict
|
17 |
+
from typing import TYPE_CHECKING, Any, List, Mapping, Optional
|
18 |
+
|
19 |
+
from packaging import version
|
20 |
+
|
21 |
+
|
22 |
+
if TYPE_CHECKING:
|
23 |
+
from transformers import PreTrainedTokenizer, TensorType
|
24 |
+
|
25 |
+
from transformers.configuration_utils import PretrainedConfig
|
26 |
+
from transformers.utils import is_torch_available, logging
|
27 |
+
|
28 |
+
|
29 |
+
logger = logging.get_logger(__name__)
|
30 |
+
|
31 |
+
|
32 |
+
class CCBloomConfig(PretrainedConfig):
|
33 |
+
"""
|
34 |
+
This is the configuration class to store the configuration of a [`BloomModel`]. It is used to instantiate a Bloom
|
35 |
+
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
|
36 |
+
defaults will yield a similar configuration to the Bloom architecture
|
37 |
+
[bigscience/bloom](https://huggingface.co/bigscience/bloom).
|
38 |
+
|
39 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
40 |
+
documentation from [`PretrainedConfig`] for more information.
|
41 |
+
|
42 |
+
|
43 |
+
Args:
|
44 |
+
vocab_size (`int`, *optional*, defaults to 250880):
|
45 |
+
Vocabulary size of the Bloom model. Defines the maximum number of different tokens that can be represented
|
46 |
+
by the `inputs_ids` passed when calling [`BloomModel`]. Check [this
|
47 |
+
discussion](https://huggingface.co/bigscience/bloom/discussions/120#633d28389addb8530b406c2a) on how the
|
48 |
+
`vocab_size` has been defined.
|
49 |
+
hidden_size (`int`, *optional*, defaults to 64):
|
50 |
+
Dimensionality of the embeddings and hidden states.
|
51 |
+
n_layer (`int`, *optional*, defaults to 2):
|
52 |
+
Number of hidden layers in the Transformer encoder.
|
53 |
+
n_head (`int`, *optional*, defaults to 8):
|
54 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
55 |
+
layer_norm_epsilon (`float`, *optional*, defaults to 1e-5):
|
56 |
+
The epsilon to use in the layer normalization layers.
|
57 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
58 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
59 |
+
apply_residual_connection_post_layernorm (`bool`, *optional*, defaults to `False`):
|
60 |
+
If enabled, use the layer norm of the hidden states as the residual in the transformer blocks
|
61 |
+
hidden_dropout (`float`, *optional*, defaults to 0.1):
|
62 |
+
Dropout rate of the dropout function on the bias dropout.
|
63 |
+
attention_dropout (`float`, *optional*, defaults to 0.1):
|
64 |
+
Dropout rate applied to the attention probs
|
65 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
66 |
+
Whether or not the model should return the last key/values attentions (not used by all models).
|
67 |
+
pretraining_tp (`int`, *optional*, defaults to `1`):
|
68 |
+
Experimental feature. Tensor parallelism rank used during pretraining with Megatron. Please refer to [this
|
69 |
+
document](https://huggingface.co/docs/transformers/parallelism) to understand more about it. This value is
|
70 |
+
necessary to ensure exact reproducibility of the pretraining results. Please refer to [this
|
71 |
+
issue](https://github.com/pytorch/pytorch/issues/76232). Note also that this is enabled only when
|
72 |
+
`slow_but_exact=True`.
|
73 |
+
slow_but_exact (`bool`, *optional*, defaults to `False`):
|
74 |
+
Experimental feature. Whether to use slow but exact implementation of the attention mechanism. While
|
75 |
+
merging the TP rank tensors, due to slicing operations the results may be slightly different between the
|
76 |
+
model trained on Megatron and our model. Please refer to [this
|
77 |
+
issue](https://github.com/pytorch/pytorch/issues/76232). A solution to obtain more accurate results is to
|
78 |
+
enable this feature. Enabling this will hurt the computational time of the inference. Will be probably
|
79 |
+
resolved in the future once the main model has been fine-tuned with TP_rank=1.
|
80 |
+
"""
|
81 |
+
|
82 |
+
model_type = "ccbloom"
|
83 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
84 |
+
attribute_map = {
|
85 |
+
"num_hidden_layers": "n_layer",
|
86 |
+
"num_attention_heads": "n_head",
|
87 |
+
}
|
88 |
+
|
89 |
+
def __init__(
|
90 |
+
self,
|
91 |
+
vocab_size=250880,
|
92 |
+
hidden_size=64,
|
93 |
+
n_layer=2,
|
94 |
+
n_head=8,
|
95 |
+
layer_norm_epsilon=1e-5,
|
96 |
+
initializer_range=0.02,
|
97 |
+
use_cache=True,
|
98 |
+
bos_token_id=1,
|
99 |
+
eos_token_id=2,
|
100 |
+
apply_residual_connection_post_layernorm=False,
|
101 |
+
hidden_dropout=0.0,
|
102 |
+
attention_dropout=0.0,
|
103 |
+
pretraining_tp=1, # TP rank used when training with megatron
|
104 |
+
slow_but_exact=False,
|
105 |
+
**kwargs,
|
106 |
+
):
|
107 |
+
self.vocab_size = vocab_size
|
108 |
+
# Backward compatibility with n_embed kwarg
|
109 |
+
n_embed = kwargs.pop("n_embed", None)
|
110 |
+
self.hidden_size = hidden_size if n_embed is None else n_embed
|
111 |
+
self.n_layer = n_layer
|
112 |
+
self.n_head = n_head
|
113 |
+
self.layer_norm_epsilon = layer_norm_epsilon
|
114 |
+
self.initializer_range = initializer_range
|
115 |
+
self.use_cache = use_cache
|
116 |
+
self.pretraining_tp = pretraining_tp
|
117 |
+
self.apply_residual_connection_post_layernorm = apply_residual_connection_post_layernorm
|
118 |
+
self.hidden_dropout = hidden_dropout
|
119 |
+
self.attention_dropout = attention_dropout
|
120 |
+
|
121 |
+
self.bos_token_id = bos_token_id
|
122 |
+
self.eos_token_id = eos_token_id
|
123 |
+
self.slow_but_exact = slow_but_exact
|
124 |
+
|
125 |
+
super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)
|
126 |
+
|
127 |
+
|
generation_config.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 1,
|
4 |
+
"eos_token_id": 2,
|
5 |
+
"pad_token_id": 3,
|
6 |
+
"transformers_version": "4.31.0"
|
7 |
+
}
|
modeling_cc_bloom.py
ADDED
@@ -0,0 +1,1552 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2022 HuggingFace Inc. team and BigScience workshop.
|
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 |
+
"""PyTorch BLOOM model."""
|
16 |
+
|
17 |
+
import os
|
18 |
+
import os.path as osp
|
19 |
+
import math
|
20 |
+
import warnings
|
21 |
+
from typing import Optional, Tuple, Union
|
22 |
+
|
23 |
+
import torch
|
24 |
+
import torch.utils.checkpoint
|
25 |
+
from torch import nn
|
26 |
+
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, LayerNorm, MSELoss
|
27 |
+
from torch.nn import functional as F
|
28 |
+
|
29 |
+
from transformers.file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward
|
30 |
+
from transformers.modeling_outputs import (
|
31 |
+
BaseModelOutputWithPastAndCrossAttentions,
|
32 |
+
CausalLMOutputWithCrossAttentions,
|
33 |
+
QuestionAnsweringModelOutput,
|
34 |
+
SequenceClassifierOutputWithPast,
|
35 |
+
TokenClassifierOutput,
|
36 |
+
)
|
37 |
+
from transformers.modeling_utils import PreTrainedModel
|
38 |
+
from transformers.utils import logging
|
39 |
+
|
40 |
+
try:
|
41 |
+
from flash_attn import flash_attn_func
|
42 |
+
except ImportError:
|
43 |
+
flash_attn_func = None
|
44 |
+
|
45 |
+
from transformers.models.bloom.configuration_bloom import BloomConfig as CCBloomConfig
|
46 |
+
|
47 |
+
# from transformers.models.llama.modeling_llama import LlamaDynamicNTKScalingRotaryEmbedding, LlamaLinearScalingRotaryEmbedding, LlamaRotaryEmbedding
|
48 |
+
|
49 |
+
|
50 |
+
logger = logging.get_logger(__name__)
|
51 |
+
|
52 |
+
_CHECKPOINT_FOR_DOC = "bigscience/bloom-560m"
|
53 |
+
_CONFIG_FOR_DOC = "CCBloomConfig"
|
54 |
+
|
55 |
+
BLOOM_PRETRAINED_MODEL_ARCHIVE_LIST = [
|
56 |
+
"bigscience/bigscience-small-testing",
|
57 |
+
"bigscience/bloom-560m",
|
58 |
+
"bigscience/bloom-1b1",
|
59 |
+
"bigscience/bloom-1b7",
|
60 |
+
"bigscience/bloom-3b",
|
61 |
+
"bigscience/bloom-7b1",
|
62 |
+
"bigscience/bloom",
|
63 |
+
]
|
64 |
+
|
65 |
+
|
66 |
+
def _make_causal_mask(
|
67 |
+
input_ids_shape: torch.Size, device: torch.device, past_key_values_length: int
|
68 |
+
) -> torch.BoolTensor:
|
69 |
+
"""
|
70 |
+
Make causal mask used for self-attention.
|
71 |
+
"""
|
72 |
+
batch_size, target_length = input_ids_shape
|
73 |
+
mask = torch.empty((target_length, target_length + past_key_values_length), dtype=torch.bool, device=device)
|
74 |
+
# ONNX doesn't support `torch.Tensor.triu` properly, thus we use this workaround
|
75 |
+
seq_ids = torch.arange(target_length, device=device)
|
76 |
+
mask[:, past_key_values_length:] = seq_ids[:, None] < seq_ids[None, :]
|
77 |
+
|
78 |
+
if past_key_values_length > 0:
|
79 |
+
mask[:, :past_key_values_length] = False
|
80 |
+
|
81 |
+
expanded_mask = mask[None, None, :, :].expand(batch_size, 1, target_length, target_length + past_key_values_length)
|
82 |
+
return expanded_mask
|
83 |
+
|
84 |
+
|
85 |
+
def _expand_mask(mask: torch.Tensor, tgt_length: int) -> torch.BoolTensor:
|
86 |
+
"""
|
87 |
+
Expands attention_mask from `[batch_size, src_length]` to `[batch_size, 1, tgt_length, src_length]`.
|
88 |
+
"""
|
89 |
+
batch_size, src_length = mask.shape
|
90 |
+
tgt_length = tgt_length if tgt_length is not None else src_length
|
91 |
+
|
92 |
+
expanded_mask = ~(mask[:, None, None, :].to(torch.bool))
|
93 |
+
return expanded_mask.expand(batch_size, 1, tgt_length, src_length)
|
94 |
+
|
95 |
+
|
96 |
+
def build_alibi_tensor(attention_mask: torch.Tensor, num_heads: int, dtype: torch.dtype) -> torch.Tensor:
|
97 |
+
"""
|
98 |
+
Link to paper: https://arxiv.org/abs/2108.12409 Alibi tensor is not causal as the original paper mentions, it
|
99 |
+
relies on a translation invariance of softmax for quick implementation: with l being a tensor, and a fixed value
|
100 |
+
`softmax(l+a) = softmax(l)`. Based on
|
101 |
+
https://github.com/ofirpress/attention_with_linear_biases/blob/a35aaca144e0eb6b789dfcb46784c4b8e31b7983/fairseq/models/transformer.py#L742
|
102 |
+
TODO @thomasw21 this doesn't work as nicely due to the masking strategy, and so masking varies slightly.
|
103 |
+
|
104 |
+
Args:
|
105 |
+
Returns tensor shaped (batch_size * num_heads, 1, max_seq_len)
|
106 |
+
attention_mask (`torch.Tensor`):
|
107 |
+
Token-wise attention mask, this should be of shape (batch_size, max_seq_len).
|
108 |
+
num_heads (`int`, *required*):
|
109 |
+
number of heads
|
110 |
+
dtype (`torch.dtype`, *optional*, default=`torch.bfloat16`):
|
111 |
+
dtype of the output tensor
|
112 |
+
"""
|
113 |
+
batch_size, seq_length = attention_mask.shape
|
114 |
+
closest_power_of_2 = 2 ** math.floor(math.log2(num_heads))
|
115 |
+
base = torch.tensor(
|
116 |
+
2 ** (-(2 ** -(math.log2(closest_power_of_2) - 3))), device=attention_mask.device, dtype=torch.float32
|
117 |
+
)
|
118 |
+
powers = torch.arange(1, 1 + closest_power_of_2, device=attention_mask.device, dtype=torch.int32)
|
119 |
+
slopes = torch.pow(base, powers)
|
120 |
+
|
121 |
+
if closest_power_of_2 != num_heads:
|
122 |
+
extra_base = torch.tensor(
|
123 |
+
2 ** (-(2 ** -(math.log2(2 * closest_power_of_2) - 3))), device=attention_mask.device, dtype=torch.float32
|
124 |
+
)
|
125 |
+
num_remaining_heads = min(closest_power_of_2, num_heads - closest_power_of_2)
|
126 |
+
extra_powers = torch.arange(1, 1 + 2 * num_remaining_heads, 2, device=attention_mask.device, dtype=torch.int32)
|
127 |
+
slopes = torch.cat([slopes, torch.pow(extra_base, extra_powers)], dim=0)
|
128 |
+
|
129 |
+
# Note: alibi will added to the attention bias that will be applied to the query, key product of attention
|
130 |
+
# => therefore alibi will have to be of shape (batch_size, num_heads, query_length, key_length)
|
131 |
+
# => here we set (batch_size=1, num_heads=num_heads, query_length=1, key_length=max_length)
|
132 |
+
# => the query_length dimension will then be broadcasted correctly
|
133 |
+
# This is more or less identical to T5's relative position bias:
|
134 |
+
# https://github.com/huggingface/transformers/blob/f681437203baa7671de3174b0fa583c349d9d5e1/src/transformers/models/t5/modeling_t5.py#L527
|
135 |
+
arange_tensor = ((attention_mask.cumsum(dim=-1) - 1) * attention_mask)[:, None, :]
|
136 |
+
alibi = slopes[..., None] * arange_tensor
|
137 |
+
return alibi.reshape(batch_size * num_heads, 1, seq_length).to(dtype)
|
138 |
+
|
139 |
+
|
140 |
+
def dropout_add(x: torch.Tensor, residual: torch.Tensor, prob: float, training: bool) -> torch.Tensor:
|
141 |
+
"""
|
142 |
+
Dropout add function
|
143 |
+
|
144 |
+
Args:
|
145 |
+
x (`torch.tensor`, *required*):
|
146 |
+
input tensor
|
147 |
+
residual (`torch.tensor`, *required*):
|
148 |
+
esidual tensor
|
149 |
+
prob (`float`, *required*):
|
150 |
+
dropout probability
|
151 |
+
training (`bool`, *required*):
|
152 |
+
training mode
|
153 |
+
"""
|
154 |
+
out = F.dropout(x, p=prob, training=training)
|
155 |
+
out = residual + out
|
156 |
+
return out
|
157 |
+
|
158 |
+
|
159 |
+
def bloom_gelu_forward(x: torch.Tensor) -> torch.Tensor:
|
160 |
+
"""
|
161 |
+
Custom bias GELU function. Adapted from Megatron-DeepSpeed code. Here we use a simple implementation (inference) to
|
162 |
+
make the model jitable.
|
163 |
+
|
164 |
+
Args:
|
165 |
+
x (`torch.tensor`, *required*):
|
166 |
+
input hidden states
|
167 |
+
"""
|
168 |
+
return x * 0.5 * (1.0 + torch.tanh(0.79788456 * x * (1 + 0.044715 * x * x)))
|
169 |
+
|
170 |
+
|
171 |
+
def bloom_gelu_back(g: torch.Tensor, x: torch.Tensor) -> torch.Tensor:
|
172 |
+
"""
|
173 |
+
gradient of tanh approximation of gelu gradient of actual gelu is: 0.5 * (1. + torch.erf(x * 0.70710678)) +
|
174 |
+
0.3989423 * x * torch.exp(-0.5 * x * x)
|
175 |
+
|
176 |
+
Args:
|
177 |
+
g (`torch.tensor`, *required*):
|
178 |
+
gradient output tensor
|
179 |
+
x (`torch.tensor`, *required*):
|
180 |
+
input tensor
|
181 |
+
"""
|
182 |
+
x = x[0] # x is a tuple of 1 element, needs to unpack it first
|
183 |
+
tanh_out = torch.tanh(0.79788456 * x * (1 + 0.044715 * x * x))
|
184 |
+
# sqrt(2/pi) * 3 * 0.044715 -> 0.1070322243
|
185 |
+
ff = 0.5 * x * ((1 - tanh_out * tanh_out) * (0.79788456 + 0.1070322243 * x * x)) + 0.5 * (1 + tanh_out)
|
186 |
+
return ff * g
|
187 |
+
|
188 |
+
|
189 |
+
class GeLUFunction(torch.autograd.Function):
|
190 |
+
|
191 |
+
@staticmethod
|
192 |
+
def forward(ctx, input: torch.Tensor) -> torch.Tensor:
|
193 |
+
ctx.save_for_backward(input)
|
194 |
+
return bloom_gelu_forward(input)
|
195 |
+
|
196 |
+
@staticmethod
|
197 |
+
def backward(ctx, grad_output: torch.Tensor) -> torch.Tensor:
|
198 |
+
input = ctx.saved_tensors
|
199 |
+
tmp = bloom_gelu_back(grad_output, input)
|
200 |
+
return tmp
|
201 |
+
|
202 |
+
|
203 |
+
class BloomGelu(nn.Module):
|
204 |
+
"""
|
205 |
+
BloomBiasGelu wrapper function that make use of the simple function on inference mode to make the model
|
206 |
+
torchscriptable and use the autograd function in training mode to get the accurate results of the gradients Partly
|
207 |
+
copied from Megatron-DeepSpeed code and adapted for our needs
|
208 |
+
|
209 |
+
See here why autograd functions are not torchscriptable: https://github.com/pytorch/pytorch/issues/22329
|
210 |
+
"""
|
211 |
+
|
212 |
+
def __init__(self):
|
213 |
+
super().__init__()
|
214 |
+
|
215 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
216 |
+
if self.training:
|
217 |
+
return GeLUFunction.apply(x)
|
218 |
+
else:
|
219 |
+
return bloom_gelu_forward(x)
|
220 |
+
|
221 |
+
|
222 |
+
class LlamaRotaryEmbedding(nn.Module):
|
223 |
+
|
224 |
+
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
|
225 |
+
super().__init__()
|
226 |
+
|
227 |
+
self.dim = dim
|
228 |
+
self.max_position_embeddings = max_position_embeddings
|
229 |
+
self.base = base
|
230 |
+
inv_freq = 1.0 / (self.base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
|
231 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
232 |
+
|
233 |
+
# Build here to make `torch.jit.trace` work.
|
234 |
+
# self._set_cos_sin_cache(
|
235 |
+
# seq_len=max_position_embeddings, device=self.inv_freq.device, dtype=torch.float32
|
236 |
+
# )
|
237 |
+
self.max_seq_len_cached = max_position_embeddings
|
238 |
+
self.cos_cached = None
|
239 |
+
self.sin_cached = None
|
240 |
+
|
241 |
+
def _set_cos_sin_cache(self, seq_len, device, dtype):
|
242 |
+
self.max_seq_len_cached = seq_len
|
243 |
+
t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
|
244 |
+
|
245 |
+
freqs = torch.einsum("i,j->ij", t, self.inv_freq)
|
246 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
247 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
248 |
+
self.cos_cached = emb.cos()[None, None, :, :].to(dtype)
|
249 |
+
self.sin_cached = emb.sin()[None, None, :, :].to(dtype)
|
250 |
+
|
251 |
+
def forward(self, x, seq_len=None):
|
252 |
+
# x: [bs, num_attention_heads, seq_len, head_size]
|
253 |
+
if self.cos_cached is None:
|
254 |
+
self._set_cos_sin_cache(seq_len=self.max_seq_len_cached, device=x.device, dtype=torch.float32)
|
255 |
+
if seq_len > self.max_seq_len_cached:
|
256 |
+
print('reset cos/sin cache')
|
257 |
+
self._set_cos_sin_cache(seq_len=seq_len, device=x.device, dtype=torch.float32)
|
258 |
+
|
259 |
+
self.cos_cached = self.cos_cached.to(x.device)
|
260 |
+
self.sin_cached = self.sin_cached.to(x.device)
|
261 |
+
return (
|
262 |
+
self.cos_cached[:, :, :seq_len, ...],
|
263 |
+
self.sin_cached[:, :, :seq_len, ...],
|
264 |
+
)
|
265 |
+
|
266 |
+
|
267 |
+
class LlamaLinearScalingRotaryEmbedding(LlamaRotaryEmbedding):
|
268 |
+
"""LlamaRotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
|
269 |
+
|
270 |
+
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
|
271 |
+
self.scaling_factor = scaling_factor
|
272 |
+
super().__init__(dim, max_position_embeddings, base, device)
|
273 |
+
|
274 |
+
def _set_cos_sin_cache(self, seq_len, device, dtype):
|
275 |
+
self.max_seq_len_cached = seq_len
|
276 |
+
t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
|
277 |
+
t = t / self.scaling_factor
|
278 |
+
|
279 |
+
freqs = torch.einsum("i,j->ij", t, self.inv_freq)
|
280 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
281 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
282 |
+
self.cos_cached = emb.cos()[None, None, :, :].to(dtype)
|
283 |
+
self.sin_cached = emb.sin()[None, None, :, :].to(dtype)
|
284 |
+
|
285 |
+
|
286 |
+
class LlamaDynamicNTKScalingRotaryEmbedding(LlamaRotaryEmbedding):
|
287 |
+
"""LlamaRotaryEmbedding extended with Dynamic NTK scaling. Credits to the Reddit users /u/bloc97 and /u/emozilla"""
|
288 |
+
|
289 |
+
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
|
290 |
+
self.scaling_factor = scaling_factor
|
291 |
+
super().__init__(dim, max_position_embeddings, base, device)
|
292 |
+
|
293 |
+
def _set_cos_sin_cache(self, seq_len, device, dtype):
|
294 |
+
self.max_seq_len_cached = seq_len
|
295 |
+
|
296 |
+
if seq_len > self.max_position_embeddings:
|
297 |
+
base = self.base * (
|
298 |
+
(self.scaling_factor * seq_len / self.max_position_embeddings) - (self.scaling_factor - 1)
|
299 |
+
) ** (self.dim / (self.dim - 2))
|
300 |
+
inv_freq = 1.0 / (base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
|
301 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
302 |
+
|
303 |
+
t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
|
304 |
+
|
305 |
+
freqs = torch.einsum("i,j->ij", t, self.inv_freq)
|
306 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
307 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
308 |
+
self.cos_cached = emb.cos()[None, None, :, :].to(dtype)
|
309 |
+
self.sin_cached = emb.sin()[None, None, :, :].to(dtype)
|
310 |
+
|
311 |
+
|
312 |
+
def rotate_half(x):
|
313 |
+
"""Rotates half the hidden dims of the input."""
|
314 |
+
x1 = x[..., : x.shape[-1] // 2]
|
315 |
+
x2 = x[..., x.shape[-1] // 2 :]
|
316 |
+
return torch.cat((-x2, x1), dim=-1)
|
317 |
+
|
318 |
+
|
319 |
+
def apply_rotary_pos_emb(q, k, cos, sin, position_ids):
|
320 |
+
'''
|
321 |
+
q: [bs, seq_len, num_heads, head_dim]
|
322 |
+
k: [bs, seq_len, num_heads, head_dim]
|
323 |
+
|
324 |
+
cos: [1, 1, seq_len, dim]
|
325 |
+
sin: [1, 1, seq_len, dim]
|
326 |
+
|
327 |
+
position_ids: [bs, seq_len]
|
328 |
+
'''
|
329 |
+
# The first two dimensions of cos and sin are always 1, so we can `squeeze` them.
|
330 |
+
cos = cos.squeeze(1).squeeze(0) # [seq_len, dim]
|
331 |
+
sin = sin.squeeze(1).squeeze(0) # [seq_len, dim]
|
332 |
+
|
333 |
+
cos = cos[position_ids].unsqueeze(2) # [bs, seq_len, 1, dim]
|
334 |
+
sin = sin[position_ids].unsqueeze(2) # [bs, seq_len, 1, dim]
|
335 |
+
|
336 |
+
# q_embed and k_embed: [bs, seq_len, num_heads, dim]
|
337 |
+
q_embed = (q.float() * cos) + (rotate_half(q.float()) * sin)
|
338 |
+
k_embed = (k.float() * cos) + (rotate_half(k.float()) * sin)
|
339 |
+
return q_embed.to(q.dtype), k_embed.to(k.dtype)
|
340 |
+
|
341 |
+
|
342 |
+
class BloomAttention(nn.Module):
|
343 |
+
|
344 |
+
def __init__(self, config: CCBloomConfig):
|
345 |
+
super().__init__()
|
346 |
+
|
347 |
+
self.config = config
|
348 |
+
self.pretraining_tp = config.pretraining_tp
|
349 |
+
self.slow_but_exact = config.slow_but_exact
|
350 |
+
|
351 |
+
self.hidden_size = config.hidden_size
|
352 |
+
self.num_heads = config.n_head
|
353 |
+
self.head_dim = self.hidden_size // self.num_heads
|
354 |
+
self.split_size = self.hidden_size
|
355 |
+
self.hidden_dropout = config.hidden_dropout
|
356 |
+
self.p_attn_dropout = config.attention_dropout
|
357 |
+
self.max_position_embeddings = config.seq_length
|
358 |
+
|
359 |
+
if self.head_dim * self.num_heads != self.hidden_size:
|
360 |
+
raise ValueError(
|
361 |
+
f"`hidden_size` must be divisible by num_heads (got `hidden_size`: {self.hidden_size} and `num_heads`:"
|
362 |
+
f" {self.num_heads})."
|
363 |
+
)
|
364 |
+
|
365 |
+
# Layer-wise attention scaling
|
366 |
+
self.inv_norm_factor = 1.0 / math.sqrt(self.head_dim)
|
367 |
+
self.beta = 1.0
|
368 |
+
|
369 |
+
self.query_key_value = nn.Linear(self.hidden_size, 3 * self.hidden_size, bias=True)
|
370 |
+
self.dense = nn.Linear(self.hidden_size, self.hidden_size)
|
371 |
+
self.attention_dropout = nn.Dropout(config.attention_dropout)
|
372 |
+
|
373 |
+
self._init_rope()
|
374 |
+
|
375 |
+
|
376 |
+
def _init_rope(self):
|
377 |
+
if self.config.rope_scaling is None:
|
378 |
+
self.rotary_emb = LlamaRotaryEmbedding(self.head_dim, max_position_embeddings=self.max_position_embeddings)
|
379 |
+
else:
|
380 |
+
scaling_type = self.config.rope_scaling["type"]
|
381 |
+
scaling_factor = self.config.rope_scaling["factor"]
|
382 |
+
if scaling_type == "linear":
|
383 |
+
self.rotary_emb = LlamaLinearScalingRotaryEmbedding(
|
384 |
+
self.head_dim, max_position_embeddings=self.max_position_embeddings, scaling_factor=scaling_factor
|
385 |
+
)
|
386 |
+
elif scaling_type == "dynamic":
|
387 |
+
self.rotary_emb = LlamaDynamicNTKScalingRotaryEmbedding(
|
388 |
+
self.head_dim, max_position_embeddings=self.max_position_embeddings, scaling_factor=scaling_factor
|
389 |
+
)
|
390 |
+
else:
|
391 |
+
raise ValueError(f"Unknown RoPE scaling type {scaling_type}")
|
392 |
+
|
393 |
+
|
394 |
+
def _split_heads(self, fused_qkv: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
395 |
+
"""
|
396 |
+
Split the last dimension into (num_heads, head_dim) without making any copies, results share same memory
|
397 |
+
storage as `fused_qkv`
|
398 |
+
|
399 |
+
Args:
|
400 |
+
fused_qkv (`torch.tensor`, *required*): [batch_size, seq_length, num_heads * 3 * head_dim]
|
401 |
+
|
402 |
+
Returns:
|
403 |
+
query: [batch_size, seq_length, num_heads, head_dim] key: [batch_size, seq_length, num_heads, head_dim]
|
404 |
+
value: [batch_size, seq_length, num_heads, head_dim]
|
405 |
+
"""
|
406 |
+
batch_size, seq_length, three_times_hidden_size = fused_qkv.shape
|
407 |
+
fused_qkv = fused_qkv.view(batch_size, seq_length, self.num_heads, 3, self.head_dim)
|
408 |
+
return fused_qkv[..., 0, :], fused_qkv[..., 1, :], fused_qkv[..., 2, :]
|
409 |
+
|
410 |
+
|
411 |
+
def forward(
|
412 |
+
self,
|
413 |
+
hidden_states: torch.Tensor,
|
414 |
+
residual: torch.Tensor,
|
415 |
+
# alibi: torch.Tensor,
|
416 |
+
attention_mask: torch.Tensor,
|
417 |
+
causal_mask: torch.Tensor,
|
418 |
+
layer_past: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
|
419 |
+
head_mask: Optional[torch.Tensor] = None,
|
420 |
+
use_cache: bool = False,
|
421 |
+
output_attentions: bool = False,
|
422 |
+
):
|
423 |
+
fused_qkv = self.query_key_value(hidden_states) # [batch_size, seq_length, 3 x hidden_size]
|
424 |
+
|
425 |
+
# 3 x [batch_size, seq_length, num_heads, head_dim]
|
426 |
+
(query_layer, key_layer, value_layer) = self._split_heads(fused_qkv)
|
427 |
+
batch_size, q_length, num_heads, head_dim = query_layer.shape
|
428 |
+
|
429 |
+
kv_length = key_layer.shape[1]
|
430 |
+
position_ids = attention_mask.cumsum(dim=-1) - 1
|
431 |
+
if layer_past is not None:
|
432 |
+
kv_length += layer_past[0].shape[1]
|
433 |
+
position_ids = position_ids[:, -1:]
|
434 |
+
|
435 |
+
## add rope
|
436 |
+
cos, sin = self.rotary_emb(value_layer, seq_len=kv_length)
|
437 |
+
query_layer, key_layer = apply_rotary_pos_emb(query_layer, key_layer, cos, sin, position_ids)
|
438 |
+
# still [bs, seq_len, num_heads, head_dim]
|
439 |
+
|
440 |
+
if layer_past is not None:
|
441 |
+
past_key, past_value = layer_past
|
442 |
+
# concatenate along seq_length dimension:
|
443 |
+
# - key: [batch_size, kv_length, num_heads, head_dim]
|
444 |
+
# - value: [batch_size, kv_length, num_heads, head_dim]
|
445 |
+
key_layer = torch.cat((past_key, key_layer), dim=1)
|
446 |
+
value_layer = torch.cat((past_value, value_layer), dim=1)
|
447 |
+
|
448 |
+
if use_cache is True:
|
449 |
+
present = (key_layer, value_layer)
|
450 |
+
else:
|
451 |
+
present = None
|
452 |
+
|
453 |
+
context_layer = self.compute_qkv_attn(query_layer, key_layer,
|
454 |
+
value_layer, causal_mask, head_mask=head_mask,
|
455 |
+
causal=layer_past is None)
|
456 |
+
|
457 |
+
# aggregate results across tp ranks. See here: https://github.com/pytorch/pytorch/issues/76232
|
458 |
+
if self.pretraining_tp > 1 and self.slow_but_exact:
|
459 |
+
slices = self.hidden_size / self.pretraining_tp
|
460 |
+
output_tensor = torch.zeros_like(context_layer)
|
461 |
+
for i in range(self.pretraining_tp):
|
462 |
+
output_tensor = output_tensor + F.linear(
|
463 |
+
context_layer[:, :, int(i * slices) : int((i + 1) * slices)],
|
464 |
+
self.dense.weight[:, int(i * slices) : int((i + 1) * slices)],
|
465 |
+
)
|
466 |
+
else:
|
467 |
+
output_tensor = self.dense(context_layer)
|
468 |
+
|
469 |
+
output_tensor = dropout_add(output_tensor, residual, self.hidden_dropout, self.training)
|
470 |
+
|
471 |
+
outputs = (output_tensor, present)
|
472 |
+
if output_attentions:
|
473 |
+
outputs += (attention_probs,)
|
474 |
+
|
475 |
+
return outputs
|
476 |
+
|
477 |
+
def compute_qkv_attn(self, query_layer, key_layer, value_layer, causal_mask, head_mask=None, causal=False):
|
478 |
+
batch_size, q_length, num_heads, head_dim = query_layer.shape
|
479 |
+
kv_length = key_layer.size(1)
|
480 |
+
|
481 |
+
query_layer = query_layer.transpose(1, 2)
|
482 |
+
key_layer = key_layer.permute(0, 2, 3, 1)
|
483 |
+
attn_weights = torch.matmul(query_layer, key_layer).mul(self.inv_norm_factor)
|
484 |
+
# attn_weights is [batch_size, num_heads, q_length, kv_length]
|
485 |
+
|
486 |
+
# cast attention scores to fp32, compute scaled softmax and cast back to initial dtype - [batch_size, num_heads, q_length, kv_length]
|
487 |
+
# `float16` has a minimum value of -65504.0, whereas `bfloat16` and `float32` have a minimum value of `-3.4e+38`
|
488 |
+
input_dtype = attn_weights.dtype
|
489 |
+
if input_dtype == torch.float16:
|
490 |
+
attn_weights = attn_weights.to(torch.float)
|
491 |
+
|
492 |
+
attn_weights = torch.masked_fill(attn_weights, causal_mask,
|
493 |
+
torch.finfo(attn_weights.dtype).min)
|
494 |
+
attention_probs = F.softmax(attn_weights, dim=-1, dtype=torch.float32).to(input_dtype)
|
495 |
+
# [batch_size, num_heads, q_length, kv_length]
|
496 |
+
|
497 |
+
attention_probs = self.attention_dropout(attention_probs)
|
498 |
+
|
499 |
+
if head_mask is not None:
|
500 |
+
attention_probs = attention_probs * head_mask
|
501 |
+
|
502 |
+
# change v view [bs, num_heads, kv_length, head_dim]
|
503 |
+
value_layer = value_layer.transpose(1, 2)
|
504 |
+
|
505 |
+
# matmul: [batch_size, num_heads, q_length, head_dim]
|
506 |
+
num = batch_size * num_heads
|
507 |
+
attention_probs = attention_probs.reshape(num, q_length, kv_length)
|
508 |
+
value_layer = value_layer.reshape(num, kv_length, head_dim)
|
509 |
+
context_layer = torch.bmm(attention_probs, value_layer)
|
510 |
+
context_layer = context_layer.reshape(batch_size, num_heads, q_length, head_dim)
|
511 |
+
context_layer = torch.einsum('bhld->blhd', context_layer)
|
512 |
+
context_layer = context_layer.flatten(2)
|
513 |
+
return context_layer
|
514 |
+
|
515 |
+
|
516 |
+
class BloomAttentionFlashAttn(BloomAttention):
|
517 |
+
|
518 |
+
def __init__(self, config: CCBloomConfig):
|
519 |
+
super().__init__(config)
|
520 |
+
|
521 |
+
def compute_qkv_attn(self, query_layer, key_layer, value_layer, causal_mask, head_mask=None, causal=False):
|
522 |
+
batch_size, q_length, num_heads, head_dim = query_layer.shape
|
523 |
+
|
524 |
+
# flash attention requires qkv to be [bs, seq_len, num_heads, head_dim]
|
525 |
+
context_layer = flash_attn_func(query_layer, key_layer,
|
526 |
+
value_layer, dropout_p=self.p_attn_dropout,
|
527 |
+
softmax_scale=self.inv_norm_factor, causal=causal)
|
528 |
+
# output is: [batch_size, q_length, num_heads, head_dim]
|
529 |
+
|
530 |
+
context_layer = context_layer.flatten(2)
|
531 |
+
return context_layer
|
532 |
+
|
533 |
+
|
534 |
+
class BloomAttentionTorchFast(BloomAttention):
|
535 |
+
|
536 |
+
def __init__(self, config: CCBloomConfig):
|
537 |
+
super().__init__(config)
|
538 |
+
|
539 |
+
def compute_qkv_attn(self, query_layer, key_layer, value_layer, causal_mask, head_mask=None, causal=False):
|
540 |
+
batch_size, q_length, num_heads, head_dim = query_layer.shape
|
541 |
+
kv_length = key_layer.size(1)
|
542 |
+
|
543 |
+
## requires qkv to have shape: [batch_size, num_heads, length, head_dim]
|
544 |
+
# query_layer = torch.einsum('blhd->bhld', query_layer)
|
545 |
+
# key_layer = torch.einsum('blhd->bhld', key_layer)
|
546 |
+
# value_layer = torch.einsum('blhd->bhld', value_layer)
|
547 |
+
query_layer = query_layer.transpose(1, 2)
|
548 |
+
key_layer = key_layer.transpose(1, 2)
|
549 |
+
value_layer = value_layer.transpose(1, 2)
|
550 |
+
attn_mask = torch.zeros(batch_size, 1, q_length, kv_length,
|
551 |
+
device=query_layer.device, dtype=query_layer.dtype)
|
552 |
+
attn_mask.masked_fill_(causal_mask, torch.finfo(attn_mask.dtype).min)
|
553 |
+
with torch.backends.cuda.sdp_kernel(enable_flash=True, enable_math=True, enable_mem_efficient=True):
|
554 |
+
context_layer = F.scaled_dot_product_attention(query_layer, key_layer,
|
555 |
+
value_layer, dropout_p=self.p_attn_dropout, attn_mask=attn_mask,
|
556 |
+
scale=self.inv_norm_factor)
|
557 |
+
context_layer = context_layer.transpose(1, 2)
|
558 |
+
# context_layer = torch.einsum('blhd->bhld', context_layer)
|
559 |
+
|
560 |
+
context_layer = context_layer.flatten(2)
|
561 |
+
return context_layer
|
562 |
+
|
563 |
+
|
564 |
+
|
565 |
+
class BloomMLP(nn.Module):
|
566 |
+
|
567 |
+
def __init__(self, config: CCBloomConfig):
|
568 |
+
super().__init__()
|
569 |
+
hidden_size = config.hidden_size
|
570 |
+
|
571 |
+
self.pretraining_tp = config.pretraining_tp
|
572 |
+
self.slow_but_exact = config.slow_but_exact
|
573 |
+
self.dense_h_to_4h = nn.Linear(hidden_size, 4 * hidden_size)
|
574 |
+
self.gelu_impl = BloomGelu()
|
575 |
+
self.dense_4h_to_h = nn.Linear(4 * hidden_size, hidden_size)
|
576 |
+
self.hidden_dropout = config.hidden_dropout
|
577 |
+
|
578 |
+
def forward(self, hidden_states: torch.Tensor, residual: torch.Tensor) -> torch.Tensor:
|
579 |
+
hidden_states = self.gelu_impl(self.dense_h_to_4h(hidden_states))
|
580 |
+
|
581 |
+
if self.pretraining_tp > 1 and self.slow_but_exact:
|
582 |
+
intermediate_output = torch.zeros_like(residual)
|
583 |
+
slices = self.dense_4h_to_h.weight.shape[-1] / self.pretraining_tp
|
584 |
+
for i in range(self.pretraining_tp):
|
585 |
+
intermediate_output = intermediate_output + F.linear(
|
586 |
+
hidden_states[:, :, int(i * slices) : int((i + 1) * slices)],
|
587 |
+
self.dense_4h_to_h.weight[:, int(i * slices) : int((i + 1) * slices)],
|
588 |
+
)
|
589 |
+
else:
|
590 |
+
intermediate_output = self.dense_4h_to_h(hidden_states)
|
591 |
+
|
592 |
+
output = dropout_add(intermediate_output, residual, self.hidden_dropout, self.training)
|
593 |
+
|
594 |
+
return output
|
595 |
+
|
596 |
+
|
597 |
+
class BloomBlock(nn.Module):
|
598 |
+
|
599 |
+
def __init__(self, config: CCBloomConfig):
|
600 |
+
super().__init__()
|
601 |
+
self.config = config
|
602 |
+
hidden_size = config.hidden_size
|
603 |
+
|
604 |
+
self.input_layernorm = LayerNorm(hidden_size, eps=config.layer_norm_epsilon)
|
605 |
+
self.num_heads = config.n_head
|
606 |
+
|
607 |
+
if config.use_flash_attn:
|
608 |
+
self.self_attention = BloomAttentionFlashAttn(config)
|
609 |
+
else:
|
610 |
+
self.self_attention = BloomAttention(config)
|
611 |
+
# self.self_attention = BloomAttentionTorchFast(config)
|
612 |
+
|
613 |
+
self.post_attention_layernorm = LayerNorm(hidden_size, eps=config.layer_norm_epsilon)
|
614 |
+
|
615 |
+
self.mlp = BloomMLP(config)
|
616 |
+
|
617 |
+
self.apply_residual_connection_post_layernorm = config.apply_residual_connection_post_layernorm
|
618 |
+
self.hidden_dropout = config.hidden_dropout
|
619 |
+
|
620 |
+
# @torch.compile
|
621 |
+
def forward(
|
622 |
+
self,
|
623 |
+
hidden_states: torch.Tensor,
|
624 |
+
attention_mask: torch.Tensor,
|
625 |
+
causal_mask: torch.Tensor,
|
626 |
+
layer_past: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
|
627 |
+
head_mask: Optional[torch.Tensor] = None,
|
628 |
+
use_cache: bool = False,
|
629 |
+
output_attentions: bool = False,
|
630 |
+
):
|
631 |
+
# hidden_states: [batch_size, seq_length, hidden_size]
|
632 |
+
|
633 |
+
# Layer norm at the beginning of the transformer layer.
|
634 |
+
layernorm_output = self.input_layernorm(hidden_states)
|
635 |
+
|
636 |
+
# Layer norm post the self attention.
|
637 |
+
if self.apply_residual_connection_post_layernorm:
|
638 |
+
residual = layernorm_output
|
639 |
+
else:
|
640 |
+
residual = hidden_states
|
641 |
+
|
642 |
+
# Self attention.
|
643 |
+
attn_outputs = self.self_attention(
|
644 |
+
layernorm_output,
|
645 |
+
residual,
|
646 |
+
layer_past=layer_past,
|
647 |
+
attention_mask=attention_mask,
|
648 |
+
causal_mask=causal_mask,
|
649 |
+
# alibi=alibi,
|
650 |
+
head_mask=head_mask,
|
651 |
+
use_cache=use_cache,
|
652 |
+
output_attentions=output_attentions,
|
653 |
+
)
|
654 |
+
|
655 |
+
attention_output = attn_outputs[0]
|
656 |
+
|
657 |
+
outputs = attn_outputs[1:]
|
658 |
+
|
659 |
+
layernorm_output = self.post_attention_layernorm(attention_output)
|
660 |
+
|
661 |
+
# Get residual
|
662 |
+
if self.apply_residual_connection_post_layernorm:
|
663 |
+
residual = layernorm_output
|
664 |
+
else:
|
665 |
+
residual = attention_output
|
666 |
+
|
667 |
+
# MLP.
|
668 |
+
output = self.mlp(layernorm_output, residual)
|
669 |
+
|
670 |
+
if use_cache:
|
671 |
+
outputs = (output,) + outputs
|
672 |
+
else:
|
673 |
+
outputs = (output,) + outputs[1:]
|
674 |
+
|
675 |
+
return outputs # hidden_states, present, attentions
|
676 |
+
|
677 |
+
|
678 |
+
class NormHead(nn.Module):
|
679 |
+
|
680 |
+
def __init__(self, hidden_size, vocab_size, bias=False):
|
681 |
+
super().__init__()
|
682 |
+
self.weight = nn.Parameter(torch.empty((vocab_size, hidden_size)))
|
683 |
+
nn.init.kaiming_uniform_(self.weight, a=math.sqrt(5))
|
684 |
+
self.first_flag = True
|
685 |
+
|
686 |
+
def forward(self, hidden_states):
|
687 |
+
if self.training:
|
688 |
+
norm_weight = nn.functional.normalize(self.weight)
|
689 |
+
elif self.first_flag:
|
690 |
+
self.first_flag = False
|
691 |
+
self.weight = nn.Parameter(nn.functional.normalize(self.weight))
|
692 |
+
norm_weight = self.weight
|
693 |
+
else:
|
694 |
+
norm_weight = self.weight
|
695 |
+
return F.linear(hidden_states, norm_weight)
|
696 |
+
|
697 |
+
|
698 |
+
class SmoothEmbedding(nn.Embedding):
|
699 |
+
|
700 |
+
def __init__(self, vocab_size, embed_dim):
|
701 |
+
super().__init__(vocab_size, embed_dim)
|
702 |
+
|
703 |
+
def forward(self, input_ids):
|
704 |
+
word_emb = super().forward(input_ids)
|
705 |
+
mean_emb = self.weight.mean(dim=0, keepdim=True)
|
706 |
+
emb = word_emb * 0.9 + mean_emb * 0.1
|
707 |
+
return emb
|
708 |
+
|
709 |
+
|
710 |
+
class BloomPreTrainedModel(PreTrainedModel):
|
711 |
+
_keys_to_ignore_on_load_missing = [r"h.*.self_attention.scale_mask_softmax.causal_mask", r"lm_head.weight"]
|
712 |
+
"""
|
713 |
+
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
|
714 |
+
models.
|
715 |
+
"""
|
716 |
+
|
717 |
+
config_class = CCBloomConfig
|
718 |
+
base_model_prefix = "transformer"
|
719 |
+
supports_gradient_checkpointing = True
|
720 |
+
_no_split_modules = ["BloomBlock"]
|
721 |
+
_skip_keys_device_placement = "past_key_values"
|
722 |
+
|
723 |
+
def __init__(self, *inputs, **kwargs):
|
724 |
+
super().__init__(*inputs, **kwargs)
|
725 |
+
|
726 |
+
def _init_weights(self, module: nn.Module):
|
727 |
+
"""Initialize the weights."""
|
728 |
+
if isinstance(module, nn.Linear):
|
729 |
+
# Slightly different from the TF version which uses truncated_normal for initialization
|
730 |
+
# cf https://github.com/pytorch/pytorch/pull/5617
|
731 |
+
module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
|
732 |
+
if module.bias is not None:
|
733 |
+
module.bias.data.zero_()
|
734 |
+
elif isinstance(module, nn.Embedding):
|
735 |
+
module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
|
736 |
+
if module.padding_idx is not None:
|
737 |
+
module.weight.data[module.padding_idx].zero_()
|
738 |
+
elif isinstance(module, LayerNorm):
|
739 |
+
module.bias.data.zero_()
|
740 |
+
module.weight.data.fill_(1.0)
|
741 |
+
|
742 |
+
def _set_gradient_checkpointing(self, module: nn.Module, value: bool = False):
|
743 |
+
if isinstance(module, BloomModel):
|
744 |
+
module.gradient_checkpointing = value
|
745 |
+
|
746 |
+
@staticmethod
|
747 |
+
def _convert_to_standard_cache(
|
748 |
+
past_key_value: Tuple[Tuple[torch.Tensor, torch.Tensor]], batch_size: int
|
749 |
+
) -> Tuple[Tuple[torch.Tensor, torch.Tensor]]:
|
750 |
+
"""
|
751 |
+
Standardizes the format of the cache so as to match most implementations, i.e. to tuple(tuple([batch_size,
|
752 |
+
num_heads, ...]))
|
753 |
+
"""
|
754 |
+
# seq_length, num_heads, head_dim = past_key_value[0][0].shape
|
755 |
+
# batch_size_times_num_heads, seq_length, head_dim = past_key_value[0][0].shape
|
756 |
+
# num_heads = batch_size_times_num_heads // batch_size
|
757 |
+
# key: [batch_size, seq_length, num_heads, head_dim] -> [batch_size, num_heads, head_dim, seq_length]
|
758 |
+
# value: [batch_size, seq_length, num_heads, head_dim] -> [batch_size, num_heads, seq_length, head_dim]
|
759 |
+
return tuple(
|
760 |
+
(
|
761 |
+
layer_past[0].permute(0, 2, 3, 1),
|
762 |
+
layer_past[1].permute(0, 2, 1, 3),
|
763 |
+
)
|
764 |
+
for layer_past in past_key_value
|
765 |
+
)
|
766 |
+
|
767 |
+
@staticmethod
|
768 |
+
def _convert_to_bloom_cache(
|
769 |
+
past_key_value: Tuple[Tuple[torch.Tensor, torch.Tensor]]
|
770 |
+
) -> Tuple[Tuple[torch.Tensor, torch.Tensor]]:
|
771 |
+
"""
|
772 |
+
Converts the cache to the format expected by Bloom, i.e. to tuple(tuple([batch_size * num_heads, ...]))
|
773 |
+
"""
|
774 |
+
# key: [batch_size, num_heads, head_dim, seq_length] -> [batch_size, seq_length, num_heads, head_dim]
|
775 |
+
# value: [batch_size, num_heads, seq_length, head_dim] -> [batch_size, seq_length, num_heads, head_dim]
|
776 |
+
return tuple(
|
777 |
+
(
|
778 |
+
torch.einsum('bhdl->blhd', layer_past[0]),
|
779 |
+
torch.einsum('bhld->blhd', layer_past[1])
|
780 |
+
)
|
781 |
+
for layer_past in past_key_value
|
782 |
+
)
|
783 |
+
|
784 |
+
|
785 |
+
BLOOM_START_DOCSTRING = r"""
|
786 |
+
|
787 |
+
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
|
788 |
+
library implements for all its model (such as downloading or saving, resizing the input embeddings etc.)
|
789 |
+
|
790 |
+
This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
|
791 |
+
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
|
792 |
+
and behavior.
|
793 |
+
|
794 |
+
Parameters:
|
795 |
+
config ([`CCBloomConfig`]): Model configuration class with all the parameters of the model.
|
796 |
+
Initializing with a config file does not load the weights associated with the model, only the
|
797 |
+
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
|
798 |
+
"""
|
799 |
+
|
800 |
+
BLOOM_INPUTS_DOCSTRING = r"""
|
801 |
+
Args:
|
802 |
+
input_ids (`torch.LongTensor` of shape `(batch_size, input_ids_length)`):
|
803 |
+
`input_ids_length` = `sequence_length` if `past_key_values` is `None` else `past_key_values[0][0].shape[2]`
|
804 |
+
(`sequence_length` of input past key value states). Indices of input sequence tokens in the vocabulary.
|
805 |
+
|
806 |
+
If `past_key_values` is used, only `input_ids` that do not have their past calculated should be passed as
|
807 |
+
`input_ids`.
|
808 |
+
|
809 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
810 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
811 |
+
|
812 |
+
[What are input IDs?](../glossary#input-ids)
|
813 |
+
past_key_values (`Tuple[Tuple[torch.Tensor]]` of length `config.n_layers`):
|
814 |
+
Contains precomputed hidden-states (key and values in the attention blocks) as computed by the model (see
|
815 |
+
`past_key_values` output below). Can be used to speed up sequential decoding. The `input_ids` which have
|
816 |
+
their past given to this model should not be passed as `input_ids` as they have already been computed.
|
817 |
+
|
818 |
+
Each element of `past_key_values` is a tuple (past_key, past_value):
|
819 |
+
- past_key: [batch_size * num_heads, head_dim, kv_length]
|
820 |
+
- past_value: [batch_size * num_heads, kv_length, head_dim]
|
821 |
+
attention_mask (`torch.FloatTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
822 |
+
Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
|
823 |
+
|
824 |
+
- 1 for tokens that are **not masked**,
|
825 |
+
- 0 for tokens that are **masked**.
|
826 |
+
|
827 |
+
[What are attention masks?](../glossary#attention-mask)
|
828 |
+
head_mask (`torch.FloatTensor` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*):
|
829 |
+
Mask to nullify selected heads of the self-attention modules. Mask values selected in `[0, 1]`:
|
830 |
+
|
831 |
+
- 1 indicates the head is **not masked**,
|
832 |
+
- 0 indicates the head is **masked**.
|
833 |
+
|
834 |
+
inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
|
835 |
+
Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
|
836 |
+
is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
|
837 |
+
model's internal embedding lookup matrix.
|
838 |
+
|
839 |
+
If `past_key_values` is used, optionally only the last `inputs_embeds` have to be input (see
|
840 |
+
`past_key_values`).
|
841 |
+
use_cache (`bool`, *optional*):
|
842 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
|
843 |
+
`past_key_values`).
|
844 |
+
output_attentions (`bool`, *optional*):
|
845 |
+
Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
|
846 |
+
tensors for more detail.
|
847 |
+
output_hidden_states (`bool`, *optional*):
|
848 |
+
Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
|
849 |
+
more detail.
|
850 |
+
return_dict (`bool`, *optional*):
|
851 |
+
Whether or not to return a [`~file_utils.ModelOutput`] instead of a plain tuple.
|
852 |
+
"""
|
853 |
+
|
854 |
+
|
855 |
+
@add_start_docstrings(
|
856 |
+
"The bare Bloom Model transformer outputting raw hidden-states without any specific head on top.",
|
857 |
+
BLOOM_START_DOCSTRING,
|
858 |
+
)
|
859 |
+
class BloomModel(BloomPreTrainedModel):
|
860 |
+
_auto_class = 'ccbloom'
|
861 |
+
|
862 |
+
def __init__(self, config: CCBloomConfig):
|
863 |
+
super().__init__(config)
|
864 |
+
|
865 |
+
self.embed_dim = config.hidden_size
|
866 |
+
self.num_heads = config.n_head
|
867 |
+
|
868 |
+
# Embedding + LN Embedding
|
869 |
+
self.word_embeddings = SmoothEmbedding(config.vocab_size, self.embed_dim)
|
870 |
+
# self.word_embeddings = nn.Embedding(config.vocab_size, self.embed_dim)
|
871 |
+
self.word_embeddings_layernorm = LayerNorm(self.embed_dim, eps=config.layer_norm_epsilon)
|
872 |
+
|
873 |
+
# Transformer blocks
|
874 |
+
self.h = nn.ModuleList([BloomBlock(config) for _ in range(config.num_hidden_layers)])
|
875 |
+
|
876 |
+
# Final Layer Norm
|
877 |
+
self.ln_f = LayerNorm(self.embed_dim, eps=config.layer_norm_epsilon)
|
878 |
+
|
879 |
+
self.gradient_checkpointing = False
|
880 |
+
|
881 |
+
# Initialize weights and apply final processing
|
882 |
+
self.post_init()
|
883 |
+
|
884 |
+
def build_alibi_tensor(self, attention_mask: torch.Tensor, num_heads: int, dtype: torch.dtype) -> torch.Tensor:
|
885 |
+
return build_alibi_tensor(attention_mask, num_heads, dtype)
|
886 |
+
|
887 |
+
def get_input_embeddings(self):
|
888 |
+
return self.word_embeddings
|
889 |
+
|
890 |
+
def _prepare_attn_mask(
|
891 |
+
self, attention_mask: torch.Tensor, input_shape: Tuple[int, int], past_key_values_length: int
|
892 |
+
) -> torch.BoolTensor:
|
893 |
+
# create causal mask
|
894 |
+
# [batch_size, seq_length] -> [batch_size, 1, tgt_length, src_length]
|
895 |
+
combined_attention_mask = None
|
896 |
+
device = attention_mask.device
|
897 |
+
_, src_length = input_shape
|
898 |
+
|
899 |
+
if src_length > 1:
|
900 |
+
combined_attention_mask = _make_causal_mask(
|
901 |
+
input_shape, device=device, past_key_values_length=past_key_values_length
|
902 |
+
)
|
903 |
+
|
904 |
+
# [batch_size, seq_length] -> [batch_size, 1, tgt_length, src_length]
|
905 |
+
expanded_attn_mask = _expand_mask(attention_mask, tgt_length=src_length)
|
906 |
+
combined_attention_mask = (
|
907 |
+
expanded_attn_mask if combined_attention_mask is None else expanded_attn_mask | combined_attention_mask
|
908 |
+
)
|
909 |
+
|
910 |
+
return combined_attention_mask
|
911 |
+
|
912 |
+
def set_input_embeddings(self, new_embeddings: torch.Tensor):
|
913 |
+
self.word_embeddings = new_embeddings
|
914 |
+
|
915 |
+
@add_start_docstrings_to_model_forward(BLOOM_INPUTS_DOCSTRING)
|
916 |
+
@add_code_sample_docstrings(
|
917 |
+
checkpoint=_CHECKPOINT_FOR_DOC,
|
918 |
+
output_type=BaseModelOutputWithPastAndCrossAttentions,
|
919 |
+
config_class=_CONFIG_FOR_DOC,
|
920 |
+
)
|
921 |
+
def forward(
|
922 |
+
self,
|
923 |
+
input_ids: Optional[torch.LongTensor] = None,
|
924 |
+
past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
|
925 |
+
attention_mask: Optional[torch.Tensor] = None,
|
926 |
+
head_mask: Optional[torch.LongTensor] = None,
|
927 |
+
inputs_embeds: Optional[torch.LongTensor] = None,
|
928 |
+
use_cache: Optional[bool] = None,
|
929 |
+
output_attentions: Optional[bool] = None,
|
930 |
+
output_hidden_states: Optional[bool] = None,
|
931 |
+
return_dict: Optional[bool] = None,
|
932 |
+
**deprecated_arguments,
|
933 |
+
) -> Union[Tuple[torch.Tensor, ...], BaseModelOutputWithPastAndCrossAttentions]:
|
934 |
+
if deprecated_arguments.pop("position_ids", False) is not False:
|
935 |
+
# `position_ids` could have been `torch.Tensor` or `None` so defaulting pop to `False` allows to detect if users were passing explicitly `None`
|
936 |
+
warnings.warn(
|
937 |
+
"`position_ids` have no functionality in BLOOM and will be removed in v5.0.0. You can safely ignore"
|
938 |
+
" passing `position_ids`.",
|
939 |
+
FutureWarning,
|
940 |
+
)
|
941 |
+
if len(deprecated_arguments) > 0:
|
942 |
+
raise ValueError(f"Got unexpected arguments: {deprecated_arguments}")
|
943 |
+
|
944 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
945 |
+
output_hidden_states = (
|
946 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
947 |
+
)
|
948 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
949 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
950 |
+
|
951 |
+
if input_ids is not None and inputs_embeds is not None:
|
952 |
+
raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
|
953 |
+
elif input_ids is not None:
|
954 |
+
batch_size, seq_length = input_ids.shape
|
955 |
+
elif inputs_embeds is not None:
|
956 |
+
batch_size, seq_length, _ = inputs_embeds.shape
|
957 |
+
else:
|
958 |
+
raise ValueError("You have to specify either input_ids or inputs_embeds")
|
959 |
+
|
960 |
+
if past_key_values is None:
|
961 |
+
past_key_values = tuple([None] * len(self.h))
|
962 |
+
|
963 |
+
# Prepare head mask if needed
|
964 |
+
# 1.0 in head_mask indicate we keep the head
|
965 |
+
# attention_probs has shape batch_size x num_heads x N x N
|
966 |
+
# head_mask has shape n_layer x batch x num_heads x N x N
|
967 |
+
head_mask = self.get_head_mask(head_mask, self.config.n_layer)
|
968 |
+
|
969 |
+
if inputs_embeds is None:
|
970 |
+
inputs_embeds = self.word_embeddings(input_ids)
|
971 |
+
|
972 |
+
hidden_states = self.word_embeddings_layernorm(inputs_embeds)
|
973 |
+
|
974 |
+
presents = () if use_cache else None
|
975 |
+
all_self_attentions = () if output_attentions else None
|
976 |
+
all_hidden_states = () if output_hidden_states else None
|
977 |
+
|
978 |
+
if self.gradient_checkpointing and self.training:
|
979 |
+
if use_cache:
|
980 |
+
logger.warning_once(
|
981 |
+
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
|
982 |
+
)
|
983 |
+
use_cache = False
|
984 |
+
|
985 |
+
# Compute alibi tensor: check build_alibi_tensor documentation
|
986 |
+
seq_length_with_past = seq_length
|
987 |
+
past_key_values_length = 0
|
988 |
+
if past_key_values[0] is not None:
|
989 |
+
past_key_values_length = past_key_values[0][0].shape[2]
|
990 |
+
seq_length_with_past = seq_length_with_past + past_key_values_length
|
991 |
+
if attention_mask is None:
|
992 |
+
attention_mask = torch.ones((batch_size, seq_length_with_past), device=hidden_states.device)
|
993 |
+
else:
|
994 |
+
attention_mask = attention_mask.to(hidden_states.device)
|
995 |
+
|
996 |
+
## lower triangular mask
|
997 |
+
causal_mask = None
|
998 |
+
if self.config.use_flash_attn == False:
|
999 |
+
# if True:
|
1000 |
+
causal_mask = self._prepare_attn_mask(
|
1001 |
+
attention_mask,
|
1002 |
+
input_shape=(batch_size, seq_length),
|
1003 |
+
past_key_values_length=past_key_values_length,
|
1004 |
+
)
|
1005 |
+
|
1006 |
+
for i, (block, layer_past) in enumerate(zip(self.h, past_key_values)):
|
1007 |
+
if output_hidden_states:
|
1008 |
+
all_hidden_states = all_hidden_states + (hidden_states,)
|
1009 |
+
|
1010 |
+
if self.gradient_checkpointing and self.training:
|
1011 |
+
|
1012 |
+
def create_custom_forward(module):
|
1013 |
+
def custom_forward(*inputs):
|
1014 |
+
# None for past_key_value
|
1015 |
+
return module(*inputs, use_cache=use_cache, output_attentions=output_attentions)
|
1016 |
+
|
1017 |
+
return custom_forward
|
1018 |
+
|
1019 |
+
outputs = torch.utils.checkpoint.checkpoint(
|
1020 |
+
create_custom_forward(block),
|
1021 |
+
hidden_states,
|
1022 |
+
attention_mask,
|
1023 |
+
causal_mask,
|
1024 |
+
layer_past,
|
1025 |
+
head_mask[i],
|
1026 |
+
)
|
1027 |
+
else:
|
1028 |
+
outputs = block(
|
1029 |
+
hidden_states,
|
1030 |
+
layer_past=layer_past,
|
1031 |
+
attention_mask=attention_mask,
|
1032 |
+
causal_mask=causal_mask,
|
1033 |
+
head_mask=head_mask[i],
|
1034 |
+
use_cache=use_cache,
|
1035 |
+
output_attentions=output_attentions,
|
1036 |
+
)
|
1037 |
+
|
1038 |
+
hidden_states = outputs[0]
|
1039 |
+
if use_cache is True:
|
1040 |
+
presents = presents + (outputs[1],)
|
1041 |
+
|
1042 |
+
if output_attentions:
|
1043 |
+
all_self_attentions = all_self_attentions + (outputs[2 if use_cache else 1],)
|
1044 |
+
|
1045 |
+
# Add last hidden state
|
1046 |
+
hidden_states = self.ln_f(hidden_states)
|
1047 |
+
|
1048 |
+
if output_hidden_states:
|
1049 |
+
all_hidden_states = all_hidden_states + (hidden_states,)
|
1050 |
+
|
1051 |
+
if not return_dict:
|
1052 |
+
return tuple(v for v in [hidden_states, presents, all_hidden_states, all_self_attentions] if v is not None)
|
1053 |
+
|
1054 |
+
return BaseModelOutputWithPastAndCrossAttentions(
|
1055 |
+
last_hidden_state=hidden_states,
|
1056 |
+
past_key_values=presents,
|
1057 |
+
hidden_states=all_hidden_states,
|
1058 |
+
attentions=all_self_attentions,
|
1059 |
+
)
|
1060 |
+
|
1061 |
+
|
1062 |
+
@add_start_docstrings(
|
1063 |
+
"""
|
1064 |
+
The Bloom Model transformer with a language modeling head on top (linear layer with weights tied to the input
|
1065 |
+
embeddings).
|
1066 |
+
""",
|
1067 |
+
BLOOM_START_DOCSTRING,
|
1068 |
+
)
|
1069 |
+
class CCBloomForCausalLM(BloomPreTrainedModel):
|
1070 |
+
_keys_to_ignore_on_load_missing = [r"h.*.self_attention.scale_mask_softmax.causal_mask", r"lm_head.weight"]
|
1071 |
+
|
1072 |
+
def __init__(self, config: CCBloomConfig):
|
1073 |
+
super().__init__(config)
|
1074 |
+
self.transformer = BloomModel(config)
|
1075 |
+
# self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
1076 |
+
self.lm_head = NormHead(config.hidden_size, config.vocab_size)
|
1077 |
+
|
1078 |
+
# Initialize weights and apply final processing
|
1079 |
+
self.post_init()
|
1080 |
+
|
1081 |
+
def get_output_embeddings(self):
|
1082 |
+
return self.lm_head
|
1083 |
+
|
1084 |
+
def set_output_embeddings(self, new_embeddings: torch.Tensor):
|
1085 |
+
self.lm_head = new_embeddings
|
1086 |
+
|
1087 |
+
def prepare_inputs_for_generation(
|
1088 |
+
self,
|
1089 |
+
input_ids: torch.LongTensor,
|
1090 |
+
past_key_values: Optional[torch.Tensor] = None,
|
1091 |
+
attention_mask: Optional[torch.Tensor] = None,
|
1092 |
+
inputs_embeds: Optional[torch.Tensor] = None,
|
1093 |
+
**kwargs,
|
1094 |
+
) -> dict:
|
1095 |
+
# only last token for input_ids if past is not None
|
1096 |
+
if past_key_values:
|
1097 |
+
input_ids = input_ids[:, -1].unsqueeze(-1)
|
1098 |
+
|
1099 |
+
# the cache may be in the stardard format (e.g. in contrastive search), convert to bloom's format if needed
|
1100 |
+
# if past_key_values[0][0].shape[0] == input_ids.shape[0]:
|
1101 |
+
# past_key_values = self._convert_to_bloom_cache(past_key_values)
|
1102 |
+
|
1103 |
+
# if `inputs_embeds` are passed, we only want to use them in the 1st generation step
|
1104 |
+
if inputs_embeds is not None and past_key_values is None:
|
1105 |
+
model_inputs = {"inputs_embeds": inputs_embeds}
|
1106 |
+
else:
|
1107 |
+
model_inputs = {"input_ids": input_ids}
|
1108 |
+
|
1109 |
+
model_inputs.update(
|
1110 |
+
{
|
1111 |
+
"past_key_values": past_key_values,
|
1112 |
+
"use_cache": kwargs.get("use_cache"),
|
1113 |
+
"attention_mask": attention_mask,
|
1114 |
+
}
|
1115 |
+
)
|
1116 |
+
return model_inputs
|
1117 |
+
|
1118 |
+
@add_start_docstrings_to_model_forward(BLOOM_INPUTS_DOCSTRING)
|
1119 |
+
@add_code_sample_docstrings(
|
1120 |
+
checkpoint=_CHECKPOINT_FOR_DOC,
|
1121 |
+
output_type=CausalLMOutputWithCrossAttentions,
|
1122 |
+
config_class=_CONFIG_FOR_DOC,
|
1123 |
+
)
|
1124 |
+
def forward(
|
1125 |
+
self,
|
1126 |
+
input_ids: Optional[torch.LongTensor] = None,
|
1127 |
+
past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
|
1128 |
+
attention_mask: Optional[torch.Tensor] = None,
|
1129 |
+
head_mask: Optional[torch.Tensor] = None,
|
1130 |
+
inputs_embeds: Optional[torch.Tensor] = None,
|
1131 |
+
labels: Optional[torch.Tensor] = None,
|
1132 |
+
use_cache: Optional[bool] = None,
|
1133 |
+
output_attentions: Optional[bool] = None,
|
1134 |
+
output_hidden_states: Optional[bool] = None,
|
1135 |
+
return_dict: Optional[bool] = None,
|
1136 |
+
**deprecated_arguments,
|
1137 |
+
) -> Union[Tuple[torch.Tensor], CausalLMOutputWithCrossAttentions]:
|
1138 |
+
r"""
|
1139 |
+
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
1140 |
+
Labels for language modeling. Note that the labels **are shifted** inside the model, i.e. you can set
|
1141 |
+
`labels = input_ids` Indices are selected in `[-100, 0, ..., config.vocab_size]` All labels set to `-100`
|
1142 |
+
are ignored (masked), the loss is only computed for labels in `[0, ..., config.vocab_size]`
|
1143 |
+
"""
|
1144 |
+
if deprecated_arguments.pop("position_ids", False) is not False:
|
1145 |
+
# `position_ids` could have been `torch.Tensor` or `None` so defaulting pop to `False` allows to detect if users were passing explicitly `None`
|
1146 |
+
warnings.warn(
|
1147 |
+
"`position_ids` have no functionality in BLOOM and will be removed in v5.0.0. You can safely ignore"
|
1148 |
+
" passing `position_ids`.",
|
1149 |
+
FutureWarning,
|
1150 |
+
)
|
1151 |
+
if len(deprecated_arguments) > 0:
|
1152 |
+
raise ValueError(f"Got unexpected arguments: {deprecated_arguments}")
|
1153 |
+
|
1154 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
1155 |
+
|
1156 |
+
transformer_outputs = self.transformer(
|
1157 |
+
input_ids,
|
1158 |
+
past_key_values=past_key_values,
|
1159 |
+
attention_mask=attention_mask,
|
1160 |
+
head_mask=head_mask,
|
1161 |
+
inputs_embeds=inputs_embeds,
|
1162 |
+
use_cache=use_cache,
|
1163 |
+
output_attentions=output_attentions,
|
1164 |
+
output_hidden_states=output_hidden_states,
|
1165 |
+
return_dict=return_dict,
|
1166 |
+
)
|
1167 |
+
hidden_states = transformer_outputs[0]
|
1168 |
+
|
1169 |
+
lm_logits = self.lm_head(hidden_states)
|
1170 |
+
|
1171 |
+
loss = None
|
1172 |
+
if labels is not None:
|
1173 |
+
# move labels to correct device to enable model parallelism
|
1174 |
+
labels = labels.to(lm_logits.device)
|
1175 |
+
# Shift so that tokens < n predict n
|
1176 |
+
shift_logits = lm_logits[..., :-1, :].contiguous()
|
1177 |
+
shift_labels = labels[..., 1:].contiguous()
|
1178 |
+
batch_size, seq_length, vocab_size = shift_logits.shape
|
1179 |
+
# Flatten the tokens
|
1180 |
+
loss_fct = CrossEntropyLoss()
|
1181 |
+
loss = loss_fct(
|
1182 |
+
shift_logits.view(batch_size * seq_length, vocab_size), shift_labels.view(batch_size * seq_length)
|
1183 |
+
)
|
1184 |
+
|
1185 |
+
if not return_dict:
|
1186 |
+
output = (lm_logits,) + transformer_outputs[1:]
|
1187 |
+
return ((loss,) + output) if loss is not None else output
|
1188 |
+
|
1189 |
+
return CausalLMOutputWithCrossAttentions(
|
1190 |
+
loss=loss,
|
1191 |
+
logits=lm_logits,
|
1192 |
+
past_key_values=transformer_outputs.past_key_values,
|
1193 |
+
hidden_states=transformer_outputs.hidden_states,
|
1194 |
+
attentions=transformer_outputs.attentions,
|
1195 |
+
)
|
1196 |
+
|
1197 |
+
def _reorder_cache(
|
1198 |
+
self, past: Tuple[Tuple[torch.Tensor, torch.Tensor], ...], beam_idx: torch.LongTensor
|
1199 |
+
) -> Tuple[Tuple[torch.Tensor, torch.Tensor], ...]:
|
1200 |
+
"""
|
1201 |
+
This function is used to re-order the `past_key_values` cache if [`~PreTrainedModel.beam_search`] or
|
1202 |
+
[`~PreTrainedModel.beam_sample`] is called. This is required to match `past_key_values` with the correct
|
1203 |
+
beam_idx at every generation step.
|
1204 |
+
|
1205 |
+
Output shares the same memory storage as `past`.
|
1206 |
+
"""
|
1207 |
+
standardized_past = self._convert_to_standard_cache(past, batch_size=len(beam_idx))
|
1208 |
+
|
1209 |
+
# Get a copy of `beam_idx` on all the devices where we need those indices.
|
1210 |
+
device_to_beam_idx = {
|
1211 |
+
past_state.device: beam_idx.to(past_state.device) for layer_past in past for past_state in layer_past
|
1212 |
+
}
|
1213 |
+
reordered_past = tuple(
|
1214 |
+
(
|
1215 |
+
layer_past[0].index_select(0, device_to_beam_idx[layer_past[0].device]),
|
1216 |
+
layer_past[1].index_select(0, device_to_beam_idx[layer_past[0].device]),
|
1217 |
+
)
|
1218 |
+
for layer_past in standardized_past
|
1219 |
+
)
|
1220 |
+
return self._convert_to_bloom_cache(reordered_past)
|
1221 |
+
|
1222 |
+
|
1223 |
+
@add_start_docstrings(
|
1224 |
+
"""
|
1225 |
+
The Bloom Model transformer with a sequence classification head on top (linear layer).
|
1226 |
+
|
1227 |
+
[`BloomForSequenceClassification`] uses the last token in order to do the classification, as other causal models
|
1228 |
+
(e.g. GPT-1) do.
|
1229 |
+
|
1230 |
+
Since it does classification on the last token, it requires to know the position of the last token. If a
|
1231 |
+
`pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
|
1232 |
+
no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
|
1233 |
+
padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
|
1234 |
+
each row of the batch).
|
1235 |
+
""",
|
1236 |
+
BLOOM_START_DOCSTRING,
|
1237 |
+
)
|
1238 |
+
class BloomForSequenceClassification(BloomPreTrainedModel):
|
1239 |
+
_keys_to_ignore_on_load_missing = [r"h.*.self_attention.scale_mask_softmax.causal_mask", r"lm_head.weight"]
|
1240 |
+
|
1241 |
+
def __init__(self, config: CCBloomConfig):
|
1242 |
+
super().__init__(config)
|
1243 |
+
self.num_labels = config.num_labels
|
1244 |
+
self.transformer = BloomModel(config)
|
1245 |
+
self.score = nn.Linear(config.hidden_size, config.num_labels, bias=False)
|
1246 |
+
|
1247 |
+
# Initialize weights and apply final processing
|
1248 |
+
self.post_init()
|
1249 |
+
|
1250 |
+
@add_start_docstrings_to_model_forward(BLOOM_INPUTS_DOCSTRING)
|
1251 |
+
@add_code_sample_docstrings(
|
1252 |
+
checkpoint=_CHECKPOINT_FOR_DOC,
|
1253 |
+
output_type=SequenceClassifierOutputWithPast,
|
1254 |
+
config_class=_CONFIG_FOR_DOC,
|
1255 |
+
)
|
1256 |
+
def forward(
|
1257 |
+
self,
|
1258 |
+
input_ids: Optional[torch.LongTensor] = None,
|
1259 |
+
past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
|
1260 |
+
attention_mask: Optional[torch.Tensor] = None,
|
1261 |
+
head_mask: Optional[torch.Tensor] = None,
|
1262 |
+
inputs_embeds: Optional[torch.Tensor] = None,
|
1263 |
+
labels: Optional[torch.Tensor] = None,
|
1264 |
+
use_cache: Optional[bool] = None,
|
1265 |
+
output_attentions: Optional[bool] = None,
|
1266 |
+
output_hidden_states: Optional[bool] = None,
|
1267 |
+
return_dict: Optional[bool] = None,
|
1268 |
+
**deprecated_arguments,
|
1269 |
+
) -> Union[Tuple[torch.Tensor], SequenceClassifierOutputWithPast]:
|
1270 |
+
r"""
|
1271 |
+
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
|
1272 |
+
Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
|
1273 |
+
config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
|
1274 |
+
`config.num_labels > 1` a classification loss is computed (Cross-Entropy).
|
1275 |
+
"""
|
1276 |
+
if deprecated_arguments.pop("position_ids", False) is not False:
|
1277 |
+
# `position_ids` could have been `torch.Tensor` or `None` so defaulting pop to `False` allows to detect if users were passing explicitly `None`
|
1278 |
+
warnings.warn(
|
1279 |
+
"`position_ids` have no functionality in BLOOM and will be removed in v5.0.0. You can safely ignore"
|
1280 |
+
" passing `position_ids`.",
|
1281 |
+
FutureWarning,
|
1282 |
+
)
|
1283 |
+
if len(deprecated_arguments) > 0:
|
1284 |
+
raise ValueError(f"Got unexpected arguments: {deprecated_arguments}")
|
1285 |
+
|
1286 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
1287 |
+
|
1288 |
+
transformer_outputs = self.transformer(
|
1289 |
+
input_ids,
|
1290 |
+
past_key_values=past_key_values,
|
1291 |
+
attention_mask=attention_mask,
|
1292 |
+
head_mask=head_mask,
|
1293 |
+
inputs_embeds=inputs_embeds,
|
1294 |
+
use_cache=use_cache,
|
1295 |
+
output_attentions=output_attentions,
|
1296 |
+
output_hidden_states=output_hidden_states,
|
1297 |
+
return_dict=return_dict,
|
1298 |
+
)
|
1299 |
+
|
1300 |
+
hidden_states = transformer_outputs[0]
|
1301 |
+
logits = self.score(hidden_states)
|
1302 |
+
|
1303 |
+
if input_ids is not None:
|
1304 |
+
batch_size = input_ids.shape[0]
|
1305 |
+
else:
|
1306 |
+
batch_size = inputs_embeds.shape[0]
|
1307 |
+
|
1308 |
+
if self.config.pad_token_id is None and batch_size != 1:
|
1309 |
+
raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
|
1310 |
+
if self.config.pad_token_id is None:
|
1311 |
+
sequence_lengths = -1
|
1312 |
+
else:
|
1313 |
+
if input_ids is not None:
|
1314 |
+
sequence_lengths = (torch.ne(input_ids, self.config.pad_token_id).sum(-1) - 1).to(logits.device)
|
1315 |
+
else:
|
1316 |
+
sequence_lengths = -1
|
1317 |
+
logger.warning(
|
1318 |
+
f"{self.__class__.__name__} will not detect padding tokens in `inputs_embeds`. Results may be "
|
1319 |
+
"unexpected if using padding tokens in conjunction with `inputs_embeds.`"
|
1320 |
+
)
|
1321 |
+
|
1322 |
+
pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
|
1323 |
+
|
1324 |
+
loss = None
|
1325 |
+
if labels is not None:
|
1326 |
+
if self.config.problem_type is None:
|
1327 |
+
if self.num_labels == 1:
|
1328 |
+
self.config.problem_type = "regression"
|
1329 |
+
elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
|
1330 |
+
self.config.problem_type = "single_label_classification"
|
1331 |
+
else:
|
1332 |
+
self.config.problem_type = "multi_label_classification"
|
1333 |
+
|
1334 |
+
if self.config.problem_type == "regression":
|
1335 |
+
loss_fct = MSELoss()
|
1336 |
+
if self.num_labels == 1:
|
1337 |
+
loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
|
1338 |
+
else:
|
1339 |
+
loss = loss_fct(pooled_logits, labels)
|
1340 |
+
elif self.config.problem_type == "single_label_classification":
|
1341 |
+
loss_fct = CrossEntropyLoss()
|
1342 |
+
loss = loss_fct(pooled_logits, labels)
|
1343 |
+
elif self.config.problem_type == "multi_label_classification":
|
1344 |
+
loss_fct = BCEWithLogitsLoss()
|
1345 |
+
loss = loss_fct(pooled_logits, labels)
|
1346 |
+
if not return_dict:
|
1347 |
+
output = (pooled_logits,) + transformer_outputs[1:]
|
1348 |
+
return ((loss,) + output) if loss is not None else output
|
1349 |
+
|
1350 |
+
return SequenceClassifierOutputWithPast(
|
1351 |
+
loss=loss,
|
1352 |
+
logits=pooled_logits,
|
1353 |
+
past_key_values=transformer_outputs.past_key_values,
|
1354 |
+
hidden_states=transformer_outputs.hidden_states,
|
1355 |
+
attentions=transformer_outputs.attentions,
|
1356 |
+
)
|
1357 |
+
|
1358 |
+
|
1359 |
+
@add_start_docstrings(
|
1360 |
+
"""
|
1361 |
+
Bloom Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
|
1362 |
+
Named-Entity-Recognition (NER) tasks.
|
1363 |
+
""",
|
1364 |
+
BLOOM_START_DOCSTRING,
|
1365 |
+
)
|
1366 |
+
class BloomForTokenClassification(BloomPreTrainedModel):
|
1367 |
+
_keys_to_ignore_on_load_missing = [r"h.*.self_attention.scale_mask_softmax.causal_mask", r"lm_head.weight"]
|
1368 |
+
|
1369 |
+
def __init__(self, config: CCBloomConfig):
|
1370 |
+
super().__init__(config)
|
1371 |
+
self.num_labels = config.num_labels
|
1372 |
+
|
1373 |
+
self.transformer = BloomModel(config)
|
1374 |
+
if hasattr(config, "classifier_dropout") and config.classifier_dropout is not None:
|
1375 |
+
classifier_dropout = config.classifier_dropout
|
1376 |
+
elif hasattr(config, "hidden_dropout") and config.hidden_dropout is not None:
|
1377 |
+
classifier_dropout = config.hidden_dropout
|
1378 |
+
else:
|
1379 |
+
classifier_dropout = 0.1
|
1380 |
+
self.dropout = nn.Dropout(classifier_dropout)
|
1381 |
+
self.classifier = nn.Linear(config.hidden_size, config.num_labels)
|
1382 |
+
|
1383 |
+
# Initialize weights and apply final processing
|
1384 |
+
self.post_init()
|
1385 |
+
|
1386 |
+
@add_start_docstrings_to_model_forward(BLOOM_INPUTS_DOCSTRING)
|
1387 |
+
@add_code_sample_docstrings(
|
1388 |
+
checkpoint=_CHECKPOINT_FOR_DOC,
|
1389 |
+
output_type=TokenClassifierOutput,
|
1390 |
+
config_class=_CONFIG_FOR_DOC,
|
1391 |
+
)
|
1392 |
+
def forward(
|
1393 |
+
self,
|
1394 |
+
input_ids: Optional[torch.LongTensor] = None,
|
1395 |
+
past_key_values: Optional[Tuple[Tuple[torch.Tensor, torch.Tensor], ...]] = None,
|
1396 |
+
attention_mask: Optional[torch.Tensor] = None,
|
1397 |
+
head_mask: Optional[torch.Tensor] = None,
|
1398 |
+
inputs_embeds: Optional[torch.Tensor] = None,
|
1399 |
+
labels: Optional[torch.Tensor] = None,
|
1400 |
+
use_cache: Optional[bool] = None,
|
1401 |
+
output_attentions: Optional[bool] = None,
|
1402 |
+
output_hidden_states: Optional[bool] = None,
|
1403 |
+
return_dict: Optional[bool] = None,
|
1404 |
+
**deprecated_arguments,
|
1405 |
+
) -> Union[Tuple[torch.Tensor], TokenClassifierOutput]:
|
1406 |
+
r"""
|
1407 |
+
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
|
1408 |
+
Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
|
1409 |
+
config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
|
1410 |
+
`config.num_labels > 1` a classification loss is computed (Cross-Entropy).
|
1411 |
+
"""
|
1412 |
+
if deprecated_arguments.pop("position_ids", False) is not False:
|
1413 |
+
# `position_ids` could have been `torch.Tensor` or `None` so defaulting pop to `False` allows to detect if users were passing explicitly `None`
|
1414 |
+
warnings.warn(
|
1415 |
+
"`position_ids` have no functionality in BLOOM and will be removed in v5.0.0. You can safely ignore"
|
1416 |
+
" passing `position_ids`.",
|
1417 |
+
FutureWarning,
|
1418 |
+
)
|
1419 |
+
if len(deprecated_arguments) > 0:
|
1420 |
+
raise ValueError(f"Got unexpected arguments: {deprecated_arguments}")
|
1421 |
+
|
1422 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
1423 |
+
|
1424 |
+
transformer_outputs = self.transformer(
|
1425 |
+
input_ids,
|
1426 |
+
past_key_values=past_key_values,
|
1427 |
+
attention_mask=attention_mask,
|
1428 |
+
head_mask=head_mask,
|
1429 |
+
inputs_embeds=inputs_embeds,
|
1430 |
+
use_cache=use_cache,
|
1431 |
+
output_attentions=output_attentions,
|
1432 |
+
output_hidden_states=output_hidden_states,
|
1433 |
+
return_dict=return_dict,
|
1434 |
+
)
|
1435 |
+
|
1436 |
+
hidden_states = transformer_outputs[0]
|
1437 |
+
hidden_states = self.dropout(hidden_states)
|
1438 |
+
logits = self.classifier(hidden_states)
|
1439 |
+
|
1440 |
+
loss = None
|
1441 |
+
if labels is not None:
|
1442 |
+
# move labels to correct device to enable model parallelism
|
1443 |
+
labels = labels.to(logits.device)
|
1444 |
+
batch_size, seq_length = labels.shape
|
1445 |
+
loss_fct = CrossEntropyLoss()
|
1446 |
+
loss = loss_fct(
|
1447 |
+
logits.view(batch_size * seq_length, self.num_labels), labels.view(batch_size * seq_length)
|
1448 |
+
)
|
1449 |
+
|
1450 |
+
if not return_dict:
|
1451 |
+
output = (logits,) + transformer_outputs[2:]
|
1452 |
+
return ((loss,) + output) if loss is not None else output
|
1453 |
+
|
1454 |
+
return TokenClassifierOutput(
|
1455 |
+
loss=loss,
|
1456 |
+
logits=logits,
|
1457 |
+
hidden_states=transformer_outputs.hidden_states,
|
1458 |
+
attentions=transformer_outputs.attentions,
|
1459 |
+
)
|
1460 |
+
|
1461 |
+
|
1462 |
+
@add_start_docstrings(
|
1463 |
+
"""
|
1464 |
+
The BLOOM Model transformer with a span classification head on top for extractive question-answering tasks like
|
1465 |
+
SQuAD (a linear layers on top of the hidden-states output to compute `span start logits` and `span end logits`).
|
1466 |
+
""",
|
1467 |
+
BLOOM_START_DOCSTRING,
|
1468 |
+
)
|
1469 |
+
class BloomForQuestionAnswering(BloomPreTrainedModel):
|
1470 |
+
_keys_to_ignore_on_load_missing = [r"h.*.self_attention.scale_mask_softmax.causal_mask", r"lm_head.weight"]
|
1471 |
+
|
1472 |
+
def __init__(self, config):
|
1473 |
+
super().__init__(config)
|
1474 |
+
self.transformer = BloomModel(config)
|
1475 |
+
self.qa_outputs = nn.Linear(config.hidden_size, 2)
|
1476 |
+
|
1477 |
+
# Initialize weights and apply final processing
|
1478 |
+
self.post_init()
|
1479 |
+
|
1480 |
+
@add_start_docstrings_to_model_forward(BLOOM_INPUTS_DOCSTRING.format("batch_size, sequence_length"))
|
1481 |
+
def forward(
|
1482 |
+
self,
|
1483 |
+
input_ids: Optional[torch.LongTensor] = None,
|
1484 |
+
attention_mask: Optional[torch.FloatTensor] = None,
|
1485 |
+
position_ids: Optional[torch.LongTensor] = None,
|
1486 |
+
head_mask: Optional[torch.FloatTensor] = None,
|
1487 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
1488 |
+
start_positions: Optional[torch.LongTensor] = None,
|
1489 |
+
end_positions: Optional[torch.LongTensor] = None,
|
1490 |
+
output_attentions: Optional[bool] = None,
|
1491 |
+
output_hidden_states: Optional[bool] = None,
|
1492 |
+
return_dict: Optional[bool] = None,
|
1493 |
+
) -> Union[Tuple, QuestionAnsweringModelOutput]:
|
1494 |
+
r"""
|
1495 |
+
start_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
|
1496 |
+
Labels for position (index) of the start of the labelled span for computing the token classification loss.
|
1497 |
+
Positions are clamped to the length of the sequence (`sequence_length`). Position outside of the sequence
|
1498 |
+
are not taken into account for computing the loss.
|
1499 |
+
end_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
|
1500 |
+
Labels for position (index) of the end of the labelled span for computing the token classification loss.
|
1501 |
+
Positions are clamped to the length of the sequence (`sequence_length`). Position outside of the sequence
|
1502 |
+
are not taken into account for computing the loss.
|
1503 |
+
"""
|
1504 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
1505 |
+
|
1506 |
+
outputs = self.transformer(
|
1507 |
+
input_ids,
|
1508 |
+
attention_mask=attention_mask,
|
1509 |
+
position_ids=position_ids,
|
1510 |
+
head_mask=head_mask,
|
1511 |
+
inputs_embeds=inputs_embeds,
|
1512 |
+
output_attentions=output_attentions,
|
1513 |
+
output_hidden_states=output_hidden_states,
|
1514 |
+
return_dict=return_dict,
|
1515 |
+
)
|
1516 |
+
|
1517 |
+
sequence_output = outputs[0]
|
1518 |
+
|
1519 |
+
logits = self.qa_outputs(sequence_output)
|
1520 |
+
start_logits, end_logits = logits.split(1, dim=-1)
|
1521 |
+
start_logits = start_logits.squeeze(-1).contiguous()
|
1522 |
+
end_logits = end_logits.squeeze(-1).contiguous()
|
1523 |
+
|
1524 |
+
total_loss = None
|
1525 |
+
if start_positions is not None and end_positions is not None:
|
1526 |
+
# If we are on multi-GPU, split add a dimension
|
1527 |
+
if len(start_positions.size()) > 1:
|
1528 |
+
start_positions = start_positions.squeeze(-1)
|
1529 |
+
if len(end_positions.size()) > 1:
|
1530 |
+
end_positions = end_positions.squeeze(-1)
|
1531 |
+
# sometimes the start/end positions are outside our model inputs, we ignore these terms
|
1532 |
+
ignored_index = start_logits.size(1)
|
1533 |
+
start_positions = start_positions.clamp(0, ignored_index)
|
1534 |
+
end_positions = end_positions.clamp(0, ignored_index)
|
1535 |
+
|
1536 |
+
loss_fct = CrossEntropyLoss(ignore_index=ignored_index)
|
1537 |
+
start_loss = loss_fct(start_logits, start_positions)
|
1538 |
+
end_loss = loss_fct(end_logits, end_positions)
|
1539 |
+
total_loss = (start_loss + end_loss) / 2
|
1540 |
+
|
1541 |
+
if not return_dict:
|
1542 |
+
output = (start_logits, end_logits) + outputs[2:]
|
1543 |
+
return ((total_loss,) + output) if total_loss is not None else output
|
1544 |
+
|
1545 |
+
return QuestionAnsweringModelOutput(
|
1546 |
+
loss=total_loss,
|
1547 |
+
start_logits=start_logits,
|
1548 |
+
end_logits=end_logits,
|
1549 |
+
hidden_states=outputs.hidden_states,
|
1550 |
+
attentions=outputs.attentions,
|
1551 |
+
)
|
1552 |
+
|
pytorch_model-00001-of-00014.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:df5ba779f2b1d0ffcc19fda8d8a958a430743a14eae2c0fc3fa198dd5bc23693
|
3 |
+
size 927086401
|
pytorch_model-00002-of-00014.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ed09b6a4a5ae5b1917ee05f5f7484581a98b92b4f5ac2d1167734a4b140e8a50
|
3 |
+
size 939796331
|
pytorch_model-00003-of-00014.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d7d027fb4930f1f7d22682211889de321a164d6092bc5d30d8e7b8c15cf1cdd7
|
3 |
+
size 939778659
|
pytorch_model-00004-of-00014.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:29058b10814361ae89c78eabced2d7e9a1abfca3c2fe0c77f17e29ac48b3533b
|
3 |
+
size 939771079
|
pytorch_model-00005-of-00014.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fffda31283253b879a348fbb094110873a0a32d01983f1368f691df827b1732d
|
3 |
+
size 939796331
|
pytorch_model-00006-of-00014.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a0a732472370f3025055b988379d9c289c0d1ffc3d28c4106e1e92ba265c9482
|
3 |
+
size 939778659
|
pytorch_model-00007-of-00014.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ff1b12fe6e14db5aa2680298df1fe76dac02247c7590c12f5e1a0d02c7e59105
|
3 |
+
size 939771079
|
pytorch_model-00008-of-00014.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2b7fdd228fdd86bc2ddc61d6671d1ea187749f5a7ec0012f2938a9219ed0a6aa
|
3 |
+
size 939796331
|
pytorch_model-00009-of-00014.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:64fc0567bb455d1763bf8262876c785db3a0eab04a51115feae4bccf84b10bfc
|
3 |
+
size 939778659
|
pytorch_model-00010-of-00014.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:488679b37dad5e9416e87129689944b89c796809b7a2e5ab93e3beba8e8c58f9
|
3 |
+
size 939771079
|
pytorch_model-00011-of-00014.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:44a3ad467d6b8c8b43d48fb6ce8a9855d671c8739376fd6fd6be2253b320d806
|
3 |
+
size 939796331
|
pytorch_model-00012-of-00014.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7be7478ffbc5e6f6075dc2eea80a29a34335f9158036506fdebd37ae67fd5946
|
3 |
+
size 939778659
|
pytorch_model-00013-of-00014.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9c261788ad6d5003622fac486b098b3e55ea46c686a7d3d28c226dd686c437a8
|
3 |
+
size 939771079
|
pytorch_model-00014-of-00014.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6f37f159283ca191a4af43fcc60c0909c6f09c8334073c45b4cd587c4ca986c3
|
3 |
+
size 927052345
|
pytorch_model.bin.index.json
ADDED
@@ -0,0 +1,373 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"metadata": {
|
3 |
+
"total_size": 13131399168
|
4 |
+
},
|
5 |
+
"weight_map": {
|
6 |
+
"lm_head.weight": "pytorch_model-00014-of-00014.bin",
|
7 |
+
"transformer.h.0.input_layernorm.bias": "pytorch_model-00001-of-00014.bin",
|
8 |
+
"transformer.h.0.input_layernorm.weight": "pytorch_model-00001-of-00014.bin",
|
9 |
+
"transformer.h.0.mlp.dense_4h_to_h.bias": "pytorch_model-00001-of-00014.bin",
|
10 |
+
"transformer.h.0.mlp.dense_4h_to_h.weight": "pytorch_model-00001-of-00014.bin",
|
11 |
+
"transformer.h.0.mlp.dense_h_to_4h.bias": "pytorch_model-00001-of-00014.bin",
|
12 |
+
"transformer.h.0.mlp.dense_h_to_4h.weight": "pytorch_model-00001-of-00014.bin",
|
13 |
+
"transformer.h.0.post_attention_layernorm.bias": "pytorch_model-00001-of-00014.bin",
|
14 |
+
"transformer.h.0.post_attention_layernorm.weight": "pytorch_model-00001-of-00014.bin",
|
15 |
+
"transformer.h.0.self_attention.dense.bias": "pytorch_model-00001-of-00014.bin",
|
16 |
+
"transformer.h.0.self_attention.dense.weight": "pytorch_model-00001-of-00014.bin",
|
17 |
+
"transformer.h.0.self_attention.query_key_value.bias": "pytorch_model-00001-of-00014.bin",
|
18 |
+
"transformer.h.0.self_attention.query_key_value.weight": "pytorch_model-00001-of-00014.bin",
|
19 |
+
"transformer.h.1.input_layernorm.bias": "pytorch_model-00001-of-00014.bin",
|
20 |
+
"transformer.h.1.input_layernorm.weight": "pytorch_model-00001-of-00014.bin",
|
21 |
+
"transformer.h.1.mlp.dense_4h_to_h.bias": "pytorch_model-00002-of-00014.bin",
|
22 |
+
"transformer.h.1.mlp.dense_4h_to_h.weight": "pytorch_model-00002-of-00014.bin",
|
23 |
+
"transformer.h.1.mlp.dense_h_to_4h.bias": "pytorch_model-00002-of-00014.bin",
|
24 |
+
"transformer.h.1.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00014.bin",
|
25 |
+
"transformer.h.1.post_attention_layernorm.bias": "pytorch_model-00002-of-00014.bin",
|
26 |
+
"transformer.h.1.post_attention_layernorm.weight": "pytorch_model-00002-of-00014.bin",
|
27 |
+
"transformer.h.1.self_attention.dense.bias": "pytorch_model-00002-of-00014.bin",
|
28 |
+
"transformer.h.1.self_attention.dense.weight": "pytorch_model-00002-of-00014.bin",
|
29 |
+
"transformer.h.1.self_attention.query_key_value.bias": "pytorch_model-00002-of-00014.bin",
|
30 |
+
"transformer.h.1.self_attention.query_key_value.weight": "pytorch_model-00002-of-00014.bin",
|
31 |
+
"transformer.h.10.input_layernorm.bias": "pytorch_model-00005-of-00014.bin",
|
32 |
+
"transformer.h.10.input_layernorm.weight": "pytorch_model-00005-of-00014.bin",
|
33 |
+
"transformer.h.10.mlp.dense_4h_to_h.bias": "pytorch_model-00006-of-00014.bin",
|
34 |
+
"transformer.h.10.mlp.dense_4h_to_h.weight": "pytorch_model-00006-of-00014.bin",
|
35 |
+
"transformer.h.10.mlp.dense_h_to_4h.bias": "pytorch_model-00006-of-00014.bin",
|
36 |
+
"transformer.h.10.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00014.bin",
|
37 |
+
"transformer.h.10.post_attention_layernorm.bias": "pytorch_model-00005-of-00014.bin",
|
38 |
+
"transformer.h.10.post_attention_layernorm.weight": "pytorch_model-00005-of-00014.bin",
|
39 |
+
"transformer.h.10.self_attention.dense.bias": "pytorch_model-00005-of-00014.bin",
|
40 |
+
"transformer.h.10.self_attention.dense.weight": "pytorch_model-00005-of-00014.bin",
|
41 |
+
"transformer.h.10.self_attention.query_key_value.bias": "pytorch_model-00005-of-00014.bin",
|
42 |
+
"transformer.h.10.self_attention.query_key_value.weight": "pytorch_model-00005-of-00014.bin",
|
43 |
+
"transformer.h.11.input_layernorm.bias": "pytorch_model-00006-of-00014.bin",
|
44 |
+
"transformer.h.11.input_layernorm.weight": "pytorch_model-00006-of-00014.bin",
|
45 |
+
"transformer.h.11.mlp.dense_4h_to_h.bias": "pytorch_model-00006-of-00014.bin",
|
46 |
+
"transformer.h.11.mlp.dense_4h_to_h.weight": "pytorch_model-00006-of-00014.bin",
|
47 |
+
"transformer.h.11.mlp.dense_h_to_4h.bias": "pytorch_model-00006-of-00014.bin",
|
48 |
+
"transformer.h.11.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00014.bin",
|
49 |
+
"transformer.h.11.post_attention_layernorm.bias": "pytorch_model-00006-of-00014.bin",
|
50 |
+
"transformer.h.11.post_attention_layernorm.weight": "pytorch_model-00006-of-00014.bin",
|
51 |
+
"transformer.h.11.self_attention.dense.bias": "pytorch_model-00006-of-00014.bin",
|
52 |
+
"transformer.h.11.self_attention.dense.weight": "pytorch_model-00006-of-00014.bin",
|
53 |
+
"transformer.h.11.self_attention.query_key_value.bias": "pytorch_model-00006-of-00014.bin",
|
54 |
+
"transformer.h.11.self_attention.query_key_value.weight": "pytorch_model-00006-of-00014.bin",
|
55 |
+
"transformer.h.12.input_layernorm.bias": "pytorch_model-00006-of-00014.bin",
|
56 |
+
"transformer.h.12.input_layernorm.weight": "pytorch_model-00006-of-00014.bin",
|
57 |
+
"transformer.h.12.mlp.dense_4h_to_h.bias": "pytorch_model-00007-of-00014.bin",
|
58 |
+
"transformer.h.12.mlp.dense_4h_to_h.weight": "pytorch_model-00007-of-00014.bin",
|
59 |
+
"transformer.h.12.mlp.dense_h_to_4h.bias": "pytorch_model-00006-of-00014.bin",
|
60 |
+
"transformer.h.12.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00014.bin",
|
61 |
+
"transformer.h.12.post_attention_layernorm.bias": "pytorch_model-00006-of-00014.bin",
|
62 |
+
"transformer.h.12.post_attention_layernorm.weight": "pytorch_model-00006-of-00014.bin",
|
63 |
+
"transformer.h.12.self_attention.dense.bias": "pytorch_model-00006-of-00014.bin",
|
64 |
+
"transformer.h.12.self_attention.dense.weight": "pytorch_model-00006-of-00014.bin",
|
65 |
+
"transformer.h.12.self_attention.query_key_value.bias": "pytorch_model-00006-of-00014.bin",
|
66 |
+
"transformer.h.12.self_attention.query_key_value.weight": "pytorch_model-00006-of-00014.bin",
|
67 |
+
"transformer.h.13.input_layernorm.bias": "pytorch_model-00007-of-00014.bin",
|
68 |
+
"transformer.h.13.input_layernorm.weight": "pytorch_model-00007-of-00014.bin",
|
69 |
+
"transformer.h.13.mlp.dense_4h_to_h.bias": "pytorch_model-00007-of-00014.bin",
|
70 |
+
"transformer.h.13.mlp.dense_4h_to_h.weight": "pytorch_model-00007-of-00014.bin",
|
71 |
+
"transformer.h.13.mlp.dense_h_to_4h.bias": "pytorch_model-00007-of-00014.bin",
|
72 |
+
"transformer.h.13.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00014.bin",
|
73 |
+
"transformer.h.13.post_attention_layernorm.bias": "pytorch_model-00007-of-00014.bin",
|
74 |
+
"transformer.h.13.post_attention_layernorm.weight": "pytorch_model-00007-of-00014.bin",
|
75 |
+
"transformer.h.13.self_attention.dense.bias": "pytorch_model-00007-of-00014.bin",
|
76 |
+
"transformer.h.13.self_attention.dense.weight": "pytorch_model-00007-of-00014.bin",
|
77 |
+
"transformer.h.13.self_attention.query_key_value.bias": "pytorch_model-00007-of-00014.bin",
|
78 |
+
"transformer.h.13.self_attention.query_key_value.weight": "pytorch_model-00007-of-00014.bin",
|
79 |
+
"transformer.h.14.input_layernorm.bias": "pytorch_model-00007-of-00014.bin",
|
80 |
+
"transformer.h.14.input_layernorm.weight": "pytorch_model-00007-of-00014.bin",
|
81 |
+
"transformer.h.14.mlp.dense_4h_to_h.bias": "pytorch_model-00007-of-00014.bin",
|
82 |
+
"transformer.h.14.mlp.dense_4h_to_h.weight": "pytorch_model-00007-of-00014.bin",
|
83 |
+
"transformer.h.14.mlp.dense_h_to_4h.bias": "pytorch_model-00007-of-00014.bin",
|
84 |
+
"transformer.h.14.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00014.bin",
|
85 |
+
"transformer.h.14.post_attention_layernorm.bias": "pytorch_model-00007-of-00014.bin",
|
86 |
+
"transformer.h.14.post_attention_layernorm.weight": "pytorch_model-00007-of-00014.bin",
|
87 |
+
"transformer.h.14.self_attention.dense.bias": "pytorch_model-00007-of-00014.bin",
|
88 |
+
"transformer.h.14.self_attention.dense.weight": "pytorch_model-00007-of-00014.bin",
|
89 |
+
"transformer.h.14.self_attention.query_key_value.bias": "pytorch_model-00007-of-00014.bin",
|
90 |
+
"transformer.h.14.self_attention.query_key_value.weight": "pytorch_model-00007-of-00014.bin",
|
91 |
+
"transformer.h.15.input_layernorm.bias": "pytorch_model-00007-of-00014.bin",
|
92 |
+
"transformer.h.15.input_layernorm.weight": "pytorch_model-00007-of-00014.bin",
|
93 |
+
"transformer.h.15.mlp.dense_4h_to_h.bias": "pytorch_model-00008-of-00014.bin",
|
94 |
+
"transformer.h.15.mlp.dense_4h_to_h.weight": "pytorch_model-00008-of-00014.bin",
|
95 |
+
"transformer.h.15.mlp.dense_h_to_4h.bias": "pytorch_model-00008-of-00014.bin",
|
96 |
+
"transformer.h.15.mlp.dense_h_to_4h.weight": "pytorch_model-00008-of-00014.bin",
|
97 |
+
"transformer.h.15.post_attention_layernorm.bias": "pytorch_model-00008-of-00014.bin",
|
98 |
+
"transformer.h.15.post_attention_layernorm.weight": "pytorch_model-00008-of-00014.bin",
|
99 |
+
"transformer.h.15.self_attention.dense.bias": "pytorch_model-00008-of-00014.bin",
|
100 |
+
"transformer.h.15.self_attention.dense.weight": "pytorch_model-00008-of-00014.bin",
|
101 |
+
"transformer.h.15.self_attention.query_key_value.bias": "pytorch_model-00008-of-00014.bin",
|
102 |
+
"transformer.h.15.self_attention.query_key_value.weight": "pytorch_model-00008-of-00014.bin",
|
103 |
+
"transformer.h.16.input_layernorm.bias": "pytorch_model-00008-of-00014.bin",
|
104 |
+
"transformer.h.16.input_layernorm.weight": "pytorch_model-00008-of-00014.bin",
|
105 |
+
"transformer.h.16.mlp.dense_4h_to_h.bias": "pytorch_model-00008-of-00014.bin",
|
106 |
+
"transformer.h.16.mlp.dense_4h_to_h.weight": "pytorch_model-00008-of-00014.bin",
|
107 |
+
"transformer.h.16.mlp.dense_h_to_4h.bias": "pytorch_model-00008-of-00014.bin",
|
108 |
+
"transformer.h.16.mlp.dense_h_to_4h.weight": "pytorch_model-00008-of-00014.bin",
|
109 |
+
"transformer.h.16.post_attention_layernorm.bias": "pytorch_model-00008-of-00014.bin",
|
110 |
+
"transformer.h.16.post_attention_layernorm.weight": "pytorch_model-00008-of-00014.bin",
|
111 |
+
"transformer.h.16.self_attention.dense.bias": "pytorch_model-00008-of-00014.bin",
|
112 |
+
"transformer.h.16.self_attention.dense.weight": "pytorch_model-00008-of-00014.bin",
|
113 |
+
"transformer.h.16.self_attention.query_key_value.bias": "pytorch_model-00008-of-00014.bin",
|
114 |
+
"transformer.h.16.self_attention.query_key_value.weight": "pytorch_model-00008-of-00014.bin",
|
115 |
+
"transformer.h.17.input_layernorm.bias": "pytorch_model-00008-of-00014.bin",
|
116 |
+
"transformer.h.17.input_layernorm.weight": "pytorch_model-00008-of-00014.bin",
|
117 |
+
"transformer.h.17.mlp.dense_4h_to_h.bias": "pytorch_model-00009-of-00014.bin",
|
118 |
+
"transformer.h.17.mlp.dense_4h_to_h.weight": "pytorch_model-00009-of-00014.bin",
|
119 |
+
"transformer.h.17.mlp.dense_h_to_4h.bias": "pytorch_model-00009-of-00014.bin",
|
120 |
+
"transformer.h.17.mlp.dense_h_to_4h.weight": "pytorch_model-00009-of-00014.bin",
|
121 |
+
"transformer.h.17.post_attention_layernorm.bias": "pytorch_model-00008-of-00014.bin",
|
122 |
+
"transformer.h.17.post_attention_layernorm.weight": "pytorch_model-00008-of-00014.bin",
|
123 |
+
"transformer.h.17.self_attention.dense.bias": "pytorch_model-00008-of-00014.bin",
|
124 |
+
"transformer.h.17.self_attention.dense.weight": "pytorch_model-00008-of-00014.bin",
|
125 |
+
"transformer.h.17.self_attention.query_key_value.bias": "pytorch_model-00008-of-00014.bin",
|
126 |
+
"transformer.h.17.self_attention.query_key_value.weight": "pytorch_model-00008-of-00014.bin",
|
127 |
+
"transformer.h.18.input_layernorm.bias": "pytorch_model-00009-of-00014.bin",
|
128 |
+
"transformer.h.18.input_layernorm.weight": "pytorch_model-00009-of-00014.bin",
|
129 |
+
"transformer.h.18.mlp.dense_4h_to_h.bias": "pytorch_model-00009-of-00014.bin",
|
130 |
+
"transformer.h.18.mlp.dense_4h_to_h.weight": "pytorch_model-00009-of-00014.bin",
|
131 |
+
"transformer.h.18.mlp.dense_h_to_4h.bias": "pytorch_model-00009-of-00014.bin",
|
132 |
+
"transformer.h.18.mlp.dense_h_to_4h.weight": "pytorch_model-00009-of-00014.bin",
|
133 |
+
"transformer.h.18.post_attention_layernorm.bias": "pytorch_model-00009-of-00014.bin",
|
134 |
+
"transformer.h.18.post_attention_layernorm.weight": "pytorch_model-00009-of-00014.bin",
|
135 |
+
"transformer.h.18.self_attention.dense.bias": "pytorch_model-00009-of-00014.bin",
|
136 |
+
"transformer.h.18.self_attention.dense.weight": "pytorch_model-00009-of-00014.bin",
|
137 |
+
"transformer.h.18.self_attention.query_key_value.bias": "pytorch_model-00009-of-00014.bin",
|
138 |
+
"transformer.h.18.self_attention.query_key_value.weight": "pytorch_model-00009-of-00014.bin",
|
139 |
+
"transformer.h.19.input_layernorm.bias": "pytorch_model-00009-of-00014.bin",
|
140 |
+
"transformer.h.19.input_layernorm.weight": "pytorch_model-00009-of-00014.bin",
|
141 |
+
"transformer.h.19.mlp.dense_4h_to_h.bias": "pytorch_model-00010-of-00014.bin",
|
142 |
+
"transformer.h.19.mlp.dense_4h_to_h.weight": "pytorch_model-00010-of-00014.bin",
|
143 |
+
"transformer.h.19.mlp.dense_h_to_4h.bias": "pytorch_model-00009-of-00014.bin",
|
144 |
+
"transformer.h.19.mlp.dense_h_to_4h.weight": "pytorch_model-00009-of-00014.bin",
|
145 |
+
"transformer.h.19.post_attention_layernorm.bias": "pytorch_model-00009-of-00014.bin",
|
146 |
+
"transformer.h.19.post_attention_layernorm.weight": "pytorch_model-00009-of-00014.bin",
|
147 |
+
"transformer.h.19.self_attention.dense.bias": "pytorch_model-00009-of-00014.bin",
|
148 |
+
"transformer.h.19.self_attention.dense.weight": "pytorch_model-00009-of-00014.bin",
|
149 |
+
"transformer.h.19.self_attention.query_key_value.bias": "pytorch_model-00009-of-00014.bin",
|
150 |
+
"transformer.h.19.self_attention.query_key_value.weight": "pytorch_model-00009-of-00014.bin",
|
151 |
+
"transformer.h.2.input_layernorm.bias": "pytorch_model-00002-of-00014.bin",
|
152 |
+
"transformer.h.2.input_layernorm.weight": "pytorch_model-00002-of-00014.bin",
|
153 |
+
"transformer.h.2.mlp.dense_4h_to_h.bias": "pytorch_model-00002-of-00014.bin",
|
154 |
+
"transformer.h.2.mlp.dense_4h_to_h.weight": "pytorch_model-00002-of-00014.bin",
|
155 |
+
"transformer.h.2.mlp.dense_h_to_4h.bias": "pytorch_model-00002-of-00014.bin",
|
156 |
+
"transformer.h.2.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00014.bin",
|
157 |
+
"transformer.h.2.post_attention_layernorm.bias": "pytorch_model-00002-of-00014.bin",
|
158 |
+
"transformer.h.2.post_attention_layernorm.weight": "pytorch_model-00002-of-00014.bin",
|
159 |
+
"transformer.h.2.self_attention.dense.bias": "pytorch_model-00002-of-00014.bin",
|
160 |
+
"transformer.h.2.self_attention.dense.weight": "pytorch_model-00002-of-00014.bin",
|
161 |
+
"transformer.h.2.self_attention.query_key_value.bias": "pytorch_model-00002-of-00014.bin",
|
162 |
+
"transformer.h.2.self_attention.query_key_value.weight": "pytorch_model-00002-of-00014.bin",
|
163 |
+
"transformer.h.20.input_layernorm.bias": "pytorch_model-00010-of-00014.bin",
|
164 |
+
"transformer.h.20.input_layernorm.weight": "pytorch_model-00010-of-00014.bin",
|
165 |
+
"transformer.h.20.mlp.dense_4h_to_h.bias": "pytorch_model-00010-of-00014.bin",
|
166 |
+
"transformer.h.20.mlp.dense_4h_to_h.weight": "pytorch_model-00010-of-00014.bin",
|
167 |
+
"transformer.h.20.mlp.dense_h_to_4h.bias": "pytorch_model-00010-of-00014.bin",
|
168 |
+
"transformer.h.20.mlp.dense_h_to_4h.weight": "pytorch_model-00010-of-00014.bin",
|
169 |
+
"transformer.h.20.post_attention_layernorm.bias": "pytorch_model-00010-of-00014.bin",
|
170 |
+
"transformer.h.20.post_attention_layernorm.weight": "pytorch_model-00010-of-00014.bin",
|
171 |
+
"transformer.h.20.self_attention.dense.bias": "pytorch_model-00010-of-00014.bin",
|
172 |
+
"transformer.h.20.self_attention.dense.weight": "pytorch_model-00010-of-00014.bin",
|
173 |
+
"transformer.h.20.self_attention.query_key_value.bias": "pytorch_model-00010-of-00014.bin",
|
174 |
+
"transformer.h.20.self_attention.query_key_value.weight": "pytorch_model-00010-of-00014.bin",
|
175 |
+
"transformer.h.21.input_layernorm.bias": "pytorch_model-00010-of-00014.bin",
|
176 |
+
"transformer.h.21.input_layernorm.weight": "pytorch_model-00010-of-00014.bin",
|
177 |
+
"transformer.h.21.mlp.dense_4h_to_h.bias": "pytorch_model-00010-of-00014.bin",
|
178 |
+
"transformer.h.21.mlp.dense_4h_to_h.weight": "pytorch_model-00010-of-00014.bin",
|
179 |
+
"transformer.h.21.mlp.dense_h_to_4h.bias": "pytorch_model-00010-of-00014.bin",
|
180 |
+
"transformer.h.21.mlp.dense_h_to_4h.weight": "pytorch_model-00010-of-00014.bin",
|
181 |
+
"transformer.h.21.post_attention_layernorm.bias": "pytorch_model-00010-of-00014.bin",
|
182 |
+
"transformer.h.21.post_attention_layernorm.weight": "pytorch_model-00010-of-00014.bin",
|
183 |
+
"transformer.h.21.self_attention.dense.bias": "pytorch_model-00010-of-00014.bin",
|
184 |
+
"transformer.h.21.self_attention.dense.weight": "pytorch_model-00010-of-00014.bin",
|
185 |
+
"transformer.h.21.self_attention.query_key_value.bias": "pytorch_model-00010-of-00014.bin",
|
186 |
+
"transformer.h.21.self_attention.query_key_value.weight": "pytorch_model-00010-of-00014.bin",
|
187 |
+
"transformer.h.22.input_layernorm.bias": "pytorch_model-00010-of-00014.bin",
|
188 |
+
"transformer.h.22.input_layernorm.weight": "pytorch_model-00010-of-00014.bin",
|
189 |
+
"transformer.h.22.mlp.dense_4h_to_h.bias": "pytorch_model-00011-of-00014.bin",
|
190 |
+
"transformer.h.22.mlp.dense_4h_to_h.weight": "pytorch_model-00011-of-00014.bin",
|
191 |
+
"transformer.h.22.mlp.dense_h_to_4h.bias": "pytorch_model-00011-of-00014.bin",
|
192 |
+
"transformer.h.22.mlp.dense_h_to_4h.weight": "pytorch_model-00011-of-00014.bin",
|
193 |
+
"transformer.h.22.post_attention_layernorm.bias": "pytorch_model-00011-of-00014.bin",
|
194 |
+
"transformer.h.22.post_attention_layernorm.weight": "pytorch_model-00011-of-00014.bin",
|
195 |
+
"transformer.h.22.self_attention.dense.bias": "pytorch_model-00011-of-00014.bin",
|
196 |
+
"transformer.h.22.self_attention.dense.weight": "pytorch_model-00011-of-00014.bin",
|
197 |
+
"transformer.h.22.self_attention.query_key_value.bias": "pytorch_model-00011-of-00014.bin",
|
198 |
+
"transformer.h.22.self_attention.query_key_value.weight": "pytorch_model-00011-of-00014.bin",
|
199 |
+
"transformer.h.23.input_layernorm.bias": "pytorch_model-00011-of-00014.bin",
|
200 |
+
"transformer.h.23.input_layernorm.weight": "pytorch_model-00011-of-00014.bin",
|
201 |
+
"transformer.h.23.mlp.dense_4h_to_h.bias": "pytorch_model-00011-of-00014.bin",
|
202 |
+
"transformer.h.23.mlp.dense_4h_to_h.weight": "pytorch_model-00011-of-00014.bin",
|
203 |
+
"transformer.h.23.mlp.dense_h_to_4h.bias": "pytorch_model-00011-of-00014.bin",
|
204 |
+
"transformer.h.23.mlp.dense_h_to_4h.weight": "pytorch_model-00011-of-00014.bin",
|
205 |
+
"transformer.h.23.post_attention_layernorm.bias": "pytorch_model-00011-of-00014.bin",
|
206 |
+
"transformer.h.23.post_attention_layernorm.weight": "pytorch_model-00011-of-00014.bin",
|
207 |
+
"transformer.h.23.self_attention.dense.bias": "pytorch_model-00011-of-00014.bin",
|
208 |
+
"transformer.h.23.self_attention.dense.weight": "pytorch_model-00011-of-00014.bin",
|
209 |
+
"transformer.h.23.self_attention.query_key_value.bias": "pytorch_model-00011-of-00014.bin",
|
210 |
+
"transformer.h.23.self_attention.query_key_value.weight": "pytorch_model-00011-of-00014.bin",
|
211 |
+
"transformer.h.24.input_layernorm.bias": "pytorch_model-00011-of-00014.bin",
|
212 |
+
"transformer.h.24.input_layernorm.weight": "pytorch_model-00011-of-00014.bin",
|
213 |
+
"transformer.h.24.mlp.dense_4h_to_h.bias": "pytorch_model-00012-of-00014.bin",
|
214 |
+
"transformer.h.24.mlp.dense_4h_to_h.weight": "pytorch_model-00012-of-00014.bin",
|
215 |
+
"transformer.h.24.mlp.dense_h_to_4h.bias": "pytorch_model-00012-of-00014.bin",
|
216 |
+
"transformer.h.24.mlp.dense_h_to_4h.weight": "pytorch_model-00012-of-00014.bin",
|
217 |
+
"transformer.h.24.post_attention_layernorm.bias": "pytorch_model-00011-of-00014.bin",
|
218 |
+
"transformer.h.24.post_attention_layernorm.weight": "pytorch_model-00011-of-00014.bin",
|
219 |
+
"transformer.h.24.self_attention.dense.bias": "pytorch_model-00011-of-00014.bin",
|
220 |
+
"transformer.h.24.self_attention.dense.weight": "pytorch_model-00011-of-00014.bin",
|
221 |
+
"transformer.h.24.self_attention.query_key_value.bias": "pytorch_model-00011-of-00014.bin",
|
222 |
+
"transformer.h.24.self_attention.query_key_value.weight": "pytorch_model-00011-of-00014.bin",
|
223 |
+
"transformer.h.25.input_layernorm.bias": "pytorch_model-00012-of-00014.bin",
|
224 |
+
"transformer.h.25.input_layernorm.weight": "pytorch_model-00012-of-00014.bin",
|
225 |
+
"transformer.h.25.mlp.dense_4h_to_h.bias": "pytorch_model-00012-of-00014.bin",
|
226 |
+
"transformer.h.25.mlp.dense_4h_to_h.weight": "pytorch_model-00012-of-00014.bin",
|
227 |
+
"transformer.h.25.mlp.dense_h_to_4h.bias": "pytorch_model-00012-of-00014.bin",
|
228 |
+
"transformer.h.25.mlp.dense_h_to_4h.weight": "pytorch_model-00012-of-00014.bin",
|
229 |
+
"transformer.h.25.post_attention_layernorm.bias": "pytorch_model-00012-of-00014.bin",
|
230 |
+
"transformer.h.25.post_attention_layernorm.weight": "pytorch_model-00012-of-00014.bin",
|
231 |
+
"transformer.h.25.self_attention.dense.bias": "pytorch_model-00012-of-00014.bin",
|
232 |
+
"transformer.h.25.self_attention.dense.weight": "pytorch_model-00012-of-00014.bin",
|
233 |
+
"transformer.h.25.self_attention.query_key_value.bias": "pytorch_model-00012-of-00014.bin",
|
234 |
+
"transformer.h.25.self_attention.query_key_value.weight": "pytorch_model-00012-of-00014.bin",
|
235 |
+
"transformer.h.26.input_layernorm.bias": "pytorch_model-00012-of-00014.bin",
|
236 |
+
"transformer.h.26.input_layernorm.weight": "pytorch_model-00012-of-00014.bin",
|
237 |
+
"transformer.h.26.mlp.dense_4h_to_h.bias": "pytorch_model-00013-of-00014.bin",
|
238 |
+
"transformer.h.26.mlp.dense_4h_to_h.weight": "pytorch_model-00013-of-00014.bin",
|
239 |
+
"transformer.h.26.mlp.dense_h_to_4h.bias": "pytorch_model-00012-of-00014.bin",
|
240 |
+
"transformer.h.26.mlp.dense_h_to_4h.weight": "pytorch_model-00012-of-00014.bin",
|
241 |
+
"transformer.h.26.post_attention_layernorm.bias": "pytorch_model-00012-of-00014.bin",
|
242 |
+
"transformer.h.26.post_attention_layernorm.weight": "pytorch_model-00012-of-00014.bin",
|
243 |
+
"transformer.h.26.self_attention.dense.bias": "pytorch_model-00012-of-00014.bin",
|
244 |
+
"transformer.h.26.self_attention.dense.weight": "pytorch_model-00012-of-00014.bin",
|
245 |
+
"transformer.h.26.self_attention.query_key_value.bias": "pytorch_model-00012-of-00014.bin",
|
246 |
+
"transformer.h.26.self_attention.query_key_value.weight": "pytorch_model-00012-of-00014.bin",
|
247 |
+
"transformer.h.27.input_layernorm.bias": "pytorch_model-00013-of-00014.bin",
|
248 |
+
"transformer.h.27.input_layernorm.weight": "pytorch_model-00013-of-00014.bin",
|
249 |
+
"transformer.h.27.mlp.dense_4h_to_h.bias": "pytorch_model-00013-of-00014.bin",
|
250 |
+
"transformer.h.27.mlp.dense_4h_to_h.weight": "pytorch_model-00013-of-00014.bin",
|
251 |
+
"transformer.h.27.mlp.dense_h_to_4h.bias": "pytorch_model-00013-of-00014.bin",
|
252 |
+
"transformer.h.27.mlp.dense_h_to_4h.weight": "pytorch_model-00013-of-00014.bin",
|
253 |
+
"transformer.h.27.post_attention_layernorm.bias": "pytorch_model-00013-of-00014.bin",
|
254 |
+
"transformer.h.27.post_attention_layernorm.weight": "pytorch_model-00013-of-00014.bin",
|
255 |
+
"transformer.h.27.self_attention.dense.bias": "pytorch_model-00013-of-00014.bin",
|
256 |
+
"transformer.h.27.self_attention.dense.weight": "pytorch_model-00013-of-00014.bin",
|
257 |
+
"transformer.h.27.self_attention.query_key_value.bias": "pytorch_model-00013-of-00014.bin",
|
258 |
+
"transformer.h.27.self_attention.query_key_value.weight": "pytorch_model-00013-of-00014.bin",
|
259 |
+
"transformer.h.28.input_layernorm.bias": "pytorch_model-00013-of-00014.bin",
|
260 |
+
"transformer.h.28.input_layernorm.weight": "pytorch_model-00013-of-00014.bin",
|
261 |
+
"transformer.h.28.mlp.dense_4h_to_h.bias": "pytorch_model-00013-of-00014.bin",
|
262 |
+
"transformer.h.28.mlp.dense_4h_to_h.weight": "pytorch_model-00013-of-00014.bin",
|
263 |
+
"transformer.h.28.mlp.dense_h_to_4h.bias": "pytorch_model-00013-of-00014.bin",
|
264 |
+
"transformer.h.28.mlp.dense_h_to_4h.weight": "pytorch_model-00013-of-00014.bin",
|
265 |
+
"transformer.h.28.post_attention_layernorm.bias": "pytorch_model-00013-of-00014.bin",
|
266 |
+
"transformer.h.28.post_attention_layernorm.weight": "pytorch_model-00013-of-00014.bin",
|
267 |
+
"transformer.h.28.self_attention.dense.bias": "pytorch_model-00013-of-00014.bin",
|
268 |
+
"transformer.h.28.self_attention.dense.weight": "pytorch_model-00013-of-00014.bin",
|
269 |
+
"transformer.h.28.self_attention.query_key_value.bias": "pytorch_model-00013-of-00014.bin",
|
270 |
+
"transformer.h.28.self_attention.query_key_value.weight": "pytorch_model-00013-of-00014.bin",
|
271 |
+
"transformer.h.29.input_layernorm.bias": "pytorch_model-00013-of-00014.bin",
|
272 |
+
"transformer.h.29.input_layernorm.weight": "pytorch_model-00013-of-00014.bin",
|
273 |
+
"transformer.h.29.mlp.dense_4h_to_h.bias": "pytorch_model-00014-of-00014.bin",
|
274 |
+
"transformer.h.29.mlp.dense_4h_to_h.weight": "pytorch_model-00014-of-00014.bin",
|
275 |
+
"transformer.h.29.mlp.dense_h_to_4h.bias": "pytorch_model-00014-of-00014.bin",
|
276 |
+
"transformer.h.29.mlp.dense_h_to_4h.weight": "pytorch_model-00014-of-00014.bin",
|
277 |
+
"transformer.h.29.post_attention_layernorm.bias": "pytorch_model-00014-of-00014.bin",
|
278 |
+
"transformer.h.29.post_attention_layernorm.weight": "pytorch_model-00014-of-00014.bin",
|
279 |
+
"transformer.h.29.self_attention.dense.bias": "pytorch_model-00014-of-00014.bin",
|
280 |
+
"transformer.h.29.self_attention.dense.weight": "pytorch_model-00014-of-00014.bin",
|
281 |
+
"transformer.h.29.self_attention.query_key_value.bias": "pytorch_model-00014-of-00014.bin",
|
282 |
+
"transformer.h.29.self_attention.query_key_value.weight": "pytorch_model-00014-of-00014.bin",
|
283 |
+
"transformer.h.3.input_layernorm.bias": "pytorch_model-00002-of-00014.bin",
|
284 |
+
"transformer.h.3.input_layernorm.weight": "pytorch_model-00002-of-00014.bin",
|
285 |
+
"transformer.h.3.mlp.dense_4h_to_h.bias": "pytorch_model-00003-of-00014.bin",
|
286 |
+
"transformer.h.3.mlp.dense_4h_to_h.weight": "pytorch_model-00003-of-00014.bin",
|
287 |
+
"transformer.h.3.mlp.dense_h_to_4h.bias": "pytorch_model-00003-of-00014.bin",
|
288 |
+
"transformer.h.3.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00014.bin",
|
289 |
+
"transformer.h.3.post_attention_layernorm.bias": "pytorch_model-00002-of-00014.bin",
|
290 |
+
"transformer.h.3.post_attention_layernorm.weight": "pytorch_model-00002-of-00014.bin",
|
291 |
+
"transformer.h.3.self_attention.dense.bias": "pytorch_model-00002-of-00014.bin",
|
292 |
+
"transformer.h.3.self_attention.dense.weight": "pytorch_model-00002-of-00014.bin",
|
293 |
+
"transformer.h.3.self_attention.query_key_value.bias": "pytorch_model-00002-of-00014.bin",
|
294 |
+
"transformer.h.3.self_attention.query_key_value.weight": "pytorch_model-00002-of-00014.bin",
|
295 |
+
"transformer.h.4.input_layernorm.bias": "pytorch_model-00003-of-00014.bin",
|
296 |
+
"transformer.h.4.input_layernorm.weight": "pytorch_model-00003-of-00014.bin",
|
297 |
+
"transformer.h.4.mlp.dense_4h_to_h.bias": "pytorch_model-00003-of-00014.bin",
|
298 |
+
"transformer.h.4.mlp.dense_4h_to_h.weight": "pytorch_model-00003-of-00014.bin",
|
299 |
+
"transformer.h.4.mlp.dense_h_to_4h.bias": "pytorch_model-00003-of-00014.bin",
|
300 |
+
"transformer.h.4.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00014.bin",
|
301 |
+
"transformer.h.4.post_attention_layernorm.bias": "pytorch_model-00003-of-00014.bin",
|
302 |
+
"transformer.h.4.post_attention_layernorm.weight": "pytorch_model-00003-of-00014.bin",
|
303 |
+
"transformer.h.4.self_attention.dense.bias": "pytorch_model-00003-of-00014.bin",
|
304 |
+
"transformer.h.4.self_attention.dense.weight": "pytorch_model-00003-of-00014.bin",
|
305 |
+
"transformer.h.4.self_attention.query_key_value.bias": "pytorch_model-00003-of-00014.bin",
|
306 |
+
"transformer.h.4.self_attention.query_key_value.weight": "pytorch_model-00003-of-00014.bin",
|
307 |
+
"transformer.h.5.input_layernorm.bias": "pytorch_model-00003-of-00014.bin",
|
308 |
+
"transformer.h.5.input_layernorm.weight": "pytorch_model-00003-of-00014.bin",
|
309 |
+
"transformer.h.5.mlp.dense_4h_to_h.bias": "pytorch_model-00004-of-00014.bin",
|
310 |
+
"transformer.h.5.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00014.bin",
|
311 |
+
"transformer.h.5.mlp.dense_h_to_4h.bias": "pytorch_model-00003-of-00014.bin",
|
312 |
+
"transformer.h.5.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00014.bin",
|
313 |
+
"transformer.h.5.post_attention_layernorm.bias": "pytorch_model-00003-of-00014.bin",
|
314 |
+
"transformer.h.5.post_attention_layernorm.weight": "pytorch_model-00003-of-00014.bin",
|
315 |
+
"transformer.h.5.self_attention.dense.bias": "pytorch_model-00003-of-00014.bin",
|
316 |
+
"transformer.h.5.self_attention.dense.weight": "pytorch_model-00003-of-00014.bin",
|
317 |
+
"transformer.h.5.self_attention.query_key_value.bias": "pytorch_model-00003-of-00014.bin",
|
318 |
+
"transformer.h.5.self_attention.query_key_value.weight": "pytorch_model-00003-of-00014.bin",
|
319 |
+
"transformer.h.6.input_layernorm.bias": "pytorch_model-00004-of-00014.bin",
|
320 |
+
"transformer.h.6.input_layernorm.weight": "pytorch_model-00004-of-00014.bin",
|
321 |
+
"transformer.h.6.mlp.dense_4h_to_h.bias": "pytorch_model-00004-of-00014.bin",
|
322 |
+
"transformer.h.6.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00014.bin",
|
323 |
+
"transformer.h.6.mlp.dense_h_to_4h.bias": "pytorch_model-00004-of-00014.bin",
|
324 |
+
"transformer.h.6.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00014.bin",
|
325 |
+
"transformer.h.6.post_attention_layernorm.bias": "pytorch_model-00004-of-00014.bin",
|
326 |
+
"transformer.h.6.post_attention_layernorm.weight": "pytorch_model-00004-of-00014.bin",
|
327 |
+
"transformer.h.6.self_attention.dense.bias": "pytorch_model-00004-of-00014.bin",
|
328 |
+
"transformer.h.6.self_attention.dense.weight": "pytorch_model-00004-of-00014.bin",
|
329 |
+
"transformer.h.6.self_attention.query_key_value.bias": "pytorch_model-00004-of-00014.bin",
|
330 |
+
"transformer.h.6.self_attention.query_key_value.weight": "pytorch_model-00004-of-00014.bin",
|
331 |
+
"transformer.h.7.input_layernorm.bias": "pytorch_model-00004-of-00014.bin",
|
332 |
+
"transformer.h.7.input_layernorm.weight": "pytorch_model-00004-of-00014.bin",
|
333 |
+
"transformer.h.7.mlp.dense_4h_to_h.bias": "pytorch_model-00004-of-00014.bin",
|
334 |
+
"transformer.h.7.mlp.dense_4h_to_h.weight": "pytorch_model-00004-of-00014.bin",
|
335 |
+
"transformer.h.7.mlp.dense_h_to_4h.bias": "pytorch_model-00004-of-00014.bin",
|
336 |
+
"transformer.h.7.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00014.bin",
|
337 |
+
"transformer.h.7.post_attention_layernorm.bias": "pytorch_model-00004-of-00014.bin",
|
338 |
+
"transformer.h.7.post_attention_layernorm.weight": "pytorch_model-00004-of-00014.bin",
|
339 |
+
"transformer.h.7.self_attention.dense.bias": "pytorch_model-00004-of-00014.bin",
|
340 |
+
"transformer.h.7.self_attention.dense.weight": "pytorch_model-00004-of-00014.bin",
|
341 |
+
"transformer.h.7.self_attention.query_key_value.bias": "pytorch_model-00004-of-00014.bin",
|
342 |
+
"transformer.h.7.self_attention.query_key_value.weight": "pytorch_model-00004-of-00014.bin",
|
343 |
+
"transformer.h.8.input_layernorm.bias": "pytorch_model-00004-of-00014.bin",
|
344 |
+
"transformer.h.8.input_layernorm.weight": "pytorch_model-00004-of-00014.bin",
|
345 |
+
"transformer.h.8.mlp.dense_4h_to_h.bias": "pytorch_model-00005-of-00014.bin",
|
346 |
+
"transformer.h.8.mlp.dense_4h_to_h.weight": "pytorch_model-00005-of-00014.bin",
|
347 |
+
"transformer.h.8.mlp.dense_h_to_4h.bias": "pytorch_model-00005-of-00014.bin",
|
348 |
+
"transformer.h.8.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00014.bin",
|
349 |
+
"transformer.h.8.post_attention_layernorm.bias": "pytorch_model-00005-of-00014.bin",
|
350 |
+
"transformer.h.8.post_attention_layernorm.weight": "pytorch_model-00005-of-00014.bin",
|
351 |
+
"transformer.h.8.self_attention.dense.bias": "pytorch_model-00005-of-00014.bin",
|
352 |
+
"transformer.h.8.self_attention.dense.weight": "pytorch_model-00005-of-00014.bin",
|
353 |
+
"transformer.h.8.self_attention.query_key_value.bias": "pytorch_model-00005-of-00014.bin",
|
354 |
+
"transformer.h.8.self_attention.query_key_value.weight": "pytorch_model-00005-of-00014.bin",
|
355 |
+
"transformer.h.9.input_layernorm.bias": "pytorch_model-00005-of-00014.bin",
|
356 |
+
"transformer.h.9.input_layernorm.weight": "pytorch_model-00005-of-00014.bin",
|
357 |
+
"transformer.h.9.mlp.dense_4h_to_h.bias": "pytorch_model-00005-of-00014.bin",
|
358 |
+
"transformer.h.9.mlp.dense_4h_to_h.weight": "pytorch_model-00005-of-00014.bin",
|
359 |
+
"transformer.h.9.mlp.dense_h_to_4h.bias": "pytorch_model-00005-of-00014.bin",
|
360 |
+
"transformer.h.9.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00014.bin",
|
361 |
+
"transformer.h.9.post_attention_layernorm.bias": "pytorch_model-00005-of-00014.bin",
|
362 |
+
"transformer.h.9.post_attention_layernorm.weight": "pytorch_model-00005-of-00014.bin",
|
363 |
+
"transformer.h.9.self_attention.dense.bias": "pytorch_model-00005-of-00014.bin",
|
364 |
+
"transformer.h.9.self_attention.dense.weight": "pytorch_model-00005-of-00014.bin",
|
365 |
+
"transformer.h.9.self_attention.query_key_value.bias": "pytorch_model-00005-of-00014.bin",
|
366 |
+
"transformer.h.9.self_attention.query_key_value.weight": "pytorch_model-00005-of-00014.bin",
|
367 |
+
"transformer.ln_f.bias": "pytorch_model-00014-of-00014.bin",
|
368 |
+
"transformer.ln_f.weight": "pytorch_model-00014-of-00014.bin",
|
369 |
+
"transformer.word_embeddings.weight": "pytorch_model-00001-of-00014.bin",
|
370 |
+
"transformer.word_embeddings_layernorm.bias": "pytorch_model-00001-of-00014.bin",
|
371 |
+
"transformer.word_embeddings_layernorm.weight": "pytorch_model-00001-of-00014.bin"
|
372 |
+
}
|
373 |
+
}
|
special_tokens_map.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<s>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": true,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"eos_token": {
|
10 |
+
"content": "</s>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": true,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"pad_token": {
|
17 |
+
"content": "<unk>",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": true,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
},
|
23 |
+
"unk_token": {
|
24 |
+
"content": "<unk>",
|
25 |
+
"lstrip": false,
|
26 |
+
"normalized": true,
|
27 |
+
"rstrip": false,
|
28 |
+
"single_word": false
|
29 |
+
}
|
30 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4be54af290d93c113bcbf421115ae9eed9d6340408f564898f1e966dc738ef01
|
3 |
+
size 1136699
|
tokenizer_config.json
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": false,
|
3 |
+
"add_eos_token": false,
|
4 |
+
"bos_token": {
|
5 |
+
"__type": "AddedToken",
|
6 |
+
"content": "<s>",
|
7 |
+
"lstrip": false,
|
8 |
+
"normalized": true,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false
|
11 |
+
},
|
12 |
+
"clean_up_tokenization_spaces": false,
|
13 |
+
"eos_token": {
|
14 |
+
"__type": "AddedToken",
|
15 |
+
"content": "</s>",
|
16 |
+
"lstrip": false,
|
17 |
+
"normalized": true,
|
18 |
+
"rstrip": false,
|
19 |
+
"single_word": false
|
20 |
+
},
|
21 |
+
"legacy": true,
|
22 |
+
"model_max_length": 1000000000000000019884624838656,
|
23 |
+
"pad_token": {
|
24 |
+
"__type": "AddedToken",
|
25 |
+
"content": "<unk>",
|
26 |
+
"lstrip": false,
|
27 |
+
"normalized": true,
|
28 |
+
"rstrip": false,
|
29 |
+
"single_word": false
|
30 |
+
},
|
31 |
+
"padding_side": "left",
|
32 |
+
"sp_model_kwargs": {},
|
33 |
+
"tokenizer_class": "LlamaTokenizer",
|
34 |
+
"unk_token": {
|
35 |
+
"__type": "AddedToken",
|
36 |
+
"content": "<unk>",
|
37 |
+
"lstrip": false,
|
38 |
+
"normalized": true,
|
39 |
+
"rstrip": false,
|
40 |
+
"single_word": false
|
41 |
+
}
|
42 |
+
}
|