Upload configuration_bailing_moe_v2.py with huggingface_hub
Browse files
configuration_bailing_moe_v2.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Bailing MoE V2 model configuration"""
|
| 2 |
+
|
| 3 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class BailingMoeV2Config(PretrainedConfig):
|
| 7 |
+
|
| 8 |
+
def __init__(
|
| 9 |
+
self,
|
| 10 |
+
vocab_size=157184,
|
| 11 |
+
hidden_size=2048,
|
| 12 |
+
intermediate_size=5120,
|
| 13 |
+
num_hidden_layers=20,
|
| 14 |
+
num_attention_heads=16,
|
| 15 |
+
num_key_value_heads=4,
|
| 16 |
+
hidden_act="silu",
|
| 17 |
+
use_qkv_bias=False, # bailing only
|
| 18 |
+
use_bias=False, # bailing only
|
| 19 |
+
rms_norm_eps=1e-06,
|
| 20 |
+
tie_word_embeddings=False, # PretrainedConfig key, here change default value.
|
| 21 |
+
embedding_dropout=0.0,
|
| 22 |
+
attention_dropout=0.0,
|
| 23 |
+
output_dropout=0.0,
|
| 24 |
+
initializer_range=0.02,
|
| 25 |
+
max_position_embeddings=32768,
|
| 26 |
+
rope_theta=600000.0,
|
| 27 |
+
use_cache=True,
|
| 28 |
+
max_window_layers=20,
|
| 29 |
+
rope_scaling=None,
|
| 30 |
+
pad_token_id=156892,
|
| 31 |
+
eos_token_id=156892,
|
| 32 |
+
num_experts=256,
|
| 33 |
+
num_shared_experts=1,
|
| 34 |
+
num_experts_per_tok=8,
|
| 35 |
+
n_group=8,
|
| 36 |
+
topk_group=4,
|
| 37 |
+
moe_intermediate_size=512,
|
| 38 |
+
first_k_dense_replace=1,
|
| 39 |
+
head_dim=128,
|
| 40 |
+
output_router_logits=False,
|
| 41 |
+
use_qk_norm=True,
|
| 42 |
+
num_nextn_predict_layers=0,
|
| 43 |
+
mtp_loss_scaling_factor=0,
|
| 44 |
+
moe_router_enable_expert_bias=True,
|
| 45 |
+
routed_scaling_factor=1.0,
|
| 46 |
+
**kwargs,
|
| 47 |
+
):
|
| 48 |
+
self.num_hidden_layers = num_hidden_layers
|
| 49 |
+
self.vocab_size = vocab_size
|
| 50 |
+
self.hidden_size = hidden_size
|
| 51 |
+
self.intermediate_size = intermediate_size
|
| 52 |
+
self.num_attention_heads = num_attention_heads
|
| 53 |
+
self.num_key_value_heads = num_key_value_heads
|
| 54 |
+
self.hidden_act = hidden_act
|
| 55 |
+
self.use_qkv_bias = use_qkv_bias
|
| 56 |
+
self.use_bias = use_bias
|
| 57 |
+
self.rms_norm_eps = rms_norm_eps
|
| 58 |
+
self.embedding_dropout = embedding_dropout
|
| 59 |
+
self.attention_dropout = attention_dropout
|
| 60 |
+
self.output_dropout = output_dropout
|
| 61 |
+
self.num_nextn_predict_layers = num_nextn_predict_layers
|
| 62 |
+
self.mtp_loss_scaling_factor = mtp_loss_scaling_factor
|
| 63 |
+
self.initializer_range = initializer_range
|
| 64 |
+
self.max_position_embeddings = max_position_embeddings
|
| 65 |
+
self.rope_theta = rope_theta
|
| 66 |
+
self.use_cache = use_cache
|
| 67 |
+
self.max_window_layers = max_window_layers
|
| 68 |
+
self.head_dim = head_dim or self.hidden_size // self.num_attention_heads
|
| 69 |
+
self.rope_scaling = rope_scaling
|
| 70 |
+
self.use_qk_norm = use_qk_norm
|
| 71 |
+
self.moe_router_enable_expert_bias = moe_router_enable_expert_bias
|
| 72 |
+
self.routed_scaling_factor = routed_scaling_factor
|
| 73 |
+
|
| 74 |
+
# MoE configs
|
| 75 |
+
self.num_experts = num_experts
|
| 76 |
+
self.num_shared_experts = num_shared_experts
|
| 77 |
+
self.num_experts_per_tok = num_experts_per_tok
|
| 78 |
+
self.n_group = n_group
|
| 79 |
+
self.topk_group = topk_group
|
| 80 |
+
self.moe_intermediate_size = moe_intermediate_size
|
| 81 |
+
self.first_k_dense_replace = first_k_dense_replace
|
| 82 |
+
self.output_router_logits = output_router_logits
|
| 83 |
+
|
| 84 |
+
super().__init__(pad_token_id=pad_token_id, eos_token_id=eos_token_id, tie_word_embeddings=tie_word_embeddings, **kwargs)
|