Add model and tokenizer files
Browse files- README.md +259 -0
- config.json +30 -0
- model.safetensors +3 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +7 -0
- tokenizer.json +0 -0
- tokenizer_config.json +56 -0
- vocab.txt +0 -0
README.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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+
- cv
|
| 26 |
+
- hr
|
| 27 |
+
- cs
|
| 28 |
+
- da
|
| 29 |
+
- nl
|
| 30 |
+
- en
|
| 31 |
+
- et
|
| 32 |
+
- fi
|
| 33 |
+
- fr
|
| 34 |
+
- gl
|
| 35 |
+
- ka
|
| 36 |
+
- de
|
| 37 |
+
- el
|
| 38 |
+
- gu
|
| 39 |
+
- ht
|
| 40 |
+
- he
|
| 41 |
+
- hi
|
| 42 |
+
- hu
|
| 43 |
+
- is
|
| 44 |
+
- io
|
| 45 |
+
- id
|
| 46 |
+
- ga
|
| 47 |
+
- it
|
| 48 |
+
- ja
|
| 49 |
+
- jv
|
| 50 |
+
- kn
|
| 51 |
+
- kk
|
| 52 |
+
- ky
|
| 53 |
+
- ko
|
| 54 |
+
- la
|
| 55 |
+
- lv
|
| 56 |
+
- lt
|
| 57 |
+
- roa
|
| 58 |
+
- nds
|
| 59 |
+
- lm
|
| 60 |
+
- mk
|
| 61 |
+
- mg
|
| 62 |
+
- ms
|
| 63 |
+
- ml
|
| 64 |
+
- mr
|
| 65 |
+
- mn
|
| 66 |
+
- min
|
| 67 |
+
- ne
|
| 68 |
+
- new
|
| 69 |
+
- nb
|
| 70 |
+
- nn
|
| 71 |
+
- oc
|
| 72 |
+
- fa
|
| 73 |
+
- pms
|
| 74 |
+
- pl
|
| 75 |
+
- pt
|
| 76 |
+
- pa
|
| 77 |
+
- ro
|
| 78 |
+
- ru
|
| 79 |
+
- sco
|
| 80 |
+
- sr
|
| 81 |
+
- hr
|
| 82 |
+
- scn
|
| 83 |
+
- sk
|
| 84 |
+
- sl
|
| 85 |
+
- aze
|
| 86 |
+
- es
|
| 87 |
+
- su
|
| 88 |
+
- sw
|
| 89 |
+
- sv
|
| 90 |
+
- tl
|
| 91 |
+
- tg
|
| 92 |
+
- th
|
| 93 |
+
- ta
|
| 94 |
+
- tt
|
| 95 |
+
- te
|
| 96 |
+
- tr
|
| 97 |
+
- uk
|
| 98 |
+
- ud
|
| 99 |
+
- uz
|
| 100 |
+
- vi
|
| 101 |
+
- vo
|
| 102 |
+
- war
|
| 103 |
+
- cy
|
| 104 |
+
- fry
|
| 105 |
+
- pnb
|
| 106 |
+
- yo
|
| 107 |
+
license: apache-2.0
|
| 108 |
+
datasets:
|
| 109 |
+
- wikipedia
|
| 110 |
+
---
|
| 111 |
+
|
| 112 |
+
This a trained version of
|
| 113 |
+
bert-base-multilingual-cased which is trained on a large scale energy QA judging dataset. This is the model at step 1220.
|
| 114 |
+
|
| 115 |
+
# BERT multilingual base model (cased)
|
| 116 |
+
|
| 117 |
+
Pretrained model on the top 104 languages with the largest Wikipedia using a masked language modeling (MLM) objective.
|
| 118 |
+
It was introduced in [this paper](https://arxiv.org/abs/1810.04805) and first released in
|
| 119 |
+
[this repository](https://github.com/google-research/bert). This model is case sensitive: it makes a difference
|
| 120 |
+
between english and English.
|
| 121 |
+
|
| 122 |
+
Disclaimer: The team releasing BERT did not write a model card for this model so this model card has been written by
|
| 123 |
+
the Hugging Face team.
|
| 124 |
+
|
| 125 |
+
## Model description
|
| 126 |
+
|
| 127 |
+
BERT is a transformers model pretrained on a large corpus of multilingual data in a self-supervised fashion. This means
|
| 128 |
+
it was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of
|
| 129 |
+
publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely, it
|
| 130 |
+
was pretrained with two objectives:
|
| 131 |
+
|
| 132 |
+
- Masked language modeling (MLM): taking a sentence, the model randomly masks 15% of the words in the input then run
|
| 133 |
+
the entire masked sentence through the model and has to predict the masked words. This is different from traditional
|
| 134 |
+
recurrent neural networks (RNNs) that usually see the words one after the other, or from autoregressive models like
|
| 135 |
+
GPT which internally mask the future tokens. It allows the model to learn a bidirectional representation of the
|
| 136 |
+
sentence.
|
| 137 |
+
- Next sentence prediction (NSP): the models concatenates two masked sentences as inputs during pretraining. Sometimes
|
| 138 |
+
they correspond to sentences that were next to each other in the original text, sometimes not. The model then has to
|
| 139 |
+
predict if the two sentences were following each other or not.
|
| 140 |
+
|
| 141 |
+
This way, the model learns an inner representation of the languages in the training set that can then be used to
|
| 142 |
+
extract features useful for downstream tasks: if you have a dataset of labeled sentences for instance, you can train a
|
| 143 |
+
standard classifier using the features produced by the BERT model as inputs.
|
| 144 |
+
|
| 145 |
+
## Intended uses & limitations
|
| 146 |
+
|
| 147 |
+
You can use the raw model for either masked language modeling or next sentence prediction, but it's mostly intended to
|
| 148 |
+
be fine-tuned on a downstream task. See the [model hub](https://huggingface.co/models?filter=bert) to look for
|
| 149 |
+
fine-tuned versions on a task that interests you.
|
| 150 |
+
|
| 151 |
+
Note that this model is primarily aimed at being fine-tuned on tasks that use the whole sentence (potentially masked)
|
| 152 |
+
to make decisions, such as sequence classification, token classification or question answering. For tasks such as text
|
| 153 |
+
generation you should look at model like GPT2.
|
| 154 |
+
|
| 155 |
+
### How to use
|
| 156 |
+
|
| 157 |
+
You can use this model directly with a pipeline for masked language modeling:
|
| 158 |
+
|
| 159 |
+
```python
|
| 160 |
+
>>> from transformers import pipeline
|
| 161 |
+
>>> unmasker = pipeline('fill-mask', model='bert-base-multilingual-cased')
|
| 162 |
+
>>> unmasker("Hello I'm a [MASK] model.")
|
| 163 |
+
|
| 164 |
+
[{'sequence': "[CLS] Hello I'm a model model. [SEP]",
|
| 165 |
+
'score': 0.10182085633277893,
|
| 166 |
+
'token': 13192,
|
| 167 |
+
'token_str': 'model'},
|
| 168 |
+
{'sequence': "[CLS] Hello I'm a world model. [SEP]",
|
| 169 |
+
'score': 0.052126359194517136,
|
| 170 |
+
'token': 11356,
|
| 171 |
+
'token_str': 'world'},
|
| 172 |
+
{'sequence': "[CLS] Hello I'm a data model. [SEP]",
|
| 173 |
+
'score': 0.048930276185274124,
|
| 174 |
+
'token': 11165,
|
| 175 |
+
'token_str': 'data'},
|
| 176 |
+
{'sequence': "[CLS] Hello I'm a flight model. [SEP]",
|
| 177 |
+
'score': 0.02036019042134285,
|
| 178 |
+
'token': 23578,
|
| 179 |
+
'token_str': 'flight'},
|
| 180 |
+
{'sequence': "[CLS] Hello I'm a business model. [SEP]",
|
| 181 |
+
'score': 0.020079681649804115,
|
| 182 |
+
'token': 14155,
|
| 183 |
+
'token_str': 'business'}]
|
| 184 |
+
```
|
| 185 |
+
|
| 186 |
+
Here is how to use this model to get the features of a given text in PyTorch:
|
| 187 |
+
|
| 188 |
+
```python
|
| 189 |
+
from transformers import BertTokenizer, BertModel
|
| 190 |
+
tokenizer = BertTokenizer.from_pretrained('bert-base-multilingual-cased')
|
| 191 |
+
model = BertModel.from_pretrained("bert-base-multilingual-cased")
|
| 192 |
+
text = "Replace me by any text you'd like."
|
| 193 |
+
encoded_input = tokenizer(text, return_tensors='pt')
|
| 194 |
+
output = model(**encoded_input)
|
| 195 |
+
```
|
| 196 |
+
|
| 197 |
+
and in TensorFlow:
|
| 198 |
+
|
| 199 |
+
```python
|
| 200 |
+
from transformers import BertTokenizer, TFBertModel
|
| 201 |
+
tokenizer = BertTokenizer.from_pretrained('bert-base-multilingual-cased')
|
| 202 |
+
model = TFBertModel.from_pretrained("bert-base-multilingual-cased")
|
| 203 |
+
text = "Replace me by any text you'd like."
|
| 204 |
+
encoded_input = tokenizer(text, return_tensors='tf')
|
| 205 |
+
output = model(encoded_input)
|
| 206 |
+
```
|
| 207 |
+
|
| 208 |
+
## Training data
|
| 209 |
+
|
| 210 |
+
The BERT model was pretrained on the 104 languages with the largest Wikipedias. You can find the complete list
|
| 211 |
+
[here](https://github.com/google-research/bert/blob/master/multilingual.md#list-of-languages).
|
| 212 |
+
|
| 213 |
+
## Training procedure
|
| 214 |
+
|
| 215 |
+
### Preprocessing
|
| 216 |
+
|
| 217 |
+
The texts are lowercased and tokenized using WordPiece and a shared vocabulary size of 110,000. The languages with a
|
| 218 |
+
larger Wikipedia are under-sampled and the ones with lower resources are oversampled. For languages like Chinese,
|
| 219 |
+
Japanese Kanji and Korean Hanja that don't have space, a CJK Unicode block is added around every character.
|
| 220 |
+
|
| 221 |
+
The inputs of the model are then of the form:
|
| 222 |
+
|
| 223 |
+
```
|
| 224 |
+
[CLS] Sentence A [SEP] Sentence B [SEP]
|
| 225 |
+
```
|
| 226 |
+
|
| 227 |
+
With probability 0.5, sentence A and sentence B correspond to two consecutive sentences in the original corpus and in
|
| 228 |
+
the other cases, it's another random sentence in the corpus. Note that what is considered a sentence here is a
|
| 229 |
+
consecutive span of text usually longer than a single sentence. The only constrain is that the result with the two
|
| 230 |
+
"sentences" has a combined length of less than 512 tokens.
|
| 231 |
+
|
| 232 |
+
The details of the masking procedure for each sentence are the following:
|
| 233 |
+
- 15% of the tokens are masked.
|
| 234 |
+
- In 80% of the cases, the masked tokens are replaced by `[MASK]`.
|
| 235 |
+
- In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
|
| 236 |
+
- In the 10% remaining cases, the masked tokens are left as is.
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
### BibTeX entry and citation info
|
| 240 |
+
|
| 241 |
+
```bibtex
|
| 242 |
+
@article{DBLP:journals/corr/abs-1810-04805,
|
| 243 |
+
author = {Jacob Devlin and
|
| 244 |
+
Ming{-}Wei Chang and
|
| 245 |
+
Kenton Lee and
|
| 246 |
+
Kristina Toutanova},
|
| 247 |
+
title = {{BERT:} Pre-training of Deep Bidirectional Transformers for Language
|
| 248 |
+
Understanding},
|
| 249 |
+
journal = {CoRR},
|
| 250 |
+
volume = {abs/1810.04805},
|
| 251 |
+
year = {2018},
|
| 252 |
+
url = {http://arxiv.org/abs/1810.04805},
|
| 253 |
+
archivePrefix = {arXiv},
|
| 254 |
+
eprint = {1810.04805},
|
| 255 |
+
timestamp = {Tue, 30 Oct 2018 20:39:56 +0100},
|
| 256 |
+
biburl = {https://dblp.org/rec/journals/corr/abs-1810-04805.bib},
|
| 257 |
+
bibsource = {dblp computer science bibliography, https://dblp.org}
|
| 258 |
+
}
|
| 259 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"BertModel"
|
| 4 |
+
],
|
| 5 |
+
"attention_probs_dropout_prob": 0.1,
|
| 6 |
+
"classifier_dropout": null,
|
| 7 |
+
"directionality": "bidi",
|
| 8 |
+
"hidden_act": "gelu",
|
| 9 |
+
"hidden_dropout_prob": 0.1,
|
| 10 |
+
"hidden_size": 768,
|
| 11 |
+
"initializer_range": 0.02,
|
| 12 |
+
"intermediate_size": 3072,
|
| 13 |
+
"layer_norm_eps": 1e-12,
|
| 14 |
+
"max_position_embeddings": 512,
|
| 15 |
+
"model_type": "bert",
|
| 16 |
+
"num_attention_heads": 12,
|
| 17 |
+
"num_hidden_layers": 12,
|
| 18 |
+
"pad_token_id": 0,
|
| 19 |
+
"pooler_fc_size": 768,
|
| 20 |
+
"pooler_num_attention_heads": 12,
|
| 21 |
+
"pooler_num_fc_layers": 3,
|
| 22 |
+
"pooler_size_per_head": 128,
|
| 23 |
+
"pooler_type": "first_token_transform",
|
| 24 |
+
"position_embedding_type": "absolute",
|
| 25 |
+
"torch_dtype": "float32",
|
| 26 |
+
"transformers_version": "4.51.1",
|
| 27 |
+
"type_vocab_size": 2,
|
| 28 |
+
"use_cache": true,
|
| 29 |
+
"vocab_size": 119547
|
| 30 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:68cf33d5e6e03f49d9cbe552a8d098e1f4ba766a5a0a301826f82e030fc71b2e
|
| 3 |
+
size 711436136
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:93f5b2ac25380c56e6082c4165bcf19f1339658d80354e103d2171eb24dbdbfa
|
| 3 |
+
size 712680822
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cls_token": "[CLS]",
|
| 3 |
+
"mask_token": "[MASK]",
|
| 4 |
+
"pad_token": "[PAD]",
|
| 5 |
+
"sep_token": "[SEP]",
|
| 6 |
+
"unk_token": "[UNK]"
|
| 7 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[PAD]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"100": {
|
| 12 |
+
"content": "[UNK]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"101": {
|
| 20 |
+
"content": "[CLS]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"102": {
|
| 28 |
+
"content": "[SEP]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"103": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"clean_up_tokenization_spaces": false,
|
| 45 |
+
"cls_token": "[CLS]",
|
| 46 |
+
"do_lower_case": false,
|
| 47 |
+
"extra_special_tokens": {},
|
| 48 |
+
"mask_token": "[MASK]",
|
| 49 |
+
"model_max_length": 512,
|
| 50 |
+
"pad_token": "[PAD]",
|
| 51 |
+
"sep_token": "[SEP]",
|
| 52 |
+
"strip_accents": null,
|
| 53 |
+
"tokenize_chinese_chars": true,
|
| 54 |
+
"tokenizer_class": "BertTokenizer",
|
| 55 |
+
"unk_token": "[UNK]"
|
| 56 |
+
}
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|