jungseok commited on
Commit
d4e2a17
·
1 Parent(s): a1cb53a

add model

Browse files
Files changed (3) hide show
  1. ROBERTA.py +20 -0
  2. config.json +32 -0
  3. pytorch_model.bin +3 -0
ROBERTA.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import PreTrainedModel
2
+ import torch.nn as nn
3
+
4
+ class CustomModel(PreTrainedModel):
5
+
6
+ def __init__(self,config, base_model, n_label):
7
+ super().__init__(config)
8
+ self.model = base_model
9
+ ### New layers:
10
+ self.linear = nn.Linear(1024, n_label)
11
+ self.log_softmax = nn.LogSoftmax(dim= 1)
12
+
13
+ def forward(self,X):
14
+
15
+ bert_output = self.model(**X)
16
+ # sequence_output has the following shape: (batch_size, sequence_length, 1024)
17
+ output = self.linear(bert_output[1]) ##
18
+ output = self.log_softmax(output)
19
+
20
+ return output
config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "klue/roberta-large",
3
+ "architectures": [
4
+ "CustomModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "auto_map": {
8
+ "AutoModel": "ROBERTA.CustomModel"
9
+ },
10
+ "bos_token_id": 0,
11
+ "classifier_dropout": null,
12
+ "eos_token_id": 2,
13
+ "gradient_checkpointing": false,
14
+ "hidden_act": "gelu",
15
+ "hidden_dropout_prob": 0.1,
16
+ "hidden_size": 1024,
17
+ "initializer_range": 0.02,
18
+ "intermediate_size": 4096,
19
+ "layer_norm_eps": 1e-05,
20
+ "max_position_embeddings": 514,
21
+ "model_type": "roberta",
22
+ "num_attention_heads": 16,
23
+ "num_hidden_layers": 24,
24
+ "pad_token_id": 1,
25
+ "position_embedding_type": "absolute",
26
+ "tokenizer_class": "BertTokenizer",
27
+ "torch_dtype": "float32",
28
+ "transformers_version": "4.21.3",
29
+ "type_vocab_size": 1,
30
+ "use_cache": true,
31
+ "vocab_size": 32000
32
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:43d8d1cbac442c4ab0a1d68769796524cc178d0c1a2571da999d6a86b894f11d
3
+ size 1346802925