Transformers
PyTorch
code
custom_code
Inference Endpoints
File size: 2,106 Bytes
9e71a7f
 
 
 
 
 
775a3c5
 
 
 
 
 
9e71a7f
 
f984418
9e71a7f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python
# coding=utf-8
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

from transformers.configuration_utils import PretrainedConfig

CODESAGE_PRETRAINED_CONFIG_ARCHIVE_MAP = {
    "codesage/codesage-small": "https://huggingface.co/codesage/codesage-small/resolve/main/config.json",
    "codesage/codesage-base": "https://huggingface.co/codesage/codesage-base/resolve/main/config.json",
    "codesage/codesage-large": "https://huggingface.co/codesage/codesage-large/resolve/main/config.json",
}


class CodeSageConfig(PretrainedConfig):
    model_type = "codesage"

    def __init__(
            self,
            vocab_size=50257,
            max_position_embeddings=1024,
            hidden_size=768,
            num_hidden_layers=12,
            num_attention_heads=12,
            intermediate_size=3072,
            activation_function="gelu_new",
            residual_dropout_prob=0.1,
            embedding_dropout_prob=0.1,
            attention_dropout_prob=0.1,
            layer_norm_epsilon=1e-5,
            initializer_range=0.02,
            position_embedding_type='absolute',
            bos_token_id=0,
            eos_token_id=0,
            pad_token_id=49153,
            **kwargs
    ):
        self.vocab_size = vocab_size
        self.max_position_embeddings = max_position_embeddings
        self.hidden_size = hidden_size
        self.num_hidden_layers = num_hidden_layers
        self.num_attention_heads = num_attention_heads
        self.intermediate_size = intermediate_size
        assert 'gelu' in activation_function
        self.activation_function = activation_function
        self.residual_dropout_prob = residual_dropout_prob
        self.embedding_dropout_prob = embedding_dropout_prob
        self.attention_dropout_prob = attention_dropout_prob
        self.layer_norm_epsilon = layer_norm_epsilon
        self.initializer_range = initializer_range
        self.position_embedding_type = position_embedding_type

        super().__init__(pad_token_id=pad_token_id, bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)