Commit
•
64d14bc
1
Parent(s):
cc66adb
Add model
Browse files- README.md +117 -0
- config.json +24 -0
- pytorch_model.bin +3 -0
README.md
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: en
|
3 |
+
tags:
|
4 |
+
- exbert
|
5 |
+
- multiberts
|
6 |
+
license: apache-2.0
|
7 |
+
datasets:
|
8 |
+
- bookcorpus
|
9 |
+
- wikipedia
|
10 |
+
---
|
11 |
+
# MultiBERTs Seed 160000 Checkpoint 160k (uncased)
|
12 |
+
Seed 160000 intermediate checkpoint 160k 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
|
15 |
+
between english and English.
|
16 |
+
|
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
|
27 |
+
GPT which internally mask the future tokens. It allows the model to learn a bidirectional representation of the
|
28 |
+
sentence.
|
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.
|
40 |
+
Note that this model is primarily aimed at being fine-tuned on tasks that use the whole sentence (potentially masked)
|
41 |
+
to make decisions, such as sequence classification, token classification or question answering. For tasks such as text
|
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('bert-base-uncased')
|
49 |
+
model = BertModel.from_pretrained("multiberts-seed-160000-160k")
|
50 |
+
text = "Replace me by any text you'd like."
|
51 |
+
encoded_input = tokenizer(text, return_tensors='pt')
|
52 |
+
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
|
92 |
+
Steve Yadlowsky and
|
93 |
+
Jason Wei and
|
94 |
+
Naomi Saphra and
|
95 |
+
Alexander D'Amour and
|
96 |
+
Tal Linzen and
|
97 |
+
Jasmijn Bastings and
|
98 |
+
Iulia Turc and
|
99 |
+
Jacob Eisenstein and
|
100 |
+
Dipanjan Das and
|
101 |
+
Ian Tenney and
|
102 |
+
Ellie Pavlick},
|
103 |
+
title = {The MultiBERTs: {BERT} Reproductions for Robustness Analysis},
|
104 |
+
journal = {CoRR},
|
105 |
+
volume = {abs/2106.16163},
|
106 |
+
year = {2021},
|
107 |
+
url = {https://arxiv.org/abs/2106.16163},
|
108 |
+
eprinttype = {arXiv},
|
109 |
+
eprint = {2106.16163},
|
110 |
+
timestamp = {Mon, 05 Jul 2021 15:15:50 +0200},
|
111 |
+
biburl = {https://dblp.org/rec/journals/corr/abs-2106-16163.bib},
|
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>
|
config.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"BertForPreTraining"
|
4 |
+
],
|
5 |
+
"attention_probs_dropout_prob": 0.1,
|
6 |
+
"classifier_dropout": null,
|
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 |
+
"position_embedding_type": "absolute",
|
19 |
+
"torch_dtype": "float32",
|
20 |
+
"transformers_version": "4.11.0.dev0",
|
21 |
+
"type_vocab_size": 2,
|
22 |
+
"use_cache": true,
|
23 |
+
"vocab_size": 30522
|
24 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:042150a045ef20a628a0fc902fd971eb8bc4fe168deeb3c7b75971cb583df3f4
|
3 |
+
size 440509027
|