Delete configuration_telechat.py
Browse files- configuration_telechat.py +0 -94
configuration_telechat.py
DELETED
|
@@ -1,94 +0,0 @@
|
|
| 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 |
-
|
| 16 |
-
""" Telechat configuration"""
|
| 17 |
-
|
| 18 |
-
from packaging import version
|
| 19 |
-
from collections import OrderedDict
|
| 20 |
-
from transformers.utils import is_torch_available, logging
|
| 21 |
-
from transformers.configuration_utils import PretrainedConfig
|
| 22 |
-
from typing import TYPE_CHECKING, Any, List, Mapping, Optional
|
| 23 |
-
|
| 24 |
-
logger = logging.get_logger(__name__)
|
| 25 |
-
|
| 26 |
-
class TelechatConfig(PretrainedConfig):
|
| 27 |
-
"""
|
| 28 |
-
Args:
|
| 29 |
-
vocab_size (`int`, *optional*, defaults to 160256): Vocabulary size of the Telechat model.
|
| 30 |
-
hidden_size (`int`, *optional*, defaults to 4096): Dimensionality of the embeddings and hidden states.
|
| 31 |
-
ffn_hidden_size (`int`, *optional*, defaults to 12288): Dimensionality of the feed-forward hidden states.
|
| 32 |
-
n_layer (`int`, *optional*, defaults to 30): Number of hidden layers in the Transformer
|
| 33 |
-
n_head (`int`, *optional*, defaults to 32): Number of attention heads for each attention layer.
|
| 34 |
-
layer_norm_epsilon (`float`, *optional*, defaults to 1e-5): The epsilon to use in the layer normalization layers.
|
| 35 |
-
initializer_range (`float`, *optional*, defaults to 0.02): The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 36 |
-
apply_residual_connection_post_layernorm (`bool`, *optional*, defaults to `False`): If enabled, use the layer norm of the hidden states as the residual in the transformer blocks
|
| 37 |
-
hidden_dropout (`float`, *optional*, defaults to 0.0): Dropout rate of the dropout function on the bias dropout.
|
| 38 |
-
attention_dropout (`float`, *optional*, defaults to 0.0): Dropout rate applied to the attention probs
|
| 39 |
-
use_cache (`bool`, *optional*, defaults to `True`): Whether or not the model should return the last key/values attentions.
|
| 40 |
-
training_seqlen (`int`, *optional*, defaults to 8192): Sequence length during last finetuning.
|
| 41 |
-
logn (`bool`, *optional*, defaults to `True`): Whether or not to use logN during extrapolation.
|
| 42 |
-
embed_layernorm (`bool`, *optional*, defaults to `True`): Whether or not to use embedding layernorm.
|
| 43 |
-
|
| 44 |
-
"""
|
| 45 |
-
|
| 46 |
-
model_type = "telechat"
|
| 47 |
-
keys_to_ignore_at_inference = ["past_key_values"]
|
| 48 |
-
attribute_map = {
|
| 49 |
-
"num_hidden_layers": "n_layer",
|
| 50 |
-
"num_attention_heads": "n_head",
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
def __init__(
|
| 54 |
-
self,
|
| 55 |
-
vocab_size=160256,
|
| 56 |
-
hidden_size=4096,
|
| 57 |
-
n_layer=30,
|
| 58 |
-
n_head=32,
|
| 59 |
-
layer_norm_epsilon=1e-5,
|
| 60 |
-
initializer_range=0.02,
|
| 61 |
-
use_cache=True,
|
| 62 |
-
bos_token_id=1,
|
| 63 |
-
eos_token_id=2,
|
| 64 |
-
apply_residual_connection_post_layernorm=False,
|
| 65 |
-
hidden_dropout=0.0,
|
| 66 |
-
attention_dropout=0.0,
|
| 67 |
-
ffn_hidden_size=12288,
|
| 68 |
-
training_seqlen = 8192,
|
| 69 |
-
logn = True,
|
| 70 |
-
embed_layernorm = False,
|
| 71 |
-
**kwargs,
|
| 72 |
-
):
|
| 73 |
-
self.vocab_size = vocab_size
|
| 74 |
-
n_embed = kwargs.pop("n_embed", None)
|
| 75 |
-
self.hidden_size = hidden_size if n_embed is None else n_embed
|
| 76 |
-
self.n_layer = n_layer
|
| 77 |
-
self.n_head = n_head
|
| 78 |
-
self.layer_norm_epsilon = layer_norm_epsilon
|
| 79 |
-
self.initializer_range = initializer_range
|
| 80 |
-
self.use_cache = use_cache
|
| 81 |
-
self.apply_residual_connection_post_layernorm = apply_residual_connection_post_layernorm
|
| 82 |
-
self.hidden_dropout = hidden_dropout
|
| 83 |
-
self.attention_dropout = attention_dropout
|
| 84 |
-
self.bos_token_id = bos_token_id
|
| 85 |
-
self.eos_token_id = eos_token_id
|
| 86 |
-
self.logn = logn
|
| 87 |
-
self.ffn_hidden_size = ffn_hidden_size
|
| 88 |
-
self.training_seqlen = training_seqlen
|
| 89 |
-
self.embed_layernorm = embed_layernorm
|
| 90 |
-
self.num_key_value_heads= kwargs.pop("num_key_value_heads", None)
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|