Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- added_tokens.json +104 -0
- config.json +25 -0
- configuration_relik.py +45 -0
- model.safetensors +3 -0
- modeling_relik.py +1007 -0
- special_tokens_map.json +118 -0
- spm.model +3 -0
- tokenizer.json +3 -0
- tokenizer_config.json +970 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
added_tokens.json
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"--NME--": 250102,
|
3 |
+
"[E-0]": 250103,
|
4 |
+
"[E-10]": 250113,
|
5 |
+
"[E-11]": 250114,
|
6 |
+
"[E-12]": 250115,
|
7 |
+
"[E-13]": 250116,
|
8 |
+
"[E-14]": 250117,
|
9 |
+
"[E-15]": 250118,
|
10 |
+
"[E-16]": 250119,
|
11 |
+
"[E-17]": 250120,
|
12 |
+
"[E-18]": 250121,
|
13 |
+
"[E-19]": 250122,
|
14 |
+
"[E-1]": 250104,
|
15 |
+
"[E-20]": 250123,
|
16 |
+
"[E-21]": 250124,
|
17 |
+
"[E-22]": 250125,
|
18 |
+
"[E-23]": 250126,
|
19 |
+
"[E-24]": 250127,
|
20 |
+
"[E-25]": 250128,
|
21 |
+
"[E-26]": 250129,
|
22 |
+
"[E-27]": 250130,
|
23 |
+
"[E-28]": 250131,
|
24 |
+
"[E-29]": 250132,
|
25 |
+
"[E-2]": 250105,
|
26 |
+
"[E-30]": 250133,
|
27 |
+
"[E-31]": 250134,
|
28 |
+
"[E-32]": 250135,
|
29 |
+
"[E-33]": 250136,
|
30 |
+
"[E-34]": 250137,
|
31 |
+
"[E-35]": 250138,
|
32 |
+
"[E-36]": 250139,
|
33 |
+
"[E-37]": 250140,
|
34 |
+
"[E-38]": 250141,
|
35 |
+
"[E-39]": 250142,
|
36 |
+
"[E-3]": 250106,
|
37 |
+
"[E-40]": 250143,
|
38 |
+
"[E-41]": 250144,
|
39 |
+
"[E-42]": 250145,
|
40 |
+
"[E-43]": 250146,
|
41 |
+
"[E-44]": 250147,
|
42 |
+
"[E-45]": 250148,
|
43 |
+
"[E-46]": 250149,
|
44 |
+
"[E-47]": 250150,
|
45 |
+
"[E-48]": 250151,
|
46 |
+
"[E-49]": 250152,
|
47 |
+
"[E-4]": 250107,
|
48 |
+
"[E-50]": 250153,
|
49 |
+
"[E-51]": 250154,
|
50 |
+
"[E-52]": 250155,
|
51 |
+
"[E-53]": 250156,
|
52 |
+
"[E-54]": 250157,
|
53 |
+
"[E-55]": 250158,
|
54 |
+
"[E-56]": 250159,
|
55 |
+
"[E-57]": 250160,
|
56 |
+
"[E-58]": 250161,
|
57 |
+
"[E-59]": 250162,
|
58 |
+
"[E-5]": 250108,
|
59 |
+
"[E-60]": 250163,
|
60 |
+
"[E-61]": 250164,
|
61 |
+
"[E-62]": 250165,
|
62 |
+
"[E-63]": 250166,
|
63 |
+
"[E-64]": 250167,
|
64 |
+
"[E-65]": 250168,
|
65 |
+
"[E-66]": 250169,
|
66 |
+
"[E-67]": 250170,
|
67 |
+
"[E-68]": 250171,
|
68 |
+
"[E-69]": 250172,
|
69 |
+
"[E-6]": 250109,
|
70 |
+
"[E-70]": 250173,
|
71 |
+
"[E-71]": 250174,
|
72 |
+
"[E-72]": 250175,
|
73 |
+
"[E-73]": 250176,
|
74 |
+
"[E-74]": 250177,
|
75 |
+
"[E-75]": 250178,
|
76 |
+
"[E-76]": 250179,
|
77 |
+
"[E-77]": 250180,
|
78 |
+
"[E-78]": 250181,
|
79 |
+
"[E-79]": 250182,
|
80 |
+
"[E-7]": 250110,
|
81 |
+
"[E-80]": 250183,
|
82 |
+
"[E-81]": 250184,
|
83 |
+
"[E-82]": 250185,
|
84 |
+
"[E-83]": 250186,
|
85 |
+
"[E-84]": 250187,
|
86 |
+
"[E-85]": 250188,
|
87 |
+
"[E-86]": 250189,
|
88 |
+
"[E-87]": 250190,
|
89 |
+
"[E-88]": 250191,
|
90 |
+
"[E-89]": 250192,
|
91 |
+
"[E-8]": 250111,
|
92 |
+
"[E-90]": 250193,
|
93 |
+
"[E-91]": 250194,
|
94 |
+
"[E-92]": 250195,
|
95 |
+
"[E-93]": 250196,
|
96 |
+
"[E-94]": 250197,
|
97 |
+
"[E-95]": 250198,
|
98 |
+
"[E-96]": 250199,
|
99 |
+
"[E-97]": 250200,
|
100 |
+
"[E-98]": 250201,
|
101 |
+
"[E-99]": 250202,
|
102 |
+
"[E-9]": 250112,
|
103 |
+
"[MASK]": 250101
|
104 |
+
}
|
config.json
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"activation": "gelu",
|
3 |
+
"add_entity_embedding": null,
|
4 |
+
"additional_special_symbols": 101,
|
5 |
+
"additional_special_symbols_types": 0,
|
6 |
+
"architectures": [
|
7 |
+
"RelikReaderSpanModel"
|
8 |
+
],
|
9 |
+
"auto_map": {
|
10 |
+
"AutoConfig": "configuration_relik.RelikReaderConfig",
|
11 |
+
"AutoModel": "modeling_relik.RelikReaderSpanModel"
|
12 |
+
},
|
13 |
+
"binary_end_logits": false,
|
14 |
+
"default_reader_class": null,
|
15 |
+
"entity_type_loss": false,
|
16 |
+
"linears_hidden_size": 512,
|
17 |
+
"model_type": "relik-reader",
|
18 |
+
"num_layers": null,
|
19 |
+
"threshold": 0.5,
|
20 |
+
"torch_dtype": "float32",
|
21 |
+
"training": true,
|
22 |
+
"transformer_model": "/leonardo_work/IscrC_MEL/hf_cache/microsoft/mdeberta-v3-base",
|
23 |
+
"transformers_version": "4.41.2",
|
24 |
+
"use_last_k_layers": 1
|
25 |
+
}
|
configuration_relik.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Optional
|
2 |
+
|
3 |
+
from transformers import AutoConfig
|
4 |
+
from transformers.configuration_utils import PretrainedConfig
|
5 |
+
|
6 |
+
|
7 |
+
class RelikReaderConfig(PretrainedConfig):
|
8 |
+
model_type = "relik-reader"
|
9 |
+
|
10 |
+
def __init__(
|
11 |
+
self,
|
12 |
+
transformer_model: str = "microsoft/deberta-v3-base",
|
13 |
+
additional_special_symbols: int = 101,
|
14 |
+
additional_special_symbols_types: Optional[int] = 0,
|
15 |
+
num_layers: Optional[int] = None,
|
16 |
+
activation: str = "gelu",
|
17 |
+
linears_hidden_size: Optional[int] = 512,
|
18 |
+
use_last_k_layers: int = 1,
|
19 |
+
entity_type_loss: bool = False,
|
20 |
+
add_entity_embedding: bool = None,
|
21 |
+
binary_end_logits: bool = False,
|
22 |
+
training: bool = False,
|
23 |
+
default_reader_class: Optional[str] = None,
|
24 |
+
threshold: Optional[float] = 0.5,
|
25 |
+
**kwargs
|
26 |
+
) -> None:
|
27 |
+
# TODO: add name_or_path to kwargs
|
28 |
+
self.transformer_model = transformer_model
|
29 |
+
self.additional_special_symbols = additional_special_symbols
|
30 |
+
self.additional_special_symbols_types = additional_special_symbols_types
|
31 |
+
self.num_layers = num_layers
|
32 |
+
self.activation = activation
|
33 |
+
self.linears_hidden_size = linears_hidden_size
|
34 |
+
self.use_last_k_layers = use_last_k_layers
|
35 |
+
self.entity_type_loss = entity_type_loss
|
36 |
+
self.add_entity_embedding = (
|
37 |
+
True
|
38 |
+
if add_entity_embedding is None and entity_type_loss
|
39 |
+
else add_entity_embedding
|
40 |
+
)
|
41 |
+
self.threshold = threshold
|
42 |
+
self.binary_end_logits = binary_end_logits
|
43 |
+
self.training = training
|
44 |
+
self.default_reader_class = default_reader_class
|
45 |
+
super().__init__(**kwargs)
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1373f64275ba720dd8aa09e32d7768f5896f03fd1476cbc3dfa663f9ce84a907
|
3 |
+
size 1124782884
|
modeling_relik.py
ADDED
@@ -0,0 +1,1007 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Any, Dict, Optional
|
2 |
+
|
3 |
+
import torch
|
4 |
+
from transformers import AutoModel, PreTrainedModel
|
5 |
+
from transformers.activations import ClippedGELUActivation, GELUActivation
|
6 |
+
from transformers.configuration_utils import PretrainedConfig
|
7 |
+
from transformers.modeling_utils import PoolerEndLogits
|
8 |
+
|
9 |
+
from .configuration_relik import RelikReaderConfig
|
10 |
+
|
11 |
+
|
12 |
+
class RelikReaderSample:
|
13 |
+
def __init__(self, **kwargs):
|
14 |
+
super().__setattr__("_d", {})
|
15 |
+
self._d = kwargs
|
16 |
+
|
17 |
+
def __getattribute__(self, item):
|
18 |
+
return super(RelikReaderSample, self).__getattribute__(item)
|
19 |
+
|
20 |
+
def __getattr__(self, item):
|
21 |
+
if item.startswith("__") and item.endswith("__"):
|
22 |
+
# this is likely some python library-specific variable (such as __deepcopy__ for copy)
|
23 |
+
# better follow standard behavior here
|
24 |
+
raise AttributeError(item)
|
25 |
+
elif item in self._d:
|
26 |
+
return self._d[item]
|
27 |
+
else:
|
28 |
+
return None
|
29 |
+
|
30 |
+
def __setattr__(self, key, value):
|
31 |
+
if key in self._d:
|
32 |
+
self._d[key] = value
|
33 |
+
else:
|
34 |
+
super().__setattr__(key, value)
|
35 |
+
self._d[key] = value
|
36 |
+
|
37 |
+
|
38 |
+
activation2functions = {
|
39 |
+
"relu": torch.nn.ReLU(),
|
40 |
+
"gelu": GELUActivation(),
|
41 |
+
"gelu_10": ClippedGELUActivation(-10, 10),
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
class PoolerEndLogitsBi(PoolerEndLogits):
|
46 |
+
def __init__(self, config: PretrainedConfig):
|
47 |
+
super().__init__(config)
|
48 |
+
self.dense_1 = torch.nn.Linear(config.hidden_size, 2)
|
49 |
+
|
50 |
+
def forward(
|
51 |
+
self,
|
52 |
+
hidden_states: torch.FloatTensor,
|
53 |
+
start_states: Optional[torch.FloatTensor] = None,
|
54 |
+
start_positions: Optional[torch.LongTensor] = None,
|
55 |
+
p_mask: Optional[torch.FloatTensor] = None,
|
56 |
+
) -> torch.FloatTensor:
|
57 |
+
if p_mask is not None:
|
58 |
+
p_mask = p_mask.unsqueeze(-1)
|
59 |
+
logits = super().forward(
|
60 |
+
hidden_states,
|
61 |
+
start_states,
|
62 |
+
start_positions,
|
63 |
+
p_mask,
|
64 |
+
)
|
65 |
+
return logits
|
66 |
+
|
67 |
+
|
68 |
+
class RelikReaderSpanModel(PreTrainedModel):
|
69 |
+
config_class = RelikReaderConfig
|
70 |
+
|
71 |
+
def __init__(self, config: RelikReaderConfig, *args, **kwargs):
|
72 |
+
super().__init__(config)
|
73 |
+
# Transformer model declaration
|
74 |
+
self.config = config
|
75 |
+
self.transformer_model = (
|
76 |
+
AutoModel.from_pretrained(self.config.transformer_model)
|
77 |
+
if self.config.num_layers is None
|
78 |
+
else AutoModel.from_pretrained(
|
79 |
+
self.config.transformer_model, num_hidden_layers=self.config.num_layers
|
80 |
+
)
|
81 |
+
)
|
82 |
+
self.transformer_model.resize_token_embeddings(
|
83 |
+
self.transformer_model.config.vocab_size
|
84 |
+
+ self.config.additional_special_symbols
|
85 |
+
)
|
86 |
+
|
87 |
+
self.activation = self.config.activation
|
88 |
+
self.linears_hidden_size = self.config.linears_hidden_size
|
89 |
+
self.use_last_k_layers = self.config.use_last_k_layers
|
90 |
+
|
91 |
+
# named entity detection layers
|
92 |
+
self.ned_start_classifier = self._get_projection_layer(
|
93 |
+
self.activation, last_hidden=2, layer_norm=False
|
94 |
+
)
|
95 |
+
if self.config.binary_end_logits:
|
96 |
+
self.ned_end_classifier = PoolerEndLogitsBi(self.transformer_model.config)
|
97 |
+
else:
|
98 |
+
self.ned_end_classifier = PoolerEndLogits(self.transformer_model.config)
|
99 |
+
|
100 |
+
# END entity disambiguation layer
|
101 |
+
self.ed_start_projector = self._get_projection_layer(self.activation)
|
102 |
+
self.ed_end_projector = self._get_projection_layer(self.activation)
|
103 |
+
|
104 |
+
self.training = self.config.training
|
105 |
+
|
106 |
+
# criterion
|
107 |
+
self.criterion = torch.nn.CrossEntropyLoss()
|
108 |
+
|
109 |
+
def _get_projection_layer(
|
110 |
+
self,
|
111 |
+
activation: str,
|
112 |
+
last_hidden: Optional[int] = None,
|
113 |
+
input_hidden=None,
|
114 |
+
layer_norm: bool = True,
|
115 |
+
) -> torch.nn.Sequential:
|
116 |
+
head_components = [
|
117 |
+
torch.nn.Dropout(0.1),
|
118 |
+
torch.nn.Linear(
|
119 |
+
(
|
120 |
+
self.transformer_model.config.hidden_size * self.use_last_k_layers
|
121 |
+
if input_hidden is None
|
122 |
+
else input_hidden
|
123 |
+
),
|
124 |
+
self.linears_hidden_size,
|
125 |
+
),
|
126 |
+
activation2functions[activation],
|
127 |
+
torch.nn.Dropout(0.1),
|
128 |
+
torch.nn.Linear(
|
129 |
+
self.linears_hidden_size,
|
130 |
+
self.linears_hidden_size if last_hidden is None else last_hidden,
|
131 |
+
),
|
132 |
+
]
|
133 |
+
|
134 |
+
if layer_norm:
|
135 |
+
head_components.append(
|
136 |
+
torch.nn.LayerNorm(
|
137 |
+
self.linears_hidden_size if last_hidden is None else last_hidden,
|
138 |
+
self.transformer_model.config.layer_norm_eps,
|
139 |
+
)
|
140 |
+
)
|
141 |
+
|
142 |
+
return torch.nn.Sequential(*head_components)
|
143 |
+
|
144 |
+
def _mask_logits(self, logits: torch.Tensor, mask: torch.Tensor) -> torch.Tensor:
|
145 |
+
mask = mask.unsqueeze(-1)
|
146 |
+
if next(self.parameters()).dtype == torch.float16:
|
147 |
+
logits = logits * (1 - mask) - 65500 * mask
|
148 |
+
else:
|
149 |
+
logits = logits * (1 - mask) - 1e30 * mask
|
150 |
+
return logits
|
151 |
+
|
152 |
+
def _get_model_features(
|
153 |
+
self,
|
154 |
+
input_ids: torch.Tensor,
|
155 |
+
attention_mask: torch.Tensor,
|
156 |
+
token_type_ids: Optional[torch.Tensor],
|
157 |
+
):
|
158 |
+
model_input = {
|
159 |
+
"input_ids": input_ids,
|
160 |
+
"attention_mask": attention_mask,
|
161 |
+
"output_hidden_states": self.use_last_k_layers > 1,
|
162 |
+
}
|
163 |
+
|
164 |
+
if token_type_ids is not None:
|
165 |
+
model_input["token_type_ids"] = token_type_ids
|
166 |
+
|
167 |
+
model_output = self.transformer_model(**model_input)
|
168 |
+
|
169 |
+
if self.use_last_k_layers > 1:
|
170 |
+
model_features = torch.cat(
|
171 |
+
model_output[1][-self.use_last_k_layers :], dim=-1
|
172 |
+
)
|
173 |
+
else:
|
174 |
+
model_features = model_output[0]
|
175 |
+
|
176 |
+
return model_features
|
177 |
+
|
178 |
+
def compute_ned_end_logits(
|
179 |
+
self,
|
180 |
+
start_predictions,
|
181 |
+
start_labels,
|
182 |
+
model_features,
|
183 |
+
prediction_mask,
|
184 |
+
batch_size,
|
185 |
+
) -> Optional[torch.Tensor]:
|
186 |
+
# todo: maybe when constraining on the spans,
|
187 |
+
# we should not use a prediction_mask for the end tokens.
|
188 |
+
# at least we should not during training imo
|
189 |
+
start_positions = start_labels if self.training else start_predictions
|
190 |
+
start_positions_indices = (
|
191 |
+
torch.arange(start_positions.size(1), device=start_positions.device)
|
192 |
+
.unsqueeze(0)
|
193 |
+
.expand(batch_size, -1)[start_positions > 0]
|
194 |
+
).to(start_positions.device)
|
195 |
+
|
196 |
+
if len(start_positions_indices) > 0:
|
197 |
+
expanded_features = model_features.repeat_interleave(
|
198 |
+
torch.sum(start_positions > 0, dim=-1), dim=0
|
199 |
+
)
|
200 |
+
expanded_prediction_mask = prediction_mask.repeat_interleave(
|
201 |
+
torch.sum(start_positions > 0, dim=-1), dim=0
|
202 |
+
)
|
203 |
+
end_logits = self.ned_end_classifier(
|
204 |
+
hidden_states=expanded_features,
|
205 |
+
start_positions=start_positions_indices,
|
206 |
+
p_mask=expanded_prediction_mask,
|
207 |
+
)
|
208 |
+
|
209 |
+
return end_logits
|
210 |
+
|
211 |
+
return None
|
212 |
+
|
213 |
+
def compute_classification_logits(
|
214 |
+
self,
|
215 |
+
model_features_start,
|
216 |
+
model_features_end,
|
217 |
+
special_symbols_features,
|
218 |
+
) -> torch.Tensor:
|
219 |
+
model_start_features = self.ed_start_projector(model_features_start)
|
220 |
+
model_end_features = self.ed_end_projector(model_features_end)
|
221 |
+
model_start_features_symbols = self.ed_start_projector(special_symbols_features)
|
222 |
+
model_end_features_symbols = self.ed_end_projector(special_symbols_features)
|
223 |
+
|
224 |
+
model_ed_features = torch.cat(
|
225 |
+
[model_start_features, model_end_features], dim=-1
|
226 |
+
)
|
227 |
+
special_symbols_representation = torch.cat(
|
228 |
+
[model_start_features_symbols, model_end_features_symbols], dim=-1
|
229 |
+
)
|
230 |
+
|
231 |
+
logits = torch.bmm(
|
232 |
+
model_ed_features,
|
233 |
+
torch.permute(special_symbols_representation, (0, 2, 1)),
|
234 |
+
)
|
235 |
+
|
236 |
+
logits = self._mask_logits(logits, (model_features_start == -100).all(2).long())
|
237 |
+
return logits
|
238 |
+
|
239 |
+
def forward(
|
240 |
+
self,
|
241 |
+
input_ids: torch.Tensor,
|
242 |
+
attention_mask: torch.Tensor,
|
243 |
+
token_type_ids: Optional[torch.Tensor] = None,
|
244 |
+
prediction_mask: Optional[torch.Tensor] = None,
|
245 |
+
special_symbols_mask: Optional[torch.Tensor] = None,
|
246 |
+
start_labels: Optional[torch.Tensor] = None,
|
247 |
+
end_labels: Optional[torch.Tensor] = None,
|
248 |
+
use_predefined_spans: bool = False,
|
249 |
+
*args,
|
250 |
+
**kwargs,
|
251 |
+
) -> Dict[str, Any]:
|
252 |
+
batch_size, seq_len = input_ids.shape
|
253 |
+
|
254 |
+
model_features = self._get_model_features(
|
255 |
+
input_ids, attention_mask, token_type_ids
|
256 |
+
)
|
257 |
+
|
258 |
+
ned_start_labels = None
|
259 |
+
|
260 |
+
# named entity detection if required
|
261 |
+
if use_predefined_spans: # no need to compute spans
|
262 |
+
ned_start_logits, ned_start_probabilities, ned_start_predictions = (
|
263 |
+
None,
|
264 |
+
None,
|
265 |
+
(
|
266 |
+
torch.clone(start_labels)
|
267 |
+
if start_labels is not None
|
268 |
+
else torch.zeros_like(input_ids)
|
269 |
+
),
|
270 |
+
)
|
271 |
+
ned_end_logits, ned_end_probabilities, ned_end_predictions = (
|
272 |
+
None,
|
273 |
+
None,
|
274 |
+
(
|
275 |
+
torch.clone(end_labels)
|
276 |
+
if end_labels is not None
|
277 |
+
else torch.zeros_like(input_ids)
|
278 |
+
),
|
279 |
+
)
|
280 |
+
ned_start_predictions[ned_start_predictions > 0] = 1
|
281 |
+
ned_end_predictions[end_labels > 0] = 1
|
282 |
+
ned_end_predictions = ned_end_predictions[~(end_labels == -100).all(2)]
|
283 |
+
|
284 |
+
else: # compute spans
|
285 |
+
# start boundary prediction
|
286 |
+
ned_start_logits = self.ned_start_classifier(model_features)
|
287 |
+
ned_start_logits = self._mask_logits(ned_start_logits, prediction_mask)
|
288 |
+
ned_start_probabilities = torch.softmax(ned_start_logits, dim=-1)
|
289 |
+
ned_start_predictions = ned_start_probabilities.argmax(dim=-1)
|
290 |
+
|
291 |
+
# end boundary prediction
|
292 |
+
ned_start_labels = (
|
293 |
+
torch.zeros_like(start_labels) if start_labels is not None else None
|
294 |
+
)
|
295 |
+
|
296 |
+
if ned_start_labels is not None:
|
297 |
+
ned_start_labels[start_labels == -100] = -100
|
298 |
+
ned_start_labels[start_labels > 0] = 1
|
299 |
+
|
300 |
+
ned_end_logits = self.compute_ned_end_logits(
|
301 |
+
ned_start_predictions,
|
302 |
+
ned_start_labels,
|
303 |
+
model_features,
|
304 |
+
prediction_mask,
|
305 |
+
batch_size,
|
306 |
+
)
|
307 |
+
|
308 |
+
if ned_end_logits is not None:
|
309 |
+
ned_end_probabilities = torch.softmax(ned_end_logits, dim=-1)
|
310 |
+
if not self.config.binary_end_logits:
|
311 |
+
ned_end_predictions = torch.argmax(
|
312 |
+
ned_end_probabilities, dim=-1, keepdim=True
|
313 |
+
)
|
314 |
+
ned_end_predictions = torch.zeros_like(
|
315 |
+
ned_end_probabilities
|
316 |
+
).scatter_(1, ned_end_predictions, 1)
|
317 |
+
else:
|
318 |
+
ned_end_predictions = torch.argmax(ned_end_probabilities, dim=-1)
|
319 |
+
else:
|
320 |
+
ned_end_logits, ned_end_probabilities = None, None
|
321 |
+
ned_end_predictions = ned_start_predictions.new_zeros(
|
322 |
+
batch_size, seq_len
|
323 |
+
)
|
324 |
+
|
325 |
+
if not self.training:
|
326 |
+
# if len(ned_end_predictions.shape) < 2:
|
327 |
+
# print(ned_end_predictions)
|
328 |
+
end_preds_count = ned_end_predictions.sum(1)
|
329 |
+
# If there are no end predictions for a start prediction, remove the start prediction
|
330 |
+
if (end_preds_count == 0).any() and (ned_start_predictions > 0).any():
|
331 |
+
ned_start_predictions[ned_start_predictions == 1] = (
|
332 |
+
end_preds_count != 0
|
333 |
+
).long()
|
334 |
+
ned_end_predictions = ned_end_predictions[end_preds_count != 0]
|
335 |
+
|
336 |
+
if end_labels is not None:
|
337 |
+
end_labels = end_labels[~(end_labels == -100).all(2)]
|
338 |
+
|
339 |
+
start_position, end_position = (
|
340 |
+
(start_labels, end_labels)
|
341 |
+
if self.training
|
342 |
+
else (ned_start_predictions, ned_end_predictions)
|
343 |
+
)
|
344 |
+
start_counts = (start_position > 0).sum(1)
|
345 |
+
if (start_counts > 0).any():
|
346 |
+
ned_end_predictions = ned_end_predictions.split(start_counts.tolist())
|
347 |
+
# Entity disambiguation
|
348 |
+
if (end_position > 0).sum() > 0:
|
349 |
+
ends_count = (end_position > 0).sum(1)
|
350 |
+
model_entity_start = torch.repeat_interleave(
|
351 |
+
model_features[start_position > 0], ends_count, dim=0
|
352 |
+
)
|
353 |
+
model_entity_end = torch.repeat_interleave(
|
354 |
+
model_features, start_counts, dim=0
|
355 |
+
)[end_position > 0]
|
356 |
+
ents_count = torch.nn.utils.rnn.pad_sequence(
|
357 |
+
torch.split(ends_count, start_counts.tolist()),
|
358 |
+
batch_first=True,
|
359 |
+
padding_value=0,
|
360 |
+
).sum(1)
|
361 |
+
|
362 |
+
model_entity_start = torch.nn.utils.rnn.pad_sequence(
|
363 |
+
torch.split(model_entity_start, ents_count.tolist()),
|
364 |
+
batch_first=True,
|
365 |
+
padding_value=-100,
|
366 |
+
)
|
367 |
+
|
368 |
+
model_entity_end = torch.nn.utils.rnn.pad_sequence(
|
369 |
+
torch.split(model_entity_end, ents_count.tolist()),
|
370 |
+
batch_first=True,
|
371 |
+
padding_value=-100,
|
372 |
+
)
|
373 |
+
|
374 |
+
ed_logits = self.compute_classification_logits(
|
375 |
+
model_entity_start,
|
376 |
+
model_entity_end,
|
377 |
+
model_features[special_symbols_mask].view(
|
378 |
+
batch_size, -1, model_features.shape[-1]
|
379 |
+
),
|
380 |
+
)
|
381 |
+
ed_probabilities = torch.softmax(ed_logits, dim=-1)
|
382 |
+
ed_predictions = torch.argmax(ed_probabilities, dim=-1)
|
383 |
+
else:
|
384 |
+
ed_logits, ed_probabilities, ed_predictions = (
|
385 |
+
None,
|
386 |
+
ned_start_predictions.new_zeros(batch_size, seq_len),
|
387 |
+
ned_start_predictions.new_zeros(batch_size),
|
388 |
+
)
|
389 |
+
# output build
|
390 |
+
output_dict = dict(
|
391 |
+
batch_size=batch_size,
|
392 |
+
ned_start_logits=ned_start_logits,
|
393 |
+
ned_start_probabilities=ned_start_probabilities,
|
394 |
+
ned_start_predictions=ned_start_predictions,
|
395 |
+
ned_end_logits=ned_end_logits,
|
396 |
+
ned_end_probabilities=ned_end_probabilities,
|
397 |
+
ned_end_predictions=ned_end_predictions,
|
398 |
+
ed_logits=ed_logits,
|
399 |
+
ed_probabilities=ed_probabilities,
|
400 |
+
ed_predictions=ed_predictions,
|
401 |
+
)
|
402 |
+
|
403 |
+
# compute loss if labels
|
404 |
+
if start_labels is not None and end_labels is not None and self.training:
|
405 |
+
# named entity detection loss
|
406 |
+
|
407 |
+
# start
|
408 |
+
if ned_start_logits is not None:
|
409 |
+
ned_start_loss = self.criterion(
|
410 |
+
ned_start_logits.view(-1, ned_start_logits.shape[-1]),
|
411 |
+
ned_start_labels.view(-1),
|
412 |
+
)
|
413 |
+
else:
|
414 |
+
ned_start_loss = 0
|
415 |
+
|
416 |
+
# end
|
417 |
+
# use ents_count to assign the labels to the correct positions i.e. using end_labels -> [[0,0,4,0], [0,0,0,2]] -> [4,2] (this is just an element, for batch we need to mask it with ents_count), ie -> [[4,2,-100,-100], [3,1,2,-100], [1,3,2,5]]
|
418 |
+
|
419 |
+
if ned_end_logits is not None:
|
420 |
+
ed_labels = end_labels.clone()
|
421 |
+
ed_labels = torch.nn.utils.rnn.pad_sequence(
|
422 |
+
torch.split(ed_labels[ed_labels > 0], ents_count.tolist()),
|
423 |
+
batch_first=True,
|
424 |
+
padding_value=-100,
|
425 |
+
)
|
426 |
+
end_labels[end_labels > 0] = 1
|
427 |
+
if not self.config.binary_end_logits:
|
428 |
+
# transform label to position in the sequence
|
429 |
+
end_labels = end_labels.argmax(dim=-1)
|
430 |
+
ned_end_loss = self.criterion(
|
431 |
+
ned_end_logits.view(-1, ned_end_logits.shape[-1]),
|
432 |
+
end_labels.view(-1),
|
433 |
+
)
|
434 |
+
else:
|
435 |
+
ned_end_loss = self.criterion(
|
436 |
+
ned_end_logits.reshape(-1, ned_end_logits.shape[-1]),
|
437 |
+
end_labels.reshape(-1).long(),
|
438 |
+
)
|
439 |
+
|
440 |
+
# entity disambiguation loss
|
441 |
+
ed_loss = self.criterion(
|
442 |
+
ed_logits.view(-1, ed_logits.shape[-1]),
|
443 |
+
ed_labels.view(-1).long(),
|
444 |
+
)
|
445 |
+
|
446 |
+
else:
|
447 |
+
ned_end_loss = 0
|
448 |
+
ed_loss = 0
|
449 |
+
|
450 |
+
output_dict["ned_start_loss"] = ned_start_loss
|
451 |
+
output_dict["ned_end_loss"] = ned_end_loss
|
452 |
+
output_dict["ed_loss"] = ed_loss
|
453 |
+
|
454 |
+
output_dict["loss"] = ned_start_loss + ned_end_loss + ed_loss
|
455 |
+
|
456 |
+
return output_dict
|
457 |
+
|
458 |
+
|
459 |
+
class RelikReaderREModel(PreTrainedModel):
|
460 |
+
config_class = RelikReaderConfig
|
461 |
+
|
462 |
+
def __init__(self, config, *args, **kwargs):
|
463 |
+
super().__init__(config)
|
464 |
+
# Transformer model declaration
|
465 |
+
# self.transformer_model_name = transformer_model
|
466 |
+
self.config = config
|
467 |
+
self.transformer_model = (
|
468 |
+
AutoModel.from_pretrained(config.transformer_model)
|
469 |
+
if config.num_layers is None
|
470 |
+
else AutoModel.from_pretrained(
|
471 |
+
config.transformer_model, num_hidden_layers=config.num_layers
|
472 |
+
)
|
473 |
+
)
|
474 |
+
self.transformer_model.resize_token_embeddings(
|
475 |
+
self.transformer_model.config.vocab_size
|
476 |
+
+ config.additional_special_symbols
|
477 |
+
+ config.additional_special_symbols_types,
|
478 |
+
)
|
479 |
+
|
480 |
+
# named entity detection layers
|
481 |
+
self.ned_start_classifier = self._get_projection_layer(
|
482 |
+
config.activation, last_hidden=2, layer_norm=False
|
483 |
+
)
|
484 |
+
|
485 |
+
self.ned_end_classifier = PoolerEndLogitsBi(self.transformer_model.config)
|
486 |
+
|
487 |
+
self.relation_disambiguation_loss = (
|
488 |
+
config.relation_disambiguation_loss
|
489 |
+
if hasattr(config, "relation_disambiguation_loss")
|
490 |
+
else False
|
491 |
+
)
|
492 |
+
|
493 |
+
if self.config.entity_type_loss and self.config.add_entity_embedding:
|
494 |
+
input_hidden_ents = 3
|
495 |
+
else:
|
496 |
+
input_hidden_ents = 2
|
497 |
+
|
498 |
+
self.re_projector = self._get_projection_layer(
|
499 |
+
config.activation,
|
500 |
+
input_hidden=input_hidden_ents * self.transformer_model.config.hidden_size,
|
501 |
+
hidden=input_hidden_ents * self.config.linears_hidden_size,
|
502 |
+
last_hidden=2 * self.config.linears_hidden_size,
|
503 |
+
)
|
504 |
+
|
505 |
+
self.re_relation_projector = self._get_projection_layer(
|
506 |
+
config.activation,
|
507 |
+
input_hidden=self.transformer_model.config.hidden_size,
|
508 |
+
)
|
509 |
+
|
510 |
+
if self.config.entity_type_loss or self.relation_disambiguation_loss:
|
511 |
+
self.re_entities_projector = self._get_projection_layer(
|
512 |
+
config.activation,
|
513 |
+
input_hidden=2 * self.transformer_model.config.hidden_size,
|
514 |
+
)
|
515 |
+
self.re_definition_projector = self._get_projection_layer(
|
516 |
+
config.activation,
|
517 |
+
)
|
518 |
+
|
519 |
+
self.re_classifier = self._get_projection_layer(
|
520 |
+
config.activation,
|
521 |
+
input_hidden=config.linears_hidden_size,
|
522 |
+
last_hidden=2,
|
523 |
+
layer_norm=False,
|
524 |
+
)
|
525 |
+
|
526 |
+
self.training = config.training
|
527 |
+
|
528 |
+
# criterion
|
529 |
+
self.criterion = torch.nn.CrossEntropyLoss()
|
530 |
+
self.criterion_type = torch.nn.BCEWithLogitsLoss()
|
531 |
+
|
532 |
+
def _get_projection_layer(
|
533 |
+
self,
|
534 |
+
activation: str,
|
535 |
+
last_hidden: Optional[int] = None,
|
536 |
+
hidden: Optional[int] = None,
|
537 |
+
input_hidden=None,
|
538 |
+
layer_norm: bool = True,
|
539 |
+
) -> torch.nn.Sequential:
|
540 |
+
head_components = [
|
541 |
+
torch.nn.Dropout(0.1),
|
542 |
+
torch.nn.Linear(
|
543 |
+
(
|
544 |
+
self.transformer_model.config.hidden_size
|
545 |
+
* self.config.use_last_k_layers
|
546 |
+
if input_hidden is None
|
547 |
+
else input_hidden
|
548 |
+
),
|
549 |
+
self.config.linears_hidden_size if hidden is None else hidden,
|
550 |
+
),
|
551 |
+
activation2functions[activation],
|
552 |
+
torch.nn.Dropout(0.1),
|
553 |
+
torch.nn.Linear(
|
554 |
+
self.config.linears_hidden_size if hidden is None else hidden,
|
555 |
+
self.config.linears_hidden_size if last_hidden is None else last_hidden,
|
556 |
+
),
|
557 |
+
]
|
558 |
+
|
559 |
+
if layer_norm:
|
560 |
+
head_components.append(
|
561 |
+
torch.nn.LayerNorm(
|
562 |
+
(
|
563 |
+
self.config.linears_hidden_size
|
564 |
+
if last_hidden is None
|
565 |
+
else last_hidden
|
566 |
+
),
|
567 |
+
self.transformer_model.config.layer_norm_eps,
|
568 |
+
)
|
569 |
+
)
|
570 |
+
|
571 |
+
return torch.nn.Sequential(*head_components)
|
572 |
+
|
573 |
+
def _mask_logits(self, logits: torch.Tensor, mask: torch.Tensor) -> torch.Tensor:
|
574 |
+
mask = mask.unsqueeze(-1)
|
575 |
+
if next(self.parameters()).dtype == torch.float16:
|
576 |
+
logits = logits * (1 - mask) - 65500 * mask
|
577 |
+
else:
|
578 |
+
logits = logits * (1 - mask) - 1e30 * mask
|
579 |
+
return logits
|
580 |
+
|
581 |
+
def _get_model_features(
|
582 |
+
self,
|
583 |
+
input_ids: torch.Tensor,
|
584 |
+
attention_mask: torch.Tensor,
|
585 |
+
token_type_ids: Optional[torch.Tensor],
|
586 |
+
):
|
587 |
+
model_input = {
|
588 |
+
"input_ids": input_ids,
|
589 |
+
"attention_mask": attention_mask,
|
590 |
+
"output_hidden_states": self.config.use_last_k_layers > 1,
|
591 |
+
}
|
592 |
+
|
593 |
+
if token_type_ids is not None:
|
594 |
+
model_input["token_type_ids"] = token_type_ids
|
595 |
+
|
596 |
+
model_output = self.transformer_model(**model_input)
|
597 |
+
|
598 |
+
if self.config.use_last_k_layers > 1:
|
599 |
+
model_features = torch.cat(
|
600 |
+
model_output[1][-self.config.use_last_k_layers :], dim=-1
|
601 |
+
)
|
602 |
+
else:
|
603 |
+
model_features = model_output[0]
|
604 |
+
|
605 |
+
return model_features
|
606 |
+
|
607 |
+
def compute_ned_end_logits(
|
608 |
+
self,
|
609 |
+
start_predictions,
|
610 |
+
start_labels,
|
611 |
+
model_features,
|
612 |
+
prediction_mask,
|
613 |
+
batch_size,
|
614 |
+
mask_preceding: bool = False,
|
615 |
+
) -> Optional[torch.Tensor]:
|
616 |
+
# todo: maybe when constraining on the spans,
|
617 |
+
# we should not use a prediction_mask for the end tokens.
|
618 |
+
# at least we should not during training imo
|
619 |
+
start_positions = start_labels if self.training else start_predictions
|
620 |
+
start_positions_indices = (
|
621 |
+
torch.arange(start_positions.size(1), device=start_positions.device)
|
622 |
+
.unsqueeze(0)
|
623 |
+
.expand(batch_size, -1)[start_positions > 0]
|
624 |
+
).to(start_positions.device)
|
625 |
+
|
626 |
+
if len(start_positions_indices) > 0:
|
627 |
+
expanded_features = model_features.repeat_interleave(
|
628 |
+
torch.sum(start_positions > 0, dim=-1), dim=0
|
629 |
+
)
|
630 |
+
expanded_prediction_mask = prediction_mask.repeat_interleave(
|
631 |
+
torch.sum(start_positions > 0, dim=-1), dim=0
|
632 |
+
)
|
633 |
+
if mask_preceding:
|
634 |
+
expanded_prediction_mask[
|
635 |
+
torch.arange(
|
636 |
+
expanded_prediction_mask.shape[1],
|
637 |
+
device=expanded_prediction_mask.device,
|
638 |
+
)
|
639 |
+
< start_positions_indices.unsqueeze(1)
|
640 |
+
] = 1
|
641 |
+
end_logits = self.ned_end_classifier(
|
642 |
+
hidden_states=expanded_features,
|
643 |
+
start_positions=start_positions_indices,
|
644 |
+
p_mask=expanded_prediction_mask,
|
645 |
+
)
|
646 |
+
|
647 |
+
return end_logits
|
648 |
+
|
649 |
+
return None
|
650 |
+
|
651 |
+
def compute_relation_logits(
|
652 |
+
self,
|
653 |
+
model_entity_features,
|
654 |
+
special_symbols_features,
|
655 |
+
) -> torch.Tensor:
|
656 |
+
model_subject_object_features = self.re_projector(model_entity_features)
|
657 |
+
model_subject_features = model_subject_object_features[
|
658 |
+
:, :, : model_subject_object_features.shape[-1] // 2
|
659 |
+
]
|
660 |
+
model_object_features = model_subject_object_features[
|
661 |
+
:, :, model_subject_object_features.shape[-1] // 2 :
|
662 |
+
]
|
663 |
+
special_symbols_start_representation = self.re_relation_projector(
|
664 |
+
special_symbols_features
|
665 |
+
)
|
666 |
+
re_logits = torch.einsum(
|
667 |
+
"bse,bde,bfe->bsdfe",
|
668 |
+
model_subject_features,
|
669 |
+
model_object_features,
|
670 |
+
special_symbols_start_representation,
|
671 |
+
)
|
672 |
+
re_logits = self.re_classifier(re_logits)
|
673 |
+
|
674 |
+
return re_logits
|
675 |
+
|
676 |
+
def compute_entity_logits(
|
677 |
+
self,
|
678 |
+
model_entity_features,
|
679 |
+
special_symbols_features,
|
680 |
+
) -> torch.Tensor:
|
681 |
+
model_ed_features = self.re_entities_projector(model_entity_features)
|
682 |
+
special_symbols_ed_representation = self.re_definition_projector(
|
683 |
+
special_symbols_features
|
684 |
+
)
|
685 |
+
|
686 |
+
logits = torch.bmm(
|
687 |
+
model_ed_features,
|
688 |
+
torch.permute(special_symbols_ed_representation, (0, 2, 1)),
|
689 |
+
)
|
690 |
+
logits = self._mask_logits(
|
691 |
+
logits, (model_entity_features == -100).all(2).long()
|
692 |
+
)
|
693 |
+
return logits
|
694 |
+
|
695 |
+
def compute_loss(self, logits, labels, mask=None):
|
696 |
+
logits = logits.reshape(-1, logits.shape[-1])
|
697 |
+
labels = labels.reshape(-1).long()
|
698 |
+
if mask is not None:
|
699 |
+
return self.criterion(logits[mask], labels[mask])
|
700 |
+
return self.criterion(logits, labels)
|
701 |
+
|
702 |
+
def compute_ned_type_loss(
|
703 |
+
self,
|
704 |
+
disambiguation_labels,
|
705 |
+
re_ned_entities_logits,
|
706 |
+
ned_type_logits,
|
707 |
+
re_entities_logits,
|
708 |
+
entity_types,
|
709 |
+
mask,
|
710 |
+
):
|
711 |
+
if self.config.entity_type_loss and self.relation_disambiguation_loss:
|
712 |
+
return self.criterion_type(
|
713 |
+
re_ned_entities_logits[disambiguation_labels != -100],
|
714 |
+
disambiguation_labels[disambiguation_labels != -100],
|
715 |
+
)
|
716 |
+
if self.config.entity_type_loss:
|
717 |
+
return self.criterion_type(
|
718 |
+
ned_type_logits[mask],
|
719 |
+
disambiguation_labels[:, :, :entity_types][mask],
|
720 |
+
)
|
721 |
+
|
722 |
+
if self.relation_disambiguation_loss:
|
723 |
+
return self.criterion_type(
|
724 |
+
re_entities_logits[disambiguation_labels != -100],
|
725 |
+
disambiguation_labels[disambiguation_labels != -100],
|
726 |
+
)
|
727 |
+
return 0
|
728 |
+
|
729 |
+
def compute_relation_loss(self, relation_labels, re_logits):
|
730 |
+
return self.compute_loss(
|
731 |
+
re_logits, relation_labels, relation_labels.view(-1) != -100
|
732 |
+
)
|
733 |
+
|
734 |
+
def forward(
|
735 |
+
self,
|
736 |
+
input_ids: torch.Tensor,
|
737 |
+
attention_mask: torch.Tensor,
|
738 |
+
token_type_ids: torch.Tensor,
|
739 |
+
prediction_mask: Optional[torch.Tensor] = None,
|
740 |
+
special_symbols_mask: Optional[torch.Tensor] = None,
|
741 |
+
special_symbols_mask_entities: Optional[torch.Tensor] = None,
|
742 |
+
start_labels: Optional[torch.Tensor] = None,
|
743 |
+
end_labels: Optional[torch.Tensor] = None,
|
744 |
+
disambiguation_labels: Optional[torch.Tensor] = None,
|
745 |
+
relation_labels: Optional[torch.Tensor] = None,
|
746 |
+
relation_threshold: float = None,
|
747 |
+
is_validation: bool = False,
|
748 |
+
is_prediction: bool = False,
|
749 |
+
use_predefined_spans: bool = False,
|
750 |
+
*args,
|
751 |
+
**kwargs,
|
752 |
+
) -> Dict[str, Any]:
|
753 |
+
relation_threshold = (
|
754 |
+
self.config.threshold if relation_threshold is None else relation_threshold
|
755 |
+
)
|
756 |
+
|
757 |
+
batch_size = input_ids.shape[0]
|
758 |
+
|
759 |
+
model_features = self._get_model_features(
|
760 |
+
input_ids, attention_mask, token_type_ids
|
761 |
+
)
|
762 |
+
|
763 |
+
# named entity detection
|
764 |
+
if use_predefined_spans:
|
765 |
+
ned_start_logits, ned_start_probabilities, ned_start_predictions = (
|
766 |
+
None,
|
767 |
+
None,
|
768 |
+
torch.zeros_like(start_labels),
|
769 |
+
)
|
770 |
+
ned_end_logits, ned_end_probabilities, ned_end_predictions = (
|
771 |
+
None,
|
772 |
+
None,
|
773 |
+
torch.zeros_like(end_labels),
|
774 |
+
)
|
775 |
+
|
776 |
+
ned_start_predictions[start_labels > 0] = 1
|
777 |
+
ned_end_predictions[end_labels > 0] = 1
|
778 |
+
ned_end_predictions = ned_end_predictions[~(end_labels == -100).all(2)]
|
779 |
+
ned_start_labels = start_labels
|
780 |
+
ned_start_labels[start_labels > 0] = 1
|
781 |
+
else:
|
782 |
+
# start boundary prediction
|
783 |
+
ned_start_logits = self.ned_start_classifier(model_features)
|
784 |
+
if is_validation or is_prediction:
|
785 |
+
ned_start_logits = self._mask_logits(
|
786 |
+
ned_start_logits, prediction_mask
|
787 |
+
) # why?
|
788 |
+
ned_start_probabilities = torch.softmax(ned_start_logits, dim=-1)
|
789 |
+
ned_start_predictions = ned_start_probabilities.argmax(dim=-1)
|
790 |
+
|
791 |
+
# end boundary prediction
|
792 |
+
ned_start_labels = (
|
793 |
+
torch.zeros_like(start_labels) if start_labels is not None else None
|
794 |
+
)
|
795 |
+
|
796 |
+
# start_labels contain entity id at their position, we just need 1 for start of entity
|
797 |
+
if ned_start_labels is not None:
|
798 |
+
ned_start_labels[start_labels == -100] = -100
|
799 |
+
ned_start_labels[start_labels > 0] = 1
|
800 |
+
|
801 |
+
# compute end logits only if there are any start predictions.
|
802 |
+
# For each start prediction, n end predictions are made
|
803 |
+
ned_end_logits = self.compute_ned_end_logits(
|
804 |
+
ned_start_predictions,
|
805 |
+
ned_start_labels,
|
806 |
+
model_features,
|
807 |
+
prediction_mask,
|
808 |
+
batch_size,
|
809 |
+
True,
|
810 |
+
)
|
811 |
+
|
812 |
+
if ned_end_logits is not None:
|
813 |
+
# For each start prediction, n end predictions are made based on
|
814 |
+
# binary classification ie. argmax at each position.
|
815 |
+
ned_end_probabilities = torch.softmax(ned_end_logits, dim=-1)
|
816 |
+
ned_end_predictions = ned_end_probabilities.argmax(dim=-1)
|
817 |
+
else:
|
818 |
+
ned_end_logits, ned_end_probabilities = None, None
|
819 |
+
ned_end_predictions = torch.zeros_like(ned_start_predictions)
|
820 |
+
|
821 |
+
if is_prediction or is_validation:
|
822 |
+
end_preds_count = ned_end_predictions.sum(1)
|
823 |
+
# If there are no end predictions for a start prediction, remove the start prediction
|
824 |
+
if (end_preds_count == 0).any() and (ned_start_predictions > 0).any():
|
825 |
+
ned_start_predictions[ned_start_predictions == 1] = (
|
826 |
+
end_preds_count != 0
|
827 |
+
).long()
|
828 |
+
ned_end_predictions = ned_end_predictions[end_preds_count != 0]
|
829 |
+
|
830 |
+
if end_labels is not None:
|
831 |
+
end_labels = end_labels[~(end_labels == -100).all(2)]
|
832 |
+
|
833 |
+
start_position, end_position = (
|
834 |
+
(start_labels, end_labels)
|
835 |
+
if (not is_prediction and not is_validation)
|
836 |
+
else (ned_start_predictions, ned_end_predictions)
|
837 |
+
)
|
838 |
+
|
839 |
+
start_counts = (start_position > 0).sum(1)
|
840 |
+
if (start_counts > 0).any():
|
841 |
+
ned_end_predictions = ned_end_predictions.split(start_counts.tolist())
|
842 |
+
else:
|
843 |
+
ned_end_predictions = [torch.empty(0, input_ids.shape[1], dtype=torch.int64) for _ in range(batch_size)]
|
844 |
+
# limit to 30 predictions per document using start_counts, by setting all po after sum is 30 to 0
|
845 |
+
# if is_validation or is_prediction:
|
846 |
+
# ned_start_predictions[ned_start_predictions == 1] = start_counts
|
847 |
+
# We can only predict relations if we have start and end predictions
|
848 |
+
if (end_position > 0).sum() > 0:
|
849 |
+
ends_count = (end_position > 0).sum(1)
|
850 |
+
model_subject_features = torch.cat(
|
851 |
+
[
|
852 |
+
torch.repeat_interleave(
|
853 |
+
model_features[start_position > 0], ends_count, dim=0
|
854 |
+
), # start position features
|
855 |
+
torch.repeat_interleave(model_features, start_counts, dim=0)[
|
856 |
+
end_position > 0
|
857 |
+
], # end position features
|
858 |
+
],
|
859 |
+
dim=-1,
|
860 |
+
)
|
861 |
+
ents_count = torch.nn.utils.rnn.pad_sequence(
|
862 |
+
torch.split(ends_count, start_counts.tolist()),
|
863 |
+
batch_first=True,
|
864 |
+
padding_value=0,
|
865 |
+
).sum(1)
|
866 |
+
model_subject_features = torch.nn.utils.rnn.pad_sequence(
|
867 |
+
torch.split(model_subject_features, ents_count.tolist()),
|
868 |
+
batch_first=True,
|
869 |
+
padding_value=-100,
|
870 |
+
)
|
871 |
+
|
872 |
+
# if is_validation or is_prediction:
|
873 |
+
# model_subject_features = model_subject_features[:, :30, :]
|
874 |
+
|
875 |
+
# entity disambiguation. Here relation_disambiguation_loss would only be useful to
|
876 |
+
# reduce the number of candidate relations for the next step, but currently unused.
|
877 |
+
if self.config.entity_type_loss or self.relation_disambiguation_loss:
|
878 |
+
(re_ned_entities_logits) = self.compute_entity_logits(
|
879 |
+
model_subject_features,
|
880 |
+
model_features[
|
881 |
+
special_symbols_mask | special_symbols_mask_entities
|
882 |
+
].view(batch_size, -1, model_features.shape[-1]),
|
883 |
+
)
|
884 |
+
entity_types = torch.sum(special_symbols_mask_entities, dim=1)[0].item()
|
885 |
+
ned_type_logits = re_ned_entities_logits[:, :, :entity_types]
|
886 |
+
re_entities_logits = re_ned_entities_logits[:, :, entity_types:]
|
887 |
+
|
888 |
+
if self.config.entity_type_loss:
|
889 |
+
ned_type_probabilities = torch.sigmoid(ned_type_logits)
|
890 |
+
ned_type_predictions = ned_type_probabilities.argmax(dim=-1)
|
891 |
+
|
892 |
+
if self.config.add_entity_embedding:
|
893 |
+
special_symbols_representation = model_features[
|
894 |
+
special_symbols_mask_entities
|
895 |
+
].view(batch_size, entity_types, -1)
|
896 |
+
|
897 |
+
entities_representation = torch.einsum(
|
898 |
+
"bsp,bpe->bse",
|
899 |
+
ned_type_probabilities,
|
900 |
+
special_symbols_representation,
|
901 |
+
)
|
902 |
+
model_subject_features = torch.cat(
|
903 |
+
[model_subject_features, entities_representation], dim=-1
|
904 |
+
)
|
905 |
+
re_entities_probabilities = torch.sigmoid(re_entities_logits)
|
906 |
+
re_entities_predictions = re_entities_probabilities.round()
|
907 |
+
else:
|
908 |
+
(
|
909 |
+
ned_type_logits,
|
910 |
+
ned_type_probabilities,
|
911 |
+
re_entities_logits,
|
912 |
+
re_entities_probabilities,
|
913 |
+
) = (None, None, None, None)
|
914 |
+
ned_type_predictions, re_entities_predictions = (
|
915 |
+
torch.zeros([batch_size, 1], dtype=torch.long).to(input_ids.device),
|
916 |
+
torch.zeros([batch_size, 1], dtype=torch.long).to(input_ids.device),
|
917 |
+
)
|
918 |
+
|
919 |
+
# Compute relation logits
|
920 |
+
re_logits = self.compute_relation_logits(
|
921 |
+
model_subject_features,
|
922 |
+
model_features[special_symbols_mask].view(
|
923 |
+
batch_size, -1, model_features.shape[-1]
|
924 |
+
),
|
925 |
+
)
|
926 |
+
|
927 |
+
re_probabilities = torch.softmax(re_logits, dim=-1)
|
928 |
+
# we set a thresshold instead of argmax in cause it needs to be tweaked
|
929 |
+
re_predictions = re_probabilities[:, :, :, :, 1] > relation_threshold
|
930 |
+
re_probabilities = re_probabilities[:, :, :, :, 1]
|
931 |
+
else:
|
932 |
+
(
|
933 |
+
ned_type_logits,
|
934 |
+
ned_type_probabilities,
|
935 |
+
re_entities_logits,
|
936 |
+
re_entities_probabilities,
|
937 |
+
) = (None, None, None, None)
|
938 |
+
ned_type_predictions, re_entities_predictions = (
|
939 |
+
torch.zeros([batch_size, 1], dtype=torch.long).to(input_ids.device),
|
940 |
+
torch.zeros([batch_size, 1], dtype=torch.long).to(input_ids.device),
|
941 |
+
)
|
942 |
+
re_logits, re_probabilities, re_predictions = (
|
943 |
+
torch.zeros(
|
944 |
+
[batch_size, 1, 1, special_symbols_mask.sum(1)[0]], dtype=torch.long
|
945 |
+
).to(input_ids.device),
|
946 |
+
torch.zeros(
|
947 |
+
[batch_size, 1, 1, special_symbols_mask.sum(1)[0]], dtype=torch.long
|
948 |
+
).to(input_ids.device),
|
949 |
+
torch.zeros(
|
950 |
+
[batch_size, 1, 1, special_symbols_mask.sum(1)[0]], dtype=torch.long
|
951 |
+
).to(input_ids.device),
|
952 |
+
)
|
953 |
+
|
954 |
+
# output build
|
955 |
+
output_dict = dict(
|
956 |
+
batch_size=batch_size,
|
957 |
+
ned_start_logits=ned_start_logits,
|
958 |
+
ned_start_probabilities=ned_start_probabilities,
|
959 |
+
ned_start_predictions=ned_start_predictions,
|
960 |
+
ned_end_logits=ned_end_logits,
|
961 |
+
ned_end_probabilities=ned_end_probabilities,
|
962 |
+
ned_end_predictions=ned_end_predictions,
|
963 |
+
ned_type_logits=ned_type_logits,
|
964 |
+
ned_type_probabilities=ned_type_probabilities,
|
965 |
+
ned_type_predictions=ned_type_predictions,
|
966 |
+
re_entities_logits=re_entities_logits,
|
967 |
+
re_entities_probabilities=re_entities_probabilities,
|
968 |
+
re_entities_predictions=re_entities_predictions,
|
969 |
+
re_logits=re_logits,
|
970 |
+
re_probabilities=re_probabilities,
|
971 |
+
re_predictions=re_predictions,
|
972 |
+
)
|
973 |
+
|
974 |
+
if (
|
975 |
+
start_labels is not None
|
976 |
+
and end_labels is not None
|
977 |
+
and relation_labels is not None
|
978 |
+
and is_prediction is False
|
979 |
+
):
|
980 |
+
ned_start_loss = self.compute_loss(ned_start_logits, ned_start_labels)
|
981 |
+
end_labels[end_labels > 0] = 1
|
982 |
+
ned_end_loss = self.compute_loss(ned_end_logits, end_labels)
|
983 |
+
if self.config.entity_type_loss or self.relation_disambiguation_loss:
|
984 |
+
ned_type_loss = self.compute_ned_type_loss(
|
985 |
+
disambiguation_labels,
|
986 |
+
re_ned_entities_logits,
|
987 |
+
ned_type_logits,
|
988 |
+
re_entities_logits,
|
989 |
+
entity_types,
|
990 |
+
(model_subject_features != -100).all(2),
|
991 |
+
)
|
992 |
+
relation_loss = self.compute_relation_loss(relation_labels, re_logits)
|
993 |
+
# compute loss. We can skip the relation loss if we are in the first epochs (optional)
|
994 |
+
if self.config.entity_type_loss or self.relation_disambiguation_loss:
|
995 |
+
output_dict["loss"] = (
|
996 |
+
ned_start_loss + ned_end_loss + relation_loss + ned_type_loss
|
997 |
+
) / 4
|
998 |
+
output_dict["ned_type_loss"] = ned_type_loss
|
999 |
+
else:
|
1000 |
+
output_dict["loss"] = ((1 / 20) * (ned_start_loss + ned_end_loss)) + (
|
1001 |
+
(9 / 10) * relation_loss
|
1002 |
+
)
|
1003 |
+
output_dict["ned_start_loss"] = ned_start_loss
|
1004 |
+
output_dict["ned_end_loss"] = ned_end_loss
|
1005 |
+
output_dict["re_loss"] = relation_loss
|
1006 |
+
|
1007 |
+
return output_dict
|
special_tokens_map.json
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"additional_special_tokens": [
|
3 |
+
"--NME--",
|
4 |
+
"[E-0]",
|
5 |
+
"[E-1]",
|
6 |
+
"[E-2]",
|
7 |
+
"[E-3]",
|
8 |
+
"[E-4]",
|
9 |
+
"[E-5]",
|
10 |
+
"[E-6]",
|
11 |
+
"[E-7]",
|
12 |
+
"[E-8]",
|
13 |
+
"[E-9]",
|
14 |
+
"[E-10]",
|
15 |
+
"[E-11]",
|
16 |
+
"[E-12]",
|
17 |
+
"[E-13]",
|
18 |
+
"[E-14]",
|
19 |
+
"[E-15]",
|
20 |
+
"[E-16]",
|
21 |
+
"[E-17]",
|
22 |
+
"[E-18]",
|
23 |
+
"[E-19]",
|
24 |
+
"[E-20]",
|
25 |
+
"[E-21]",
|
26 |
+
"[E-22]",
|
27 |
+
"[E-23]",
|
28 |
+
"[E-24]",
|
29 |
+
"[E-25]",
|
30 |
+
"[E-26]",
|
31 |
+
"[E-27]",
|
32 |
+
"[E-28]",
|
33 |
+
"[E-29]",
|
34 |
+
"[E-30]",
|
35 |
+
"[E-31]",
|
36 |
+
"[E-32]",
|
37 |
+
"[E-33]",
|
38 |
+
"[E-34]",
|
39 |
+
"[E-35]",
|
40 |
+
"[E-36]",
|
41 |
+
"[E-37]",
|
42 |
+
"[E-38]",
|
43 |
+
"[E-39]",
|
44 |
+
"[E-40]",
|
45 |
+
"[E-41]",
|
46 |
+
"[E-42]",
|
47 |
+
"[E-43]",
|
48 |
+
"[E-44]",
|
49 |
+
"[E-45]",
|
50 |
+
"[E-46]",
|
51 |
+
"[E-47]",
|
52 |
+
"[E-48]",
|
53 |
+
"[E-49]",
|
54 |
+
"[E-50]",
|
55 |
+
"[E-51]",
|
56 |
+
"[E-52]",
|
57 |
+
"[E-53]",
|
58 |
+
"[E-54]",
|
59 |
+
"[E-55]",
|
60 |
+
"[E-56]",
|
61 |
+
"[E-57]",
|
62 |
+
"[E-58]",
|
63 |
+
"[E-59]",
|
64 |
+
"[E-60]",
|
65 |
+
"[E-61]",
|
66 |
+
"[E-62]",
|
67 |
+
"[E-63]",
|
68 |
+
"[E-64]",
|
69 |
+
"[E-65]",
|
70 |
+
"[E-66]",
|
71 |
+
"[E-67]",
|
72 |
+
"[E-68]",
|
73 |
+
"[E-69]",
|
74 |
+
"[E-70]",
|
75 |
+
"[E-71]",
|
76 |
+
"[E-72]",
|
77 |
+
"[E-73]",
|
78 |
+
"[E-74]",
|
79 |
+
"[E-75]",
|
80 |
+
"[E-76]",
|
81 |
+
"[E-77]",
|
82 |
+
"[E-78]",
|
83 |
+
"[E-79]",
|
84 |
+
"[E-80]",
|
85 |
+
"[E-81]",
|
86 |
+
"[E-82]",
|
87 |
+
"[E-83]",
|
88 |
+
"[E-84]",
|
89 |
+
"[E-85]",
|
90 |
+
"[E-86]",
|
91 |
+
"[E-87]",
|
92 |
+
"[E-88]",
|
93 |
+
"[E-89]",
|
94 |
+
"[E-90]",
|
95 |
+
"[E-91]",
|
96 |
+
"[E-92]",
|
97 |
+
"[E-93]",
|
98 |
+
"[E-94]",
|
99 |
+
"[E-95]",
|
100 |
+
"[E-96]",
|
101 |
+
"[E-97]",
|
102 |
+
"[E-98]",
|
103 |
+
"[E-99]"
|
104 |
+
],
|
105 |
+
"bos_token": "[CLS]",
|
106 |
+
"cls_token": "[CLS]",
|
107 |
+
"eos_token": "[SEP]",
|
108 |
+
"mask_token": "[MASK]",
|
109 |
+
"pad_token": "[PAD]",
|
110 |
+
"sep_token": "[SEP]",
|
111 |
+
"unk_token": {
|
112 |
+
"content": "[UNK]",
|
113 |
+
"lstrip": false,
|
114 |
+
"normalized": true,
|
115 |
+
"rstrip": false,
|
116 |
+
"single_word": false
|
117 |
+
}
|
118 |
+
}
|
spm.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:13c8d666d62a7bc4ac8f040aab68e942c861f93303156cc28f5c7e885d86d6e3
|
3 |
+
size 4305025
|
tokenizer.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b38b963be88cfff37b4f83908ee2f8c1480c38ff03a5822512377c427e13b44e
|
3 |
+
size 16349848
|
tokenizer_config.json
ADDED
@@ -0,0 +1,970 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_prefix_space": true,
|
3 |
+
"added_tokens_decoder": {
|
4 |
+
"0": {
|
5 |
+
"content": "[PAD]",
|
6 |
+
"lstrip": false,
|
7 |
+
"normalized": false,
|
8 |
+
"rstrip": false,
|
9 |
+
"single_word": false,
|
10 |
+
"special": true
|
11 |
+
},
|
12 |
+
"1": {
|
13 |
+
"content": "[CLS]",
|
14 |
+
"lstrip": false,
|
15 |
+
"normalized": false,
|
16 |
+
"rstrip": false,
|
17 |
+
"single_word": false,
|
18 |
+
"special": true
|
19 |
+
},
|
20 |
+
"2": {
|
21 |
+
"content": "[SEP]",
|
22 |
+
"lstrip": false,
|
23 |
+
"normalized": false,
|
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 |
+
"250101": {
|
37 |
+
"content": "[MASK]",
|
38 |
+
"lstrip": false,
|
39 |
+
"normalized": false,
|
40 |
+
"rstrip": false,
|
41 |
+
"single_word": false,
|
42 |
+
"special": true
|
43 |
+
},
|
44 |
+
"250102": {
|
45 |
+
"content": "--NME--",
|
46 |
+
"lstrip": false,
|
47 |
+
"normalized": false,
|
48 |
+
"rstrip": false,
|
49 |
+
"single_word": false,
|
50 |
+
"special": true
|
51 |
+
},
|
52 |
+
"250103": {
|
53 |
+
"content": "[E-0]",
|
54 |
+
"lstrip": false,
|
55 |
+
"normalized": false,
|
56 |
+
"rstrip": false,
|
57 |
+
"single_word": false,
|
58 |
+
"special": true
|
59 |
+
},
|
60 |
+
"250104": {
|
61 |
+
"content": "[E-1]",
|
62 |
+
"lstrip": false,
|
63 |
+
"normalized": false,
|
64 |
+
"rstrip": false,
|
65 |
+
"single_word": false,
|
66 |
+
"special": true
|
67 |
+
},
|
68 |
+
"250105": {
|
69 |
+
"content": "[E-2]",
|
70 |
+
"lstrip": false,
|
71 |
+
"normalized": false,
|
72 |
+
"rstrip": false,
|
73 |
+
"single_word": false,
|
74 |
+
"special": true
|
75 |
+
},
|
76 |
+
"250106": {
|
77 |
+
"content": "[E-3]",
|
78 |
+
"lstrip": false,
|
79 |
+
"normalized": false,
|
80 |
+
"rstrip": false,
|
81 |
+
"single_word": false,
|
82 |
+
"special": true
|
83 |
+
},
|
84 |
+
"250107": {
|
85 |
+
"content": "[E-4]",
|
86 |
+
"lstrip": false,
|
87 |
+
"normalized": false,
|
88 |
+
"rstrip": false,
|
89 |
+
"single_word": false,
|
90 |
+
"special": true
|
91 |
+
},
|
92 |
+
"250108": {
|
93 |
+
"content": "[E-5]",
|
94 |
+
"lstrip": false,
|
95 |
+
"normalized": false,
|
96 |
+
"rstrip": false,
|
97 |
+
"single_word": false,
|
98 |
+
"special": true
|
99 |
+
},
|
100 |
+
"250109": {
|
101 |
+
"content": "[E-6]",
|
102 |
+
"lstrip": false,
|
103 |
+
"normalized": false,
|
104 |
+
"rstrip": false,
|
105 |
+
"single_word": false,
|
106 |
+
"special": true
|
107 |
+
},
|
108 |
+
"250110": {
|
109 |
+
"content": "[E-7]",
|
110 |
+
"lstrip": false,
|
111 |
+
"normalized": false,
|
112 |
+
"rstrip": false,
|
113 |
+
"single_word": false,
|
114 |
+
"special": true
|
115 |
+
},
|
116 |
+
"250111": {
|
117 |
+
"content": "[E-8]",
|
118 |
+
"lstrip": false,
|
119 |
+
"normalized": false,
|
120 |
+
"rstrip": false,
|
121 |
+
"single_word": false,
|
122 |
+
"special": true
|
123 |
+
},
|
124 |
+
"250112": {
|
125 |
+
"content": "[E-9]",
|
126 |
+
"lstrip": false,
|
127 |
+
"normalized": false,
|
128 |
+
"rstrip": false,
|
129 |
+
"single_word": false,
|
130 |
+
"special": true
|
131 |
+
},
|
132 |
+
"250113": {
|
133 |
+
"content": "[E-10]",
|
134 |
+
"lstrip": false,
|
135 |
+
"normalized": false,
|
136 |
+
"rstrip": false,
|
137 |
+
"single_word": false,
|
138 |
+
"special": true
|
139 |
+
},
|
140 |
+
"250114": {
|
141 |
+
"content": "[E-11]",
|
142 |
+
"lstrip": false,
|
143 |
+
"normalized": false,
|
144 |
+
"rstrip": false,
|
145 |
+
"single_word": false,
|
146 |
+
"special": true
|
147 |
+
},
|
148 |
+
"250115": {
|
149 |
+
"content": "[E-12]",
|
150 |
+
"lstrip": false,
|
151 |
+
"normalized": false,
|
152 |
+
"rstrip": false,
|
153 |
+
"single_word": false,
|
154 |
+
"special": true
|
155 |
+
},
|
156 |
+
"250116": {
|
157 |
+
"content": "[E-13]",
|
158 |
+
"lstrip": false,
|
159 |
+
"normalized": false,
|
160 |
+
"rstrip": false,
|
161 |
+
"single_word": false,
|
162 |
+
"special": true
|
163 |
+
},
|
164 |
+
"250117": {
|
165 |
+
"content": "[E-14]",
|
166 |
+
"lstrip": false,
|
167 |
+
"normalized": false,
|
168 |
+
"rstrip": false,
|
169 |
+
"single_word": false,
|
170 |
+
"special": true
|
171 |
+
},
|
172 |
+
"250118": {
|
173 |
+
"content": "[E-15]",
|
174 |
+
"lstrip": false,
|
175 |
+
"normalized": false,
|
176 |
+
"rstrip": false,
|
177 |
+
"single_word": false,
|
178 |
+
"special": true
|
179 |
+
},
|
180 |
+
"250119": {
|
181 |
+
"content": "[E-16]",
|
182 |
+
"lstrip": false,
|
183 |
+
"normalized": false,
|
184 |
+
"rstrip": false,
|
185 |
+
"single_word": false,
|
186 |
+
"special": true
|
187 |
+
},
|
188 |
+
"250120": {
|
189 |
+
"content": "[E-17]",
|
190 |
+
"lstrip": false,
|
191 |
+
"normalized": false,
|
192 |
+
"rstrip": false,
|
193 |
+
"single_word": false,
|
194 |
+
"special": true
|
195 |
+
},
|
196 |
+
"250121": {
|
197 |
+
"content": "[E-18]",
|
198 |
+
"lstrip": false,
|
199 |
+
"normalized": false,
|
200 |
+
"rstrip": false,
|
201 |
+
"single_word": false,
|
202 |
+
"special": true
|
203 |
+
},
|
204 |
+
"250122": {
|
205 |
+
"content": "[E-19]",
|
206 |
+
"lstrip": false,
|
207 |
+
"normalized": false,
|
208 |
+
"rstrip": false,
|
209 |
+
"single_word": false,
|
210 |
+
"special": true
|
211 |
+
},
|
212 |
+
"250123": {
|
213 |
+
"content": "[E-20]",
|
214 |
+
"lstrip": false,
|
215 |
+
"normalized": false,
|
216 |
+
"rstrip": false,
|
217 |
+
"single_word": false,
|
218 |
+
"special": true
|
219 |
+
},
|
220 |
+
"250124": {
|
221 |
+
"content": "[E-21]",
|
222 |
+
"lstrip": false,
|
223 |
+
"normalized": false,
|
224 |
+
"rstrip": false,
|
225 |
+
"single_word": false,
|
226 |
+
"special": true
|
227 |
+
},
|
228 |
+
"250125": {
|
229 |
+
"content": "[E-22]",
|
230 |
+
"lstrip": false,
|
231 |
+
"normalized": false,
|
232 |
+
"rstrip": false,
|
233 |
+
"single_word": false,
|
234 |
+
"special": true
|
235 |
+
},
|
236 |
+
"250126": {
|
237 |
+
"content": "[E-23]",
|
238 |
+
"lstrip": false,
|
239 |
+
"normalized": false,
|
240 |
+
"rstrip": false,
|
241 |
+
"single_word": false,
|
242 |
+
"special": true
|
243 |
+
},
|
244 |
+
"250127": {
|
245 |
+
"content": "[E-24]",
|
246 |
+
"lstrip": false,
|
247 |
+
"normalized": false,
|
248 |
+
"rstrip": false,
|
249 |
+
"single_word": false,
|
250 |
+
"special": true
|
251 |
+
},
|
252 |
+
"250128": {
|
253 |
+
"content": "[E-25]",
|
254 |
+
"lstrip": false,
|
255 |
+
"normalized": false,
|
256 |
+
"rstrip": false,
|
257 |
+
"single_word": false,
|
258 |
+
"special": true
|
259 |
+
},
|
260 |
+
"250129": {
|
261 |
+
"content": "[E-26]",
|
262 |
+
"lstrip": false,
|
263 |
+
"normalized": false,
|
264 |
+
"rstrip": false,
|
265 |
+
"single_word": false,
|
266 |
+
"special": true
|
267 |
+
},
|
268 |
+
"250130": {
|
269 |
+
"content": "[E-27]",
|
270 |
+
"lstrip": false,
|
271 |
+
"normalized": false,
|
272 |
+
"rstrip": false,
|
273 |
+
"single_word": false,
|
274 |
+
"special": true
|
275 |
+
},
|
276 |
+
"250131": {
|
277 |
+
"content": "[E-28]",
|
278 |
+
"lstrip": false,
|
279 |
+
"normalized": false,
|
280 |
+
"rstrip": false,
|
281 |
+
"single_word": false,
|
282 |
+
"special": true
|
283 |
+
},
|
284 |
+
"250132": {
|
285 |
+
"content": "[E-29]",
|
286 |
+
"lstrip": false,
|
287 |
+
"normalized": false,
|
288 |
+
"rstrip": false,
|
289 |
+
"single_word": false,
|
290 |
+
"special": true
|
291 |
+
},
|
292 |
+
"250133": {
|
293 |
+
"content": "[E-30]",
|
294 |
+
"lstrip": false,
|
295 |
+
"normalized": false,
|
296 |
+
"rstrip": false,
|
297 |
+
"single_word": false,
|
298 |
+
"special": true
|
299 |
+
},
|
300 |
+
"250134": {
|
301 |
+
"content": "[E-31]",
|
302 |
+
"lstrip": false,
|
303 |
+
"normalized": false,
|
304 |
+
"rstrip": false,
|
305 |
+
"single_word": false,
|
306 |
+
"special": true
|
307 |
+
},
|
308 |
+
"250135": {
|
309 |
+
"content": "[E-32]",
|
310 |
+
"lstrip": false,
|
311 |
+
"normalized": false,
|
312 |
+
"rstrip": false,
|
313 |
+
"single_word": false,
|
314 |
+
"special": true
|
315 |
+
},
|
316 |
+
"250136": {
|
317 |
+
"content": "[E-33]",
|
318 |
+
"lstrip": false,
|
319 |
+
"normalized": false,
|
320 |
+
"rstrip": false,
|
321 |
+
"single_word": false,
|
322 |
+
"special": true
|
323 |
+
},
|
324 |
+
"250137": {
|
325 |
+
"content": "[E-34]",
|
326 |
+
"lstrip": false,
|
327 |
+
"normalized": false,
|
328 |
+
"rstrip": false,
|
329 |
+
"single_word": false,
|
330 |
+
"special": true
|
331 |
+
},
|
332 |
+
"250138": {
|
333 |
+
"content": "[E-35]",
|
334 |
+
"lstrip": false,
|
335 |
+
"normalized": false,
|
336 |
+
"rstrip": false,
|
337 |
+
"single_word": false,
|
338 |
+
"special": true
|
339 |
+
},
|
340 |
+
"250139": {
|
341 |
+
"content": "[E-36]",
|
342 |
+
"lstrip": false,
|
343 |
+
"normalized": false,
|
344 |
+
"rstrip": false,
|
345 |
+
"single_word": false,
|
346 |
+
"special": true
|
347 |
+
},
|
348 |
+
"250140": {
|
349 |
+
"content": "[E-37]",
|
350 |
+
"lstrip": false,
|
351 |
+
"normalized": false,
|
352 |
+
"rstrip": false,
|
353 |
+
"single_word": false,
|
354 |
+
"special": true
|
355 |
+
},
|
356 |
+
"250141": {
|
357 |
+
"content": "[E-38]",
|
358 |
+
"lstrip": false,
|
359 |
+
"normalized": false,
|
360 |
+
"rstrip": false,
|
361 |
+
"single_word": false,
|
362 |
+
"special": true
|
363 |
+
},
|
364 |
+
"250142": {
|
365 |
+
"content": "[E-39]",
|
366 |
+
"lstrip": false,
|
367 |
+
"normalized": false,
|
368 |
+
"rstrip": false,
|
369 |
+
"single_word": false,
|
370 |
+
"special": true
|
371 |
+
},
|
372 |
+
"250143": {
|
373 |
+
"content": "[E-40]",
|
374 |
+
"lstrip": false,
|
375 |
+
"normalized": false,
|
376 |
+
"rstrip": false,
|
377 |
+
"single_word": false,
|
378 |
+
"special": true
|
379 |
+
},
|
380 |
+
"250144": {
|
381 |
+
"content": "[E-41]",
|
382 |
+
"lstrip": false,
|
383 |
+
"normalized": false,
|
384 |
+
"rstrip": false,
|
385 |
+
"single_word": false,
|
386 |
+
"special": true
|
387 |
+
},
|
388 |
+
"250145": {
|
389 |
+
"content": "[E-42]",
|
390 |
+
"lstrip": false,
|
391 |
+
"normalized": false,
|
392 |
+
"rstrip": false,
|
393 |
+
"single_word": false,
|
394 |
+
"special": true
|
395 |
+
},
|
396 |
+
"250146": {
|
397 |
+
"content": "[E-43]",
|
398 |
+
"lstrip": false,
|
399 |
+
"normalized": false,
|
400 |
+
"rstrip": false,
|
401 |
+
"single_word": false,
|
402 |
+
"special": true
|
403 |
+
},
|
404 |
+
"250147": {
|
405 |
+
"content": "[E-44]",
|
406 |
+
"lstrip": false,
|
407 |
+
"normalized": false,
|
408 |
+
"rstrip": false,
|
409 |
+
"single_word": false,
|
410 |
+
"special": true
|
411 |
+
},
|
412 |
+
"250148": {
|
413 |
+
"content": "[E-45]",
|
414 |
+
"lstrip": false,
|
415 |
+
"normalized": false,
|
416 |
+
"rstrip": false,
|
417 |
+
"single_word": false,
|
418 |
+
"special": true
|
419 |
+
},
|
420 |
+
"250149": {
|
421 |
+
"content": "[E-46]",
|
422 |
+
"lstrip": false,
|
423 |
+
"normalized": false,
|
424 |
+
"rstrip": false,
|
425 |
+
"single_word": false,
|
426 |
+
"special": true
|
427 |
+
},
|
428 |
+
"250150": {
|
429 |
+
"content": "[E-47]",
|
430 |
+
"lstrip": false,
|
431 |
+
"normalized": false,
|
432 |
+
"rstrip": false,
|
433 |
+
"single_word": false,
|
434 |
+
"special": true
|
435 |
+
},
|
436 |
+
"250151": {
|
437 |
+
"content": "[E-48]",
|
438 |
+
"lstrip": false,
|
439 |
+
"normalized": false,
|
440 |
+
"rstrip": false,
|
441 |
+
"single_word": false,
|
442 |
+
"special": true
|
443 |
+
},
|
444 |
+
"250152": {
|
445 |
+
"content": "[E-49]",
|
446 |
+
"lstrip": false,
|
447 |
+
"normalized": false,
|
448 |
+
"rstrip": false,
|
449 |
+
"single_word": false,
|
450 |
+
"special": true
|
451 |
+
},
|
452 |
+
"250153": {
|
453 |
+
"content": "[E-50]",
|
454 |
+
"lstrip": false,
|
455 |
+
"normalized": false,
|
456 |
+
"rstrip": false,
|
457 |
+
"single_word": false,
|
458 |
+
"special": true
|
459 |
+
},
|
460 |
+
"250154": {
|
461 |
+
"content": "[E-51]",
|
462 |
+
"lstrip": false,
|
463 |
+
"normalized": false,
|
464 |
+
"rstrip": false,
|
465 |
+
"single_word": false,
|
466 |
+
"special": true
|
467 |
+
},
|
468 |
+
"250155": {
|
469 |
+
"content": "[E-52]",
|
470 |
+
"lstrip": false,
|
471 |
+
"normalized": false,
|
472 |
+
"rstrip": false,
|
473 |
+
"single_word": false,
|
474 |
+
"special": true
|
475 |
+
},
|
476 |
+
"250156": {
|
477 |
+
"content": "[E-53]",
|
478 |
+
"lstrip": false,
|
479 |
+
"normalized": false,
|
480 |
+
"rstrip": false,
|
481 |
+
"single_word": false,
|
482 |
+
"special": true
|
483 |
+
},
|
484 |
+
"250157": {
|
485 |
+
"content": "[E-54]",
|
486 |
+
"lstrip": false,
|
487 |
+
"normalized": false,
|
488 |
+
"rstrip": false,
|
489 |
+
"single_word": false,
|
490 |
+
"special": true
|
491 |
+
},
|
492 |
+
"250158": {
|
493 |
+
"content": "[E-55]",
|
494 |
+
"lstrip": false,
|
495 |
+
"normalized": false,
|
496 |
+
"rstrip": false,
|
497 |
+
"single_word": false,
|
498 |
+
"special": true
|
499 |
+
},
|
500 |
+
"250159": {
|
501 |
+
"content": "[E-56]",
|
502 |
+
"lstrip": false,
|
503 |
+
"normalized": false,
|
504 |
+
"rstrip": false,
|
505 |
+
"single_word": false,
|
506 |
+
"special": true
|
507 |
+
},
|
508 |
+
"250160": {
|
509 |
+
"content": "[E-57]",
|
510 |
+
"lstrip": false,
|
511 |
+
"normalized": false,
|
512 |
+
"rstrip": false,
|
513 |
+
"single_word": false,
|
514 |
+
"special": true
|
515 |
+
},
|
516 |
+
"250161": {
|
517 |
+
"content": "[E-58]",
|
518 |
+
"lstrip": false,
|
519 |
+
"normalized": false,
|
520 |
+
"rstrip": false,
|
521 |
+
"single_word": false,
|
522 |
+
"special": true
|
523 |
+
},
|
524 |
+
"250162": {
|
525 |
+
"content": "[E-59]",
|
526 |
+
"lstrip": false,
|
527 |
+
"normalized": false,
|
528 |
+
"rstrip": false,
|
529 |
+
"single_word": false,
|
530 |
+
"special": true
|
531 |
+
},
|
532 |
+
"250163": {
|
533 |
+
"content": "[E-60]",
|
534 |
+
"lstrip": false,
|
535 |
+
"normalized": false,
|
536 |
+
"rstrip": false,
|
537 |
+
"single_word": false,
|
538 |
+
"special": true
|
539 |
+
},
|
540 |
+
"250164": {
|
541 |
+
"content": "[E-61]",
|
542 |
+
"lstrip": false,
|
543 |
+
"normalized": false,
|
544 |
+
"rstrip": false,
|
545 |
+
"single_word": false,
|
546 |
+
"special": true
|
547 |
+
},
|
548 |
+
"250165": {
|
549 |
+
"content": "[E-62]",
|
550 |
+
"lstrip": false,
|
551 |
+
"normalized": false,
|
552 |
+
"rstrip": false,
|
553 |
+
"single_word": false,
|
554 |
+
"special": true
|
555 |
+
},
|
556 |
+
"250166": {
|
557 |
+
"content": "[E-63]",
|
558 |
+
"lstrip": false,
|
559 |
+
"normalized": false,
|
560 |
+
"rstrip": false,
|
561 |
+
"single_word": false,
|
562 |
+
"special": true
|
563 |
+
},
|
564 |
+
"250167": {
|
565 |
+
"content": "[E-64]",
|
566 |
+
"lstrip": false,
|
567 |
+
"normalized": false,
|
568 |
+
"rstrip": false,
|
569 |
+
"single_word": false,
|
570 |
+
"special": true
|
571 |
+
},
|
572 |
+
"250168": {
|
573 |
+
"content": "[E-65]",
|
574 |
+
"lstrip": false,
|
575 |
+
"normalized": false,
|
576 |
+
"rstrip": false,
|
577 |
+
"single_word": false,
|
578 |
+
"special": true
|
579 |
+
},
|
580 |
+
"250169": {
|
581 |
+
"content": "[E-66]",
|
582 |
+
"lstrip": false,
|
583 |
+
"normalized": false,
|
584 |
+
"rstrip": false,
|
585 |
+
"single_word": false,
|
586 |
+
"special": true
|
587 |
+
},
|
588 |
+
"250170": {
|
589 |
+
"content": "[E-67]",
|
590 |
+
"lstrip": false,
|
591 |
+
"normalized": false,
|
592 |
+
"rstrip": false,
|
593 |
+
"single_word": false,
|
594 |
+
"special": true
|
595 |
+
},
|
596 |
+
"250171": {
|
597 |
+
"content": "[E-68]",
|
598 |
+
"lstrip": false,
|
599 |
+
"normalized": false,
|
600 |
+
"rstrip": false,
|
601 |
+
"single_word": false,
|
602 |
+
"special": true
|
603 |
+
},
|
604 |
+
"250172": {
|
605 |
+
"content": "[E-69]",
|
606 |
+
"lstrip": false,
|
607 |
+
"normalized": false,
|
608 |
+
"rstrip": false,
|
609 |
+
"single_word": false,
|
610 |
+
"special": true
|
611 |
+
},
|
612 |
+
"250173": {
|
613 |
+
"content": "[E-70]",
|
614 |
+
"lstrip": false,
|
615 |
+
"normalized": false,
|
616 |
+
"rstrip": false,
|
617 |
+
"single_word": false,
|
618 |
+
"special": true
|
619 |
+
},
|
620 |
+
"250174": {
|
621 |
+
"content": "[E-71]",
|
622 |
+
"lstrip": false,
|
623 |
+
"normalized": false,
|
624 |
+
"rstrip": false,
|
625 |
+
"single_word": false,
|
626 |
+
"special": true
|
627 |
+
},
|
628 |
+
"250175": {
|
629 |
+
"content": "[E-72]",
|
630 |
+
"lstrip": false,
|
631 |
+
"normalized": false,
|
632 |
+
"rstrip": false,
|
633 |
+
"single_word": false,
|
634 |
+
"special": true
|
635 |
+
},
|
636 |
+
"250176": {
|
637 |
+
"content": "[E-73]",
|
638 |
+
"lstrip": false,
|
639 |
+
"normalized": false,
|
640 |
+
"rstrip": false,
|
641 |
+
"single_word": false,
|
642 |
+
"special": true
|
643 |
+
},
|
644 |
+
"250177": {
|
645 |
+
"content": "[E-74]",
|
646 |
+
"lstrip": false,
|
647 |
+
"normalized": false,
|
648 |
+
"rstrip": false,
|
649 |
+
"single_word": false,
|
650 |
+
"special": true
|
651 |
+
},
|
652 |
+
"250178": {
|
653 |
+
"content": "[E-75]",
|
654 |
+
"lstrip": false,
|
655 |
+
"normalized": false,
|
656 |
+
"rstrip": false,
|
657 |
+
"single_word": false,
|
658 |
+
"special": true
|
659 |
+
},
|
660 |
+
"250179": {
|
661 |
+
"content": "[E-76]",
|
662 |
+
"lstrip": false,
|
663 |
+
"normalized": false,
|
664 |
+
"rstrip": false,
|
665 |
+
"single_word": false,
|
666 |
+
"special": true
|
667 |
+
},
|
668 |
+
"250180": {
|
669 |
+
"content": "[E-77]",
|
670 |
+
"lstrip": false,
|
671 |
+
"normalized": false,
|
672 |
+
"rstrip": false,
|
673 |
+
"single_word": false,
|
674 |
+
"special": true
|
675 |
+
},
|
676 |
+
"250181": {
|
677 |
+
"content": "[E-78]",
|
678 |
+
"lstrip": false,
|
679 |
+
"normalized": false,
|
680 |
+
"rstrip": false,
|
681 |
+
"single_word": false,
|
682 |
+
"special": true
|
683 |
+
},
|
684 |
+
"250182": {
|
685 |
+
"content": "[E-79]",
|
686 |
+
"lstrip": false,
|
687 |
+
"normalized": false,
|
688 |
+
"rstrip": false,
|
689 |
+
"single_word": false,
|
690 |
+
"special": true
|
691 |
+
},
|
692 |
+
"250183": {
|
693 |
+
"content": "[E-80]",
|
694 |
+
"lstrip": false,
|
695 |
+
"normalized": false,
|
696 |
+
"rstrip": false,
|
697 |
+
"single_word": false,
|
698 |
+
"special": true
|
699 |
+
},
|
700 |
+
"250184": {
|
701 |
+
"content": "[E-81]",
|
702 |
+
"lstrip": false,
|
703 |
+
"normalized": false,
|
704 |
+
"rstrip": false,
|
705 |
+
"single_word": false,
|
706 |
+
"special": true
|
707 |
+
},
|
708 |
+
"250185": {
|
709 |
+
"content": "[E-82]",
|
710 |
+
"lstrip": false,
|
711 |
+
"normalized": false,
|
712 |
+
"rstrip": false,
|
713 |
+
"single_word": false,
|
714 |
+
"special": true
|
715 |
+
},
|
716 |
+
"250186": {
|
717 |
+
"content": "[E-83]",
|
718 |
+
"lstrip": false,
|
719 |
+
"normalized": false,
|
720 |
+
"rstrip": false,
|
721 |
+
"single_word": false,
|
722 |
+
"special": true
|
723 |
+
},
|
724 |
+
"250187": {
|
725 |
+
"content": "[E-84]",
|
726 |
+
"lstrip": false,
|
727 |
+
"normalized": false,
|
728 |
+
"rstrip": false,
|
729 |
+
"single_word": false,
|
730 |
+
"special": true
|
731 |
+
},
|
732 |
+
"250188": {
|
733 |
+
"content": "[E-85]",
|
734 |
+
"lstrip": false,
|
735 |
+
"normalized": false,
|
736 |
+
"rstrip": false,
|
737 |
+
"single_word": false,
|
738 |
+
"special": true
|
739 |
+
},
|
740 |
+
"250189": {
|
741 |
+
"content": "[E-86]",
|
742 |
+
"lstrip": false,
|
743 |
+
"normalized": false,
|
744 |
+
"rstrip": false,
|
745 |
+
"single_word": false,
|
746 |
+
"special": true
|
747 |
+
},
|
748 |
+
"250190": {
|
749 |
+
"content": "[E-87]",
|
750 |
+
"lstrip": false,
|
751 |
+
"normalized": false,
|
752 |
+
"rstrip": false,
|
753 |
+
"single_word": false,
|
754 |
+
"special": true
|
755 |
+
},
|
756 |
+
"250191": {
|
757 |
+
"content": "[E-88]",
|
758 |
+
"lstrip": false,
|
759 |
+
"normalized": false,
|
760 |
+
"rstrip": false,
|
761 |
+
"single_word": false,
|
762 |
+
"special": true
|
763 |
+
},
|
764 |
+
"250192": {
|
765 |
+
"content": "[E-89]",
|
766 |
+
"lstrip": false,
|
767 |
+
"normalized": false,
|
768 |
+
"rstrip": false,
|
769 |
+
"single_word": false,
|
770 |
+
"special": true
|
771 |
+
},
|
772 |
+
"250193": {
|
773 |
+
"content": "[E-90]",
|
774 |
+
"lstrip": false,
|
775 |
+
"normalized": false,
|
776 |
+
"rstrip": false,
|
777 |
+
"single_word": false,
|
778 |
+
"special": true
|
779 |
+
},
|
780 |
+
"250194": {
|
781 |
+
"content": "[E-91]",
|
782 |
+
"lstrip": false,
|
783 |
+
"normalized": false,
|
784 |
+
"rstrip": false,
|
785 |
+
"single_word": false,
|
786 |
+
"special": true
|
787 |
+
},
|
788 |
+
"250195": {
|
789 |
+
"content": "[E-92]",
|
790 |
+
"lstrip": false,
|
791 |
+
"normalized": false,
|
792 |
+
"rstrip": false,
|
793 |
+
"single_word": false,
|
794 |
+
"special": true
|
795 |
+
},
|
796 |
+
"250196": {
|
797 |
+
"content": "[E-93]",
|
798 |
+
"lstrip": false,
|
799 |
+
"normalized": false,
|
800 |
+
"rstrip": false,
|
801 |
+
"single_word": false,
|
802 |
+
"special": true
|
803 |
+
},
|
804 |
+
"250197": {
|
805 |
+
"content": "[E-94]",
|
806 |
+
"lstrip": false,
|
807 |
+
"normalized": false,
|
808 |
+
"rstrip": false,
|
809 |
+
"single_word": false,
|
810 |
+
"special": true
|
811 |
+
},
|
812 |
+
"250198": {
|
813 |
+
"content": "[E-95]",
|
814 |
+
"lstrip": false,
|
815 |
+
"normalized": false,
|
816 |
+
"rstrip": false,
|
817 |
+
"single_word": false,
|
818 |
+
"special": true
|
819 |
+
},
|
820 |
+
"250199": {
|
821 |
+
"content": "[E-96]",
|
822 |
+
"lstrip": false,
|
823 |
+
"normalized": false,
|
824 |
+
"rstrip": false,
|
825 |
+
"single_word": false,
|
826 |
+
"special": true
|
827 |
+
},
|
828 |
+
"250200": {
|
829 |
+
"content": "[E-97]",
|
830 |
+
"lstrip": false,
|
831 |
+
"normalized": false,
|
832 |
+
"rstrip": false,
|
833 |
+
"single_word": false,
|
834 |
+
"special": true
|
835 |
+
},
|
836 |
+
"250201": {
|
837 |
+
"content": "[E-98]",
|
838 |
+
"lstrip": false,
|
839 |
+
"normalized": false,
|
840 |
+
"rstrip": false,
|
841 |
+
"single_word": false,
|
842 |
+
"special": true
|
843 |
+
},
|
844 |
+
"250202": {
|
845 |
+
"content": "[E-99]",
|
846 |
+
"lstrip": false,
|
847 |
+
"normalized": false,
|
848 |
+
"rstrip": false,
|
849 |
+
"single_word": false,
|
850 |
+
"special": true
|
851 |
+
}
|
852 |
+
},
|
853 |
+
"additional_special_tokens": [
|
854 |
+
"--NME--",
|
855 |
+
"[E-0]",
|
856 |
+
"[E-1]",
|
857 |
+
"[E-2]",
|
858 |
+
"[E-3]",
|
859 |
+
"[E-4]",
|
860 |
+
"[E-5]",
|
861 |
+
"[E-6]",
|
862 |
+
"[E-7]",
|
863 |
+
"[E-8]",
|
864 |
+
"[E-9]",
|
865 |
+
"[E-10]",
|
866 |
+
"[E-11]",
|
867 |
+
"[E-12]",
|
868 |
+
"[E-13]",
|
869 |
+
"[E-14]",
|
870 |
+
"[E-15]",
|
871 |
+
"[E-16]",
|
872 |
+
"[E-17]",
|
873 |
+
"[E-18]",
|
874 |
+
"[E-19]",
|
875 |
+
"[E-20]",
|
876 |
+
"[E-21]",
|
877 |
+
"[E-22]",
|
878 |
+
"[E-23]",
|
879 |
+
"[E-24]",
|
880 |
+
"[E-25]",
|
881 |
+
"[E-26]",
|
882 |
+
"[E-27]",
|
883 |
+
"[E-28]",
|
884 |
+
"[E-29]",
|
885 |
+
"[E-30]",
|
886 |
+
"[E-31]",
|
887 |
+
"[E-32]",
|
888 |
+
"[E-33]",
|
889 |
+
"[E-34]",
|
890 |
+
"[E-35]",
|
891 |
+
"[E-36]",
|
892 |
+
"[E-37]",
|
893 |
+
"[E-38]",
|
894 |
+
"[E-39]",
|
895 |
+
"[E-40]",
|
896 |
+
"[E-41]",
|
897 |
+
"[E-42]",
|
898 |
+
"[E-43]",
|
899 |
+
"[E-44]",
|
900 |
+
"[E-45]",
|
901 |
+
"[E-46]",
|
902 |
+
"[E-47]",
|
903 |
+
"[E-48]",
|
904 |
+
"[E-49]",
|
905 |
+
"[E-50]",
|
906 |
+
"[E-51]",
|
907 |
+
"[E-52]",
|
908 |
+
"[E-53]",
|
909 |
+
"[E-54]",
|
910 |
+
"[E-55]",
|
911 |
+
"[E-56]",
|
912 |
+
"[E-57]",
|
913 |
+
"[E-58]",
|
914 |
+
"[E-59]",
|
915 |
+
"[E-60]",
|
916 |
+
"[E-61]",
|
917 |
+
"[E-62]",
|
918 |
+
"[E-63]",
|
919 |
+
"[E-64]",
|
920 |
+
"[E-65]",
|
921 |
+
"[E-66]",
|
922 |
+
"[E-67]",
|
923 |
+
"[E-68]",
|
924 |
+
"[E-69]",
|
925 |
+
"[E-70]",
|
926 |
+
"[E-71]",
|
927 |
+
"[E-72]",
|
928 |
+
"[E-73]",
|
929 |
+
"[E-74]",
|
930 |
+
"[E-75]",
|
931 |
+
"[E-76]",
|
932 |
+
"[E-77]",
|
933 |
+
"[E-78]",
|
934 |
+
"[E-79]",
|
935 |
+
"[E-80]",
|
936 |
+
"[E-81]",
|
937 |
+
"[E-82]",
|
938 |
+
"[E-83]",
|
939 |
+
"[E-84]",
|
940 |
+
"[E-85]",
|
941 |
+
"[E-86]",
|
942 |
+
"[E-87]",
|
943 |
+
"[E-88]",
|
944 |
+
"[E-89]",
|
945 |
+
"[E-90]",
|
946 |
+
"[E-91]",
|
947 |
+
"[E-92]",
|
948 |
+
"[E-93]",
|
949 |
+
"[E-94]",
|
950 |
+
"[E-95]",
|
951 |
+
"[E-96]",
|
952 |
+
"[E-97]",
|
953 |
+
"[E-98]",
|
954 |
+
"[E-99]"
|
955 |
+
],
|
956 |
+
"bos_token": "[CLS]",
|
957 |
+
"clean_up_tokenization_spaces": true,
|
958 |
+
"cls_token": "[CLS]",
|
959 |
+
"do_lower_case": false,
|
960 |
+
"eos_token": "[SEP]",
|
961 |
+
"mask_token": "[MASK]",
|
962 |
+
"model_max_length": 1000000000000000019884624838656,
|
963 |
+
"pad_token": "[PAD]",
|
964 |
+
"sep_token": "[SEP]",
|
965 |
+
"sp_model_kwargs": {},
|
966 |
+
"split_by_punct": false,
|
967 |
+
"tokenizer_class": "DebertaV2Tokenizer",
|
968 |
+
"unk_token": "[UNK]",
|
969 |
+
"vocab_type": "spm"
|
970 |
+
}
|