modelfix-admin commited on
Commit
5e18ca5
·
verified ·
1 Parent(s): a35b554

Retroactive batch sync

Browse files
Files changed (4) hide show
  1. config.json +38 -0
  2. configuration_nandi.py +120 -0
  3. generation_config.json +6 -0
  4. model.onnx +3 -0
config.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "NandiForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_nandi.NandiConfig",
9
+ "AutoModel": "modeling_nandi.NandiModel",
10
+ "AutoModelForCausalLM": "modeling_nandi.NandiForCausalLM"
11
+ },
12
+ "bos_token_id": 1,
13
+ "dtype": "float32",
14
+ "embedding_rank": 196,
15
+ "eos_token_id": 0,
16
+ "factorized_embedding": true,
17
+ "head_dim": 52,
18
+ "hidden_act": "silu",
19
+ "hidden_size": 832,
20
+ "initializer_range": 0.02,
21
+ "intermediate_size": 2496,
22
+ "layer_sharing": true,
23
+ "layer_sharing_repeats": 2,
24
+ "max_position_embeddings": 2048,
25
+ "mlp_bias": false,
26
+ "model_type": "nandi",
27
+ "num_attention_heads": 16,
28
+ "num_hidden_layers": 16,
29
+ "num_key_value_heads": 4,
30
+ "pretraining_tp": 1,
31
+ "rms_norm_eps": 1e-05,
32
+ "rope_parameters": {
33
+ "rope_theta": 100000
34
+ },
35
+ "transformers_version": "4.57.6",
36
+ "use_cache": false,
37
+ "vocab_size": 131072
38
+ }
configuration_nandi.py ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2026 RTA AI Labs. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from transformers.configuration_utils import PretrainedConfig
16
+
17
+
18
+ class NandiConfig(PretrainedConfig):
19
+ r"""
20
+ Configuration class for the Nandi model.
21
+
22
+ Example:
23
+
24
+ ```python
25
+ >>> from transformers import AutoConfig, AutoModelForCausalLM
26
+
27
+ >>> configuration = AutoConfig.from_pretrained("Rta-AILabs/Nandi-150M-remote", trust_remote_code=True)
28
+
29
+ >>> model = AutoModelForCausalLM.from_pretrained("Rta-AILabs/Nandi-150M-remote", trust_remote_code=True)
30
+
31
+ >>> configuration = model.config
32
+ ```
33
+ """
34
+
35
+ model_type = "nandi"
36
+ keys_to_ignore_at_inference = ["past_key_values"]
37
+
38
+ base_model_tp_plan = {
39
+ "layers.*.self_attn.q_proj": "colwise",
40
+ "layers.*.self_attn.k_proj": "colwise",
41
+ "layers.*.self_attn.v_proj": "colwise",
42
+ "layers.*.self_attn.o_proj": "rowwise",
43
+ "layers.*.mlp.gate_proj": "colwise",
44
+ "layers.*.mlp.up_proj": "colwise",
45
+ "layers.*.mlp.down_proj": "rowwise",
46
+ }
47
+
48
+ def __init__(
49
+ self,
50
+ vocab_size=131072,
51
+ hidden_size=832,
52
+ intermediate_size=2496,
53
+ num_hidden_layers=16,
54
+ num_attention_heads=16,
55
+ num_key_value_heads=4,
56
+ head_dim=None,
57
+ hidden_act="silu",
58
+ max_position_embeddings=2048,
59
+ initializer_range=0.008,
60
+ rms_norm_eps=1e-5,
61
+ use_cache=True,
62
+ pad_token_id=None,
63
+ bos_token_id=1,
64
+ eos_token_id=0,
65
+ pretraining_tp=1,
66
+ tie_word_embeddings=True,
67
+ rope_parameters=None,
68
+ attention_bias=False,
69
+ attention_dropout=0.0,
70
+ mlp_bias=False,
71
+ factorized_embedding=True,
72
+ embedding_rank=196,
73
+ layer_sharing=True,
74
+ layer_sharing_repeats=2,
75
+ **kwargs,
76
+ ):
77
+ self.vocab_size = vocab_size
78
+ self.hidden_size = hidden_size
79
+ self.intermediate_size = intermediate_size
80
+ self.num_hidden_layers = num_hidden_layers
81
+ self.num_attention_heads = num_attention_heads
82
+ self.num_key_value_heads = num_key_value_heads if num_key_value_heads is not None else num_attention_heads
83
+ self.head_dim = head_dim if head_dim is not None else hidden_size // num_attention_heads
84
+ self.hidden_act = hidden_act
85
+ self.max_position_embeddings = max_position_embeddings
86
+ self.initializer_range = initializer_range
87
+ self.rms_norm_eps = rms_norm_eps
88
+ self.use_cache = use_cache
89
+ self.pretraining_tp = pretraining_tp
90
+ self.rope_parameters = rope_parameters if rope_parameters is not None else {"rope_theta": 100000.0}
91
+ self.attention_bias = attention_bias
92
+ self.attention_dropout = attention_dropout
93
+ self.mlp_bias = mlp_bias
94
+ self.factorized_embedding = factorized_embedding
95
+ self.embedding_rank = embedding_rank
96
+ self.layer_sharing = layer_sharing
97
+ self.layer_sharing_repeats = layer_sharing_repeats if layer_sharing else 1
98
+
99
+ if self.factorized_embedding and self.embedding_rank <= 0:
100
+ raise ValueError(
101
+ f"`embedding_rank` must be positive when `factorized_embedding=True`, got {self.embedding_rank}."
102
+ )
103
+ if self.hidden_size % self.num_attention_heads != 0:
104
+ raise ValueError(
105
+ f"`hidden_size` ({self.hidden_size}) must be divisible by "
106
+ f"`num_attention_heads` ({self.num_attention_heads})."
107
+ )
108
+ if self.layer_sharing_repeats < 1:
109
+ raise ValueError(f"`layer_sharing_repeats` must be >= 1, got {self.layer_sharing_repeats}.")
110
+
111
+ super().__init__(
112
+ pad_token_id=pad_token_id,
113
+ bos_token_id=bos_token_id,
114
+ eos_token_id=eos_token_id,
115
+ tie_word_embeddings=tie_word_embeddings,
116
+ **kwargs,
117
+ )
118
+
119
+
120
+ __all__ = ["NandiConfig"]
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 0,
5
+ "transformers_version": "4.57.6"
6
+ }
model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:70e2835501bca2d2df3ec0995d7131a0695ff67fa0fe07cba858eb9e26537a57
3
+ size 614820354