noanabeshima commited on
Commit
ec97649
·
verified ·
1 Parent(s): c1c431f

Upload 9 files

Browse files
__init__.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ from .model import DebertaV3SequenceClassifier
2
+ __all__ = ["DebertaV3SequenceClassifier"]
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "[MASK]": 128000
3
+ }
config.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DebertaV3SequenceClassifier"
4
+ ],
5
+ "auto_map": {
6
+ "AutoModel": "model.DebertV3SequenceClassifier",
7
+ "AutoModelForSequenceClassification":
8
+ "model.DebertaV3SequenceClassifier"
9
+ },
10
+ "attention_probs_dropout_prob": 0.1,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout_prob": 0.1,
13
+ "hidden_size": 768,
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 3072,
16
+ "layer_norm_eps": 1e-07,
17
+ "legacy": true,
18
+ "max_position_embeddings": 512,
19
+ "max_relative_positions": -1,
20
+ "model_type": "deberta-v2",
21
+ "norm_rel_ebd": "layer_norm",
22
+ "num_attention_heads": 12,
23
+ "num_hidden_layers": 12,
24
+ "pad_token_id": 0,
25
+ "pooler_dropout": 0,
26
+ "pooler_hidden_act": "gelu",
27
+ "pooler_hidden_size": 768,
28
+ "pos_att_type": [
29
+ "p2c",
30
+ "c2p"
31
+ ],
32
+ "position_biased_input": false,
33
+ "position_buckets": 256,
34
+ "relative_attention": true,
35
+ "share_att_key": true,
36
+ "torch_dtype": "float32",
37
+ "transformers_version": "4.51.3",
38
+ "type_vocab_size": 0,
39
+ "vocab_size": 128100
40
+ }
model.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ import torch.nn.functional as F
4
+
5
+ from transformers import ( # everything stays “DeBERTa” under the hood
6
+ DebertaV2Model, # – we just add a new forward pass
7
+ DebertaV2PreTrainedModel,
8
+ DebertaV2Config,
9
+ )
10
+ from transformers.modeling_outputs import SequenceClassifierOutput
11
+
12
+ class DebertaV3SequenceClassifier(DebertaV2PreTrainedModel):
13
+ def __init__(self, config: DebertaV2Config):
14
+ super().__init__(config)
15
+ self.deberta = DebertaV2Model(config)
16
+ self.d_model = self.deberta.embeddings.LayerNorm.weight.shape[0]
17
+ self.head = nn.Linear(self.d_model, 1)
18
+ self.post_init()
19
+
20
+ @property
21
+ def device(self):
22
+ return self.head.weight.device
23
+
24
+ def forward(self, input_ids=None, attention_mask=None, labels=None, **kwargs):
25
+ x = self.deberta(input_ids, attention_mask=attention_mask).last_hidden_state
26
+
27
+ logits = self.head(x.mean(dim=-2))
28
+ probs = F.sigmoid(logits)
29
+ return {'logits': logits, 'probs': probs}
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a2594e82f30f9bff6181653a97f75c64d1d9bcfd02d477a45d30100ad5070c0
3
+ size 735353660
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "[CLS]",
3
+ "cls_token": "[CLS]",
4
+ "eos_token": "[SEP]",
5
+ "mask_token": "[MASK]",
6
+ "pad_token": "[PAD]",
7
+ "sep_token": "[SEP]",
8
+ "unk_token": {
9
+ "content": "[UNK]",
10
+ "lstrip": false,
11
+ "normalized": true,
12
+ "rstrip": false,
13
+ "single_word": false
14
+ }
15
+ }
spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c679fbf93643d19aab7ee10c0b99e460bdbc02fedf34b92b05af343b4af586fd
3
+ size 2464616
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "[CLS]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[SEP]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[UNK]",
29
+ "lstrip": false,
30
+ "normalized": true,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "128000": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "[CLS]",
45
+ "clean_up_tokenization_spaces": false,
46
+ "cls_token": "[CLS]",
47
+ "do_lower_case": false,
48
+ "eos_token": "[SEP]",
49
+ "extra_special_tokens": {},
50
+ "mask_token": "[MASK]",
51
+ "model_max_length": 1000000000000000019884624838656,
52
+ "pad_token": "[PAD]",
53
+ "sep_token": "[SEP]",
54
+ "sp_model_kwargs": {},
55
+ "split_by_punct": false,
56
+ "tokenizer_class": "DebertaV2Tokenizer",
57
+ "unk_token": "[UNK]",
58
+ "vocab_type": "spm"
59
+ }