bossyfaycal narutoelbruto commited on
Commit
b328eff
·
0 Parent(s):

Duplicate from google-bert/bert-base-multilingual-cased

Browse files

Co-authored-by: naruto bruto <narutoelbruto@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
2
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.h5 filter=lfs diff=lfs merge=lfs -text
5
+ *.tflite filter=lfs diff=lfs merge=lfs -text
6
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.ot filter=lfs diff=lfs merge=lfs -text
8
+ *.onnx filter=lfs diff=lfs merge=lfs -text
9
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
10
+ model.safetensors filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - multilingual
4
+ - af
5
+ - sq
6
+ - ar
7
+ - an
8
+ - hy
9
+ - ast
10
+ - az
11
+ - ba
12
+ - eu
13
+ - bar
14
+ - be
15
+ - bn
16
+ - inc
17
+ - bs
18
+ - br
19
+ - bg
20
+ - my
21
+ - ca
22
+ - ceb
23
+ - ce
24
+ - zh
25
+ - 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
+ # BERT multilingual base model (cased)
113
+
114
+ Pretrained model on the top 104 languages with the largest Wikipedia using a masked language modeling (MLM) objective.
115
+ It was introduced in [this paper](https://arxiv.org/abs/1810.04805) and first released in
116
+ [this repository](https://github.com/google-research/bert). This model is case sensitive: it makes a difference
117
+ between english and English.
118
+
119
+ Disclaimer: The team releasing BERT did not write a model card for this model so this model card has been written by
120
+ the Hugging Face team.
121
+
122
+ ## Model description
123
+
124
+ BERT is a transformers model pretrained on a large corpus of multilingual data in a self-supervised fashion. This means
125
+ it was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of
126
+ publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely, it
127
+ was pretrained with two objectives:
128
+
129
+ - Masked language modeling (MLM): taking a sentence, the model randomly masks 15% of the words in the input then run
130
+ the entire masked sentence through the model and has to predict the masked words. This is different from traditional
131
+ recurrent neural networks (RNNs) that usually see the words one after the other, or from autoregressive models like
132
+ GPT which internally mask the future tokens. It allows the model to learn a bidirectional representation of the
133
+ sentence.
134
+ - Next sentence prediction (NSP): the models concatenates two masked sentences as inputs during pretraining. Sometimes
135
+ they correspond to sentences that were next to each other in the original text, sometimes not. The model then has to
136
+ predict if the two sentences were following each other or not.
137
+
138
+ This way, the model learns an inner representation of the languages in the training set that can then be used to
139
+ extract features useful for downstream tasks: if you have a dataset of labeled sentences for instance, you can train a
140
+ standard classifier using the features produced by the BERT model as inputs.
141
+
142
+ ## Intended uses & limitations
143
+
144
+ You can use the raw model for either masked language modeling or next sentence prediction, but it's mostly intended to
145
+ be fine-tuned on a downstream task. See the [model hub](https://huggingface.co/models?filter=bert) to look for
146
+ fine-tuned versions on a task that interests you.
147
+
148
+ Note that this model is primarily aimed at being fine-tuned on tasks that use the whole sentence (potentially masked)
149
+ to make decisions, such as sequence classification, token classification or question answering. For tasks such as text
150
+ generation you should look at model like GPT2.
151
+
152
+ ### How to use
153
+
154
+ You can use this model directly with a pipeline for masked language modeling:
155
+
156
+ ```python
157
+ >>> from transformers import pipeline
158
+ >>> unmasker = pipeline('fill-mask', model='bert-base-multilingual-cased')
159
+ >>> unmasker("Hello I'm a [MASK] model.")
160
+
161
+ [{'sequence': "[CLS] Hello I'm a model model. [SEP]",
162
+ 'score': 0.10182085633277893,
163
+ 'token': 13192,
164
+ 'token_str': 'model'},
165
+ {'sequence': "[CLS] Hello I'm a world model. [SEP]",
166
+ 'score': 0.052126359194517136,
167
+ 'token': 11356,
168
+ 'token_str': 'world'},
169
+ {'sequence': "[CLS] Hello I'm a data model. [SEP]",
170
+ 'score': 0.048930276185274124,
171
+ 'token': 11165,
172
+ 'token_str': 'data'},
173
+ {'sequence': "[CLS] Hello I'm a flight model. [SEP]",
174
+ 'score': 0.02036019042134285,
175
+ 'token': 23578,
176
+ 'token_str': 'flight'},
177
+ {'sequence': "[CLS] Hello I'm a business model. [SEP]",
178
+ 'score': 0.020079681649804115,
179
+ 'token': 14155,
180
+ 'token_str': 'business'}]
181
+ ```
182
+
183
+ Here is how to use this model to get the features of a given text in PyTorch:
184
+
185
+ ```python
186
+ from transformers import BertTokenizer, BertModel
187
+ tokenizer = BertTokenizer.from_pretrained('bert-base-multilingual-cased')
188
+ model = BertModel.from_pretrained("bert-base-multilingual-cased")
189
+ text = "Replace me by any text you'd like."
190
+ encoded_input = tokenizer(text, return_tensors='pt')
191
+ output = model(**encoded_input)
192
+ ```
193
+
194
+ and in TensorFlow:
195
+
196
+ ```python
197
+ from transformers import BertTokenizer, TFBertModel
198
+ tokenizer = BertTokenizer.from_pretrained('bert-base-multilingual-cased')
199
+ model = TFBertModel.from_pretrained("bert-base-multilingual-cased")
200
+ text = "Replace me by any text you'd like."
201
+ encoded_input = tokenizer(text, return_tensors='tf')
202
+ output = model(encoded_input)
203
+ ```
204
+
205
+ ## Training data
206
+
207
+ The BERT model was pretrained on the 104 languages with the largest Wikipedias. You can find the complete list
208
+ [here](https://github.com/google-research/bert/blob/master/multilingual.md#list-of-languages).
209
+
210
+ ## Training procedure
211
+
212
+ ### Preprocessing
213
+
214
+ The texts are lowercased and tokenized using WordPiece and a shared vocabulary size of 110,000. The languages with a
215
+ larger Wikipedia are under-sampled and the ones with lower resources are oversampled. For languages like Chinese,
216
+ Japanese Kanji and Korean Hanja that don't have space, a CJK Unicode block is added around every character.
217
+
218
+ The inputs of the model are then of the form:
219
+
220
+ ```
221
+ [CLS] Sentence A [SEP] Sentence B [SEP]
222
+ ```
223
+
224
+ With probability 0.5, sentence A and sentence B correspond to two consecutive sentences in the original corpus and in
225
+ the other cases, it's another random sentence in the corpus. Note that what is considered a sentence here is a
226
+ consecutive span of text usually longer than a single sentence. The only constrain is that the result with the two
227
+ "sentences" has a combined length of less than 512 tokens.
228
+
229
+ The details of the masking procedure for each sentence are the following:
230
+ - 15% of the tokens are masked.
231
+ - In 80% of the cases, the masked tokens are replaced by `[MASK]`.
232
+ - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
233
+ - In the 10% remaining cases, the masked tokens are left as is.
234
+
235
+
236
+ ### BibTeX entry and citation info
237
+
238
+ ```bibtex
239
+ @article{DBLP:journals/corr/abs-1810-04805,
240
+ author = {Jacob Devlin and
241
+ Ming{-}Wei Chang and
242
+ Kenton Lee and
243
+ Kristina Toutanova},
244
+ title = {{BERT:} Pre-training of Deep Bidirectional Transformers for Language
245
+ Understanding},
246
+ journal = {CoRR},
247
+ volume = {abs/1810.04805},
248
+ year = {2018},
249
+ url = {http://arxiv.org/abs/1810.04805},
250
+ archivePrefix = {arXiv},
251
+ eprint = {1810.04805},
252
+ timestamp = {Tue, 30 Oct 2018 20:39:56 +0100},
253
+ biburl = {https://dblp.org/rec/journals/corr/abs-1810-04805.bib},
254
+ bibsource = {dblp computer science bibliography, https://dblp.org}
255
+ }
256
+ ```
config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForMaskedLM"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "directionality": "bidi",
7
+ "hidden_act": "gelu",
8
+ "hidden_dropout_prob": 0.1,
9
+ "hidden_size": 768,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 3072,
12
+ "layer_norm_eps": 1e-12,
13
+ "max_position_embeddings": 512,
14
+ "model_type": "bert",
15
+ "num_attention_heads": 12,
16
+ "num_hidden_layers": 12,
17
+ "pad_token_id": 0,
18
+ "pooler_fc_size": 768,
19
+ "pooler_num_attention_heads": 12,
20
+ "pooler_num_fc_layers": 3,
21
+ "pooler_size_per_head": 128,
22
+ "pooler_type": "first_token_transform",
23
+ "type_vocab_size": 2,
24
+ "vocab_size": 119547
25
+ }
flax_model.msgpack ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ebee9a143c50f975a7d5074642150011e112a65d8362dd6b6b84867ee689f2ad
3
+ size 711905363
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:876f584f15ebf14887dec17539c114bb99a032e96b9e72507a51c41e205337fc
3
+ size 714290682
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3496a508a9a3511c8a55e4d0e6f471c70c68c2a8c4784b3b2b5dc16ffb87d238
3
+ size 714314041
tf_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8c6fe40eebcaffac5051e6dddc93318faedfc74ed17b0de0c2512a3158f77ce5
3
+ size 1083389348
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"do_lower_case": false, "model_max_length": 512}
vocab.txt ADDED
The diff for this file is too large to render. See raw diff