kaanakdeniz commited on
Commit
40dfc44
1 Parent(s): 5b4ff05

Upload 9 files

Browse files
config.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "kiddothe2b/hierarchical-transformer-base-4096",
3
+ "architectures": [
4
+ "HATForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_hat.HATConfig",
9
+ "AutoModel": "modelling_hat.HATModel",
10
+ "AutoModelForMaskedLM": "modelling_hat.HATForMaskedLM",
11
+ "AutoModelForMultipleChoice": "modelling_hat.HATForMultipleChoice",
12
+ "AutoModelForQuestionAnswering": "modelling_hat.HATForQuestionAnswering",
13
+ "AutoModelForSequenceClassification": "modelling_hat.HATForSequenceClassification",
14
+ "AutoModelForTokenClassification": "modelling_hat.HATForTokenClassification",
15
+ "AutoTokenizer": "tokenization_hat.HATTokenizer"
16
+ },
17
+ "bos_token_id": 0,
18
+ "classifier_dropout": null,
19
+ "encoder_layout": {
20
+ "0": {
21
+ "document_encoder": false,
22
+ "sentence_encoder": true
23
+ },
24
+ "1": {
25
+ "document_encoder": false,
26
+ "sentence_encoder": true
27
+ },
28
+ "10": {
29
+ "document_encoder": false,
30
+ "sentence_encoder": true
31
+ },
32
+ "11": {
33
+ "document_encoder": true,
34
+ "sentence_encoder": true
35
+ },
36
+ "2": {
37
+ "document_encoder": true,
38
+ "sentence_encoder": true
39
+ },
40
+ "3": {
41
+ "document_encoder": false,
42
+ "sentence_encoder": true
43
+ },
44
+ "4": {
45
+ "document_encoder": false,
46
+ "sentence_encoder": true
47
+ },
48
+ "5": {
49
+ "document_encoder": true,
50
+ "sentence_encoder": true
51
+ },
52
+ "6": {
53
+ "document_encoder": false,
54
+ "sentence_encoder": true
55
+ },
56
+ "7": {
57
+ "document_encoder": false,
58
+ "sentence_encoder": true
59
+ },
60
+ "8": {
61
+ "document_encoder": true,
62
+ "sentence_encoder": true
63
+ },
64
+ "9": {
65
+ "document_encoder": false,
66
+ "sentence_encoder": true
67
+ }
68
+ },
69
+ "eos_token_id": 2,
70
+ "hidden_act": "gelu",
71
+ "hidden_dropout_prob": 0.1,
72
+ "hidden_size": 768,
73
+ "id2label": {
74
+ "0": "LABEL_0",
75
+ "1": "LABEL_1",
76
+ "2": "LABEL_2",
77
+ "3": "LABEL_3",
78
+ "4": "LABEL_4",
79
+ "5": "LABEL_5",
80
+ "6": "LABEL_6"
81
+ },
82
+ "initializer_range": 0.02,
83
+ "intermediate_size": 3072,
84
+ "label2id": {
85
+ "LABEL_0": 0,
86
+ "LABEL_1": 1,
87
+ "LABEL_2": 2,
88
+ "LABEL_3": 3,
89
+ "LABEL_4": 4,
90
+ "LABEL_5": 5,
91
+ "LABEL_6": 6
92
+ },
93
+ "layer_norm_eps": 1e-12,
94
+ "max_position_embeddings": 130,
95
+ "max_sentence_length": 128,
96
+ "max_sentence_size": 128,
97
+ "max_sentences": 32,
98
+ "model_max_length": 4096,
99
+ "model_type": "hierarchical-transformer",
100
+ "num_attention_heads": 12,
101
+ "num_hidden_layers": 12,
102
+ "output_past": true,
103
+ "pad_token_id": 1,
104
+ "parameters": 136350720,
105
+ "position_embedding_type": "absolute",
106
+ "problem_type": "single_label_classification",
107
+ "torch_dtype": "float32",
108
+ "transformers_version": "4.28.1",
109
+ "type_vocab_size": 1,
110
+ "use_cache": true,
111
+ "vocab_size": 50265
112
+ }
configuration_hat.py ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+ """ HAT configuration"""
14
+ from collections import OrderedDict
15
+ from typing import Mapping
16
+
17
+ from transformers.onnx import OnnxConfig
18
+ from transformers.utils import logging
19
+ from transformers import PretrainedConfig
20
+
21
+
22
+ logger = logging.get_logger(__name__)
23
+
24
+ HAT_PRETRAINED_CONFIG_ARCHIVE_MAP = {
25
+ "kiddothe2b/hierarchical-transformer-base-4096": "https://huggingface.co/kiddothe2b/hierarchical-transformer-base-4096/resolve/main/config.json",
26
+ "kiddothe2b/adhoc-hierarchical-transformer-base-4096": "https://huggingface.co/kiddothe2b/adhoc-hierarchical-transformer-base-4096/resolve/main/config.json",
27
+ }
28
+
29
+
30
+ class HATConfig(PretrainedConfig):
31
+ r"""
32
+ This is the configuration class to store the configuration of a :class:`~transformers.HAT`.
33
+ It is used to instantiate a HAT model according to the specified arguments,
34
+ defining the model architecture. Instantiating a configuration with the defaults will yield a similar configuration
35
+ to that of the HAT `kiddothe2b/hierarchical-transformer-base-4096
36
+ <https://huggingface.co/kiddothe2b/hierarchical-transformer-base-4096>`__ architecture.
37
+
38
+ Configuration objects inherit from :class:`~transformers.PretrainedConfig` and can be used to control the model
39
+ outputs. Read the documentation from :class:`~transformers.PretrainedConfig` for more information.
40
+
41
+
42
+ Args:
43
+ vocab_size (:obj:`int`, `optional`, defaults to 30522):
44
+ Vocabulary size of the BERT model. Defines the number of different tokens that can be represented by the
45
+ :obj:`inputs_ids` passed when calling :class:`~transformers.BertModel` or
46
+ :class:`~transformers.TFBertModel`.
47
+ max_sentences (:obj:`int`, `optional`, defaults to 64):
48
+ The maximum number of sentences that this model might ever be used with.
49
+ max_sentence_size (:obj:`int`, `optional`, defaults to 128):
50
+ The maximum sentence length that this model might ever be used with.
51
+ model_max_length (:obj:`int`, `optional`, defaults to 8192):
52
+ The maximum sequence length (max_sentences * max_sentence_size) that this model might ever be used with
53
+ encoder_layout (:obj:`Dict`):
54
+ The sentence/document encoder layout.
55
+ hidden_size (:obj:`int`, `optional`, defaults to 768):
56
+ Dimensionality of the encoder layers and the pooler layer.
57
+ num_hidden_layers (:obj:`int`, `optional`, defaults to 12):
58
+ Number of hidden layers in the Transformer encoder.
59
+ num_attention_heads (:obj:`int`, `optional`, defaults to 12):
60
+ Number of attention heads for each attention layer in the Transformer encoder.
61
+ intermediate_size (:obj:`int`, `optional`, defaults to 3072):
62
+ Dimensionality of the "intermediate" (often named feed-forward) layer in the Transformer encoder.
63
+ hidden_act (:obj:`str` or :obj:`Callable`, `optional`, defaults to :obj:`"gelu"`):
64
+ The non-linear activation function (function or string) in the encoder and pooler. If string,
65
+ :obj:`"gelu"`, :obj:`"relu"`, :obj:`"silu"` and :obj:`"gelu_new"` are supported.
66
+ hidden_dropout_prob (:obj:`float`, `optional`, defaults to 0.1):
67
+ The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
68
+ attention_probs_dropout_prob (:obj:`float`, `optional`, defaults to 0.1):
69
+ The dropout ratio for the attention probabilities.
70
+ max_position_embeddings (:obj:`int`, `optional`, defaults to 512):
71
+ The maximum sequence length that this model might ever be used with. Typically set this to something large
72
+ just in case (e.g., 512 or 1024 or 2048).
73
+ type_vocab_size (:obj:`int`, `optional`, defaults to 2):
74
+ The vocabulary size of the :obj:`token_type_ids` passed when calling :class:`~transformers.BertModel` or
75
+ :class:`~transformers.TFBertModel`.
76
+ initializer_range (:obj:`float`, `optional`, defaults to 0.02):
77
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
78
+ layer_norm_eps (:obj:`float`, `optional`, defaults to 1e-12):
79
+ The epsilon used by the layer normalization layers.
80
+ position_embedding_type (:obj:`str`, `optional`, defaults to :obj:`"absolute"`):
81
+ Type of position embedding. Choose one of :obj:`"absolute"`, :obj:`"relative_key"`,
82
+ :obj:`"relative_key_query"`. For positional embeddings use :obj:`"absolute"`. For more information on
83
+ :obj:`"relative_key"`, please refer to `Self-Attention with Relative Position Representations (Shaw et al.)
84
+ <https://arxiv.org/abs/1803.02155>`__. For more information on :obj:`"relative_key_query"`, please refer to
85
+ `Method 4` in `Improve Transformer Models with Better Relative Position Embeddings (Huang et al.)
86
+ <https://arxiv.org/abs/2009.13658>`__.
87
+ use_cache (:obj:`bool`, `optional`, defaults to :obj:`True`):
88
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
89
+ relevant if ``config.is_decoder=True``.
90
+ classifier_dropout (:obj:`float`, `optional`):
91
+ The dropout ratio for the classification head.
92
+ """
93
+ model_type = "hierarchical-transformer"
94
+
95
+ def __init__(
96
+ self,
97
+ vocab_size=30522,
98
+ hidden_size=768,
99
+ max_sentences=64,
100
+ max_sentence_size=128,
101
+ model_max_length=8192,
102
+ num_hidden_layers=12,
103
+ num_attention_heads=12,
104
+ intermediate_size=3072,
105
+ hidden_act="gelu",
106
+ hidden_dropout_prob=0.1,
107
+ attention_probs_dropout_prob=0.1,
108
+ max_position_embeddings=512,
109
+ type_vocab_size=2,
110
+ initializer_range=0.02,
111
+ layer_norm_eps=1e-12,
112
+ pad_token_id=0,
113
+ position_embedding_type="absolute",
114
+ encoder_layout=None,
115
+ use_cache=True,
116
+ classifier_dropout=None,
117
+ **kwargs
118
+ ):
119
+ super().__init__(pad_token_id=pad_token_id, **kwargs)
120
+
121
+ self.vocab_size = vocab_size
122
+ self.hidden_size = hidden_size
123
+ self.max_sentences = max_sentences
124
+ self.max_sentence_size = max_sentence_size
125
+ self.model_max_length = model_max_length
126
+ self.encoder_layout = encoder_layout
127
+ self.num_hidden_layers = num_hidden_layers
128
+ self.num_attention_heads = num_attention_heads
129
+ self.hidden_act = hidden_act
130
+ self.intermediate_size = intermediate_size
131
+ self.hidden_dropout_prob = hidden_dropout_prob
132
+ self.attention_probs_dropout_prob = attention_probs_dropout_prob
133
+ self.max_position_embeddings = max_position_embeddings
134
+ self.type_vocab_size = type_vocab_size
135
+ self.initializer_range = initializer_range
136
+ self.layer_norm_eps = layer_norm_eps
137
+ self.position_embedding_type = position_embedding_type
138
+ self.use_cache = use_cache
139
+ self.classifier_dropout = classifier_dropout
140
+
141
+
142
+ class HATOnnxConfig(OnnxConfig):
143
+ @property
144
+ def inputs(self) -> Mapping[str, Mapping[int, str]]:
145
+ return OrderedDict(
146
+ [
147
+ ("input_ids", {0: "batch", 1: "sequence"}),
148
+ ("attention_mask", {0: "batch", 1: "sequence"}),
149
+ ]
150
+ )
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
modelling_hat.py ADDED
The diff for this file is too large to render. See raw diff
 
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18d6129fa43bac603ebc4a24bc9da4357eb13f80e17d5cc889c27374127c60b0
3
+ size 611062969
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_config.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "bos_token": {
4
+ "__type": "AddedToken",
5
+ "content": "<s>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false
10
+ },
11
+ "clean_up_tokenization_spaces": true,
12
+ "cls_token": {
13
+ "__type": "AddedToken",
14
+ "content": "<s>",
15
+ "lstrip": false,
16
+ "normalized": true,
17
+ "rstrip": false,
18
+ "single_word": false
19
+ },
20
+ "eos_token": {
21
+ "__type": "AddedToken",
22
+ "content": "</s>",
23
+ "lstrip": false,
24
+ "normalized": true,
25
+ "rstrip": false,
26
+ "single_word": false
27
+ },
28
+ "errors": "replace",
29
+ "mask_token": {
30
+ "__type": "AddedToken",
31
+ "content": "<mask>",
32
+ "lstrip": true,
33
+ "normalized": true,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "model_max_length": 4096,
38
+ "pad_token": {
39
+ "__type": "AddedToken",
40
+ "content": "<pad>",
41
+ "lstrip": false,
42
+ "normalized": true,
43
+ "rstrip": false,
44
+ "single_word": false
45
+ },
46
+ "sep_token": {
47
+ "__type": "AddedToken",
48
+ "content": "</s>",
49
+ "lstrip": false,
50
+ "normalized": true,
51
+ "rstrip": false,
52
+ "single_word": false
53
+ },
54
+ "tokenizer_class": "RobertaTokenizer",
55
+ "trim_offsets": true,
56
+ "unk_token": {
57
+ "__type": "AddedToken",
58
+ "content": "<unk>",
59
+ "lstrip": false,
60
+ "normalized": true,
61
+ "rstrip": false,
62
+ "single_word": false
63
+ }
64
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0189a090bb8630e0991931c1c3072fbd7a79d80b1f6d42d4a2c7abf433d5ceb
3
+ size 3643
vocab.json ADDED
The diff for this file is too large to render. See raw diff