Kirim1 commited on
Commit
feefb3f
·
verified ·
1 Parent(s): b8028b4

Create configuration_kirim.py

Browse files
Files changed (1) hide show
  1. configuration_kirim.py +84 -0
configuration_kirim.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Kirim Model Configuration
3
+ """
4
+
5
+ from transformers.configuration_utils import PretrainedConfig
6
+ from transformers.utils import logging
7
+
8
+ logger = logging.get_logger(__name__)
9
+
10
+
11
+ class KirimConfig(PretrainedConfig):
12
+ model_type = "kirim"
13
+ keys_to_ignore_at_inference = ["past_key_values"]
14
+
15
+ def __init__(
16
+ self,
17
+ vocab_size=102400,
18
+ hidden_size=4096,
19
+ intermediate_size=11008,
20
+ num_hidden_layers=32,
21
+ num_attention_heads=32,
22
+ num_key_value_heads=8,
23
+ hidden_act="silu",
24
+ max_position_embeddings=32768,
25
+ initializer_range=0.02,
26
+ rms_norm_eps=1e-6,
27
+ use_cache=True,
28
+ pad_token_id=0,
29
+ bos_token_id=1,
30
+ eos_token_id=2,
31
+ tie_word_embeddings=False,
32
+ rope_theta=10000.0,
33
+ rope_scaling=None,
34
+ attention_bias=False,
35
+ attention_dropout=0.0,
36
+ mlp_bias=False,
37
+ **kwargs,
38
+ ):
39
+ self.vocab_size = vocab_size
40
+ self.max_position_embeddings = max_position_embeddings
41
+ self.hidden_size = hidden_size
42
+ self.intermediate_size = intermediate_size
43
+ self.num_hidden_layers = num_hidden_layers
44
+ self.num_attention_heads = num_attention_heads
45
+
46
+ if num_key_value_heads is None:
47
+ num_key_value_heads = num_attention_heads
48
+
49
+ self.num_key_value_heads = num_key_value_heads
50
+ self.hidden_act = hidden_act
51
+ self.initializer_range = initializer_range
52
+ self.rms_norm_eps = rms_norm_eps
53
+ self.use_cache = use_cache
54
+ self.rope_theta = rope_theta
55
+ self.rope_scaling = rope_scaling
56
+ self._rope_scaling_validation()
57
+ self.attention_bias = attention_bias
58
+ self.attention_dropout = attention_dropout
59
+ self.mlp_bias = mlp_bias
60
+
61
+ super().__init__(
62
+ pad_token_id=pad_token_id,
63
+ bos_token_id=bos_token_id,
64
+ eos_token_id=eos_token_id,
65
+ tie_word_embeddings=tie_word_embeddings,
66
+ **kwargs,
67
+ )
68
+
69
+ def _rope_scaling_validation(self):
70
+ if self.rope_scaling is None:
71
+ return
72
+
73
+ if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) != 2:
74
+ raise ValueError(
75
+ f"`rope_scaling` must be a dictionary with two fields, `type` and `factor`, got {self.rope_scaling}"
76
+ )
77
+ rope_scaling_type = self.rope_scaling.get("type", None)
78
+ rope_scaling_factor = self.rope_scaling.get("factor", None)
79
+ if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic", "yarn"]:
80
+ raise ValueError(
81
+ f"`rope_scaling`'s type field must be one of ['linear', 'dynamic', 'yarn'], got {rope_scaling_type}"
82
+ )
83
+ if rope_scaling_factor is None or not isinstance(rope_scaling_factor, float) or rope_scaling_factor <= 1.0:
84
+ raise ValueError(f"`rope_scaling`'s factor field must be a float > 1, got {rope_scaling_factor}")