andreim14 commited on
Commit
536c691
1 Parent(s): bb8d953

added model

Browse files
.gitattributes CHANGED
@@ -33,3 +33,6 @@ 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
+ model filter=lfs diff=lfs merge=lfs -text
37
+ model.safetensors filter=lfs diff=lfs merge=lfs -text
38
+ spm.model filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,141 @@
1
  ---
2
  license: cc-by-nc-sa-4.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: cc-by-nc-sa-4.0
3
  ---
4
+ ---
5
+ license:
6
+ - cc-by-nc-sa-4.0
7
+ source_datasets:
8
+ - original
9
+ task_ids:
10
+ - word-sense-disambiguation
11
+ pretty_name: word-sense-linking-dataset
12
+ tags:
13
+ - word-sense-linking
14
+ - word-sense-disambiguation
15
+ - lexical-semantics
16
+ size_categories:
17
+ - 10K<n<100K
18
+ extra_gated_fields:
19
+ Email: text
20
+ Company: text
21
+ Country: country
22
+ I want to use this dataset for:
23
+ type: select
24
+ options:
25
+ - Research
26
+ - Education
27
+ - label: Other
28
+ value: other
29
+ I agree to use this dataset for non-commercial use ONLY: checkbox
30
+ extra_gated_heading: "Acknowledge our [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0)](https://github.com/Babelscape/WSL/wsl_data_license.txt) to access the repository"
31
+ extra_gated_description: "Our team may take 2-3 days to process your request"
32
+ extra_gated_button_content: "Acknowledge license"
33
+ ---
34
+ ---
35
+
36
+
37
+ # Word Sense Linking: Disambiguating Outside the Sandbox
38
+
39
+ [![Conference](http://img.shields.io/badge/ACL-2024-4b44ce.svg)](https://2024.aclweb.org/)
40
+ [![Paper](http://img.shields.io/badge/paper-ACL--anthology-B31B1B.svg)](https://aclanthology.org/)
41
+ [![Hugging Face Collection](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-FCD21D)](https://huggingface.co/collections/Babelscape/word-sense-linking-66ace2182bc45680964cefcb)
42
+
43
+ ## Model Description
44
+
45
+ The Word Sense Linking model is designed to identify and disambiguate spans of text to their most suitable senses from a reference inventory. The annotations are provided as sense keys from WordNet, a large lexical database of English.
46
+
47
+ ## Installation
48
+
49
+ Installation from PyPI:
50
+
51
+ ```bash
52
+ git clone https://github.com/Babelscape/WSL
53
+ cd WSL
54
+ pip install -r requirements.txt
55
+ ```
56
+
57
+
58
+
59
+ ## Usage
60
+
61
+ WSL is composed of two main components: a retriever and a reader.
62
+ The retriever is responsible for retrieving relevant senses from a senses inventory (e.g WordNet),
63
+ while the reader is responsible for extracting spans from the input text and link them to the retrieved documents.
64
+ WSL can be used with the `from_pretrained` method to load a pre-trained pipeline.
65
+
66
+ ```python
67
+ from wsl import WSL
68
+ from wsl.inference.data.objects import WSLOutput
69
+
70
+ wsl_model = WSL.from_pretrained("Babelscape/wsl-base")
71
+ relik_out: WSLOutput = wsl_model("Bus drivers drive busses for a living.")
72
+ ```
73
+
74
+ WSLOutput(
75
+ text='Bus drivers drive busses for a living.',
76
+ tokens=['Bus', 'drivers', 'drive', 'busses', 'for', 'a', 'living', '.'],
77
+ id=0,
78
+ spans=[
79
+ Span(start=0, end=11, label='bus driver: someone who drives a bus', text='Bus drivers'),
80
+ Span(start=12, end=17, label='drive: operate or control a vehicle', text='drive'),
81
+ Span(start=18, end=24, label='bus: a vehicle carrying many passengers; used for public transport', text='busses'),
82
+ Span(start=31, end=37, label='living: the financial means whereby one lives', text='living')
83
+ ],
84
+ candidates=Candidates(
85
+ candidates=[
86
+ {"text": "bus driver: someone who drives a bus", "id": "bus_driver%1:18:00::", "metadata": {}},
87
+ {"text": "driver: the operator of a motor vehicle", "id": "driver%1:18:00::", "metadata": {}},
88
+ {"text": "driver: someone who drives animals that pull a vehicle", "id": "driver%1:18:02::", "metadata": {}},
89
+ {"text": "bus: a vehicle carrying many passengers; used for public transport", "id": "bus%1:06:00::", "metadata": {}},
90
+ {"text": "living: the financial means whereby one lives", "id": "living%1:26:00::", "metadata": {}}
91
+ ]
92
+ ),
93
+ )
94
+
95
+
96
+
97
+ ## Model Performance
98
+
99
+ Here you can find the performances of our model on the [WSL evaluation dataset](https://huggingface.co/datasets/Babelscape/wsl).
100
+
101
+ ### Validation (SE07)
102
+
103
+ | Models | P | R | F1 |
104
+ |--------------|------|--------|--------|
105
+ | BEM_SUP | 67.6 | 40.9 | 51.0 |
106
+ | BEM_HEU | 70.8 | 51.2 | 59.4 |
107
+ | ConSeC_SUP | 76.4 | 46.5 | 57.8 |
108
+ | ConSeC_HEU | **76.7** | 55.4 | 64.3 |
109
+ | **Our Model**| 73.8 | **74.9** | **74.4** |
110
+
111
+ ### Test (ALL_FULL)
112
+
113
+ | Models | P | R | F1 |
114
+ |--------------|------|--------|--------|
115
+ | BEM_SUP | 74.8 | 50.7 | 60.4 |
116
+ | BEM_HEU | 76.6 | 61.2 | 68.0 |
117
+ | ConSeC_SUP | 78.9 | 53.1 | 63.5 |
118
+ | ConSeC_HEU | **80.4** | 64.3 | 71.5 |
119
+ | **Our Model**| 75.2 | **76.7** | **75.9** |
120
+
121
+
122
+
123
+ ## Additional Information
124
+ **Licensing Information**: Contents of this repository are restricted to only non-commercial research purposes under the [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0)](https://creativecommons.org/licenses/by-nc-sa/4.0/). Copyright of the dataset contents belongs to Babelscape.
125
+
126
+ ## Citation Information
127
+
128
+
129
+ ```bibtex
130
+ @inproceedings{bejgu-etal-2024-wsl,
131
+ title = "Word Sense Linking: Disambiguating Outside the Sandbox",
132
+ author = "Bejgu, Andrei Stefan and Barba, Edoardo and Procopio, Luigi and Fern{\'a}ndez-Castro, Alberte and Navigli, Roberto",
133
+ booktitle = "Findings of the Association for Computational Linguistics: ACL 2024",
134
+ month = aug,
135
+ year = "2024",
136
+ address = "Bangkok, Thailand",
137
+ publisher = "Association for Computational Linguistics",
138
+ }
139
+ ```
140
+
141
+ **Contributions**: Thanks to [@andreim14](https://github.com/andreim14), [@edobobo](https://github.com/edobobo), [@poccio](https://github.com/poccio) and [@navigli](https://github.com/navigli) for adding this model.
added_tokens.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "--NME--": 128001,
3
+ "[E-0]": 128002,
4
+ "[E-10]": 128012,
5
+ "[E-11]": 128013,
6
+ "[E-12]": 128014,
7
+ "[E-13]": 128015,
8
+ "[E-14]": 128016,
9
+ "[E-15]": 128017,
10
+ "[E-16]": 128018,
11
+ "[E-17]": 128019,
12
+ "[E-18]": 128020,
13
+ "[E-19]": 128021,
14
+ "[E-1]": 128003,
15
+ "[E-20]": 128022,
16
+ "[E-21]": 128023,
17
+ "[E-22]": 128024,
18
+ "[E-23]": 128025,
19
+ "[E-24]": 128026,
20
+ "[E-25]": 128027,
21
+ "[E-26]": 128028,
22
+ "[E-27]": 128029,
23
+ "[E-28]": 128030,
24
+ "[E-29]": 128031,
25
+ "[E-2]": 128004,
26
+ "[E-30]": 128032,
27
+ "[E-31]": 128033,
28
+ "[E-32]": 128034,
29
+ "[E-33]": 128035,
30
+ "[E-34]": 128036,
31
+ "[E-35]": 128037,
32
+ "[E-36]": 128038,
33
+ "[E-37]": 128039,
34
+ "[E-38]": 128040,
35
+ "[E-39]": 128041,
36
+ "[E-3]": 128005,
37
+ "[E-40]": 128042,
38
+ "[E-41]": 128043,
39
+ "[E-42]": 128044,
40
+ "[E-43]": 128045,
41
+ "[E-44]": 128046,
42
+ "[E-45]": 128047,
43
+ "[E-46]": 128048,
44
+ "[E-47]": 128049,
45
+ "[E-48]": 128050,
46
+ "[E-49]": 128051,
47
+ "[E-4]": 128006,
48
+ "[E-50]": 128052,
49
+ "[E-51]": 128053,
50
+ "[E-52]": 128054,
51
+ "[E-53]": 128055,
52
+ "[E-54]": 128056,
53
+ "[E-55]": 128057,
54
+ "[E-56]": 128058,
55
+ "[E-57]": 128059,
56
+ "[E-58]": 128060,
57
+ "[E-59]": 128061,
58
+ "[E-5]": 128007,
59
+ "[E-60]": 128062,
60
+ "[E-61]": 128063,
61
+ "[E-62]": 128064,
62
+ "[E-63]": 128065,
63
+ "[E-64]": 128066,
64
+ "[E-65]": 128067,
65
+ "[E-66]": 128068,
66
+ "[E-67]": 128069,
67
+ "[E-68]": 128070,
68
+ "[E-69]": 128071,
69
+ "[E-6]": 128008,
70
+ "[E-70]": 128072,
71
+ "[E-71]": 128073,
72
+ "[E-72]": 128074,
73
+ "[E-73]": 128075,
74
+ "[E-74]": 128076,
75
+ "[E-75]": 128077,
76
+ "[E-76]": 128078,
77
+ "[E-77]": 128079,
78
+ "[E-78]": 128080,
79
+ "[E-79]": 128081,
80
+ "[E-7]": 128009,
81
+ "[E-80]": 128082,
82
+ "[E-81]": 128083,
83
+ "[E-82]": 128084,
84
+ "[E-83]": 128085,
85
+ "[E-84]": 128086,
86
+ "[E-85]": 128087,
87
+ "[E-86]": 128088,
88
+ "[E-87]": 128089,
89
+ "[E-88]": 128090,
90
+ "[E-89]": 128091,
91
+ "[E-8]": 128010,
92
+ "[E-90]": 128092,
93
+ "[E-91]": 128093,
94
+ "[E-92]": 128094,
95
+ "[E-93]": 128095,
96
+ "[E-94]": 128096,
97
+ "[E-95]": 128097,
98
+ "[E-96]": 128098,
99
+ "[E-97]": 128099,
100
+ "[E-98]": 128100,
101
+ "[E-99]": 128101,
102
+ "[E-9]": 128011,
103
+ "[MASK]": 128000
104
+ }
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/mnt/data2/neural/wsl-dataset/relik/pretrained/relik-reader/relik-reader",
3
+ "activation": "gelu",
4
+ "add_entity_embedding": null,
5
+ "additional_special_symbols": 101,
6
+ "additional_special_symbols_types": 0,
7
+ "architectures": [
8
+ "WSLReaderSpanModel"
9
+ ],
10
+ "auto_map": {
11
+ "AutoConfig": "configuration_wsl.WSLReaderConfig",
12
+ "AutoModel": "modeling_wsl.WSLReaderSpanModel"
13
+ },
14
+ "binary_end_logits": false,
15
+ "default_reader_class": null,
16
+ "entity_type_loss": false,
17
+ "linears_hidden_size": 512,
18
+ "model_type": "wsl-reader",
19
+ "num_layers": null,
20
+ "threshold": 0.5,
21
+ "torch_dtype": "float32",
22
+ "training": true,
23
+ "transformer_model": "microsoft/deberta-v3-base",
24
+ "transformers_version": "4.41.2",
25
+ "use_last_k_layers": 1
26
+ }
configuration_wsl.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 WSLReaderConfig(PretrainedConfig):
8
+ model_type = "wsl-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:a34288a25277d1027d00b8f6b739e4b8efdc4bd46d968640f603a87901fc90f1
3
+ size 747233940
modeling_wsl.py ADDED
@@ -0,0 +1,456 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_wsl import WSLReaderConfig
10
+
11
+
12
+ class WSLReaderSample:
13
+ def __init__(self, **kwargs):
14
+ super().__setattr__("_d", {})
15
+ self._d = kwargs
16
+
17
+ def __getattribute__(self, item):
18
+ return super(WSLReaderSample, 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 WSLReaderSpanModel(PreTrainedModel):
69
+ config_class = WSLReaderConfig
70
+
71
+ def __init__(self, config: WSLReaderConfig, *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
special_tokens_map.json ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": {
106
+ "content": "[CLS]",
107
+ "lstrip": false,
108
+ "normalized": false,
109
+ "rstrip": false,
110
+ "single_word": false
111
+ },
112
+ "cls_token": {
113
+ "content": "[CLS]",
114
+ "lstrip": false,
115
+ "normalized": false,
116
+ "rstrip": false,
117
+ "single_word": false
118
+ },
119
+ "eos_token": {
120
+ "content": "[SEP]",
121
+ "lstrip": false,
122
+ "normalized": false,
123
+ "rstrip": false,
124
+ "single_word": false
125
+ },
126
+ "mask_token": {
127
+ "content": "[MASK]",
128
+ "lstrip": false,
129
+ "normalized": false,
130
+ "rstrip": false,
131
+ "single_word": false
132
+ },
133
+ "pad_token": {
134
+ "content": "[PAD]",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false
139
+ },
140
+ "sep_token": {
141
+ "content": "[SEP]",
142
+ "lstrip": false,
143
+ "normalized": false,
144
+ "rstrip": false,
145
+ "single_word": false
146
+ },
147
+ "unk_token": {
148
+ "content": "[UNK]",
149
+ "lstrip": false,
150
+ "normalized": false,
151
+ "rstrip": false,
152
+ "single_word": false
153
+ }
154
+ }
spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c679fbf93643d19aab7ee10c0b99e460bdbc02fedf34b92b05af343b4af586fd
3
+ size 2464616
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,970 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "128000": {
37
+ "content": "[MASK]",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "128001": {
45
+ "content": "--NME--",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "128002": {
53
+ "content": "[E-0]",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ },
60
+ "128003": {
61
+ "content": "[E-1]",
62
+ "lstrip": false,
63
+ "normalized": false,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": true
67
+ },
68
+ "128004": {
69
+ "content": "[E-2]",
70
+ "lstrip": false,
71
+ "normalized": false,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": true
75
+ },
76
+ "128005": {
77
+ "content": "[E-3]",
78
+ "lstrip": false,
79
+ "normalized": false,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": true
83
+ },
84
+ "128006": {
85
+ "content": "[E-4]",
86
+ "lstrip": false,
87
+ "normalized": false,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": true
91
+ },
92
+ "128007": {
93
+ "content": "[E-5]",
94
+ "lstrip": false,
95
+ "normalized": false,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": true
99
+ },
100
+ "128008": {
101
+ "content": "[E-6]",
102
+ "lstrip": false,
103
+ "normalized": false,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": true
107
+ },
108
+ "128009": {
109
+ "content": "[E-7]",
110
+ "lstrip": false,
111
+ "normalized": false,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": true
115
+ },
116
+ "128010": {
117
+ "content": "[E-8]",
118
+ "lstrip": false,
119
+ "normalized": false,
120
+ "rstrip": false,
121
+ "single_word": false,
122
+ "special": true
123
+ },
124
+ "128011": {
125
+ "content": "[E-9]",
126
+ "lstrip": false,
127
+ "normalized": false,
128
+ "rstrip": false,
129
+ "single_word": false,
130
+ "special": true
131
+ },
132
+ "128012": {
133
+ "content": "[E-10]",
134
+ "lstrip": false,
135
+ "normalized": false,
136
+ "rstrip": false,
137
+ "single_word": false,
138
+ "special": true
139
+ },
140
+ "128013": {
141
+ "content": "[E-11]",
142
+ "lstrip": false,
143
+ "normalized": false,
144
+ "rstrip": false,
145
+ "single_word": false,
146
+ "special": true
147
+ },
148
+ "128014": {
149
+ "content": "[E-12]",
150
+ "lstrip": false,
151
+ "normalized": false,
152
+ "rstrip": false,
153
+ "single_word": false,
154
+ "special": true
155
+ },
156
+ "128015": {
157
+ "content": "[E-13]",
158
+ "lstrip": false,
159
+ "normalized": false,
160
+ "rstrip": false,
161
+ "single_word": false,
162
+ "special": true
163
+ },
164
+ "128016": {
165
+ "content": "[E-14]",
166
+ "lstrip": false,
167
+ "normalized": false,
168
+ "rstrip": false,
169
+ "single_word": false,
170
+ "special": true
171
+ },
172
+ "128017": {
173
+ "content": "[E-15]",
174
+ "lstrip": false,
175
+ "normalized": false,
176
+ "rstrip": false,
177
+ "single_word": false,
178
+ "special": true
179
+ },
180
+ "128018": {
181
+ "content": "[E-16]",
182
+ "lstrip": false,
183
+ "normalized": false,
184
+ "rstrip": false,
185
+ "single_word": false,
186
+ "special": true
187
+ },
188
+ "128019": {
189
+ "content": "[E-17]",
190
+ "lstrip": false,
191
+ "normalized": false,
192
+ "rstrip": false,
193
+ "single_word": false,
194
+ "special": true
195
+ },
196
+ "128020": {
197
+ "content": "[E-18]",
198
+ "lstrip": false,
199
+ "normalized": false,
200
+ "rstrip": false,
201
+ "single_word": false,
202
+ "special": true
203
+ },
204
+ "128021": {
205
+ "content": "[E-19]",
206
+ "lstrip": false,
207
+ "normalized": false,
208
+ "rstrip": false,
209
+ "single_word": false,
210
+ "special": true
211
+ },
212
+ "128022": {
213
+ "content": "[E-20]",
214
+ "lstrip": false,
215
+ "normalized": false,
216
+ "rstrip": false,
217
+ "single_word": false,
218
+ "special": true
219
+ },
220
+ "128023": {
221
+ "content": "[E-21]",
222
+ "lstrip": false,
223
+ "normalized": false,
224
+ "rstrip": false,
225
+ "single_word": false,
226
+ "special": true
227
+ },
228
+ "128024": {
229
+ "content": "[E-22]",
230
+ "lstrip": false,
231
+ "normalized": false,
232
+ "rstrip": false,
233
+ "single_word": false,
234
+ "special": true
235
+ },
236
+ "128025": {
237
+ "content": "[E-23]",
238
+ "lstrip": false,
239
+ "normalized": false,
240
+ "rstrip": false,
241
+ "single_word": false,
242
+ "special": true
243
+ },
244
+ "128026": {
245
+ "content": "[E-24]",
246
+ "lstrip": false,
247
+ "normalized": false,
248
+ "rstrip": false,
249
+ "single_word": false,
250
+ "special": true
251
+ },
252
+ "128027": {
253
+ "content": "[E-25]",
254
+ "lstrip": false,
255
+ "normalized": false,
256
+ "rstrip": false,
257
+ "single_word": false,
258
+ "special": true
259
+ },
260
+ "128028": {
261
+ "content": "[E-26]",
262
+ "lstrip": false,
263
+ "normalized": false,
264
+ "rstrip": false,
265
+ "single_word": false,
266
+ "special": true
267
+ },
268
+ "128029": {
269
+ "content": "[E-27]",
270
+ "lstrip": false,
271
+ "normalized": false,
272
+ "rstrip": false,
273
+ "single_word": false,
274
+ "special": true
275
+ },
276
+ "128030": {
277
+ "content": "[E-28]",
278
+ "lstrip": false,
279
+ "normalized": false,
280
+ "rstrip": false,
281
+ "single_word": false,
282
+ "special": true
283
+ },
284
+ "128031": {
285
+ "content": "[E-29]",
286
+ "lstrip": false,
287
+ "normalized": false,
288
+ "rstrip": false,
289
+ "single_word": false,
290
+ "special": true
291
+ },
292
+ "128032": {
293
+ "content": "[E-30]",
294
+ "lstrip": false,
295
+ "normalized": false,
296
+ "rstrip": false,
297
+ "single_word": false,
298
+ "special": true
299
+ },
300
+ "128033": {
301
+ "content": "[E-31]",
302
+ "lstrip": false,
303
+ "normalized": false,
304
+ "rstrip": false,
305
+ "single_word": false,
306
+ "special": true
307
+ },
308
+ "128034": {
309
+ "content": "[E-32]",
310
+ "lstrip": false,
311
+ "normalized": false,
312
+ "rstrip": false,
313
+ "single_word": false,
314
+ "special": true
315
+ },
316
+ "128035": {
317
+ "content": "[E-33]",
318
+ "lstrip": false,
319
+ "normalized": false,
320
+ "rstrip": false,
321
+ "single_word": false,
322
+ "special": true
323
+ },
324
+ "128036": {
325
+ "content": "[E-34]",
326
+ "lstrip": false,
327
+ "normalized": false,
328
+ "rstrip": false,
329
+ "single_word": false,
330
+ "special": true
331
+ },
332
+ "128037": {
333
+ "content": "[E-35]",
334
+ "lstrip": false,
335
+ "normalized": false,
336
+ "rstrip": false,
337
+ "single_word": false,
338
+ "special": true
339
+ },
340
+ "128038": {
341
+ "content": "[E-36]",
342
+ "lstrip": false,
343
+ "normalized": false,
344
+ "rstrip": false,
345
+ "single_word": false,
346
+ "special": true
347
+ },
348
+ "128039": {
349
+ "content": "[E-37]",
350
+ "lstrip": false,
351
+ "normalized": false,
352
+ "rstrip": false,
353
+ "single_word": false,
354
+ "special": true
355
+ },
356
+ "128040": {
357
+ "content": "[E-38]",
358
+ "lstrip": false,
359
+ "normalized": false,
360
+ "rstrip": false,
361
+ "single_word": false,
362
+ "special": true
363
+ },
364
+ "128041": {
365
+ "content": "[E-39]",
366
+ "lstrip": false,
367
+ "normalized": false,
368
+ "rstrip": false,
369
+ "single_word": false,
370
+ "special": true
371
+ },
372
+ "128042": {
373
+ "content": "[E-40]",
374
+ "lstrip": false,
375
+ "normalized": false,
376
+ "rstrip": false,
377
+ "single_word": false,
378
+ "special": true
379
+ },
380
+ "128043": {
381
+ "content": "[E-41]",
382
+ "lstrip": false,
383
+ "normalized": false,
384
+ "rstrip": false,
385
+ "single_word": false,
386
+ "special": true
387
+ },
388
+ "128044": {
389
+ "content": "[E-42]",
390
+ "lstrip": false,
391
+ "normalized": false,
392
+ "rstrip": false,
393
+ "single_word": false,
394
+ "special": true
395
+ },
396
+ "128045": {
397
+ "content": "[E-43]",
398
+ "lstrip": false,
399
+ "normalized": false,
400
+ "rstrip": false,
401
+ "single_word": false,
402
+ "special": true
403
+ },
404
+ "128046": {
405
+ "content": "[E-44]",
406
+ "lstrip": false,
407
+ "normalized": false,
408
+ "rstrip": false,
409
+ "single_word": false,
410
+ "special": true
411
+ },
412
+ "128047": {
413
+ "content": "[E-45]",
414
+ "lstrip": false,
415
+ "normalized": false,
416
+ "rstrip": false,
417
+ "single_word": false,
418
+ "special": true
419
+ },
420
+ "128048": {
421
+ "content": "[E-46]",
422
+ "lstrip": false,
423
+ "normalized": false,
424
+ "rstrip": false,
425
+ "single_word": false,
426
+ "special": true
427
+ },
428
+ "128049": {
429
+ "content": "[E-47]",
430
+ "lstrip": false,
431
+ "normalized": false,
432
+ "rstrip": false,
433
+ "single_word": false,
434
+ "special": true
435
+ },
436
+ "128050": {
437
+ "content": "[E-48]",
438
+ "lstrip": false,
439
+ "normalized": false,
440
+ "rstrip": false,
441
+ "single_word": false,
442
+ "special": true
443
+ },
444
+ "128051": {
445
+ "content": "[E-49]",
446
+ "lstrip": false,
447
+ "normalized": false,
448
+ "rstrip": false,
449
+ "single_word": false,
450
+ "special": true
451
+ },
452
+ "128052": {
453
+ "content": "[E-50]",
454
+ "lstrip": false,
455
+ "normalized": false,
456
+ "rstrip": false,
457
+ "single_word": false,
458
+ "special": true
459
+ },
460
+ "128053": {
461
+ "content": "[E-51]",
462
+ "lstrip": false,
463
+ "normalized": false,
464
+ "rstrip": false,
465
+ "single_word": false,
466
+ "special": true
467
+ },
468
+ "128054": {
469
+ "content": "[E-52]",
470
+ "lstrip": false,
471
+ "normalized": false,
472
+ "rstrip": false,
473
+ "single_word": false,
474
+ "special": true
475
+ },
476
+ "128055": {
477
+ "content": "[E-53]",
478
+ "lstrip": false,
479
+ "normalized": false,
480
+ "rstrip": false,
481
+ "single_word": false,
482
+ "special": true
483
+ },
484
+ "128056": {
485
+ "content": "[E-54]",
486
+ "lstrip": false,
487
+ "normalized": false,
488
+ "rstrip": false,
489
+ "single_word": false,
490
+ "special": true
491
+ },
492
+ "128057": {
493
+ "content": "[E-55]",
494
+ "lstrip": false,
495
+ "normalized": false,
496
+ "rstrip": false,
497
+ "single_word": false,
498
+ "special": true
499
+ },
500
+ "128058": {
501
+ "content": "[E-56]",
502
+ "lstrip": false,
503
+ "normalized": false,
504
+ "rstrip": false,
505
+ "single_word": false,
506
+ "special": true
507
+ },
508
+ "128059": {
509
+ "content": "[E-57]",
510
+ "lstrip": false,
511
+ "normalized": false,
512
+ "rstrip": false,
513
+ "single_word": false,
514
+ "special": true
515
+ },
516
+ "128060": {
517
+ "content": "[E-58]",
518
+ "lstrip": false,
519
+ "normalized": false,
520
+ "rstrip": false,
521
+ "single_word": false,
522
+ "special": true
523
+ },
524
+ "128061": {
525
+ "content": "[E-59]",
526
+ "lstrip": false,
527
+ "normalized": false,
528
+ "rstrip": false,
529
+ "single_word": false,
530
+ "special": true
531
+ },
532
+ "128062": {
533
+ "content": "[E-60]",
534
+ "lstrip": false,
535
+ "normalized": false,
536
+ "rstrip": false,
537
+ "single_word": false,
538
+ "special": true
539
+ },
540
+ "128063": {
541
+ "content": "[E-61]",
542
+ "lstrip": false,
543
+ "normalized": false,
544
+ "rstrip": false,
545
+ "single_word": false,
546
+ "special": true
547
+ },
548
+ "128064": {
549
+ "content": "[E-62]",
550
+ "lstrip": false,
551
+ "normalized": false,
552
+ "rstrip": false,
553
+ "single_word": false,
554
+ "special": true
555
+ },
556
+ "128065": {
557
+ "content": "[E-63]",
558
+ "lstrip": false,
559
+ "normalized": false,
560
+ "rstrip": false,
561
+ "single_word": false,
562
+ "special": true
563
+ },
564
+ "128066": {
565
+ "content": "[E-64]",
566
+ "lstrip": false,
567
+ "normalized": false,
568
+ "rstrip": false,
569
+ "single_word": false,
570
+ "special": true
571
+ },
572
+ "128067": {
573
+ "content": "[E-65]",
574
+ "lstrip": false,
575
+ "normalized": false,
576
+ "rstrip": false,
577
+ "single_word": false,
578
+ "special": true
579
+ },
580
+ "128068": {
581
+ "content": "[E-66]",
582
+ "lstrip": false,
583
+ "normalized": false,
584
+ "rstrip": false,
585
+ "single_word": false,
586
+ "special": true
587
+ },
588
+ "128069": {
589
+ "content": "[E-67]",
590
+ "lstrip": false,
591
+ "normalized": false,
592
+ "rstrip": false,
593
+ "single_word": false,
594
+ "special": true
595
+ },
596
+ "128070": {
597
+ "content": "[E-68]",
598
+ "lstrip": false,
599
+ "normalized": false,
600
+ "rstrip": false,
601
+ "single_word": false,
602
+ "special": true
603
+ },
604
+ "128071": {
605
+ "content": "[E-69]",
606
+ "lstrip": false,
607
+ "normalized": false,
608
+ "rstrip": false,
609
+ "single_word": false,
610
+ "special": true
611
+ },
612
+ "128072": {
613
+ "content": "[E-70]",
614
+ "lstrip": false,
615
+ "normalized": false,
616
+ "rstrip": false,
617
+ "single_word": false,
618
+ "special": true
619
+ },
620
+ "128073": {
621
+ "content": "[E-71]",
622
+ "lstrip": false,
623
+ "normalized": false,
624
+ "rstrip": false,
625
+ "single_word": false,
626
+ "special": true
627
+ },
628
+ "128074": {
629
+ "content": "[E-72]",
630
+ "lstrip": false,
631
+ "normalized": false,
632
+ "rstrip": false,
633
+ "single_word": false,
634
+ "special": true
635
+ },
636
+ "128075": {
637
+ "content": "[E-73]",
638
+ "lstrip": false,
639
+ "normalized": false,
640
+ "rstrip": false,
641
+ "single_word": false,
642
+ "special": true
643
+ },
644
+ "128076": {
645
+ "content": "[E-74]",
646
+ "lstrip": false,
647
+ "normalized": false,
648
+ "rstrip": false,
649
+ "single_word": false,
650
+ "special": true
651
+ },
652
+ "128077": {
653
+ "content": "[E-75]",
654
+ "lstrip": false,
655
+ "normalized": false,
656
+ "rstrip": false,
657
+ "single_word": false,
658
+ "special": true
659
+ },
660
+ "128078": {
661
+ "content": "[E-76]",
662
+ "lstrip": false,
663
+ "normalized": false,
664
+ "rstrip": false,
665
+ "single_word": false,
666
+ "special": true
667
+ },
668
+ "128079": {
669
+ "content": "[E-77]",
670
+ "lstrip": false,
671
+ "normalized": false,
672
+ "rstrip": false,
673
+ "single_word": false,
674
+ "special": true
675
+ },
676
+ "128080": {
677
+ "content": "[E-78]",
678
+ "lstrip": false,
679
+ "normalized": false,
680
+ "rstrip": false,
681
+ "single_word": false,
682
+ "special": true
683
+ },
684
+ "128081": {
685
+ "content": "[E-79]",
686
+ "lstrip": false,
687
+ "normalized": false,
688
+ "rstrip": false,
689
+ "single_word": false,
690
+ "special": true
691
+ },
692
+ "128082": {
693
+ "content": "[E-80]",
694
+ "lstrip": false,
695
+ "normalized": false,
696
+ "rstrip": false,
697
+ "single_word": false,
698
+ "special": true
699
+ },
700
+ "128083": {
701
+ "content": "[E-81]",
702
+ "lstrip": false,
703
+ "normalized": false,
704
+ "rstrip": false,
705
+ "single_word": false,
706
+ "special": true
707
+ },
708
+ "128084": {
709
+ "content": "[E-82]",
710
+ "lstrip": false,
711
+ "normalized": false,
712
+ "rstrip": false,
713
+ "single_word": false,
714
+ "special": true
715
+ },
716
+ "128085": {
717
+ "content": "[E-83]",
718
+ "lstrip": false,
719
+ "normalized": false,
720
+ "rstrip": false,
721
+ "single_word": false,
722
+ "special": true
723
+ },
724
+ "128086": {
725
+ "content": "[E-84]",
726
+ "lstrip": false,
727
+ "normalized": false,
728
+ "rstrip": false,
729
+ "single_word": false,
730
+ "special": true
731
+ },
732
+ "128087": {
733
+ "content": "[E-85]",
734
+ "lstrip": false,
735
+ "normalized": false,
736
+ "rstrip": false,
737
+ "single_word": false,
738
+ "special": true
739
+ },
740
+ "128088": {
741
+ "content": "[E-86]",
742
+ "lstrip": false,
743
+ "normalized": false,
744
+ "rstrip": false,
745
+ "single_word": false,
746
+ "special": true
747
+ },
748
+ "128089": {
749
+ "content": "[E-87]",
750
+ "lstrip": false,
751
+ "normalized": false,
752
+ "rstrip": false,
753
+ "single_word": false,
754
+ "special": true
755
+ },
756
+ "128090": {
757
+ "content": "[E-88]",
758
+ "lstrip": false,
759
+ "normalized": false,
760
+ "rstrip": false,
761
+ "single_word": false,
762
+ "special": true
763
+ },
764
+ "128091": {
765
+ "content": "[E-89]",
766
+ "lstrip": false,
767
+ "normalized": false,
768
+ "rstrip": false,
769
+ "single_word": false,
770
+ "special": true
771
+ },
772
+ "128092": {
773
+ "content": "[E-90]",
774
+ "lstrip": false,
775
+ "normalized": false,
776
+ "rstrip": false,
777
+ "single_word": false,
778
+ "special": true
779
+ },
780
+ "128093": {
781
+ "content": "[E-91]",
782
+ "lstrip": false,
783
+ "normalized": false,
784
+ "rstrip": false,
785
+ "single_word": false,
786
+ "special": true
787
+ },
788
+ "128094": {
789
+ "content": "[E-92]",
790
+ "lstrip": false,
791
+ "normalized": false,
792
+ "rstrip": false,
793
+ "single_word": false,
794
+ "special": true
795
+ },
796
+ "128095": {
797
+ "content": "[E-93]",
798
+ "lstrip": false,
799
+ "normalized": false,
800
+ "rstrip": false,
801
+ "single_word": false,
802
+ "special": true
803
+ },
804
+ "128096": {
805
+ "content": "[E-94]",
806
+ "lstrip": false,
807
+ "normalized": false,
808
+ "rstrip": false,
809
+ "single_word": false,
810
+ "special": true
811
+ },
812
+ "128097": {
813
+ "content": "[E-95]",
814
+ "lstrip": false,
815
+ "normalized": false,
816
+ "rstrip": false,
817
+ "single_word": false,
818
+ "special": true
819
+ },
820
+ "128098": {
821
+ "content": "[E-96]",
822
+ "lstrip": false,
823
+ "normalized": false,
824
+ "rstrip": false,
825
+ "single_word": false,
826
+ "special": true
827
+ },
828
+ "128099": {
829
+ "content": "[E-97]",
830
+ "lstrip": false,
831
+ "normalized": false,
832
+ "rstrip": false,
833
+ "single_word": false,
834
+ "special": true
835
+ },
836
+ "128100": {
837
+ "content": "[E-98]",
838
+ "lstrip": false,
839
+ "normalized": false,
840
+ "rstrip": false,
841
+ "single_word": false,
842
+ "special": true
843
+ },
844
+ "128101": {
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
+ }