Initial upload
Browse files- LE_detection/config.json +53 -0
- LE_detection/model.py +20 -0
- LE_detection/pytorch_model.bin +3 -0
- LE_detection/special_tokens_map.json +7 -0
- LE_detection/tokenizer.json +0 -0
- LE_detection/tokenizer_config.json +13 -0
- LE_detection/vocab.txt +0 -0
- Self-status_determination/config.json +31 -0
- Self-status_determination/model.py +20 -0
- Self-status_determination/pytorch_model.bin +3 -0
- Self-status_determination/special_tokens_map.json +7 -0
- Self-status_determination/tokenizer.json +0 -0
- Self-status_determination/tokenizer_config.json +13 -0
- Self-status_determination/vocab.txt +0 -0
LE_detection/config.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "bert-large-uncased",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"BertForMaskedLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"classifier_dropout": null,
|
| 8 |
+
"gradient_checkpointing": false,
|
| 9 |
+
"hidden_act": "gelu",
|
| 10 |
+
"hidden_dropout_prob": 0.1,
|
| 11 |
+
"hidden_size": 1024,
|
| 12 |
+
"id2label": {
|
| 13 |
+
"0": "Career",
|
| 14 |
+
"1": "Death",
|
| 15 |
+
"2": "Education",
|
| 16 |
+
"3": "Financial",
|
| 17 |
+
"4": "Health",
|
| 18 |
+
"5": "Identity",
|
| 19 |
+
"6": "Legal",
|
| 20 |
+
"7": "Lifestyle_Change",
|
| 21 |
+
"8": "New_Birth_in_Family",
|
| 22 |
+
"9": "Relationships_Changes",
|
| 23 |
+
"10": "Relocation",
|
| 24 |
+
"11": "Societal"
|
| 25 |
+
},
|
| 26 |
+
"initializer_range": 0.02,
|
| 27 |
+
"intermediate_size": 4096,
|
| 28 |
+
"label2id": {
|
| 29 |
+
"Career": 0,
|
| 30 |
+
"Death": 1,
|
| 31 |
+
"Education": 2,
|
| 32 |
+
"Financial": 3,
|
| 33 |
+
"Health": 4,
|
| 34 |
+
"Identity": 5,
|
| 35 |
+
"Legal": 6,
|
| 36 |
+
"Lifestyle_Change": 7,
|
| 37 |
+
"New_Birth_in_Family": 8,
|
| 38 |
+
"Relationships_Changes": 9,
|
| 39 |
+
"Relocation": 10,
|
| 40 |
+
"Societal": 11
|
| 41 |
+
},
|
| 42 |
+
"layer_norm_eps": 1e-12,
|
| 43 |
+
"max_position_embeddings": 512,
|
| 44 |
+
"model_type": "bert",
|
| 45 |
+
"num_attention_heads": 16,
|
| 46 |
+
"num_hidden_layers": 24,
|
| 47 |
+
"pad_token_id": 0,
|
| 48 |
+
"position_embedding_type": "absolute",
|
| 49 |
+
"transformers_version": "4.32.0",
|
| 50 |
+
"type_vocab_size": 2,
|
| 51 |
+
"use_cache": true,
|
| 52 |
+
"vocab_size": 30522
|
| 53 |
+
}
|
LE_detection/model.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from torch import nn
|
| 3 |
+
from transformers import AutoModel, PreTrainedModel, AutoConfig
|
| 4 |
+
|
| 5 |
+
class BERTDiseaseClassifier(nn.Module):
|
| 6 |
+
def __init__(self, model_type, num_symps) -> None:
|
| 7 |
+
super().__init__()
|
| 8 |
+
self.model_type = model_type
|
| 9 |
+
self.num_symps = num_symps
|
| 10 |
+
# multi-label binary classification
|
| 11 |
+
self.encoder = AutoModel.from_pretrained(model_type)
|
| 12 |
+
self.dropout = nn.Dropout(self.encoder.config.hidden_dropout_prob)
|
| 13 |
+
self.clf = nn.Linear(self.encoder.config.hidden_size, num_symps)
|
| 14 |
+
|
| 15 |
+
def forward(self, input_ids=None, attention_mask=None, token_type_ids=None, **kwargs):
|
| 16 |
+
outputs = self.encoder(input_ids, attention_mask, token_type_ids)
|
| 17 |
+
x = outputs.last_hidden_state[:, 0, :] # [CLS] pooling
|
| 18 |
+
x = self.dropout(x)
|
| 19 |
+
logits = self.clf(x)
|
| 20 |
+
return logits
|
LE_detection/pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:71150dfb107bda67c29d5e341687789dce8480a19cc83391ff497324168a45d5
|
| 3 |
+
size 1340772783
|
LE_detection/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 |
+
}
|
LE_detection/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
LE_detection/tokenizer_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"clean_up_tokenization_spaces": true,
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": true,
|
| 5 |
+
"mask_token": "[MASK]",
|
| 6 |
+
"model_max_length": 512,
|
| 7 |
+
"pad_token": "[PAD]",
|
| 8 |
+
"sep_token": "[SEP]",
|
| 9 |
+
"strip_accents": null,
|
| 10 |
+
"tokenize_chinese_chars": true,
|
| 11 |
+
"tokenizer_class": "BertTokenizer",
|
| 12 |
+
"unk_token": "[UNK]"
|
| 13 |
+
}
|
LE_detection/vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
Self-status_determination/config.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "bert-large-uncased",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"BertForMaskedLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"classifier_dropout": null,
|
| 8 |
+
"gradient_checkpointing": false,
|
| 9 |
+
"hidden_act": "gelu",
|
| 10 |
+
"hidden_dropout_prob": 0.1,
|
| 11 |
+
"hidden_size": 1024,
|
| 12 |
+
"id2label": {
|
| 13 |
+
"0": "Is_self"
|
| 14 |
+
},
|
| 15 |
+
"initializer_range": 0.02,
|
| 16 |
+
"intermediate_size": 4096,
|
| 17 |
+
"label2id": {
|
| 18 |
+
"Is_self": 0
|
| 19 |
+
},
|
| 20 |
+
"layer_norm_eps": 1e-12,
|
| 21 |
+
"max_position_embeddings": 512,
|
| 22 |
+
"model_type": "bert",
|
| 23 |
+
"num_attention_heads": 16,
|
| 24 |
+
"num_hidden_layers": 24,
|
| 25 |
+
"pad_token_id": 0,
|
| 26 |
+
"position_embedding_type": "absolute",
|
| 27 |
+
"transformers_version": "4.32.0",
|
| 28 |
+
"type_vocab_size": 2,
|
| 29 |
+
"use_cache": true,
|
| 30 |
+
"vocab_size": 30522
|
| 31 |
+
}
|
Self-status_determination/model.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from torch import nn
|
| 3 |
+
from transformers import AutoModel, PreTrainedModel, AutoConfig
|
| 4 |
+
|
| 5 |
+
class BERTDiseaseClassifier(nn.Module):
|
| 6 |
+
def __init__(self, model_type, num_symps) -> None:
|
| 7 |
+
super().__init__()
|
| 8 |
+
self.model_type = model_type
|
| 9 |
+
self.num_symps = num_symps
|
| 10 |
+
# multi-label binary classification
|
| 11 |
+
self.encoder = AutoModel.from_pretrained(model_type)
|
| 12 |
+
self.dropout = nn.Dropout(self.encoder.config.hidden_dropout_prob)
|
| 13 |
+
self.clf = nn.Linear(self.encoder.config.hidden_size, num_symps)
|
| 14 |
+
|
| 15 |
+
def forward(self, input_ids=None, attention_mask=None, token_type_ids=None, **kwargs):
|
| 16 |
+
outputs = self.encoder(input_ids, attention_mask, token_type_ids)
|
| 17 |
+
x = outputs.last_hidden_state[:, 0, :] # [CLS] pooling
|
| 18 |
+
x = self.dropout(x)
|
| 19 |
+
logits = self.clf(x)
|
| 20 |
+
return logits
|
Self-status_determination/pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5021fbf15ee7216b32a149f4f4ca78e03b95cbe5040ef463f22708334cff31d6
|
| 3 |
+
size 1340727727
|
Self-status_determination/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 |
+
}
|
Self-status_determination/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
Self-status_determination/tokenizer_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"clean_up_tokenization_spaces": true,
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": true,
|
| 5 |
+
"mask_token": "[MASK]",
|
| 6 |
+
"model_max_length": 512,
|
| 7 |
+
"pad_token": "[PAD]",
|
| 8 |
+
"sep_token": "[SEP]",
|
| 9 |
+
"strip_accents": null,
|
| 10 |
+
"tokenize_chinese_chars": true,
|
| 11 |
+
"tokenizer_class": "BertTokenizer",
|
| 12 |
+
"unk_token": "[UNK]"
|
| 13 |
+
}
|
Self-status_determination/vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|