Add new SentenceTransformer model.
Browse files- 1_Pooling/config.json +10 -0
- README.md +141 -0
- config.json +28 -0
- config_sentence_transformers.json +9 -0
- configuration_norbert.py +34 -0
- model.safetensors +3 -0
- modeling_norbert.py +635 -0
- modules.json +14 -0
- sentence_bert_config.json +4 -0
- special_tokens_map.json +51 -0
- tokenizer.json +0 -0
- tokenizer_config.json +870 -0
1_Pooling/config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"word_embedding_dimension": 768,
|
| 3 |
+
"pooling_mode_cls_token": false,
|
| 4 |
+
"pooling_mode_mean_tokens": true,
|
| 5 |
+
"pooling_mode_max_tokens": false,
|
| 6 |
+
"pooling_mode_mean_sqrt_len_tokens": false,
|
| 7 |
+
"pooling_mode_weightedmean_tokens": false,
|
| 8 |
+
"pooling_mode_lasttoken": false,
|
| 9 |
+
"include_prompt": true
|
| 10 |
+
}
|
README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: sentence-transformers
|
| 3 |
+
pipeline_tag: sentence-similarity
|
| 4 |
+
tags:
|
| 5 |
+
- sentence-transformers
|
| 6 |
+
- feature-extraction
|
| 7 |
+
- sentence-similarity
|
| 8 |
+
- transformers
|
| 9 |
+
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# tollefj/norbert3-multiloss-embedder
|
| 13 |
+
|
| 14 |
+
This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search.
|
| 15 |
+
|
| 16 |
+
<!--- Describe your model here -->
|
| 17 |
+
|
| 18 |
+
## Usage (Sentence-Transformers)
|
| 19 |
+
|
| 20 |
+
Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
|
| 21 |
+
|
| 22 |
+
```
|
| 23 |
+
pip install -U sentence-transformers
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
Then you can use the model like this:
|
| 27 |
+
|
| 28 |
+
```python
|
| 29 |
+
from sentence_transformers import SentenceTransformer
|
| 30 |
+
sentences = ["This is an example sentence", "Each sentence is converted"]
|
| 31 |
+
|
| 32 |
+
model = SentenceTransformer('tollefj/norbert3-multiloss-embedder')
|
| 33 |
+
embeddings = model.encode(sentences)
|
| 34 |
+
print(embeddings)
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
## Usage (HuggingFace Transformers)
|
| 40 |
+
Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
from transformers import AutoTokenizer, AutoModel
|
| 44 |
+
import torch
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
#Mean Pooling - Take attention mask into account for correct averaging
|
| 48 |
+
def mean_pooling(model_output, attention_mask):
|
| 49 |
+
token_embeddings = model_output[0] #First element of model_output contains all token embeddings
|
| 50 |
+
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
|
| 51 |
+
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
# Sentences we want sentence embeddings for
|
| 55 |
+
sentences = ['This is an example sentence', 'Each sentence is converted']
|
| 56 |
+
|
| 57 |
+
# Load model from HuggingFace Hub
|
| 58 |
+
tokenizer = AutoTokenizer.from_pretrained('tollefj/norbert3-multiloss-embedder')
|
| 59 |
+
model = AutoModel.from_pretrained('tollefj/norbert3-multiloss-embedder')
|
| 60 |
+
|
| 61 |
+
# Tokenize sentences
|
| 62 |
+
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
|
| 63 |
+
|
| 64 |
+
# Compute token embeddings
|
| 65 |
+
with torch.no_grad():
|
| 66 |
+
model_output = model(**encoded_input)
|
| 67 |
+
|
| 68 |
+
# Perform pooling. In this case, mean pooling.
|
| 69 |
+
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
|
| 70 |
+
|
| 71 |
+
print("Sentence embeddings:")
|
| 72 |
+
print(sentence_embeddings)
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
## Evaluation Results
|
| 78 |
+
|
| 79 |
+
<!--- Describe how your model was evaluated -->
|
| 80 |
+
|
| 81 |
+
For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name=tollefj/norbert3-multiloss-embedder)
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
## Training
|
| 85 |
+
The model was trained with the parameters:
|
| 86 |
+
|
| 87 |
+
**DataLoader**:
|
| 88 |
+
|
| 89 |
+
`sentence_transformers.datasets.NoDuplicatesDataLoader.NoDuplicatesDataLoader` of length 1952 with parameters:
|
| 90 |
+
```
|
| 91 |
+
{'batch_size': 32}
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
**Loss**:
|
| 95 |
+
|
| 96 |
+
`sentence_transformers.losses.CosineSimilarityLoss.CosineSimilarityLoss`
|
| 97 |
+
|
| 98 |
+
**DataLoader**:
|
| 99 |
+
|
| 100 |
+
`sentence_transformers.datasets.NoDuplicatesDataLoader.NoDuplicatesDataLoader` of length 4002 with parameters:
|
| 101 |
+
```
|
| 102 |
+
{'batch_size': 32}
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
**Loss**:
|
| 106 |
+
|
| 107 |
+
`sentence_transformers.losses.MultipleNegativesRankingLoss.MultipleNegativesRankingLoss` with parameters:
|
| 108 |
+
```
|
| 109 |
+
{'scale': 20.0, 'similarity_fct': 'cos_sim'}
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
Parameters of the fit()-Method:
|
| 113 |
+
```
|
| 114 |
+
{
|
| 115 |
+
"epochs": 1,
|
| 116 |
+
"evaluation_steps": 100,
|
| 117 |
+
"evaluator": "sentence_transformers.evaluation.EmbeddingSimilarityEvaluator.EmbeddingSimilarityEvaluator",
|
| 118 |
+
"max_grad_norm": 1,
|
| 119 |
+
"optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
|
| 120 |
+
"optimizer_params": {
|
| 121 |
+
"lr": 5e-05
|
| 122 |
+
},
|
| 123 |
+
"scheduler": "WarmupLinear",
|
| 124 |
+
"steps_per_epoch": null,
|
| 125 |
+
"warmup_steps": 596,
|
| 126 |
+
"weight_decay": 0.01
|
| 127 |
+
}
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
## Full Model Architecture
|
| 132 |
+
```
|
| 133 |
+
SentenceTransformer(
|
| 134 |
+
(0): Transformer({'max_seq_length': 192, 'do_lower_case': False}) with Transformer model: NorbertModel
|
| 135 |
+
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
|
| 136 |
+
)
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
## Citing & Authors
|
| 140 |
+
|
| 141 |
+
<!--- Describe where people can find more information -->
|
config.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "ltg/norbert3-base",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"NorbertModel"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"auto_map": {
|
| 8 |
+
"AutoConfig": "configuration_norbert.NorbertConfig",
|
| 9 |
+
"AutoModel": "modeling_norbert.NorbertModel",
|
| 10 |
+
"AutoModelForMaskedLM": "ltg/norbert3-base--modeling_norbert.NorbertForMaskedLM",
|
| 11 |
+
"AutoModelForMultipleChoice": "ltg/norbert3-base--modeling_norbert.NorbertForMultipleChoice",
|
| 12 |
+
"AutoModelForQuestionAnswering": "ltg/norbert3-base--modeling_norbert.NorbertForQuestionAnswering",
|
| 13 |
+
"AutoModelForSequenceClassification": "ltg/norbert3-base--modeling_norbert.NorbertForSequenceClassification",
|
| 14 |
+
"AutoModelForTokenClassification": "ltg/norbert3-base--modeling_norbert.NorbertForTokenClassification"
|
| 15 |
+
},
|
| 16 |
+
"hidden_dropout_prob": 0.1,
|
| 17 |
+
"hidden_size": 768,
|
| 18 |
+
"intermediate_size": 2048,
|
| 19 |
+
"layer_norm_eps": 1e-07,
|
| 20 |
+
"max_position_embeddings": 512,
|
| 21 |
+
"num_attention_heads": 12,
|
| 22 |
+
"num_hidden_layers": 12,
|
| 23 |
+
"output_all_encoded_layers": true,
|
| 24 |
+
"position_bucket_size": 32,
|
| 25 |
+
"torch_dtype": "float32",
|
| 26 |
+
"transformers_version": "4.38.2",
|
| 27 |
+
"vocab_size": 50000
|
| 28 |
+
}
|
config_sentence_transformers.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"__version__": {
|
| 3 |
+
"sentence_transformers": "2.5.1",
|
| 4 |
+
"transformers": "4.38.2",
|
| 5 |
+
"pytorch": "2.2.1+cu121"
|
| 6 |
+
},
|
| 7 |
+
"prompts": {},
|
| 8 |
+
"default_prompt_name": null
|
| 9 |
+
}
|
configuration_norbert.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class NorbertConfig(PretrainedConfig):
|
| 5 |
+
"""Configuration class to store the configuration of a `NorbertModel`.
|
| 6 |
+
"""
|
| 7 |
+
def __init__(
|
| 8 |
+
self,
|
| 9 |
+
vocab_size=50000,
|
| 10 |
+
attention_probs_dropout_prob=0.1,
|
| 11 |
+
hidden_dropout_prob=0.1,
|
| 12 |
+
hidden_size=768,
|
| 13 |
+
intermediate_size=2048,
|
| 14 |
+
max_position_embeddings=512,
|
| 15 |
+
position_bucket_size=32,
|
| 16 |
+
num_attention_heads=12,
|
| 17 |
+
num_hidden_layers=12,
|
| 18 |
+
layer_norm_eps=1.0e-7,
|
| 19 |
+
output_all_encoded_layers=True,
|
| 20 |
+
**kwargs,
|
| 21 |
+
):
|
| 22 |
+
super().__init__(**kwargs)
|
| 23 |
+
|
| 24 |
+
self.vocab_size = vocab_size
|
| 25 |
+
self.hidden_size = hidden_size
|
| 26 |
+
self.num_hidden_layers = num_hidden_layers
|
| 27 |
+
self.num_attention_heads = num_attention_heads
|
| 28 |
+
self.intermediate_size = intermediate_size
|
| 29 |
+
self.hidden_dropout_prob = hidden_dropout_prob
|
| 30 |
+
self.attention_probs_dropout_prob = attention_probs_dropout_prob
|
| 31 |
+
self.max_position_embeddings = max_position_embeddings
|
| 32 |
+
self.output_all_encoded_layers = output_all_encoded_layers
|
| 33 |
+
self.position_bucket_size = position_bucket_size
|
| 34 |
+
self.layer_norm_eps = layer_norm_eps
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f8aa5e291ba60a59390f0db357fe7925baf3c5d1813a7d5e341e21b7b47ab2d7
|
| 3 |
+
size 518941336
|
modeling_norbert.py
ADDED
|
@@ -0,0 +1,635 @@
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
from typing import List, Optional, Tuple, Union
|
| 3 |
+
|
| 4 |
+
import torch
|
| 5 |
+
import torch.nn as nn
|
| 6 |
+
import torch.nn.functional as F
|
| 7 |
+
from torch.utils import checkpoint
|
| 8 |
+
|
| 9 |
+
from .configuration_norbert import NorbertConfig
|
| 10 |
+
from transformers.modeling_utils import PreTrainedModel
|
| 11 |
+
from transformers.activations import gelu_new
|
| 12 |
+
from transformers.modeling_outputs import (
|
| 13 |
+
MaskedLMOutput,
|
| 14 |
+
MultipleChoiceModelOutput,
|
| 15 |
+
QuestionAnsweringModelOutput,
|
| 16 |
+
SequenceClassifierOutput,
|
| 17 |
+
TokenClassifierOutput,
|
| 18 |
+
BaseModelOutput
|
| 19 |
+
)
|
| 20 |
+
from transformers.pytorch_utils import softmax_backward_data
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class Encoder(nn.Module):
|
| 24 |
+
def __init__(self, config, activation_checkpointing=False):
|
| 25 |
+
super().__init__()
|
| 26 |
+
self.layers = nn.ModuleList([EncoderLayer(config) for _ in range(config.num_hidden_layers)])
|
| 27 |
+
|
| 28 |
+
for i, layer in enumerate(self.layers):
|
| 29 |
+
layer.mlp.mlp[1].weight.data *= math.sqrt(1.0 / (2.0 * (1 + i)))
|
| 30 |
+
layer.mlp.mlp[-2].weight.data *= math.sqrt(1.0 / (2.0 * (1 + i)))
|
| 31 |
+
|
| 32 |
+
self.activation_checkpointing = activation_checkpointing
|
| 33 |
+
|
| 34 |
+
def forward(self, hidden_states, attention_mask, relative_embedding):
|
| 35 |
+
hidden_states, attention_probs = [hidden_states], []
|
| 36 |
+
|
| 37 |
+
for layer in self.layers:
|
| 38 |
+
if self.activation_checkpointing:
|
| 39 |
+
hidden_state, attention_p = checkpoint.checkpoint(layer, hidden_states[-1], attention_mask, relative_embedding)
|
| 40 |
+
else:
|
| 41 |
+
hidden_state, attention_p = layer(hidden_states[-1], attention_mask, relative_embedding)
|
| 42 |
+
|
| 43 |
+
hidden_states.append(hidden_state)
|
| 44 |
+
attention_probs.append(attention_p)
|
| 45 |
+
|
| 46 |
+
return hidden_states, attention_probs
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
class MaskClassifier(nn.Module):
|
| 50 |
+
def __init__(self, config, subword_embedding):
|
| 51 |
+
super().__init__()
|
| 52 |
+
self.nonlinearity = nn.Sequential(
|
| 53 |
+
nn.LayerNorm(config.hidden_size, config.layer_norm_eps, elementwise_affine=False),
|
| 54 |
+
nn.Linear(config.hidden_size, config.hidden_size),
|
| 55 |
+
nn.GELU(),
|
| 56 |
+
nn.LayerNorm(config.hidden_size, config.layer_norm_eps, elementwise_affine=False),
|
| 57 |
+
nn.Dropout(config.hidden_dropout_prob),
|
| 58 |
+
nn.Linear(subword_embedding.size(1), subword_embedding.size(0))
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
def forward(self, x, masked_lm_labels=None):
|
| 62 |
+
if masked_lm_labels is not None:
|
| 63 |
+
x = torch.index_select(x.flatten(0, 1), 0, torch.nonzero(masked_lm_labels.flatten() != -100).squeeze())
|
| 64 |
+
x = self.nonlinearity(x)
|
| 65 |
+
return x
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
class EncoderLayer(nn.Module):
|
| 69 |
+
def __init__(self, config):
|
| 70 |
+
super().__init__()
|
| 71 |
+
self.attention = Attention(config)
|
| 72 |
+
self.mlp = FeedForward(config)
|
| 73 |
+
|
| 74 |
+
def forward(self, x, padding_mask, relative_embedding):
|
| 75 |
+
attention_output, attention_probs = self.attention(x, padding_mask, relative_embedding)
|
| 76 |
+
x = x + attention_output
|
| 77 |
+
x = x + self.mlp(x)
|
| 78 |
+
return x, attention_probs
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
class GeGLU(nn.Module):
|
| 82 |
+
def forward(self, x):
|
| 83 |
+
x, gate = x.chunk(2, dim=-1)
|
| 84 |
+
x = x * gelu_new(gate)
|
| 85 |
+
return x
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
class FeedForward(nn.Module):
|
| 89 |
+
def __init__(self, config):
|
| 90 |
+
super().__init__()
|
| 91 |
+
self.mlp = nn.Sequential(
|
| 92 |
+
nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps, elementwise_affine=False),
|
| 93 |
+
nn.Linear(config.hidden_size, 2*config.intermediate_size, bias=False),
|
| 94 |
+
GeGLU(),
|
| 95 |
+
nn.LayerNorm(config.intermediate_size, eps=config.layer_norm_eps, elementwise_affine=False),
|
| 96 |
+
nn.Linear(config.intermediate_size, config.hidden_size, bias=False),
|
| 97 |
+
nn.Dropout(config.hidden_dropout_prob)
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
def forward(self, x):
|
| 101 |
+
return self.mlp(x)
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
class MaskedSoftmax(torch.autograd.Function):
|
| 105 |
+
@staticmethod
|
| 106 |
+
def forward(self, x, mask, dim):
|
| 107 |
+
self.dim = dim
|
| 108 |
+
x.masked_fill_(mask, float('-inf'))
|
| 109 |
+
x = torch.softmax(x, self.dim)
|
| 110 |
+
x.masked_fill_(mask, 0.0)
|
| 111 |
+
self.save_for_backward(x)
|
| 112 |
+
return x
|
| 113 |
+
|
| 114 |
+
@staticmethod
|
| 115 |
+
def backward(self, grad_output):
|
| 116 |
+
output, = self.saved_tensors
|
| 117 |
+
input_grad = softmax_backward_data(self, grad_output, output, self.dim, output)
|
| 118 |
+
return input_grad, None, None
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
class Attention(nn.Module):
|
| 122 |
+
def __init__(self, config):
|
| 123 |
+
super().__init__()
|
| 124 |
+
|
| 125 |
+
self.config = config
|
| 126 |
+
|
| 127 |
+
if config.hidden_size % config.num_attention_heads != 0:
|
| 128 |
+
raise ValueError(f"The hidden size {config.hidden_size} is not a multiple of the number of attention heads {config.num_attention_heads}")
|
| 129 |
+
|
| 130 |
+
self.hidden_size = config.hidden_size
|
| 131 |
+
self.num_heads = config.num_attention_heads
|
| 132 |
+
self.head_size = config.hidden_size // config.num_attention_heads
|
| 133 |
+
|
| 134 |
+
self.in_proj_qk = nn.Linear(config.hidden_size, 2*config.hidden_size, bias=True)
|
| 135 |
+
self.in_proj_v = nn.Linear(config.hidden_size, config.hidden_size, bias=True)
|
| 136 |
+
self.out_proj = nn.Linear(config.hidden_size, config.hidden_size, bias=True)
|
| 137 |
+
|
| 138 |
+
self.pre_layer_norm = nn.LayerNorm(config.hidden_size, config.layer_norm_eps, elementwise_affine=False)
|
| 139 |
+
self.post_layer_norm = nn.LayerNorm(config.hidden_size, config.layer_norm_eps, elementwise_affine=True)
|
| 140 |
+
|
| 141 |
+
position_indices = torch.arange(config.max_position_embeddings, dtype=torch.long).unsqueeze(1) \
|
| 142 |
+
- torch.arange(config.max_position_embeddings, dtype=torch.long).unsqueeze(0)
|
| 143 |
+
position_indices = self.make_log_bucket_position(position_indices, config.position_bucket_size, config.max_position_embeddings)
|
| 144 |
+
position_indices = config.position_bucket_size - 1 + position_indices
|
| 145 |
+
self.register_buffer("position_indices", position_indices, persistent=True)
|
| 146 |
+
|
| 147 |
+
self.dropout = nn.Dropout(config.attention_probs_dropout_prob)
|
| 148 |
+
self.scale = 1.0 / math.sqrt(3 * self.head_size)
|
| 149 |
+
|
| 150 |
+
def make_log_bucket_position(self, relative_pos, bucket_size, max_position):
|
| 151 |
+
sign = torch.sign(relative_pos)
|
| 152 |
+
mid = bucket_size // 2
|
| 153 |
+
abs_pos = torch.where((relative_pos < mid) & (relative_pos > -mid), mid - 1, torch.abs(relative_pos).clamp(max=max_position - 1))
|
| 154 |
+
log_pos = torch.ceil(torch.log(abs_pos / mid) / math.log((max_position-1) / mid) * (mid - 1)).int() + mid
|
| 155 |
+
bucket_pos = torch.where(abs_pos <= mid, relative_pos, log_pos * sign).long()
|
| 156 |
+
return bucket_pos
|
| 157 |
+
|
| 158 |
+
def compute_attention_scores(self, hidden_states, relative_embedding):
|
| 159 |
+
key_len, batch_size, _ = hidden_states.size()
|
| 160 |
+
query_len = key_len
|
| 161 |
+
|
| 162 |
+
if self.position_indices.size(0) < query_len:
|
| 163 |
+
position_indices = torch.arange(query_len, dtype=torch.long).unsqueeze(1) \
|
| 164 |
+
- torch.arange(query_len, dtype=torch.long).unsqueeze(0)
|
| 165 |
+
position_indices = self.make_log_bucket_position(position_indices, self.position_bucket_size, 512)
|
| 166 |
+
position_indices = self.position_bucket_size - 1 + position_indices
|
| 167 |
+
self.position_indices = position_indices.to(hidden_states.device)
|
| 168 |
+
|
| 169 |
+
hidden_states = self.pre_layer_norm(hidden_states)
|
| 170 |
+
|
| 171 |
+
query, key = self.in_proj_qk(hidden_states).chunk(2, dim=2) # shape: [T, B, D]
|
| 172 |
+
value = self.in_proj_v(hidden_states) # shape: [T, B, D]
|
| 173 |
+
|
| 174 |
+
query = query.reshape(query_len, batch_size * self.num_heads, self.head_size).transpose(0, 1)
|
| 175 |
+
key = key.reshape(key_len, batch_size * self.num_heads, self.head_size).transpose(0, 1)
|
| 176 |
+
value = value.view(key_len, batch_size * self.num_heads, self.head_size).transpose(0, 1)
|
| 177 |
+
|
| 178 |
+
attention_scores = torch.bmm(query, key.transpose(1, 2) * self.scale)
|
| 179 |
+
|
| 180 |
+
pos = self.in_proj_qk(self.dropout(relative_embedding)) # shape: [2T-1, 2D]
|
| 181 |
+
query_pos, key_pos = pos.view(-1, self.num_heads, 2*self.head_size).chunk(2, dim=2)
|
| 182 |
+
query = query.view(batch_size, self.num_heads, query_len, self.head_size)
|
| 183 |
+
key = key.view(batch_size, self.num_heads, query_len, self.head_size)
|
| 184 |
+
|
| 185 |
+
attention_c_p = torch.einsum("bhqd,khd->bhqk", query, key_pos.squeeze(1) * self.scale)
|
| 186 |
+
attention_p_c = torch.einsum("bhkd,qhd->bhqk", key * self.scale, query_pos.squeeze(1))
|
| 187 |
+
|
| 188 |
+
position_indices = self.position_indices[:query_len, :key_len].expand(batch_size, self.num_heads, -1, -1)
|
| 189 |
+
attention_c_p = attention_c_p.gather(3, position_indices)
|
| 190 |
+
attention_p_c = attention_p_c.gather(2, position_indices)
|
| 191 |
+
|
| 192 |
+
attention_scores = attention_scores.view(batch_size, self.num_heads, query_len, key_len)
|
| 193 |
+
attention_scores.add_(attention_c_p)
|
| 194 |
+
attention_scores.add_(attention_p_c)
|
| 195 |
+
|
| 196 |
+
return attention_scores, value
|
| 197 |
+
|
| 198 |
+
def compute_output(self, attention_probs, value):
|
| 199 |
+
attention_probs = self.dropout(attention_probs)
|
| 200 |
+
context = torch.bmm(attention_probs.flatten(0, 1), value) # shape: [B*H, Q, D]
|
| 201 |
+
context = context.transpose(0, 1).reshape(context.size(1), -1, self.hidden_size) # shape: [Q, B, H*D]
|
| 202 |
+
context = self.out_proj(context)
|
| 203 |
+
context = self.post_layer_norm(context)
|
| 204 |
+
context = self.dropout(context)
|
| 205 |
+
return context
|
| 206 |
+
|
| 207 |
+
def forward(self, hidden_states, attention_mask, relative_embedding):
|
| 208 |
+
attention_scores, value = self.compute_attention_scores(hidden_states, relative_embedding)
|
| 209 |
+
attention_probs = MaskedSoftmax.apply(attention_scores, attention_mask, -1)
|
| 210 |
+
return self.compute_output(attention_probs, value), attention_probs.detach()
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
class Embedding(nn.Module):
|
| 214 |
+
def __init__(self, config):
|
| 215 |
+
super().__init__()
|
| 216 |
+
self.hidden_size = config.hidden_size
|
| 217 |
+
|
| 218 |
+
self.word_embedding = nn.Embedding(config.vocab_size, config.hidden_size)
|
| 219 |
+
self.word_layer_norm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps, elementwise_affine=False)
|
| 220 |
+
self.dropout = nn.Dropout(config.hidden_dropout_prob)
|
| 221 |
+
|
| 222 |
+
self.relative_embedding = nn.Parameter(torch.empty(2 * config.position_bucket_size - 1, config.hidden_size))
|
| 223 |
+
self.relative_layer_norm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
|
| 224 |
+
|
| 225 |
+
def forward(self, input_ids):
|
| 226 |
+
word_embedding = self.dropout(self.word_layer_norm(self.word_embedding(input_ids)))
|
| 227 |
+
relative_embeddings = self.relative_layer_norm(self.relative_embedding)
|
| 228 |
+
return word_embedding, relative_embeddings
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
#
|
| 232 |
+
# HuggingFace wrappers
|
| 233 |
+
#
|
| 234 |
+
|
| 235 |
+
class NorbertPreTrainedModel(PreTrainedModel):
|
| 236 |
+
config_class = NorbertConfig
|
| 237 |
+
base_model_prefix = "norbert3"
|
| 238 |
+
supports_gradient_checkpointing = True
|
| 239 |
+
|
| 240 |
+
def _set_gradient_checkpointing(self, module, value=False):
|
| 241 |
+
if isinstance(module, Encoder):
|
| 242 |
+
module.activation_checkpointing = value
|
| 243 |
+
|
| 244 |
+
def _init_weights(self, module):
|
| 245 |
+
std = math.sqrt(2.0 / (5.0 * self.hidden_size))
|
| 246 |
+
|
| 247 |
+
if isinstance(module, nn.Linear):
|
| 248 |
+
nn.init.trunc_normal_(module.weight.data, mean=0.0, std=std, a=-2*std, b=2*std)
|
| 249 |
+
if module.bias is not None:
|
| 250 |
+
module.bias.data.zero_()
|
| 251 |
+
elif isinstance(module, nn.Embedding):
|
| 252 |
+
nn.init.trunc_normal_(module.weight.data, mean=0.0, std=std, a=-2*std, b=2*std)
|
| 253 |
+
elif isinstance(module, nn.LayerNorm):
|
| 254 |
+
module.bias.data.zero_()
|
| 255 |
+
module.weight.data.fill_(1.0)
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
class NorbertModel(NorbertPreTrainedModel):
|
| 259 |
+
def __init__(self, config, add_mlm_layer=False, gradient_checkpointing=False, **kwargs):
|
| 260 |
+
super().__init__(config, **kwargs)
|
| 261 |
+
self.config = config
|
| 262 |
+
self.hidden_size = config.hidden_size
|
| 263 |
+
|
| 264 |
+
self.embedding = Embedding(config)
|
| 265 |
+
self.transformer = Encoder(config, activation_checkpointing=gradient_checkpointing)
|
| 266 |
+
self.classifier = MaskClassifier(config, self.embedding.word_embedding.weight) if add_mlm_layer else None
|
| 267 |
+
|
| 268 |
+
def get_input_embeddings(self):
|
| 269 |
+
return self.embedding.word_embedding
|
| 270 |
+
|
| 271 |
+
def set_input_embeddings(self, value):
|
| 272 |
+
self.embedding.word_embedding = value
|
| 273 |
+
|
| 274 |
+
def get_contextualized_embeddings(
|
| 275 |
+
self,
|
| 276 |
+
input_ids: Optional[torch.Tensor] = None,
|
| 277 |
+
attention_mask: Optional[torch.Tensor] = None
|
| 278 |
+
) -> List[torch.Tensor]:
|
| 279 |
+
if input_ids is not None:
|
| 280 |
+
input_shape = input_ids.size()
|
| 281 |
+
else:
|
| 282 |
+
raise ValueError("You have to specify input_ids")
|
| 283 |
+
|
| 284 |
+
batch_size, seq_length = input_shape
|
| 285 |
+
device = input_ids.device
|
| 286 |
+
|
| 287 |
+
if attention_mask is None:
|
| 288 |
+
attention_mask = torch.zeros(batch_size, seq_length, dtype=torch.bool, device=device)
|
| 289 |
+
else:
|
| 290 |
+
attention_mask = ~attention_mask.bool()
|
| 291 |
+
attention_mask = attention_mask.unsqueeze(1).unsqueeze(2)
|
| 292 |
+
|
| 293 |
+
static_embeddings, relative_embedding = self.embedding(input_ids.t())
|
| 294 |
+
contextualized_embeddings, attention_probs = self.transformer(static_embeddings, attention_mask, relative_embedding)
|
| 295 |
+
contextualized_embeddings = [e.transpose(0, 1) for e in contextualized_embeddings]
|
| 296 |
+
last_layer = contextualized_embeddings[-1]
|
| 297 |
+
contextualized_embeddings = [contextualized_embeddings[0]] + [
|
| 298 |
+
contextualized_embeddings[i] - contextualized_embeddings[i - 1]
|
| 299 |
+
for i in range(1, len(contextualized_embeddings))
|
| 300 |
+
]
|
| 301 |
+
return last_layer, contextualized_embeddings, attention_probs
|
| 302 |
+
|
| 303 |
+
def forward(
|
| 304 |
+
self,
|
| 305 |
+
input_ids: Optional[torch.Tensor] = None,
|
| 306 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 307 |
+
token_type_ids: Optional[torch.Tensor] = None,
|
| 308 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 309 |
+
output_hidden_states: Optional[bool] = None,
|
| 310 |
+
output_attentions: Optional[bool] = None,
|
| 311 |
+
return_dict: Optional[bool] = None,
|
| 312 |
+
**kwargs
|
| 313 |
+
) -> Union[Tuple[torch.Tensor], BaseModelOutput]:
|
| 314 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 315 |
+
|
| 316 |
+
sequence_output, contextualized_embeddings, attention_probs = self.get_contextualized_embeddings(input_ids, attention_mask)
|
| 317 |
+
|
| 318 |
+
if not return_dict:
|
| 319 |
+
return (
|
| 320 |
+
sequence_output,
|
| 321 |
+
*([contextualized_embeddings] if output_hidden_states else []),
|
| 322 |
+
*([attention_probs] if output_attentions else [])
|
| 323 |
+
)
|
| 324 |
+
|
| 325 |
+
return BaseModelOutput(
|
| 326 |
+
last_hidden_state=sequence_output,
|
| 327 |
+
hidden_states=contextualized_embeddings if output_hidden_states else None,
|
| 328 |
+
attentions=attention_probs if output_attentions else None
|
| 329 |
+
)
|
| 330 |
+
|
| 331 |
+
|
| 332 |
+
class NorbertForMaskedLM(NorbertModel):
|
| 333 |
+
_keys_to_ignore_on_load_unexpected = ["head"]
|
| 334 |
+
|
| 335 |
+
def __init__(self, config, **kwargs):
|
| 336 |
+
super().__init__(config, add_mlm_layer=True, **kwargs)
|
| 337 |
+
|
| 338 |
+
def get_output_embeddings(self):
|
| 339 |
+
return self.classifier.nonlinearity[-1].weight
|
| 340 |
+
|
| 341 |
+
def set_output_embeddings(self, new_embeddings):
|
| 342 |
+
self.classifier.nonlinearity[-1].weight = new_embeddings
|
| 343 |
+
|
| 344 |
+
def forward(
|
| 345 |
+
self,
|
| 346 |
+
input_ids: Optional[torch.Tensor] = None,
|
| 347 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 348 |
+
token_type_ids: Optional[torch.Tensor] = None,
|
| 349 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 350 |
+
output_hidden_states: Optional[bool] = None,
|
| 351 |
+
output_attentions: Optional[bool] = None,
|
| 352 |
+
return_dict: Optional[bool] = None,
|
| 353 |
+
labels: Optional[torch.LongTensor] = None,
|
| 354 |
+
**kwargs
|
| 355 |
+
) -> Union[Tuple[torch.Tensor], MaskedLMOutput]:
|
| 356 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 357 |
+
|
| 358 |
+
sequence_output, contextualized_embeddings, attention_probs = self.get_contextualized_embeddings(input_ids, attention_mask)
|
| 359 |
+
subword_prediction = self.classifier(sequence_output)
|
| 360 |
+
subword_prediction[:, :, :106+1] = float("-inf")
|
| 361 |
+
|
| 362 |
+
masked_lm_loss = None
|
| 363 |
+
if labels is not None:
|
| 364 |
+
masked_lm_loss = F.cross_entropy(subword_prediction.flatten(0, 1), labels.flatten())
|
| 365 |
+
|
| 366 |
+
if not return_dict:
|
| 367 |
+
output = (
|
| 368 |
+
subword_prediction,
|
| 369 |
+
*([contextualized_embeddings] if output_hidden_states else []),
|
| 370 |
+
*([attention_probs] if output_attentions else [])
|
| 371 |
+
)
|
| 372 |
+
return ((masked_lm_loss,) + output) if masked_lm_loss is not None else output
|
| 373 |
+
|
| 374 |
+
return MaskedLMOutput(
|
| 375 |
+
loss=masked_lm_loss,
|
| 376 |
+
logits=subword_prediction,
|
| 377 |
+
hidden_states=contextualized_embeddings if output_hidden_states else None,
|
| 378 |
+
attentions=attention_probs if output_attentions else None
|
| 379 |
+
)
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
class Classifier(nn.Module):
|
| 383 |
+
def __init__(self, config, num_labels: int):
|
| 384 |
+
super().__init__()
|
| 385 |
+
|
| 386 |
+
drop_out = getattr(config, "cls_dropout", None)
|
| 387 |
+
drop_out = config.hidden_dropout_prob if drop_out is None else drop_out
|
| 388 |
+
|
| 389 |
+
self.nonlinearity = nn.Sequential(
|
| 390 |
+
nn.LayerNorm(config.hidden_size, config.layer_norm_eps, elementwise_affine=False),
|
| 391 |
+
nn.Linear(config.hidden_size, config.hidden_size),
|
| 392 |
+
nn.GELU(),
|
| 393 |
+
nn.LayerNorm(config.hidden_size, config.layer_norm_eps, elementwise_affine=False),
|
| 394 |
+
nn.Dropout(drop_out),
|
| 395 |
+
nn.Linear(config.hidden_size, num_labels)
|
| 396 |
+
)
|
| 397 |
+
|
| 398 |
+
def forward(self, x):
|
| 399 |
+
x = self.nonlinearity(x)
|
| 400 |
+
return x
|
| 401 |
+
|
| 402 |
+
|
| 403 |
+
class NorbertForSequenceClassification(NorbertModel):
|
| 404 |
+
_keys_to_ignore_on_load_unexpected = ["classifier"]
|
| 405 |
+
_keys_to_ignore_on_load_missing = ["head"]
|
| 406 |
+
|
| 407 |
+
def __init__(self, config, **kwargs):
|
| 408 |
+
super().__init__(config, add_mlm_layer=False, **kwargs)
|
| 409 |
+
|
| 410 |
+
self.num_labels = config.num_labels
|
| 411 |
+
self.head = Classifier(config, self.num_labels)
|
| 412 |
+
|
| 413 |
+
def forward(
|
| 414 |
+
self,
|
| 415 |
+
input_ids: Optional[torch.Tensor] = None,
|
| 416 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 417 |
+
token_type_ids: Optional[torch.Tensor] = None,
|
| 418 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 419 |
+
output_attentions: Optional[bool] = None,
|
| 420 |
+
output_hidden_states: Optional[bool] = None,
|
| 421 |
+
return_dict: Optional[bool] = None,
|
| 422 |
+
labels: Optional[torch.LongTensor] = None,
|
| 423 |
+
**kwargs
|
| 424 |
+
) -> Union[Tuple[torch.Tensor], SequenceClassifierOutput]:
|
| 425 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 426 |
+
|
| 427 |
+
sequence_output, contextualized_embeddings, attention_probs = self.get_contextualized_embeddings(input_ids, attention_mask)
|
| 428 |
+
logits = self.head(sequence_output[:, 0, :])
|
| 429 |
+
|
| 430 |
+
loss = None
|
| 431 |
+
if labels is not None:
|
| 432 |
+
if self.config.problem_type is None:
|
| 433 |
+
if self.num_labels == 1:
|
| 434 |
+
self.config.problem_type = "regression"
|
| 435 |
+
elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
|
| 436 |
+
self.config.problem_type = "single_label_classification"
|
| 437 |
+
else:
|
| 438 |
+
self.config.problem_type = "multi_label_classification"
|
| 439 |
+
|
| 440 |
+
if self.config.problem_type == "regression":
|
| 441 |
+
loss_fct = nn.MSELoss()
|
| 442 |
+
if self.num_labels == 1:
|
| 443 |
+
loss = loss_fct(logits.squeeze(), labels.squeeze())
|
| 444 |
+
else:
|
| 445 |
+
loss = loss_fct(logits, labels)
|
| 446 |
+
elif self.config.problem_type == "single_label_classification":
|
| 447 |
+
loss_fct = nn.CrossEntropyLoss()
|
| 448 |
+
loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))
|
| 449 |
+
elif self.config.problem_type == "multi_label_classification":
|
| 450 |
+
loss_fct = nn.BCEWithLogitsLoss()
|
| 451 |
+
loss = loss_fct(logits, labels)
|
| 452 |
+
|
| 453 |
+
if not return_dict:
|
| 454 |
+
output = (
|
| 455 |
+
logits,
|
| 456 |
+
*([contextualized_embeddings] if output_hidden_states else []),
|
| 457 |
+
*([attention_probs] if output_attentions else [])
|
| 458 |
+
)
|
| 459 |
+
return ((loss,) + output) if loss is not None else output
|
| 460 |
+
|
| 461 |
+
return SequenceClassifierOutput(
|
| 462 |
+
loss=loss,
|
| 463 |
+
logits=logits,
|
| 464 |
+
hidden_states=contextualized_embeddings if output_hidden_states else None,
|
| 465 |
+
attentions=attention_probs if output_attentions else None
|
| 466 |
+
)
|
| 467 |
+
|
| 468 |
+
|
| 469 |
+
class NorbertForTokenClassification(NorbertModel):
|
| 470 |
+
_keys_to_ignore_on_load_unexpected = ["classifier"]
|
| 471 |
+
_keys_to_ignore_on_load_missing = ["head"]
|
| 472 |
+
|
| 473 |
+
def __init__(self, config, **kwargs):
|
| 474 |
+
super().__init__(config, add_mlm_layer=False, **kwargs)
|
| 475 |
+
|
| 476 |
+
self.num_labels = config.num_labels
|
| 477 |
+
self.head = Classifier(config, self.num_labels)
|
| 478 |
+
|
| 479 |
+
def forward(
|
| 480 |
+
self,
|
| 481 |
+
input_ids: Optional[torch.Tensor] = None,
|
| 482 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 483 |
+
token_type_ids: Optional[torch.Tensor] = None,
|
| 484 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 485 |
+
output_attentions: Optional[bool] = None,
|
| 486 |
+
output_hidden_states: Optional[bool] = None,
|
| 487 |
+
return_dict: Optional[bool] = None,
|
| 488 |
+
labels: Optional[torch.LongTensor] = None,
|
| 489 |
+
**kwargs
|
| 490 |
+
) -> Union[Tuple[torch.Tensor], TokenClassifierOutput]:
|
| 491 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 492 |
+
|
| 493 |
+
sequence_output, contextualized_embeddings, attention_probs = self.get_contextualized_embeddings(input_ids, attention_mask)
|
| 494 |
+
logits = self.head(sequence_output)
|
| 495 |
+
|
| 496 |
+
loss = None
|
| 497 |
+
if labels is not None:
|
| 498 |
+
loss_fct = nn.CrossEntropyLoss()
|
| 499 |
+
loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))
|
| 500 |
+
|
| 501 |
+
if not return_dict:
|
| 502 |
+
output = (
|
| 503 |
+
logits,
|
| 504 |
+
*([contextualized_embeddings] if output_hidden_states else []),
|
| 505 |
+
*([attention_probs] if output_attentions else [])
|
| 506 |
+
)
|
| 507 |
+
return ((loss,) + output) if loss is not None else output
|
| 508 |
+
|
| 509 |
+
return TokenClassifierOutput(
|
| 510 |
+
loss=loss,
|
| 511 |
+
logits=logits,
|
| 512 |
+
hidden_states=contextualized_embeddings if output_hidden_states else None,
|
| 513 |
+
attentions=attention_probs if output_attentions else None
|
| 514 |
+
)
|
| 515 |
+
|
| 516 |
+
|
| 517 |
+
class NorbertForQuestionAnswering(NorbertModel):
|
| 518 |
+
_keys_to_ignore_on_load_unexpected = ["classifier"]
|
| 519 |
+
_keys_to_ignore_on_load_missing = ["head"]
|
| 520 |
+
|
| 521 |
+
def __init__(self, config, **kwargs):
|
| 522 |
+
super().__init__(config, add_mlm_layer=False, **kwargs)
|
| 523 |
+
|
| 524 |
+
self.num_labels = config.num_labels
|
| 525 |
+
self.head = Classifier(config, self.num_labels)
|
| 526 |
+
|
| 527 |
+
def forward(
|
| 528 |
+
self,
|
| 529 |
+
input_ids: Optional[torch.Tensor] = None,
|
| 530 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 531 |
+
token_type_ids: Optional[torch.Tensor] = None,
|
| 532 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 533 |
+
output_attentions: Optional[bool] = None,
|
| 534 |
+
output_hidden_states: Optional[bool] = None,
|
| 535 |
+
return_dict: Optional[bool] = None,
|
| 536 |
+
start_positions: Optional[torch.Tensor] = None,
|
| 537 |
+
end_positions: Optional[torch.Tensor] = None,
|
| 538 |
+
**kwargs
|
| 539 |
+
) -> Union[Tuple[torch.Tensor], QuestionAnsweringModelOutput]:
|
| 540 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 541 |
+
|
| 542 |
+
sequence_output, contextualized_embeddings, attention_probs = self.get_contextualized_embeddings(input_ids, attention_mask)
|
| 543 |
+
logits = self.head(sequence_output)
|
| 544 |
+
|
| 545 |
+
start_logits, end_logits = logits.split(1, dim=-1)
|
| 546 |
+
start_logits = start_logits.squeeze(-1).contiguous()
|
| 547 |
+
end_logits = end_logits.squeeze(-1).contiguous()
|
| 548 |
+
|
| 549 |
+
total_loss = None
|
| 550 |
+
if start_positions is not None and end_positions is not None:
|
| 551 |
+
# If we are on multi-GPU, split add a dimension
|
| 552 |
+
if len(start_positions.size()) > 1:
|
| 553 |
+
start_positions = start_positions.squeeze(-1)
|
| 554 |
+
if len(end_positions.size()) > 1:
|
| 555 |
+
end_positions = end_positions.squeeze(-1)
|
| 556 |
+
|
| 557 |
+
# sometimes the start/end positions are outside our model inputs, we ignore these terms
|
| 558 |
+
ignored_index = start_logits.size(1)
|
| 559 |
+
start_positions = start_positions.clamp(0, ignored_index)
|
| 560 |
+
end_positions = end_positions.clamp(0, ignored_index)
|
| 561 |
+
|
| 562 |
+
loss_fct = nn.CrossEntropyLoss(ignore_index=ignored_index)
|
| 563 |
+
start_loss = loss_fct(start_logits, start_positions)
|
| 564 |
+
end_loss = loss_fct(end_logits, end_positions)
|
| 565 |
+
total_loss = (start_loss + end_loss) / 2
|
| 566 |
+
|
| 567 |
+
if not return_dict:
|
| 568 |
+
output = (
|
| 569 |
+
start_logits,
|
| 570 |
+
end_logits,
|
| 571 |
+
*([contextualized_embeddings] if output_hidden_states else []),
|
| 572 |
+
*([attention_probs] if output_attentions else [])
|
| 573 |
+
)
|
| 574 |
+
return ((total_loss,) + output) if total_loss is not None else output
|
| 575 |
+
|
| 576 |
+
return QuestionAnsweringModelOutput(
|
| 577 |
+
loss=total_loss,
|
| 578 |
+
start_logits=start_logits,
|
| 579 |
+
end_logits=end_logits,
|
| 580 |
+
hidden_states=contextualized_embeddings if output_hidden_states else None,
|
| 581 |
+
attentions=attention_probs if output_attentions else None
|
| 582 |
+
)
|
| 583 |
+
|
| 584 |
+
|
| 585 |
+
class NorbertForMultipleChoice(NorbertModel):
|
| 586 |
+
_keys_to_ignore_on_load_unexpected = ["classifier"]
|
| 587 |
+
_keys_to_ignore_on_load_missing = ["head"]
|
| 588 |
+
|
| 589 |
+
def __init__(self, config, **kwargs):
|
| 590 |
+
super().__init__(config, add_mlm_layer=False, **kwargs)
|
| 591 |
+
|
| 592 |
+
self.num_labels = getattr(config, "num_labels", 2)
|
| 593 |
+
self.head = Classifier(config, self.num_labels)
|
| 594 |
+
|
| 595 |
+
def forward(
|
| 596 |
+
self,
|
| 597 |
+
input_ids: Optional[torch.Tensor] = None,
|
| 598 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 599 |
+
token_type_ids: Optional[torch.Tensor] = None,
|
| 600 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 601 |
+
labels: Optional[torch.Tensor] = None,
|
| 602 |
+
output_attentions: Optional[bool] = None,
|
| 603 |
+
output_hidden_states: Optional[bool] = None,
|
| 604 |
+
return_dict: Optional[bool] = None,
|
| 605 |
+
**kwargs
|
| 606 |
+
) -> Union[Tuple[torch.Tensor], MultipleChoiceModelOutput]:
|
| 607 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 608 |
+
num_choices = input_ids.shape[1]
|
| 609 |
+
|
| 610 |
+
flat_input_ids = input_ids.view(-1, input_ids.size(-1))
|
| 611 |
+
flat_attention_mask = attention_mask.view(-1, attention_mask.size(-1)) if attention_mask is not None else None
|
| 612 |
+
|
| 613 |
+
sequence_output, contextualized_embeddings, attention_probs = self.get_contextualized_embeddings(flat_input_ids, flat_attention_mask)
|
| 614 |
+
logits = self.head(sequence_output)
|
| 615 |
+
reshaped_logits = logits.view(-1, num_choices)
|
| 616 |
+
|
| 617 |
+
loss = None
|
| 618 |
+
if labels is not None:
|
| 619 |
+
loss_fct = nn.CrossEntropyLoss()
|
| 620 |
+
loss = loss_fct(reshaped_logits, labels)
|
| 621 |
+
|
| 622 |
+
if not return_dict:
|
| 623 |
+
output = (
|
| 624 |
+
reshaped_logits,
|
| 625 |
+
*([contextualized_embeddings] if output_hidden_states else []),
|
| 626 |
+
*([attention_probs] if output_attentions else [])
|
| 627 |
+
)
|
| 628 |
+
return ((loss,) + output) if loss is not None else output
|
| 629 |
+
|
| 630 |
+
return MultipleChoiceModelOutput(
|
| 631 |
+
loss=loss,
|
| 632 |
+
logits=reshaped_logits,
|
| 633 |
+
hidden_states=contextualized_embeddings if output_hidden_states else None,
|
| 634 |
+
attentions=attention_probs if output_attentions else None
|
| 635 |
+
)
|
modules.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"idx": 0,
|
| 4 |
+
"name": "0",
|
| 5 |
+
"path": "",
|
| 6 |
+
"type": "sentence_transformers.models.Transformer"
|
| 7 |
+
},
|
| 8 |
+
{
|
| 9 |
+
"idx": 1,
|
| 10 |
+
"name": "1",
|
| 11 |
+
"path": "1_Pooling",
|
| 12 |
+
"type": "sentence_transformers.models.Pooling"
|
| 13 |
+
}
|
| 14 |
+
]
|
sentence_bert_config.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"max_seq_length": 192,
|
| 3 |
+
"do_lower_case": false
|
| 4 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "[BOS]",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"cls_token": {
|
| 10 |
+
"content": "[CLS]",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"eos_token": {
|
| 17 |
+
"content": "[EOS]",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
},
|
| 23 |
+
"mask_token": {
|
| 24 |
+
"content": "[MASK]",
|
| 25 |
+
"lstrip": false,
|
| 26 |
+
"normalized": false,
|
| 27 |
+
"rstrip": false,
|
| 28 |
+
"single_word": false
|
| 29 |
+
},
|
| 30 |
+
"pad_token": {
|
| 31 |
+
"content": "[PAD]",
|
| 32 |
+
"lstrip": false,
|
| 33 |
+
"normalized": false,
|
| 34 |
+
"rstrip": false,
|
| 35 |
+
"single_word": false
|
| 36 |
+
},
|
| 37 |
+
"sep_token": {
|
| 38 |
+
"content": "[SEP]",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": false,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false
|
| 43 |
+
},
|
| 44 |
+
"unk_token": {
|
| 45 |
+
"content": "[UNK]",
|
| 46 |
+
"lstrip": false,
|
| 47 |
+
"normalized": false,
|
| 48 |
+
"rstrip": false,
|
| 49 |
+
"single_word": false
|
| 50 |
+
}
|
| 51 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,870 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[UNK]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"1": {
|
| 12 |
+
"content": "[CLS]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"2": {
|
| 20 |
+
"content": "[SEP]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"3": {
|
| 28 |
+
"content": "[PAD]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"4": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
},
|
| 43 |
+
"5": {
|
| 44 |
+
"content": "[BOS]",
|
| 45 |
+
"lstrip": false,
|
| 46 |
+
"normalized": false,
|
| 47 |
+
"rstrip": false,
|
| 48 |
+
"single_word": false,
|
| 49 |
+
"special": true
|
| 50 |
+
},
|
| 51 |
+
"6": {
|
| 52 |
+
"content": "[EOS]",
|
| 53 |
+
"lstrip": false,
|
| 54 |
+
"normalized": false,
|
| 55 |
+
"rstrip": false,
|
| 56 |
+
"single_word": false,
|
| 57 |
+
"special": true
|
| 58 |
+
},
|
| 59 |
+
"7": {
|
| 60 |
+
"content": "[MASK_0]",
|
| 61 |
+
"lstrip": false,
|
| 62 |
+
"normalized": false,
|
| 63 |
+
"rstrip": false,
|
| 64 |
+
"single_word": false,
|
| 65 |
+
"special": true
|
| 66 |
+
},
|
| 67 |
+
"8": {
|
| 68 |
+
"content": "[MASK_1]",
|
| 69 |
+
"lstrip": false,
|
| 70 |
+
"normalized": false,
|
| 71 |
+
"rstrip": false,
|
| 72 |
+
"single_word": false,
|
| 73 |
+
"special": true
|
| 74 |
+
},
|
| 75 |
+
"9": {
|
| 76 |
+
"content": "[MASK_2]",
|
| 77 |
+
"lstrip": false,
|
| 78 |
+
"normalized": false,
|
| 79 |
+
"rstrip": false,
|
| 80 |
+
"single_word": false,
|
| 81 |
+
"special": true
|
| 82 |
+
},
|
| 83 |
+
"10": {
|
| 84 |
+
"content": "[MASK_3]",
|
| 85 |
+
"lstrip": false,
|
| 86 |
+
"normalized": false,
|
| 87 |
+
"rstrip": false,
|
| 88 |
+
"single_word": false,
|
| 89 |
+
"special": true
|
| 90 |
+
},
|
| 91 |
+
"11": {
|
| 92 |
+
"content": "[MASK_4]",
|
| 93 |
+
"lstrip": false,
|
| 94 |
+
"normalized": false,
|
| 95 |
+
"rstrip": false,
|
| 96 |
+
"single_word": false,
|
| 97 |
+
"special": true
|
| 98 |
+
},
|
| 99 |
+
"12": {
|
| 100 |
+
"content": "[MASK_5]",
|
| 101 |
+
"lstrip": false,
|
| 102 |
+
"normalized": false,
|
| 103 |
+
"rstrip": false,
|
| 104 |
+
"single_word": false,
|
| 105 |
+
"special": true
|
| 106 |
+
},
|
| 107 |
+
"13": {
|
| 108 |
+
"content": "[MASK_6]",
|
| 109 |
+
"lstrip": false,
|
| 110 |
+
"normalized": false,
|
| 111 |
+
"rstrip": false,
|
| 112 |
+
"single_word": false,
|
| 113 |
+
"special": true
|
| 114 |
+
},
|
| 115 |
+
"14": {
|
| 116 |
+
"content": "[MASK_7]",
|
| 117 |
+
"lstrip": false,
|
| 118 |
+
"normalized": false,
|
| 119 |
+
"rstrip": false,
|
| 120 |
+
"single_word": false,
|
| 121 |
+
"special": true
|
| 122 |
+
},
|
| 123 |
+
"15": {
|
| 124 |
+
"content": "[MASK_8]",
|
| 125 |
+
"lstrip": false,
|
| 126 |
+
"normalized": false,
|
| 127 |
+
"rstrip": false,
|
| 128 |
+
"single_word": false,
|
| 129 |
+
"special": true
|
| 130 |
+
},
|
| 131 |
+
"16": {
|
| 132 |
+
"content": "[MASK_9]",
|
| 133 |
+
"lstrip": false,
|
| 134 |
+
"normalized": false,
|
| 135 |
+
"rstrip": false,
|
| 136 |
+
"single_word": false,
|
| 137 |
+
"special": true
|
| 138 |
+
},
|
| 139 |
+
"17": {
|
| 140 |
+
"content": "[MASK_10]",
|
| 141 |
+
"lstrip": false,
|
| 142 |
+
"normalized": false,
|
| 143 |
+
"rstrip": false,
|
| 144 |
+
"single_word": false,
|
| 145 |
+
"special": true
|
| 146 |
+
},
|
| 147 |
+
"18": {
|
| 148 |
+
"content": "[MASK_11]",
|
| 149 |
+
"lstrip": false,
|
| 150 |
+
"normalized": false,
|
| 151 |
+
"rstrip": false,
|
| 152 |
+
"single_word": false,
|
| 153 |
+
"special": true
|
| 154 |
+
},
|
| 155 |
+
"19": {
|
| 156 |
+
"content": "[MASK_12]",
|
| 157 |
+
"lstrip": false,
|
| 158 |
+
"normalized": false,
|
| 159 |
+
"rstrip": false,
|
| 160 |
+
"single_word": false,
|
| 161 |
+
"special": true
|
| 162 |
+
},
|
| 163 |
+
"20": {
|
| 164 |
+
"content": "[MASK_13]",
|
| 165 |
+
"lstrip": false,
|
| 166 |
+
"normalized": false,
|
| 167 |
+
"rstrip": false,
|
| 168 |
+
"single_word": false,
|
| 169 |
+
"special": true
|
| 170 |
+
},
|
| 171 |
+
"21": {
|
| 172 |
+
"content": "[MASK_14]",
|
| 173 |
+
"lstrip": false,
|
| 174 |
+
"normalized": false,
|
| 175 |
+
"rstrip": false,
|
| 176 |
+
"single_word": false,
|
| 177 |
+
"special": true
|
| 178 |
+
},
|
| 179 |
+
"22": {
|
| 180 |
+
"content": "[MASK_15]",
|
| 181 |
+
"lstrip": false,
|
| 182 |
+
"normalized": false,
|
| 183 |
+
"rstrip": false,
|
| 184 |
+
"single_word": false,
|
| 185 |
+
"special": true
|
| 186 |
+
},
|
| 187 |
+
"23": {
|
| 188 |
+
"content": "[MASK_16]",
|
| 189 |
+
"lstrip": false,
|
| 190 |
+
"normalized": false,
|
| 191 |
+
"rstrip": false,
|
| 192 |
+
"single_word": false,
|
| 193 |
+
"special": true
|
| 194 |
+
},
|
| 195 |
+
"24": {
|
| 196 |
+
"content": "[MASK_17]",
|
| 197 |
+
"lstrip": false,
|
| 198 |
+
"normalized": false,
|
| 199 |
+
"rstrip": false,
|
| 200 |
+
"single_word": false,
|
| 201 |
+
"special": true
|
| 202 |
+
},
|
| 203 |
+
"25": {
|
| 204 |
+
"content": "[MASK_18]",
|
| 205 |
+
"lstrip": false,
|
| 206 |
+
"normalized": false,
|
| 207 |
+
"rstrip": false,
|
| 208 |
+
"single_word": false,
|
| 209 |
+
"special": true
|
| 210 |
+
},
|
| 211 |
+
"26": {
|
| 212 |
+
"content": "[MASK_19]",
|
| 213 |
+
"lstrip": false,
|
| 214 |
+
"normalized": false,
|
| 215 |
+
"rstrip": false,
|
| 216 |
+
"single_word": false,
|
| 217 |
+
"special": true
|
| 218 |
+
},
|
| 219 |
+
"27": {
|
| 220 |
+
"content": "[MASK_20]",
|
| 221 |
+
"lstrip": false,
|
| 222 |
+
"normalized": false,
|
| 223 |
+
"rstrip": false,
|
| 224 |
+
"single_word": false,
|
| 225 |
+
"special": true
|
| 226 |
+
},
|
| 227 |
+
"28": {
|
| 228 |
+
"content": "[MASK_21]",
|
| 229 |
+
"lstrip": false,
|
| 230 |
+
"normalized": false,
|
| 231 |
+
"rstrip": false,
|
| 232 |
+
"single_word": false,
|
| 233 |
+
"special": true
|
| 234 |
+
},
|
| 235 |
+
"29": {
|
| 236 |
+
"content": "[MASK_22]",
|
| 237 |
+
"lstrip": false,
|
| 238 |
+
"normalized": false,
|
| 239 |
+
"rstrip": false,
|
| 240 |
+
"single_word": false,
|
| 241 |
+
"special": true
|
| 242 |
+
},
|
| 243 |
+
"30": {
|
| 244 |
+
"content": "[MASK_23]",
|
| 245 |
+
"lstrip": false,
|
| 246 |
+
"normalized": false,
|
| 247 |
+
"rstrip": false,
|
| 248 |
+
"single_word": false,
|
| 249 |
+
"special": true
|
| 250 |
+
},
|
| 251 |
+
"31": {
|
| 252 |
+
"content": "[MASK_24]",
|
| 253 |
+
"lstrip": false,
|
| 254 |
+
"normalized": false,
|
| 255 |
+
"rstrip": false,
|
| 256 |
+
"single_word": false,
|
| 257 |
+
"special": true
|
| 258 |
+
},
|
| 259 |
+
"32": {
|
| 260 |
+
"content": "[MASK_25]",
|
| 261 |
+
"lstrip": false,
|
| 262 |
+
"normalized": false,
|
| 263 |
+
"rstrip": false,
|
| 264 |
+
"single_word": false,
|
| 265 |
+
"special": true
|
| 266 |
+
},
|
| 267 |
+
"33": {
|
| 268 |
+
"content": "[MASK_26]",
|
| 269 |
+
"lstrip": false,
|
| 270 |
+
"normalized": false,
|
| 271 |
+
"rstrip": false,
|
| 272 |
+
"single_word": false,
|
| 273 |
+
"special": true
|
| 274 |
+
},
|
| 275 |
+
"34": {
|
| 276 |
+
"content": "[MASK_27]",
|
| 277 |
+
"lstrip": false,
|
| 278 |
+
"normalized": false,
|
| 279 |
+
"rstrip": false,
|
| 280 |
+
"single_word": false,
|
| 281 |
+
"special": true
|
| 282 |
+
},
|
| 283 |
+
"35": {
|
| 284 |
+
"content": "[MASK_28]",
|
| 285 |
+
"lstrip": false,
|
| 286 |
+
"normalized": false,
|
| 287 |
+
"rstrip": false,
|
| 288 |
+
"single_word": false,
|
| 289 |
+
"special": true
|
| 290 |
+
},
|
| 291 |
+
"36": {
|
| 292 |
+
"content": "[MASK_29]",
|
| 293 |
+
"lstrip": false,
|
| 294 |
+
"normalized": false,
|
| 295 |
+
"rstrip": false,
|
| 296 |
+
"single_word": false,
|
| 297 |
+
"special": true
|
| 298 |
+
},
|
| 299 |
+
"37": {
|
| 300 |
+
"content": "[MASK_30]",
|
| 301 |
+
"lstrip": false,
|
| 302 |
+
"normalized": false,
|
| 303 |
+
"rstrip": false,
|
| 304 |
+
"single_word": false,
|
| 305 |
+
"special": true
|
| 306 |
+
},
|
| 307 |
+
"38": {
|
| 308 |
+
"content": "[MASK_31]",
|
| 309 |
+
"lstrip": false,
|
| 310 |
+
"normalized": false,
|
| 311 |
+
"rstrip": false,
|
| 312 |
+
"single_word": false,
|
| 313 |
+
"special": true
|
| 314 |
+
},
|
| 315 |
+
"39": {
|
| 316 |
+
"content": "[MASK_32]",
|
| 317 |
+
"lstrip": false,
|
| 318 |
+
"normalized": false,
|
| 319 |
+
"rstrip": false,
|
| 320 |
+
"single_word": false,
|
| 321 |
+
"special": true
|
| 322 |
+
},
|
| 323 |
+
"40": {
|
| 324 |
+
"content": "[MASK_33]",
|
| 325 |
+
"lstrip": false,
|
| 326 |
+
"normalized": false,
|
| 327 |
+
"rstrip": false,
|
| 328 |
+
"single_word": false,
|
| 329 |
+
"special": true
|
| 330 |
+
},
|
| 331 |
+
"41": {
|
| 332 |
+
"content": "[MASK_34]",
|
| 333 |
+
"lstrip": false,
|
| 334 |
+
"normalized": false,
|
| 335 |
+
"rstrip": false,
|
| 336 |
+
"single_word": false,
|
| 337 |
+
"special": true
|
| 338 |
+
},
|
| 339 |
+
"42": {
|
| 340 |
+
"content": "[MASK_35]",
|
| 341 |
+
"lstrip": false,
|
| 342 |
+
"normalized": false,
|
| 343 |
+
"rstrip": false,
|
| 344 |
+
"single_word": false,
|
| 345 |
+
"special": true
|
| 346 |
+
},
|
| 347 |
+
"43": {
|
| 348 |
+
"content": "[MASK_36]",
|
| 349 |
+
"lstrip": false,
|
| 350 |
+
"normalized": false,
|
| 351 |
+
"rstrip": false,
|
| 352 |
+
"single_word": false,
|
| 353 |
+
"special": true
|
| 354 |
+
},
|
| 355 |
+
"44": {
|
| 356 |
+
"content": "[MASK_37]",
|
| 357 |
+
"lstrip": false,
|
| 358 |
+
"normalized": false,
|
| 359 |
+
"rstrip": false,
|
| 360 |
+
"single_word": false,
|
| 361 |
+
"special": true
|
| 362 |
+
},
|
| 363 |
+
"45": {
|
| 364 |
+
"content": "[MASK_38]",
|
| 365 |
+
"lstrip": false,
|
| 366 |
+
"normalized": false,
|
| 367 |
+
"rstrip": false,
|
| 368 |
+
"single_word": false,
|
| 369 |
+
"special": true
|
| 370 |
+
},
|
| 371 |
+
"46": {
|
| 372 |
+
"content": "[MASK_39]",
|
| 373 |
+
"lstrip": false,
|
| 374 |
+
"normalized": false,
|
| 375 |
+
"rstrip": false,
|
| 376 |
+
"single_word": false,
|
| 377 |
+
"special": true
|
| 378 |
+
},
|
| 379 |
+
"47": {
|
| 380 |
+
"content": "[MASK_40]",
|
| 381 |
+
"lstrip": false,
|
| 382 |
+
"normalized": false,
|
| 383 |
+
"rstrip": false,
|
| 384 |
+
"single_word": false,
|
| 385 |
+
"special": true
|
| 386 |
+
},
|
| 387 |
+
"48": {
|
| 388 |
+
"content": "[MASK_41]",
|
| 389 |
+
"lstrip": false,
|
| 390 |
+
"normalized": false,
|
| 391 |
+
"rstrip": false,
|
| 392 |
+
"single_word": false,
|
| 393 |
+
"special": true
|
| 394 |
+
},
|
| 395 |
+
"49": {
|
| 396 |
+
"content": "[MASK_42]",
|
| 397 |
+
"lstrip": false,
|
| 398 |
+
"normalized": false,
|
| 399 |
+
"rstrip": false,
|
| 400 |
+
"single_word": false,
|
| 401 |
+
"special": true
|
| 402 |
+
},
|
| 403 |
+
"50": {
|
| 404 |
+
"content": "[MASK_43]",
|
| 405 |
+
"lstrip": false,
|
| 406 |
+
"normalized": false,
|
| 407 |
+
"rstrip": false,
|
| 408 |
+
"single_word": false,
|
| 409 |
+
"special": true
|
| 410 |
+
},
|
| 411 |
+
"51": {
|
| 412 |
+
"content": "[MASK_44]",
|
| 413 |
+
"lstrip": false,
|
| 414 |
+
"normalized": false,
|
| 415 |
+
"rstrip": false,
|
| 416 |
+
"single_word": false,
|
| 417 |
+
"special": true
|
| 418 |
+
},
|
| 419 |
+
"52": {
|
| 420 |
+
"content": "[MASK_45]",
|
| 421 |
+
"lstrip": false,
|
| 422 |
+
"normalized": false,
|
| 423 |
+
"rstrip": false,
|
| 424 |
+
"single_word": false,
|
| 425 |
+
"special": true
|
| 426 |
+
},
|
| 427 |
+
"53": {
|
| 428 |
+
"content": "[MASK_46]",
|
| 429 |
+
"lstrip": false,
|
| 430 |
+
"normalized": false,
|
| 431 |
+
"rstrip": false,
|
| 432 |
+
"single_word": false,
|
| 433 |
+
"special": true
|
| 434 |
+
},
|
| 435 |
+
"54": {
|
| 436 |
+
"content": "[MASK_47]",
|
| 437 |
+
"lstrip": false,
|
| 438 |
+
"normalized": false,
|
| 439 |
+
"rstrip": false,
|
| 440 |
+
"single_word": false,
|
| 441 |
+
"special": true
|
| 442 |
+
},
|
| 443 |
+
"55": {
|
| 444 |
+
"content": "[MASK_48]",
|
| 445 |
+
"lstrip": false,
|
| 446 |
+
"normalized": false,
|
| 447 |
+
"rstrip": false,
|
| 448 |
+
"single_word": false,
|
| 449 |
+
"special": true
|
| 450 |
+
},
|
| 451 |
+
"56": {
|
| 452 |
+
"content": "[MASK_49]",
|
| 453 |
+
"lstrip": false,
|
| 454 |
+
"normalized": false,
|
| 455 |
+
"rstrip": false,
|
| 456 |
+
"single_word": false,
|
| 457 |
+
"special": true
|
| 458 |
+
},
|
| 459 |
+
"57": {
|
| 460 |
+
"content": "[MASK_50]",
|
| 461 |
+
"lstrip": false,
|
| 462 |
+
"normalized": false,
|
| 463 |
+
"rstrip": false,
|
| 464 |
+
"single_word": false,
|
| 465 |
+
"special": true
|
| 466 |
+
},
|
| 467 |
+
"58": {
|
| 468 |
+
"content": "[MASK_51]",
|
| 469 |
+
"lstrip": false,
|
| 470 |
+
"normalized": false,
|
| 471 |
+
"rstrip": false,
|
| 472 |
+
"single_word": false,
|
| 473 |
+
"special": true
|
| 474 |
+
},
|
| 475 |
+
"59": {
|
| 476 |
+
"content": "[MASK_52]",
|
| 477 |
+
"lstrip": false,
|
| 478 |
+
"normalized": false,
|
| 479 |
+
"rstrip": false,
|
| 480 |
+
"single_word": false,
|
| 481 |
+
"special": true
|
| 482 |
+
},
|
| 483 |
+
"60": {
|
| 484 |
+
"content": "[MASK_53]",
|
| 485 |
+
"lstrip": false,
|
| 486 |
+
"normalized": false,
|
| 487 |
+
"rstrip": false,
|
| 488 |
+
"single_word": false,
|
| 489 |
+
"special": true
|
| 490 |
+
},
|
| 491 |
+
"61": {
|
| 492 |
+
"content": "[MASK_54]",
|
| 493 |
+
"lstrip": false,
|
| 494 |
+
"normalized": false,
|
| 495 |
+
"rstrip": false,
|
| 496 |
+
"single_word": false,
|
| 497 |
+
"special": true
|
| 498 |
+
},
|
| 499 |
+
"62": {
|
| 500 |
+
"content": "[MASK_55]",
|
| 501 |
+
"lstrip": false,
|
| 502 |
+
"normalized": false,
|
| 503 |
+
"rstrip": false,
|
| 504 |
+
"single_word": false,
|
| 505 |
+
"special": true
|
| 506 |
+
},
|
| 507 |
+
"63": {
|
| 508 |
+
"content": "[MASK_56]",
|
| 509 |
+
"lstrip": false,
|
| 510 |
+
"normalized": false,
|
| 511 |
+
"rstrip": false,
|
| 512 |
+
"single_word": false,
|
| 513 |
+
"special": true
|
| 514 |
+
},
|
| 515 |
+
"64": {
|
| 516 |
+
"content": "[MASK_57]",
|
| 517 |
+
"lstrip": false,
|
| 518 |
+
"normalized": false,
|
| 519 |
+
"rstrip": false,
|
| 520 |
+
"single_word": false,
|
| 521 |
+
"special": true
|
| 522 |
+
},
|
| 523 |
+
"65": {
|
| 524 |
+
"content": "[MASK_58]",
|
| 525 |
+
"lstrip": false,
|
| 526 |
+
"normalized": false,
|
| 527 |
+
"rstrip": false,
|
| 528 |
+
"single_word": false,
|
| 529 |
+
"special": true
|
| 530 |
+
},
|
| 531 |
+
"66": {
|
| 532 |
+
"content": "[MASK_59]",
|
| 533 |
+
"lstrip": false,
|
| 534 |
+
"normalized": false,
|
| 535 |
+
"rstrip": false,
|
| 536 |
+
"single_word": false,
|
| 537 |
+
"special": true
|
| 538 |
+
},
|
| 539 |
+
"67": {
|
| 540 |
+
"content": "[MASK_60]",
|
| 541 |
+
"lstrip": false,
|
| 542 |
+
"normalized": false,
|
| 543 |
+
"rstrip": false,
|
| 544 |
+
"single_word": false,
|
| 545 |
+
"special": true
|
| 546 |
+
},
|
| 547 |
+
"68": {
|
| 548 |
+
"content": "[MASK_61]",
|
| 549 |
+
"lstrip": false,
|
| 550 |
+
"normalized": false,
|
| 551 |
+
"rstrip": false,
|
| 552 |
+
"single_word": false,
|
| 553 |
+
"special": true
|
| 554 |
+
},
|
| 555 |
+
"69": {
|
| 556 |
+
"content": "[MASK_62]",
|
| 557 |
+
"lstrip": false,
|
| 558 |
+
"normalized": false,
|
| 559 |
+
"rstrip": false,
|
| 560 |
+
"single_word": false,
|
| 561 |
+
"special": true
|
| 562 |
+
},
|
| 563 |
+
"70": {
|
| 564 |
+
"content": "[MASK_63]",
|
| 565 |
+
"lstrip": false,
|
| 566 |
+
"normalized": false,
|
| 567 |
+
"rstrip": false,
|
| 568 |
+
"single_word": false,
|
| 569 |
+
"special": true
|
| 570 |
+
},
|
| 571 |
+
"71": {
|
| 572 |
+
"content": "[MASK_64]",
|
| 573 |
+
"lstrip": false,
|
| 574 |
+
"normalized": false,
|
| 575 |
+
"rstrip": false,
|
| 576 |
+
"single_word": false,
|
| 577 |
+
"special": true
|
| 578 |
+
},
|
| 579 |
+
"72": {
|
| 580 |
+
"content": "[MASK_65]",
|
| 581 |
+
"lstrip": false,
|
| 582 |
+
"normalized": false,
|
| 583 |
+
"rstrip": false,
|
| 584 |
+
"single_word": false,
|
| 585 |
+
"special": true
|
| 586 |
+
},
|
| 587 |
+
"73": {
|
| 588 |
+
"content": "[MASK_66]",
|
| 589 |
+
"lstrip": false,
|
| 590 |
+
"normalized": false,
|
| 591 |
+
"rstrip": false,
|
| 592 |
+
"single_word": false,
|
| 593 |
+
"special": true
|
| 594 |
+
},
|
| 595 |
+
"74": {
|
| 596 |
+
"content": "[MASK_67]",
|
| 597 |
+
"lstrip": false,
|
| 598 |
+
"normalized": false,
|
| 599 |
+
"rstrip": false,
|
| 600 |
+
"single_word": false,
|
| 601 |
+
"special": true
|
| 602 |
+
},
|
| 603 |
+
"75": {
|
| 604 |
+
"content": "[MASK_68]",
|
| 605 |
+
"lstrip": false,
|
| 606 |
+
"normalized": false,
|
| 607 |
+
"rstrip": false,
|
| 608 |
+
"single_word": false,
|
| 609 |
+
"special": true
|
| 610 |
+
},
|
| 611 |
+
"76": {
|
| 612 |
+
"content": "[MASK_69]",
|
| 613 |
+
"lstrip": false,
|
| 614 |
+
"normalized": false,
|
| 615 |
+
"rstrip": false,
|
| 616 |
+
"single_word": false,
|
| 617 |
+
"special": true
|
| 618 |
+
},
|
| 619 |
+
"77": {
|
| 620 |
+
"content": "[MASK_70]",
|
| 621 |
+
"lstrip": false,
|
| 622 |
+
"normalized": false,
|
| 623 |
+
"rstrip": false,
|
| 624 |
+
"single_word": false,
|
| 625 |
+
"special": true
|
| 626 |
+
},
|
| 627 |
+
"78": {
|
| 628 |
+
"content": "[MASK_71]",
|
| 629 |
+
"lstrip": false,
|
| 630 |
+
"normalized": false,
|
| 631 |
+
"rstrip": false,
|
| 632 |
+
"single_word": false,
|
| 633 |
+
"special": true
|
| 634 |
+
},
|
| 635 |
+
"79": {
|
| 636 |
+
"content": "[MASK_72]",
|
| 637 |
+
"lstrip": false,
|
| 638 |
+
"normalized": false,
|
| 639 |
+
"rstrip": false,
|
| 640 |
+
"single_word": false,
|
| 641 |
+
"special": true
|
| 642 |
+
},
|
| 643 |
+
"80": {
|
| 644 |
+
"content": "[MASK_73]",
|
| 645 |
+
"lstrip": false,
|
| 646 |
+
"normalized": false,
|
| 647 |
+
"rstrip": false,
|
| 648 |
+
"single_word": false,
|
| 649 |
+
"special": true
|
| 650 |
+
},
|
| 651 |
+
"81": {
|
| 652 |
+
"content": "[MASK_74]",
|
| 653 |
+
"lstrip": false,
|
| 654 |
+
"normalized": false,
|
| 655 |
+
"rstrip": false,
|
| 656 |
+
"single_word": false,
|
| 657 |
+
"special": true
|
| 658 |
+
},
|
| 659 |
+
"82": {
|
| 660 |
+
"content": "[MASK_75]",
|
| 661 |
+
"lstrip": false,
|
| 662 |
+
"normalized": false,
|
| 663 |
+
"rstrip": false,
|
| 664 |
+
"single_word": false,
|
| 665 |
+
"special": true
|
| 666 |
+
},
|
| 667 |
+
"83": {
|
| 668 |
+
"content": "[MASK_76]",
|
| 669 |
+
"lstrip": false,
|
| 670 |
+
"normalized": false,
|
| 671 |
+
"rstrip": false,
|
| 672 |
+
"single_word": false,
|
| 673 |
+
"special": true
|
| 674 |
+
},
|
| 675 |
+
"84": {
|
| 676 |
+
"content": "[MASK_77]",
|
| 677 |
+
"lstrip": false,
|
| 678 |
+
"normalized": false,
|
| 679 |
+
"rstrip": false,
|
| 680 |
+
"single_word": false,
|
| 681 |
+
"special": true
|
| 682 |
+
},
|
| 683 |
+
"85": {
|
| 684 |
+
"content": "[MASK_78]",
|
| 685 |
+
"lstrip": false,
|
| 686 |
+
"normalized": false,
|
| 687 |
+
"rstrip": false,
|
| 688 |
+
"single_word": false,
|
| 689 |
+
"special": true
|
| 690 |
+
},
|
| 691 |
+
"86": {
|
| 692 |
+
"content": "[MASK_79]",
|
| 693 |
+
"lstrip": false,
|
| 694 |
+
"normalized": false,
|
| 695 |
+
"rstrip": false,
|
| 696 |
+
"single_word": false,
|
| 697 |
+
"special": true
|
| 698 |
+
},
|
| 699 |
+
"87": {
|
| 700 |
+
"content": "[MASK_80]",
|
| 701 |
+
"lstrip": false,
|
| 702 |
+
"normalized": false,
|
| 703 |
+
"rstrip": false,
|
| 704 |
+
"single_word": false,
|
| 705 |
+
"special": true
|
| 706 |
+
},
|
| 707 |
+
"88": {
|
| 708 |
+
"content": "[MASK_81]",
|
| 709 |
+
"lstrip": false,
|
| 710 |
+
"normalized": false,
|
| 711 |
+
"rstrip": false,
|
| 712 |
+
"single_word": false,
|
| 713 |
+
"special": true
|
| 714 |
+
},
|
| 715 |
+
"89": {
|
| 716 |
+
"content": "[MASK_82]",
|
| 717 |
+
"lstrip": false,
|
| 718 |
+
"normalized": false,
|
| 719 |
+
"rstrip": false,
|
| 720 |
+
"single_word": false,
|
| 721 |
+
"special": true
|
| 722 |
+
},
|
| 723 |
+
"90": {
|
| 724 |
+
"content": "[MASK_83]",
|
| 725 |
+
"lstrip": false,
|
| 726 |
+
"normalized": false,
|
| 727 |
+
"rstrip": false,
|
| 728 |
+
"single_word": false,
|
| 729 |
+
"special": true
|
| 730 |
+
},
|
| 731 |
+
"91": {
|
| 732 |
+
"content": "[MASK_84]",
|
| 733 |
+
"lstrip": false,
|
| 734 |
+
"normalized": false,
|
| 735 |
+
"rstrip": false,
|
| 736 |
+
"single_word": false,
|
| 737 |
+
"special": true
|
| 738 |
+
},
|
| 739 |
+
"92": {
|
| 740 |
+
"content": "[MASK_85]",
|
| 741 |
+
"lstrip": false,
|
| 742 |
+
"normalized": false,
|
| 743 |
+
"rstrip": false,
|
| 744 |
+
"single_word": false,
|
| 745 |
+
"special": true
|
| 746 |
+
},
|
| 747 |
+
"93": {
|
| 748 |
+
"content": "[MASK_86]",
|
| 749 |
+
"lstrip": false,
|
| 750 |
+
"normalized": false,
|
| 751 |
+
"rstrip": false,
|
| 752 |
+
"single_word": false,
|
| 753 |
+
"special": true
|
| 754 |
+
},
|
| 755 |
+
"94": {
|
| 756 |
+
"content": "[MASK_87]",
|
| 757 |
+
"lstrip": false,
|
| 758 |
+
"normalized": false,
|
| 759 |
+
"rstrip": false,
|
| 760 |
+
"single_word": false,
|
| 761 |
+
"special": true
|
| 762 |
+
},
|
| 763 |
+
"95": {
|
| 764 |
+
"content": "[MASK_88]",
|
| 765 |
+
"lstrip": false,
|
| 766 |
+
"normalized": false,
|
| 767 |
+
"rstrip": false,
|
| 768 |
+
"single_word": false,
|
| 769 |
+
"special": true
|
| 770 |
+
},
|
| 771 |
+
"96": {
|
| 772 |
+
"content": "[MASK_89]",
|
| 773 |
+
"lstrip": false,
|
| 774 |
+
"normalized": false,
|
| 775 |
+
"rstrip": false,
|
| 776 |
+
"single_word": false,
|
| 777 |
+
"special": true
|
| 778 |
+
},
|
| 779 |
+
"97": {
|
| 780 |
+
"content": "[MASK_90]",
|
| 781 |
+
"lstrip": false,
|
| 782 |
+
"normalized": false,
|
| 783 |
+
"rstrip": false,
|
| 784 |
+
"single_word": false,
|
| 785 |
+
"special": true
|
| 786 |
+
},
|
| 787 |
+
"98": {
|
| 788 |
+
"content": "[MASK_91]",
|
| 789 |
+
"lstrip": false,
|
| 790 |
+
"normalized": false,
|
| 791 |
+
"rstrip": false,
|
| 792 |
+
"single_word": false,
|
| 793 |
+
"special": true
|
| 794 |
+
},
|
| 795 |
+
"99": {
|
| 796 |
+
"content": "[MASK_92]",
|
| 797 |
+
"lstrip": false,
|
| 798 |
+
"normalized": false,
|
| 799 |
+
"rstrip": false,
|
| 800 |
+
"single_word": false,
|
| 801 |
+
"special": true
|
| 802 |
+
},
|
| 803 |
+
"100": {
|
| 804 |
+
"content": "[MASK_93]",
|
| 805 |
+
"lstrip": false,
|
| 806 |
+
"normalized": false,
|
| 807 |
+
"rstrip": false,
|
| 808 |
+
"single_word": false,
|
| 809 |
+
"special": true
|
| 810 |
+
},
|
| 811 |
+
"101": {
|
| 812 |
+
"content": "[MASK_94]",
|
| 813 |
+
"lstrip": false,
|
| 814 |
+
"normalized": false,
|
| 815 |
+
"rstrip": false,
|
| 816 |
+
"single_word": false,
|
| 817 |
+
"special": true
|
| 818 |
+
},
|
| 819 |
+
"102": {
|
| 820 |
+
"content": "[MASK_95]",
|
| 821 |
+
"lstrip": false,
|
| 822 |
+
"normalized": false,
|
| 823 |
+
"rstrip": false,
|
| 824 |
+
"single_word": false,
|
| 825 |
+
"special": true
|
| 826 |
+
},
|
| 827 |
+
"103": {
|
| 828 |
+
"content": "[MASK_96]",
|
| 829 |
+
"lstrip": false,
|
| 830 |
+
"normalized": false,
|
| 831 |
+
"rstrip": false,
|
| 832 |
+
"single_word": false,
|
| 833 |
+
"special": true
|
| 834 |
+
},
|
| 835 |
+
"104": {
|
| 836 |
+
"content": "[MASK_97]",
|
| 837 |
+
"lstrip": false,
|
| 838 |
+
"normalized": false,
|
| 839 |
+
"rstrip": false,
|
| 840 |
+
"single_word": false,
|
| 841 |
+
"special": true
|
| 842 |
+
},
|
| 843 |
+
"105": {
|
| 844 |
+
"content": "[MASK_98]",
|
| 845 |
+
"lstrip": false,
|
| 846 |
+
"normalized": false,
|
| 847 |
+
"rstrip": false,
|
| 848 |
+
"single_word": false,
|
| 849 |
+
"special": true
|
| 850 |
+
},
|
| 851 |
+
"106": {
|
| 852 |
+
"content": "[MASK_99]",
|
| 853 |
+
"lstrip": false,
|
| 854 |
+
"normalized": false,
|
| 855 |
+
"rstrip": false,
|
| 856 |
+
"single_word": false,
|
| 857 |
+
"special": true
|
| 858 |
+
}
|
| 859 |
+
},
|
| 860 |
+
"bos_token": "[BOS]",
|
| 861 |
+
"clean_up_tokenization_spaces": true,
|
| 862 |
+
"cls_token": "[CLS]",
|
| 863 |
+
"eos_token": "[EOS]",
|
| 864 |
+
"mask_token": "[MASK]",
|
| 865 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 866 |
+
"pad_token": "[PAD]",
|
| 867 |
+
"sep_token": "[SEP]",
|
| 868 |
+
"tokenizer_class": "PreTrainedTokenizerFast",
|
| 869 |
+
"unk_token": "[UNK]"
|
| 870 |
+
}
|