UltraBERT-Embed-150M / configuration_ultrabert.py
PhysShell's picture dmis-lab's picture
Duplicate from dmis-lab/UltraBERT-Embed-150M
be5c0e2
Raw History Blame Contribute Delete
2.21 kB
from __future__ import annotations
from collections.abc import Iterable
from transformers.configuration_utils import PretrainedConfig
class UltrabertConfig(PretrainedConfig):
model_type = "ultrabert"
def __init__(
self,
vocab_size=32000,
hidden_size=4096,
intermediate_size=11008,
prediction_head_size=None,
num_hidden_layers=32,
num_attention_heads=32,
num_key_value_heads=None,
attention_windows=None,
hidden_act="silu",
initializer_range=0.02,
rms_norm_eps=1e-6,
pad_token_id=0,
bos_token_id=0,
eos_token_id=0,
tie_word_embeddings=False,
rope_theta=10000.0,
attention_bias=False,
attention_dropout=0.0,
mlp_bias=False,
head_dim=None,
classifier_dropout=0.0,
**kwargs,
):
super().__init__(
pad_token_id=pad_token_id,
bos_token_id=bos_token_id,
eos_token_id=eos_token_id,
tie_word_embeddings=tie_word_embeddings,
**kwargs,
)
self.vocab_size = vocab_size
self.hidden_size = hidden_size
self.intermediate_size = intermediate_size
self.prediction_head_size = prediction_head_size
self.num_hidden_layers = num_hidden_layers
self.num_attention_heads = num_attention_heads
self.num_key_value_heads = num_key_value_heads or num_attention_heads
self.attention_windows = (
attention_windows
if isinstance(attention_windows, Iterable)
else [attention_windows] * num_hidden_layers
)
self.hidden_act = hidden_act
self.initializer_range = initializer_range
self.rms_norm_eps = rms_norm_eps
self.rope_theta = (
rope_theta
if isinstance(rope_theta, Iterable)
else [rope_theta] * num_hidden_layers
)
self.attention_bias = attention_bias
self.attention_dropout = attention_dropout
self.mlp_bias = mlp_bias
self.head_dim = head_dim or self.hidden_size // self.num_attention_heads
self.classifier_dropout = classifier_dropout