Sandeep Chowdhary commited on
Commit
6e69e4d
·
verified ·
1 Parent(s): be412d5

Initial upload housing distilbert classifier

Browse files
Files changed (5) hide show
  1. model.pt +3 -0
  2. model_class.py +21 -0
  3. special_tokens_map.json +7 -0
  4. tokenizer_config.json +58 -0
  5. vocab.txt +0 -0
model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4354251d8bb7e0403ce9c1acad0d741974e26d4cbb078685cc9fa9de65040c21
3
+ size 265506843
model_class.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torch import nn
3
+ from transformers import DistilBertModel, DistilBertTokenizer
4
+
5
+ class MultilabelClassifier(nn.Module):
6
+ """Base model for multilabel classification supporting different backbones"""
7
+
8
+ def __init__(self, model_name, num_labels, dropout=0.1):
9
+ super(MultilabelClassifier, self).__init__()
10
+
11
+ self.backbone = DistilBertModel.from_pretrained(model_name)
12
+ self.dropout = nn.Dropout(dropout)
13
+ self.classifier = nn.Linear(768, num_labels)
14
+ self.sigmoid = nn.Sigmoid()
15
+
16
+ def forward(self, input_ids, attention_mask):
17
+ outputs = self.backbone(input_ids=input_ids, attention_mask=attention_mask)
18
+ pooled_output = outputs.last_hidden_state[:, 0]
19
+ x = self.dropout(pooled_output)
20
+ logits = self.classifier(x)
21
+ return self.sigmoid(logits)
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer_config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "extra_special_tokens": {},
49
+ "mask_token": "[MASK]",
50
+ "model_max_length": 512,
51
+ "never_split": null,
52
+ "pad_token": "[PAD]",
53
+ "sep_token": "[SEP]",
54
+ "strip_accents": null,
55
+ "tokenize_chinese_chars": true,
56
+ "tokenizer_class": "DistilBertTokenizer",
57
+ "unk_token": "[UNK]"
58
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff