Commit
•
f36c5fb
1
Parent(s):
d0e4bbb
Initial commit including model and configuration
Browse files- config.json +2 -2
- configuration_stacked.py +49 -0
- models.py +1 -1
- push_to_hf.py +2 -2
config.json
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
{
|
2 |
-
"_name_or_path": "
|
3 |
"architectures": [
|
4 |
"ExtendedMultitaskModelForTokenClassification"
|
5 |
],
|
6 |
"attention_probs_dropout_prob": 0.1,
|
7 |
"auto_map": {
|
8 |
-
"AutoConfig": "
|
9 |
"AutoModelForTokenClassification": "models.ExtendedMultitaskModelForTokenClassification"
|
10 |
},
|
11 |
"classifier_dropout": null,
|
|
|
1 |
{
|
2 |
+
"_name_or_path": "experiments_final/model_dbmdz_bert_medium_historic_multilingual_cased_max_sequence_length_512_epochs_5_run_extended_suffix_baseline/checkpoint-450",
|
3 |
"architectures": [
|
4 |
"ExtendedMultitaskModelForTokenClassification"
|
5 |
],
|
6 |
"attention_probs_dropout_prob": 0.1,
|
7 |
"auto_map": {
|
8 |
+
"AutoConfig": "configuration_stacked.ImpressoConfig",
|
9 |
"AutoModelForTokenClassification": "models.ExtendedMultitaskModelForTokenClassification"
|
10 |
},
|
11 |
"classifier_dropout": null,
|
configuration_stacked.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import PretrainedConfig
|
2 |
+
|
3 |
+
|
4 |
+
class ImpressoConfig(PretrainedConfig):
|
5 |
+
model_type = "stacked_bert"
|
6 |
+
|
7 |
+
def __init__(
|
8 |
+
self,
|
9 |
+
vocab_size=30522,
|
10 |
+
hidden_size=768,
|
11 |
+
num_hidden_layers=12,
|
12 |
+
num_attention_heads=12,
|
13 |
+
intermediate_size=3072,
|
14 |
+
hidden_act="gelu",
|
15 |
+
hidden_dropout_prob=0.1,
|
16 |
+
attention_probs_dropout_prob=0.1,
|
17 |
+
max_position_embeddings=512,
|
18 |
+
type_vocab_size=2,
|
19 |
+
initializer_range=0.02,
|
20 |
+
layer_norm_eps=1e-12,
|
21 |
+
pad_token_id=0,
|
22 |
+
position_embedding_type="absolute",
|
23 |
+
use_cache=True,
|
24 |
+
classifier_dropout=None,
|
25 |
+
pretrained_config=None,
|
26 |
+
**kwargs,
|
27 |
+
):
|
28 |
+
super().__init__(pad_token_id=pad_token_id, **kwargs)
|
29 |
+
|
30 |
+
self.vocab_size = vocab_size
|
31 |
+
self.hidden_size = hidden_size
|
32 |
+
self.num_hidden_layers = num_hidden_layers
|
33 |
+
self.num_attention_heads = num_attention_heads
|
34 |
+
self.hidden_act = hidden_act
|
35 |
+
self.intermediate_size = intermediate_size
|
36 |
+
self.hidden_dropout_prob = hidden_dropout_prob
|
37 |
+
self.attention_probs_dropout_prob = attention_probs_dropout_prob
|
38 |
+
self.max_position_embeddings = max_position_embeddings
|
39 |
+
self.type_vocab_size = type_vocab_size
|
40 |
+
self.initializer_range = initializer_range
|
41 |
+
self.layer_norm_eps = layer_norm_eps
|
42 |
+
self.position_embedding_type = position_embedding_type
|
43 |
+
self.use_cache = use_cache
|
44 |
+
self.classifier_dropout = classifier_dropout
|
45 |
+
self.pretrained_config = pretrained_config
|
46 |
+
|
47 |
+
|
48 |
+
# Register the configuration with the transformers library
|
49 |
+
ImpressoConfig.register_for_auto_class()
|
models.py
CHANGED
@@ -5,7 +5,7 @@ from transformers import PreTrainedModel, AutoModel, AutoConfig
|
|
5 |
from torch.nn import CrossEntropyLoss
|
6 |
from typing import Optional, Tuple, Union
|
7 |
import logging
|
8 |
-
from
|
9 |
|
10 |
logger = logging.getLogger(__name__)
|
11 |
|
|
|
5 |
from torch.nn import CrossEntropyLoss
|
6 |
from typing import Optional, Tuple, Union
|
7 |
import logging
|
8 |
+
from .configuration_stacked import ImpressoConfig
|
9 |
|
10 |
logger = logging.getLogger(__name__)
|
11 |
|
push_to_hf.py
CHANGED
@@ -4,8 +4,8 @@ import argparse
|
|
4 |
from transformers import AutoTokenizer, AutoConfig, AutoModelForTokenClassification
|
5 |
from huggingface_hub import HfApi, Repository
|
6 |
import json
|
7 |
-
from
|
8 |
-
from models import ExtendedMultitaskModelForTokenClassification
|
9 |
import subprocess
|
10 |
|
11 |
|
|
|
4 |
from transformers import AutoTokenizer, AutoConfig, AutoModelForTokenClassification
|
5 |
from huggingface_hub import HfApi, Repository
|
6 |
import json
|
7 |
+
from .configuration_stacked import ImpressoConfig
|
8 |
+
from .models import ExtendedMultitaskModelForTokenClassification
|
9 |
import subprocess
|
10 |
|
11 |
|