gchhablani
commited on
Commit
•
df8d5a2
1
Parent(s):
6bce8b5
Update README
Browse files
README.md
CHANGED
@@ -9,6 +9,7 @@ datasets:
|
|
9 |
- wikipedia
|
10 |
---
|
11 |
# MultiBERTs Seed 6 (uncased)
|
|
|
12 |
Seed 6 MultiBERTs (pretrained BERT) model on English language using a masked language modeling (MLM) objective. It was introduced in
|
13 |
[this paper](https://arxiv.org/pdf/2106.16163.pdf) and first released in
|
14 |
[this repository](https://github.com/google-research/language/tree/master/language/multiberts). This model is uncased: it does not make a difference
|
@@ -17,10 +18,12 @@ between english and English.
|
|
17 |
Disclaimer: The team releasing MultiBERTs did not write a model card for this model so this model card has been written by [gchhablani](https://hf.co/gchhablani).
|
18 |
|
19 |
## Model description
|
|
|
20 |
MultiBERTs models are transformers model pretrained on a large corpus of English data in a self-supervised fashion. This means it
|
21 |
was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of
|
22 |
publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely, it
|
23 |
was pretrained with two objectives:
|
|
|
24 |
- Masked language modeling (MLM): taking a sentence, the model randomly masks 15% of the words in the input then run
|
25 |
the entire masked sentence through the model and has to predict the masked words. This is different from traditional
|
26 |
recurrent neural networks (RNNs) that usually see the words one after the other, or from autoregressive models like
|
@@ -29,11 +32,12 @@ was pretrained with two objectives:
|
|
29 |
- Next sentence prediction (NSP): the models concatenates two masked sentences as inputs during pretraining. Sometimes
|
30 |
they correspond to sentences that were next to each other in the original text, sometimes not. The model then has to
|
31 |
predict if the two sentences were following each other or not.
|
32 |
-
This way, the model learns an inner representation of the English language that can then be used to extract features
|
33 |
-
useful for downstream tasks: if you have a dataset of labeled sentences for instance, you can train a standard
|
34 |
-
classifier using the features produced by the MultiBERTs model as inputs.
|
35 |
|
36 |
## Intended uses & limitations
|
|
|
37 |
You can use the raw model for either masked language modeling or next sentence prediction, but it's mostly intended to
|
38 |
be fine-tuned on a downstream task. See the [model hub](https://huggingface.co/models?filter=multiberts) to look for
|
39 |
fine-tuned versions on a task that interests you.
|
@@ -42,10 +46,12 @@ to make decisions, such as sequence classification, token classification or ques
|
|
42 |
generation you should look at model like GPT2.
|
43 |
|
44 |
### How to use
|
|
|
45 |
Here is how to use this model to get the features of a given text in PyTorch:
|
|
|
46 |
```python
|
47 |
from transformers import BertTokenizer, BertModel
|
48 |
-
tokenizer = BertTokenizer.from_pretrained('
|
49 |
model = BertModel.from_pretrained("multiberts-seed-6")
|
50 |
text = "Replace me by any text you'd like."
|
51 |
encoded_input = tokenizer(text, return_tensors='pt')
|
@@ -53,39 +59,48 @@ output = model(**encoded_input)
|
|
53 |
```
|
54 |
|
55 |
### Limitations and bias
|
|
|
56 |
Even if the training data used for this model could be characterized as fairly neutral, this model can have biased
|
57 |
predictions. This bias will also affect all fine-tuned versions of this model. For an understanding of bias of this particular
|
58 |
checkpoint, please try out this checkpoint with the snippet present in the [Limitation and bias section](https://huggingface.co/bert-base-uncased#limitations-and-bias) of the [bert-base-uncased](https://huggingface.co/bert-base-uncased) checkpoint.
|
59 |
|
60 |
## Training data
|
|
|
61 |
The MultiBERTs models were pretrained on [BookCorpus](https://yknzhu.wixsite.com/mbweb), a dataset consisting of 11,038
|
62 |
unpublished books and [English Wikipedia](https://en.wikipedia.org/wiki/English_Wikipedia) (excluding lists, tables and
|
63 |
headers).
|
|
|
64 |
## Training procedure
|
65 |
|
66 |
### Preprocessing
|
|
|
67 |
The texts are lowercased and tokenized using WordPiece and a vocabulary size of 30,000. The inputs of the model are
|
68 |
then of the form:
|
|
|
69 |
```
|
70 |
[CLS] Sentence A [SEP] Sentence B [SEP]
|
71 |
```
|
|
|
72 |
With probability 0.5, sentence A and sentence B correspond to two consecutive sentences in the original corpus and in
|
73 |
the other cases, it's another random sentence in the corpus. Note that what is considered a sentence here is a
|
74 |
consecutive span of text usually longer than a single sentence. The only constrain is that the result with the two
|
75 |
"sentences" has a combined length of less than 512 tokens.
|
76 |
The details of the masking procedure for each sentence are the following:
|
|
|
77 |
- 15% of the tokens are masked.
|
78 |
- In 80% of the cases, the masked tokens are replaced by `[MASK]`.
|
79 |
- In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
|
80 |
- In the 10% remaining cases, the masked tokens are left as is.
|
81 |
|
82 |
### Pretraining
|
|
|
83 |
The model was trained on 16 Cloud TPU v2 chips for two million steps with a batch size
|
84 |
of 256. The sequence length was set to 512 throughout. The optimizer
|
85 |
used is Adam with a learning rate of 1e-4, \\(\beta_{1} = 0.9\\) and \\(\beta_{2} = 0.999\\), a weight decay of 0.01,
|
86 |
learning rate warmup for 10,000 steps and linear decay of the learning rate after.
|
87 |
|
88 |
### BibTeX entry and citation info
|
|
|
89 |
```bibtex
|
90 |
@article{DBLP:journals/corr/abs-2106-16163,
|
91 |
author = {Thibault Sellam and
|
@@ -112,6 +127,7 @@ learning rate warmup for 10,000 steps and linear decay of the learning rate afte
|
|
112 |
bibsource = {dblp computer science bibliography, https://dblp.org}
|
113 |
}
|
114 |
```
|
|
|
115 |
<a href="https://huggingface.co/exbert/?model=multiberts">
|
116 |
<img width="300px" src="https://cdn-media.huggingface.co/exbert/button.png">
|
117 |
</a>
|
|
|
9 |
- wikipedia
|
10 |
---
|
11 |
# MultiBERTs Seed 6 (uncased)
|
12 |
+
|
13 |
Seed 6 MultiBERTs (pretrained BERT) model on English language using a masked language modeling (MLM) objective. It was introduced in
|
14 |
[this paper](https://arxiv.org/pdf/2106.16163.pdf) and first released in
|
15 |
[this repository](https://github.com/google-research/language/tree/master/language/multiberts). This model is uncased: it does not make a difference
|
|
|
18 |
Disclaimer: The team releasing MultiBERTs did not write a model card for this model so this model card has been written by [gchhablani](https://hf.co/gchhablani).
|
19 |
|
20 |
## Model description
|
21 |
+
|
22 |
MultiBERTs models are transformers model pretrained on a large corpus of English data in a self-supervised fashion. This means it
|
23 |
was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of
|
24 |
publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely, it
|
25 |
was pretrained with two objectives:
|
26 |
+
|
27 |
- Masked language modeling (MLM): taking a sentence, the model randomly masks 15% of the words in the input then run
|
28 |
the entire masked sentence through the model and has to predict the masked words. This is different from traditional
|
29 |
recurrent neural networks (RNNs) that usually see the words one after the other, or from autoregressive models like
|
|
|
32 |
- Next sentence prediction (NSP): the models concatenates two masked sentences as inputs during pretraining. Sometimes
|
33 |
they correspond to sentences that were next to each other in the original text, sometimes not. The model then has to
|
34 |
predict if the two sentences were following each other or not.
|
35 |
+
This way, the model learns an inner representation of the English language that can then be used to extract features
|
36 |
+
useful for downstream tasks: if you have a dataset of labeled sentences for instance, you can train a standard
|
37 |
+
classifier using the features produced by the MultiBERTs model as inputs.
|
38 |
|
39 |
## Intended uses & limitations
|
40 |
+
|
41 |
You can use the raw model for either masked language modeling or next sentence prediction, but it's mostly intended to
|
42 |
be fine-tuned on a downstream task. See the [model hub](https://huggingface.co/models?filter=multiberts) to look for
|
43 |
fine-tuned versions on a task that interests you.
|
|
|
46 |
generation you should look at model like GPT2.
|
47 |
|
48 |
### How to use
|
49 |
+
|
50 |
Here is how to use this model to get the features of a given text in PyTorch:
|
51 |
+
|
52 |
```python
|
53 |
from transformers import BertTokenizer, BertModel
|
54 |
+
tokenizer = BertTokenizer.from_pretrained('multiberts-seed-6')
|
55 |
model = BertModel.from_pretrained("multiberts-seed-6")
|
56 |
text = "Replace me by any text you'd like."
|
57 |
encoded_input = tokenizer(text, return_tensors='pt')
|
|
|
59 |
```
|
60 |
|
61 |
### Limitations and bias
|
62 |
+
|
63 |
Even if the training data used for this model could be characterized as fairly neutral, this model can have biased
|
64 |
predictions. This bias will also affect all fine-tuned versions of this model. For an understanding of bias of this particular
|
65 |
checkpoint, please try out this checkpoint with the snippet present in the [Limitation and bias section](https://huggingface.co/bert-base-uncased#limitations-and-bias) of the [bert-base-uncased](https://huggingface.co/bert-base-uncased) checkpoint.
|
66 |
|
67 |
## Training data
|
68 |
+
|
69 |
The MultiBERTs models were pretrained on [BookCorpus](https://yknzhu.wixsite.com/mbweb), a dataset consisting of 11,038
|
70 |
unpublished books and [English Wikipedia](https://en.wikipedia.org/wiki/English_Wikipedia) (excluding lists, tables and
|
71 |
headers).
|
72 |
+
|
73 |
## Training procedure
|
74 |
|
75 |
### Preprocessing
|
76 |
+
|
77 |
The texts are lowercased and tokenized using WordPiece and a vocabulary size of 30,000. The inputs of the model are
|
78 |
then of the form:
|
79 |
+
|
80 |
```
|
81 |
[CLS] Sentence A [SEP] Sentence B [SEP]
|
82 |
```
|
83 |
+
|
84 |
With probability 0.5, sentence A and sentence B correspond to two consecutive sentences in the original corpus and in
|
85 |
the other cases, it's another random sentence in the corpus. Note that what is considered a sentence here is a
|
86 |
consecutive span of text usually longer than a single sentence. The only constrain is that the result with the two
|
87 |
"sentences" has a combined length of less than 512 tokens.
|
88 |
The details of the masking procedure for each sentence are the following:
|
89 |
+
|
90 |
- 15% of the tokens are masked.
|
91 |
- In 80% of the cases, the masked tokens are replaced by `[MASK]`.
|
92 |
- In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
|
93 |
- In the 10% remaining cases, the masked tokens are left as is.
|
94 |
|
95 |
### Pretraining
|
96 |
+
|
97 |
The model was trained on 16 Cloud TPU v2 chips for two million steps with a batch size
|
98 |
of 256. The sequence length was set to 512 throughout. The optimizer
|
99 |
used is Adam with a learning rate of 1e-4, \\(\beta_{1} = 0.9\\) and \\(\beta_{2} = 0.999\\), a weight decay of 0.01,
|
100 |
learning rate warmup for 10,000 steps and linear decay of the learning rate after.
|
101 |
|
102 |
### BibTeX entry and citation info
|
103 |
+
|
104 |
```bibtex
|
105 |
@article{DBLP:journals/corr/abs-2106-16163,
|
106 |
author = {Thibault Sellam and
|
|
|
127 |
bibsource = {dblp computer science bibliography, https://dblp.org}
|
128 |
}
|
129 |
```
|
130 |
+
|
131 |
<a href="https://huggingface.co/exbert/?model=multiberts">
|
132 |
<img width="300px" src="https://cdn-media.huggingface.co/exbert/button.png">
|
133 |
</a>
|