Initial upload of EmoAxis model
Browse files- config.json +86 -0
- merges.txt +0 -0
- model.safetensors +3 -0
- modeling.py +51 -0
- special_tokens_map.json +15 -0
- tokenizer.json +0 -0
- tokenizer_config.json +58 -0
- vocab.json +0 -0
config.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"RobertaEmoPillars"
|
| 4 |
+
],
|
| 5 |
+
"attention_probs_dropout_prob": 0.1,
|
| 6 |
+
"bos_token_id": 0,
|
| 7 |
+
"classifier_dropout": null,
|
| 8 |
+
"dtype": "float32",
|
| 9 |
+
"eos_token_id": 2,
|
| 10 |
+
"hidden_act": "gelu",
|
| 11 |
+
"hidden_dropout_prob": 0.1,
|
| 12 |
+
"hidden_size": 768,
|
| 13 |
+
"id2label": {
|
| 14 |
+
"0": "LABEL_0",
|
| 15 |
+
"1": "LABEL_1",
|
| 16 |
+
"2": "LABEL_2",
|
| 17 |
+
"3": "LABEL_3",
|
| 18 |
+
"4": "LABEL_4",
|
| 19 |
+
"5": "LABEL_5",
|
| 20 |
+
"6": "LABEL_6",
|
| 21 |
+
"7": "LABEL_7",
|
| 22 |
+
"8": "LABEL_8",
|
| 23 |
+
"9": "LABEL_9",
|
| 24 |
+
"10": "LABEL_10",
|
| 25 |
+
"11": "LABEL_11",
|
| 26 |
+
"12": "LABEL_12",
|
| 27 |
+
"13": "LABEL_13",
|
| 28 |
+
"14": "LABEL_14",
|
| 29 |
+
"15": "LABEL_15",
|
| 30 |
+
"16": "LABEL_16",
|
| 31 |
+
"17": "LABEL_17",
|
| 32 |
+
"18": "LABEL_18",
|
| 33 |
+
"19": "LABEL_19",
|
| 34 |
+
"20": "LABEL_20",
|
| 35 |
+
"21": "LABEL_21",
|
| 36 |
+
"22": "LABEL_22",
|
| 37 |
+
"23": "LABEL_23",
|
| 38 |
+
"24": "LABEL_24",
|
| 39 |
+
"25": "LABEL_25",
|
| 40 |
+
"26": "LABEL_26",
|
| 41 |
+
"27": "LABEL_27"
|
| 42 |
+
},
|
| 43 |
+
"initializer_range": 0.02,
|
| 44 |
+
"intermediate_size": 3072,
|
| 45 |
+
"label2id": {
|
| 46 |
+
"LABEL_0": 0,
|
| 47 |
+
"LABEL_1": 1,
|
| 48 |
+
"LABEL_10": 10,
|
| 49 |
+
"LABEL_11": 11,
|
| 50 |
+
"LABEL_12": 12,
|
| 51 |
+
"LABEL_13": 13,
|
| 52 |
+
"LABEL_14": 14,
|
| 53 |
+
"LABEL_15": 15,
|
| 54 |
+
"LABEL_16": 16,
|
| 55 |
+
"LABEL_17": 17,
|
| 56 |
+
"LABEL_18": 18,
|
| 57 |
+
"LABEL_19": 19,
|
| 58 |
+
"LABEL_2": 2,
|
| 59 |
+
"LABEL_20": 20,
|
| 60 |
+
"LABEL_21": 21,
|
| 61 |
+
"LABEL_22": 22,
|
| 62 |
+
"LABEL_23": 23,
|
| 63 |
+
"LABEL_24": 24,
|
| 64 |
+
"LABEL_25": 25,
|
| 65 |
+
"LABEL_26": 26,
|
| 66 |
+
"LABEL_27": 27,
|
| 67 |
+
"LABEL_3": 3,
|
| 68 |
+
"LABEL_4": 4,
|
| 69 |
+
"LABEL_5": 5,
|
| 70 |
+
"LABEL_6": 6,
|
| 71 |
+
"LABEL_7": 7,
|
| 72 |
+
"LABEL_8": 8,
|
| 73 |
+
"LABEL_9": 9
|
| 74 |
+
},
|
| 75 |
+
"layer_norm_eps": 1e-05,
|
| 76 |
+
"max_position_embeddings": 514,
|
| 77 |
+
"model_type": "roberta",
|
| 78 |
+
"num_attention_heads": 12,
|
| 79 |
+
"num_hidden_layers": 12,
|
| 80 |
+
"pad_token_id": 1,
|
| 81 |
+
"position_embedding_type": "absolute",
|
| 82 |
+
"transformers_version": "4.57.1",
|
| 83 |
+
"type_vocab_size": 1,
|
| 84 |
+
"use_cache": true,
|
| 85 |
+
"vocab_size": 50265
|
| 86 |
+
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b4d28faea07e06face6719a197967d9d5ff4625356b2cdda3415080872ba61ee
|
| 3 |
+
size 500245096
|
modeling.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn as nn
|
| 3 |
+
import torch.nn.functional as F
|
| 4 |
+
from transformers import PreTrainedModel, AutoModel, AutoConfig
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class Encoder(nn.Module):
|
| 8 |
+
def __init__(self, base_encoder):
|
| 9 |
+
super().__init__()
|
| 10 |
+
self.encoder = base_encoder
|
| 11 |
+
|
| 12 |
+
def forward(self, inputs):
|
| 13 |
+
outputs = self.encoder(**inputs, output_hidden_states=True)
|
| 14 |
+
last_hidden = outputs.hidden_states[-1]
|
| 15 |
+
mask = inputs["attention_mask"].unsqueeze(-1).float()
|
| 16 |
+
pooled = (last_hidden * mask).sum(1) / mask.sum(1).clamp(min=1e-9)
|
| 17 |
+
return F.normalize(pooled, p=2, dim=1)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class Classifier(nn.Module):
|
| 21 |
+
def __init__(self, input_dim=768, num_classes=28):
|
| 22 |
+
super().__init__()
|
| 23 |
+
self.mlp = nn.Sequential(
|
| 24 |
+
nn.Linear(input_dim, 512),
|
| 25 |
+
nn.LayerNorm(512),
|
| 26 |
+
nn.GELU(),
|
| 27 |
+
nn.Dropout(0.25),
|
| 28 |
+
nn.Linear(512, num_classes),
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
def forward(self, x):
|
| 32 |
+
return self.mlp(x)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class RobertaEmoPillars(PreTrainedModel):
|
| 36 |
+
config_class = AutoConfig
|
| 37 |
+
|
| 38 |
+
def __init__(self, config):
|
| 39 |
+
super().__init__(config)
|
| 40 |
+
base_encoder = AutoModel.from_pretrained(config._name_or_path)
|
| 41 |
+
self.encoder = Encoder(base_encoder)
|
| 42 |
+
self.classifier = Classifier(
|
| 43 |
+
input_dim=base_encoder.config.hidden_size,
|
| 44 |
+
num_classes=config.num_labels,
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
def forward(self, input_ids=None, attention_mask=None):
|
| 48 |
+
inputs = {"input_ids": input_ids, "attention_mask": attention_mask}
|
| 49 |
+
emb = self.encoder(inputs)
|
| 50 |
+
logits = self.classifier(emb)
|
| 51 |
+
return logits
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": "<s>",
|
| 3 |
+
"cls_token": "<s>",
|
| 4 |
+
"eos_token": "</s>",
|
| 5 |
+
"mask_token": {
|
| 6 |
+
"content": "<mask>",
|
| 7 |
+
"lstrip": true,
|
| 8 |
+
"normalized": false,
|
| 9 |
+
"rstrip": false,
|
| 10 |
+
"single_word": false
|
| 11 |
+
},
|
| 12 |
+
"pad_token": "<pad>",
|
| 13 |
+
"sep_token": "</s>",
|
| 14 |
+
"unk_token": "<unk>"
|
| 15 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"added_tokens_decoder": {
|
| 4 |
+
"0": {
|
| 5 |
+
"content": "<s>",
|
| 6 |
+
"lstrip": false,
|
| 7 |
+
"normalized": true,
|
| 8 |
+
"rstrip": false,
|
| 9 |
+
"single_word": false,
|
| 10 |
+
"special": true
|
| 11 |
+
},
|
| 12 |
+
"1": {
|
| 13 |
+
"content": "<pad>",
|
| 14 |
+
"lstrip": false,
|
| 15 |
+
"normalized": true,
|
| 16 |
+
"rstrip": false,
|
| 17 |
+
"single_word": false,
|
| 18 |
+
"special": true
|
| 19 |
+
},
|
| 20 |
+
"2": {
|
| 21 |
+
"content": "</s>",
|
| 22 |
+
"lstrip": false,
|
| 23 |
+
"normalized": true,
|
| 24 |
+
"rstrip": false,
|
| 25 |
+
"single_word": false,
|
| 26 |
+
"special": true
|
| 27 |
+
},
|
| 28 |
+
"3": {
|
| 29 |
+
"content": "<unk>",
|
| 30 |
+
"lstrip": false,
|
| 31 |
+
"normalized": true,
|
| 32 |
+
"rstrip": false,
|
| 33 |
+
"single_word": false,
|
| 34 |
+
"special": true
|
| 35 |
+
},
|
| 36 |
+
"50264": {
|
| 37 |
+
"content": "<mask>",
|
| 38 |
+
"lstrip": true,
|
| 39 |
+
"normalized": false,
|
| 40 |
+
"rstrip": false,
|
| 41 |
+
"single_word": false,
|
| 42 |
+
"special": true
|
| 43 |
+
}
|
| 44 |
+
},
|
| 45 |
+
"bos_token": "<s>",
|
| 46 |
+
"clean_up_tokenization_spaces": false,
|
| 47 |
+
"cls_token": "<s>",
|
| 48 |
+
"eos_token": "</s>",
|
| 49 |
+
"errors": "replace",
|
| 50 |
+
"extra_special_tokens": {},
|
| 51 |
+
"mask_token": "<mask>",
|
| 52 |
+
"model_max_length": 512,
|
| 53 |
+
"pad_token": "<pad>",
|
| 54 |
+
"sep_token": "</s>",
|
| 55 |
+
"tokenizer_class": "RobertaTokenizer",
|
| 56 |
+
"trim_offsets": true,
|
| 57 |
+
"unk_token": "<unk>"
|
| 58 |
+
}
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|