shrink-init / configuration_shrink.py
crumb's picture
Upload model
be78a97
raw
history blame
No virus
2.3 kB
from collections import OrderedDict
from typing import Any, List, Mapping, Optional
from transformers import PreTrainedTokenizer, TensorType, is_torch_available
from transformers.configuration_utils import PretrainedConfig
from transformers.utils import logging
logger = logging.get_logger(__name__)
class ShrinkConfig(PretrainedConfig):
model_type = "shrink"
keys_to_ignore_at_inference = ["past_key_values"]
attribute_map = {
"hidden_size": "hidden_size",
"max_position_embeddings": "max_position_embeddings",
"num_attention_heads": "num_attention_heads",
"num_hidden_layers": "num_hidden_layers",
}
def __init__(
self,
vocab_size=32000,
max_position_embeddings=2048,
hidden_size_0=8192,
hidden_size=768,
qk_hidden_size=None, # in case you want to use cross-attention
num_hidden_layers=10,
num_attention_heads=12,
intermediate_size=None,
activation_function="silu",
layer_norm_epsilon=1e-6,
initializer_range=0.02,
scale_attn_weights=True,
use_cache=True,
bos_token_id=1,
eos_token_id=2,
combined_qkv=True,
use_bias=False,
projection_bias=True,
lm_head_bias=False,
**kwargs,
):
self.qk_hidden_size = qk_hidden_size
self.lm_head_bias = lm_head_bias
self.projection_bias = projection_bias
self.use_bias = use_bias
self.hidden_size_0 = hidden_size_0
self.combined_qkv = combined_qkv
self.vocab_size = vocab_size
self.max_position_embeddings = max_position_embeddings
self.hidden_size = hidden_size
self.num_hidden_layers = num_hidden_layers
self.num_attention_heads = num_attention_heads
self.intermediate_size = (
intermediate_size if intermediate_size is not None else hidden_size * 4
)
self.activation_function = activation_function
self.layer_norm_epsilon = layer_norm_epsilon
self.initializer_range = initializer_range
self.use_cache = use_cache
self.bos_token_id = bos_token_id
self.eos_token_id = eos_token_id
super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)