KenyaNonaka0210
commited on
Commit
·
28698b8
1
Parent(s):
71d8ac2
ok
Browse files
config.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
{
|
2 |
-
"_name_or_path": "
|
3 |
"architectures": [
|
4 |
-
"
|
5 |
],
|
6 |
"attention_probs_dropout_prob": 0.1,
|
7 |
"auto_map": {
|
8 |
-
"AutoConfig": "uzabase/UBKE-LUKE--
|
9 |
-
"AutoModel": "uzabase/UBKE-LUKE--
|
10 |
-
"AutoModelForPreTraining": "uzabase/UBKE-LUKE--
|
11 |
},
|
12 |
"bert_model_name": "cl-tohoku/bert-base-japanese-v3",
|
13 |
"bos_token_id": null,
|
@@ -25,7 +25,7 @@
|
|
25 |
"intermediate_size": 3072,
|
26 |
"layer_norm_eps": 1e-12,
|
27 |
"max_position_embeddings": 512,
|
28 |
-
"model_type": "
|
29 |
"normalize_entity_embeddings": 1,
|
30 |
"num_attention_heads": 12,
|
31 |
"num_category_entities": 0,
|
|
|
1 |
{
|
2 |
+
"_name_or_path": "ubke_ub_sample_private",
|
3 |
"architectures": [
|
4 |
+
"UbkeForMaskedLM"
|
5 |
],
|
6 |
"attention_probs_dropout_prob": 0.1,
|
7 |
"auto_map": {
|
8 |
+
"AutoConfig": "uzabase/UBKE-LUKE--configuration_ubke.UbkeConfig",
|
9 |
+
"AutoModel": "uzabase/UBKE-LUKE--modeling_ubke.UbkeForMaskedLM",
|
10 |
+
"AutoModelForPreTraining": "uzabase/UBKE-LUKE--modeling_ubke.UbkeForMaskedLM"
|
11 |
},
|
12 |
"bert_model_name": "cl-tohoku/bert-base-japanese-v3",
|
13 |
"bos_token_id": null,
|
|
|
25 |
"intermediate_size": 3072,
|
26 |
"layer_norm_eps": 1e-12,
|
27 |
"max_position_embeddings": 512,
|
28 |
+
"model_type": "ubke",
|
29 |
"normalize_entity_embeddings": 1,
|
30 |
"num_attention_heads": 12,
|
31 |
"num_category_entities": 0,
|
configuration_luxe.py → configuration_ubke.py
RENAMED
@@ -1,8 +1,8 @@
|
|
1 |
from transformers.configuration_utils import PretrainedConfig
|
2 |
|
3 |
|
4 |
-
class
|
5 |
-
model_type = "
|
6 |
|
7 |
def __init__(
|
8 |
self,
|
@@ -30,7 +30,12 @@ class LuxeConfig(PretrainedConfig):
|
|
30 |
eos_token_id=2,
|
31 |
**kwargs,
|
32 |
):
|
33 |
-
super().__init__(
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
self.vocab_size = vocab_size
|
36 |
self.entity_vocab_size = entity_vocab_size
|
|
|
1 |
from transformers.configuration_utils import PretrainedConfig
|
2 |
|
3 |
|
4 |
+
class UbkeConfig(PretrainedConfig):
|
5 |
+
model_type = "ubke"
|
6 |
|
7 |
def __init__(
|
8 |
self,
|
|
|
30 |
eos_token_id=2,
|
31 |
**kwargs,
|
32 |
):
|
33 |
+
super().__init__(
|
34 |
+
pad_token_id=pad_token_id,
|
35 |
+
bos_token_id=bos_token_id,
|
36 |
+
eos_token_id=eos_token_id,
|
37 |
+
**kwargs,
|
38 |
+
)
|
39 |
|
40 |
self.vocab_size = vocab_size
|
41 |
self.entity_vocab_size = entity_vocab_size
|
modeling_luxe.py → modeling_ubke.py
RENAMED
@@ -11,11 +11,11 @@ from transformers.models.luke.modeling_luke import (
|
|
11 |
)
|
12 |
from transformers.utils import ModelOutput
|
13 |
|
14 |
-
from .
|
15 |
|
16 |
|
17 |
@dataclass
|
18 |
-
class
|
19 |
loss: Optional[torch.FloatTensor] = None
|
20 |
mlm_loss: Optional[torch.FloatTensor] = None
|
21 |
mep_loss: Optional[torch.FloatTensor] = None
|
@@ -32,8 +32,8 @@ class LuxeMaskedLMOutput(ModelOutput):
|
|
32 |
attentions: Optional[Tuple[torch.FloatTensor, ...]] = None
|
33 |
|
34 |
|
35 |
-
class
|
36 |
-
config_class =
|
37 |
base_model_prefix = "luke"
|
38 |
supports_gradient_checkpointing = True
|
39 |
_no_split_modules = ["LukeAttention", "LukeEntityEmbeddings"]
|
@@ -55,14 +55,14 @@ class LuxePreTrainedModel(PreTrainedModel):
|
|
55 |
module.weight.data.fill_(1.0)
|
56 |
|
57 |
|
58 |
-
class
|
59 |
_tied_weights_keys = [
|
60 |
"lm_head.decoder.weight",
|
61 |
"lm_head.decoder.bias",
|
62 |
"entity_predictions.decoder.weight",
|
63 |
]
|
64 |
|
65 |
-
def __init__(self, config:
|
66 |
super().__init__(config)
|
67 |
|
68 |
self.luke = LukeModel(config)
|
@@ -114,7 +114,7 @@ class LuxeForMaskedLM(LuxePreTrainedModel):
|
|
114 |
output_attentions: Optional[bool] = None,
|
115 |
output_hidden_states: Optional[bool] = None,
|
116 |
return_dict: Optional[bool] = None,
|
117 |
-
) -> Union[Tuple,
|
118 |
return_dict = (
|
119 |
return_dict if return_dict is not None else self.config.use_return_dict
|
120 |
)
|
@@ -232,7 +232,7 @@ class LuxeForMaskedLM(LuxePreTrainedModel):
|
|
232 |
if v is not None
|
233 |
)
|
234 |
|
235 |
-
return
|
236 |
loss=loss,
|
237 |
mlm_loss=mlm_loss,
|
238 |
mep_loss=mep_loss,
|
|
|
11 |
)
|
12 |
from transformers.utils import ModelOutput
|
13 |
|
14 |
+
from .configuration_ubke import UbkeConfig
|
15 |
|
16 |
|
17 |
@dataclass
|
18 |
+
class UbkeMaskedLMOutput(ModelOutput):
|
19 |
loss: Optional[torch.FloatTensor] = None
|
20 |
mlm_loss: Optional[torch.FloatTensor] = None
|
21 |
mep_loss: Optional[torch.FloatTensor] = None
|
|
|
32 |
attentions: Optional[Tuple[torch.FloatTensor, ...]] = None
|
33 |
|
34 |
|
35 |
+
class UbkePreTrainedModel(PreTrainedModel):
|
36 |
+
config_class = UbkeConfig
|
37 |
base_model_prefix = "luke"
|
38 |
supports_gradient_checkpointing = True
|
39 |
_no_split_modules = ["LukeAttention", "LukeEntityEmbeddings"]
|
|
|
55 |
module.weight.data.fill_(1.0)
|
56 |
|
57 |
|
58 |
+
class UbkeForMaskedLM(UbkePreTrainedModel):
|
59 |
_tied_weights_keys = [
|
60 |
"lm_head.decoder.weight",
|
61 |
"lm_head.decoder.bias",
|
62 |
"entity_predictions.decoder.weight",
|
63 |
]
|
64 |
|
65 |
+
def __init__(self, config: UbkeConfig):
|
66 |
super().__init__(config)
|
67 |
|
68 |
self.luke = LukeModel(config)
|
|
|
114 |
output_attentions: Optional[bool] = None,
|
115 |
output_hidden_states: Optional[bool] = None,
|
116 |
return_dict: Optional[bool] = None,
|
117 |
+
) -> Union[Tuple, UbkeMaskedLMOutput]:
|
118 |
return_dict = (
|
119 |
return_dict if return_dict is not None else self.config.use_return_dict
|
120 |
)
|
|
|
232 |
if v is not None
|
233 |
)
|
234 |
|
235 |
+
return UbkeMaskedLMOutput(
|
236 |
loss=loss,
|
237 |
mlm_loss=mlm_loss,
|
238 |
mep_loss=mep_loss,
|