File size: 2,031 Bytes
115147b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.

from transformers import PretrainedConfig


class MobileLLMConfig(PretrainedConfig):
    model_type = "mobilellm"
    keys_to_ignore_at_inference = ["past_key_values"]

    def __init__(
        self,
        attention_bias=False,
        bos_token_id=1,
        eos_token_id=2,
        hidden_act="silu",
        hidden_size=1600,
        initializer_range=0.02,
        intermediate_size=4352,
        num_hidden_layers=54,
        num_attention_heads=25,
        num_key_value_heads=5,
        pretraining_tp=1,
        rms_norm_eps=1e-5,
        rope_scaling=None,
        rope_theta=10000.0,
        max_position_embeddings=2048,
        tie_word_embeddings=False,
        use_cache=True,
        bf16=False,
        fp16=True,
        fp32=False,
        vocab_size=32000,
        share_embedding=True,
        **kwargs,
    ):

        self.attention_bias = attention_bias
        self.bos_token_id = bos_token_id
        self.eos_token_id = eos_token_id
        self.hidden_act = hidden_act
        self.hidden_size = hidden_size
        self.initializer_range = initializer_range
        self.intermediate_size = intermediate_size
        self.num_hidden_layers = num_hidden_layers
        self.num_attention_heads = num_attention_heads
        self.num_key_value_heads = num_key_value_heads
        self.pretraining_tp = pretraining_tp
        self.rms_norm_eps = rms_norm_eps
        self.rope_scaling = rope_scaling
        self.rope_theta = rope_theta
        self.max_position_embeddings = max_position_embeddings
        self.use_cache = use_cache
        self.bf16 = bf16
        self.fp16 = fp16
        self.fp32 = fp32
        self.vocab_size = vocab_size
        self.share_embedding = share_embedding
        super().__init__(
            tie_word_embeddings=tie_word_embeddings,
            **kwargs
        )