gchhablani commited on
Commit
a1937fb
1 Parent(s): f6bf391

Add or Fix Model

Browse files
Files changed (3) hide show
  1. README.md +118 -0
  2. config.json +24 -0
  3. pytorch_model.bin +3 -0
README.md ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ tags:
4
+ - exbert
5
+ - multiberts
6
+ - multiberts-seed-1
7
+ license: apache-2.0
8
+ datasets:
9
+ - bookcorpus
10
+ - wikipedia
11
+ ---
12
+ # MultiBERTs Seed 1 Checkpoint 20k (uncased)
13
+ Seed 1 intermediate checkpoint 20k 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
16
+ between english and English.
17
+
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
+ MultiBERTs models are transformers model pretrained on a large corpus of English data in a self-supervised fashion. This means it
22
+ was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of
23
+ publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely, it
24
+ was pretrained with two objectives:
25
+ - Masked language modeling (MLM): taking a sentence, the model randomly masks 15% of the words in the input then run
26
+ the entire masked sentence through the model and has to predict the masked words. This is different from traditional
27
+ recurrent neural networks (RNNs) that usually see the words one after the other, or from autoregressive models like
28
+ GPT which internally mask the future tokens. It allows the model to learn a bidirectional representation of the
29
+ sentence.
30
+ - Next sentence prediction (NSP): the models concatenates two masked sentences as inputs during pretraining. Sometimes
31
+ they correspond to sentences that were next to each other in the original text, sometimes not. The model then has to
32
+ predict if the two sentences were following each other or not.
33
+ This way, the model learns an inner representation of the English language that can then be used to extract features
34
+ useful for downstream tasks: if you have a dataset of labeled sentences for instance, you can train a standard
35
+ classifier using the features produced by the MultiBERTs model as inputs.
36
+
37
+ ## Intended uses & limitations
38
+ You can use the raw model for either masked language modeling or next sentence prediction, but it's mostly intended to
39
+ be fine-tuned on a downstream task. See the [model hub](https://huggingface.co/models?filter=multiberts) to look for
40
+ fine-tuned versions on a task that interests you.
41
+ Note that this model is primarily aimed at being fine-tuned on tasks that use the whole sentence (potentially masked)
42
+ to make decisions, such as sequence classification, token classification or question answering. For tasks such as text
43
+ generation you should look at model like GPT2.
44
+
45
+ ### How to use
46
+ Here is how to use this model to get the features of a given text in PyTorch:
47
+ ```python
48
+ from transformers import BertTokenizer, BertModel
49
+ tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
50
+ model = BertModel.from_pretrained("multiberts-seed-1-20k")
51
+ text = "Replace me by any text you'd like."
52
+ encoded_input = tokenizer(text, return_tensors='pt')
53
+ output = model(**encoded_input)
54
+ ```
55
+
56
+ ### Limitations and bias
57
+ Even if the training data used for this model could be characterized as fairly neutral, this model can have biased
58
+ predictions. This bias will also affect all fine-tuned versions of this model. For an understanding of bias of this particular
59
+ 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.
60
+
61
+ ## Training data
62
+ The MultiBERTs models were pretrained on [BookCorpus](https://yknzhu.wixsite.com/mbweb), a dataset consisting of 11,038
63
+ unpublished books and [English Wikipedia](https://en.wikipedia.org/wiki/English_Wikipedia) (excluding lists, tables and
64
+ headers).
65
+ ## Training procedure
66
+
67
+ ### Preprocessing
68
+ The texts are lowercased and tokenized using WordPiece and a vocabulary size of 30,000. The inputs of the model are
69
+ then of the form:
70
+ ```
71
+ [CLS] Sentence A [SEP] Sentence B [SEP]
72
+ ```
73
+ With probability 0.5, sentence A and sentence B correspond to two consecutive sentences in the original corpus and in
74
+ the other cases, it's another random sentence in the corpus. Note that what is considered a sentence here is a
75
+ consecutive span of text usually longer than a single sentence. The only constrain is that the result with the two
76
+ "sentences" has a combined length of less than 512 tokens.
77
+ The details of the masking procedure for each sentence are the following:
78
+ - 15% of the tokens are masked.
79
+ - In 80% of the cases, the masked tokens are replaced by `[MASK]`.
80
+ - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
81
+ - In the 10% remaining cases, the masked tokens are left as is.
82
+
83
+ ### Pretraining
84
+ The model was trained on 16 Cloud TPU v2 chips for two million steps with a batch size
85
+ of 256. The sequence length was set to 512 throughout. The optimizer
86
+ 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,
87
+ learning rate warmup for 10,000 steps and linear decay of the learning rate after.
88
+
89
+ ### BibTeX entry and citation info
90
+ ```bibtex
91
+ @article{DBLP:journals/corr/abs-2106-16163,
92
+ author = {Thibault Sellam and
93
+ Steve Yadlowsky and
94
+ Jason Wei and
95
+ Naomi Saphra and
96
+ Alexander D'Amour and
97
+ Tal Linzen and
98
+ Jasmijn Bastings and
99
+ Iulia Turc and
100
+ Jacob Eisenstein and
101
+ Dipanjan Das and
102
+ Ian Tenney and
103
+ Ellie Pavlick},
104
+ title = {The MultiBERTs: {BERT} Reproductions for Robustness Analysis},
105
+ journal = {CoRR},
106
+ volume = {abs/2106.16163},
107
+ year = {2021},
108
+ url = {https://arxiv.org/abs/2106.16163},
109
+ eprinttype = {arXiv},
110
+ eprint = {2106.16163},
111
+ timestamp = {Mon, 05 Jul 2021 15:15:50 +0200},
112
+ biburl = {https://dblp.org/rec/journals/corr/abs-2106-16163.bib},
113
+ bibsource = {dblp computer science bibliography, https://dblp.org}
114
+ }
115
+ ```
116
+ <a href="https://huggingface.co/exbert/?model=multiberts">
117
+ <img width="300px" src="https://cdn-media.huggingface.co/exbert/button.png">
118
+ </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:bb34e6bfd7c0077762ed0b6393caa01a41cfdee3f7e9f8d807407c0670a02cb0
3
+ size 440509027