cstr commited on
Commit
1245492
·
verified ·
1 Parent(s): c004ee7

Create README.md

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