lysandre HF staff commited on
Commit
3c42132
1 Parent(s): 6f942d0

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +118 -0
README.md ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: apache-2.0
4
+ datasets:
5
+ - bookcorpus
6
+ - wikipedia
7
+ ---
8
+
9
+ # BERT large model (cased) whole word masking finetuned on SQuAD
10
+
11
+ Pretrained model on English language using a masked language modeling (MLM) objective. It was introduced in
12
+ [this paper](https://arxiv.org/abs/1810.04805) and first released in
13
+ [this repository](https://github.com/google-research/bert). This model is cased: it makes a difference between english and English.
14
+
15
+ Differently to other BERT models, this model was trained with a new technique: Whole Word Masking. In this case, all of the tokens corresponding to a word are masked at once. The overall masking rate remains the same.
16
+
17
+ The training is identical -- each masked WordPiece token is predicted independently.
18
+
19
+ After pre-training, this model was fine-tuned on the SQuAD dataset with one of our fine-tuning scripts. See below for more information regarding this fine-tuning.
20
+
21
+ Disclaimer: The team releasing BERT did not write a model card for this model so this model card has been written by
22
+ the Hugging Face team.
23
+
24
+ ## Model description
25
+
26
+ BERT is a transformers model pretrained on a large corpus of English data in a self-supervised fashion. This means it
27
+ was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of
28
+ publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely, it
29
+ was pretrained with two objectives:
30
+
31
+ - Masked language modeling (MLM): taking a sentence, the model randomly masks 15% of the words in the input then run
32
+ the entire masked sentence through the model and has to predict the masked words. This is different from traditional
33
+ recurrent neural networks (RNNs) that usually see the words one after the other, or from autoregressive models like
34
+ GPT which internally mask the future tokens. It allows the model to learn a bidirectional representation of the
35
+ sentence.
36
+ - Next sentence prediction (NSP): the models concatenates two masked sentences as inputs during pretraining. Sometimes
37
+ they correspond to sentences that were next to each other in the original text, sometimes not. The model then has to
38
+ predict if the two sentences were following each other or not.
39
+
40
+ This way, the model learns an inner representation of the English language that can then be used to extract features
41
+ useful for downstream tasks: if you have a dataset of labeled sentences for instance, you can train a standard
42
+ classifier using the features produced by the BERT model as inputs.
43
+
44
+ ## Intended uses & limitations
45
+ This model should be used as a question-answering model. You may use it in a question answering pipeline, or use it to output raw results given a query and a context. You may see other use cases in the [task summary](https://huggingface.co/transformers/task_summary.html#extractive-question-answering) of the transformers documentation.## Training data
46
+
47
+ The BERT model was pretrained on [BookCorpus](https://yknzhu.wixsite.com/mbweb), a dataset consisting of 11,038
48
+ unpublished books and [English Wikipedia](https://en.wikipedia.org/wiki/English_Wikipedia) (excluding lists, tables and
49
+ headers).
50
+
51
+ ## Training procedure
52
+
53
+ ### Preprocessing
54
+
55
+ The texts are lowercased and tokenized using WordPiece and a vocabulary size of 30,000. The inputs of the model are
56
+ then of the form:
57
+
58
+ ```
59
+ [CLS] Sentence A [SEP] Sentence B [SEP]
60
+ ```
61
+
62
+ With probability 0.5, sentence A and sentence B correspond to two consecutive sentences in the original corpus and in
63
+ the other cases, it's another random sentence in the corpus. Note that what is considered a sentence here is a
64
+ consecutive span of text usually longer than a single sentence. The only constrain is that the result with the two
65
+ "sentences" has a combined length of less than 512 tokens.
66
+
67
+ The details of the masking procedure for each sentence are the following:
68
+ - 15% of the tokens are masked.
69
+ - In 80% of the cases, the masked tokens are replaced by `[MASK]`.
70
+ - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
71
+ - In the 10% remaining cases, the masked tokens are left as is.
72
+
73
+ ### Pretraining
74
+
75
+ The model was trained on 4 cloud TPUs in Pod configuration (16 TPU chips total) for one million steps with a batch size
76
+ of 256. The sequence length was limited to 128 tokens for 90% of the steps and 512 for the remaining 10%. The optimizer
77
+ 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,
78
+ learning rate warmup for 10,000 steps and linear decay of the learning rate after.
79
+
80
+ ### Fine-tuning
81
+
82
+ After pre-training, this model was fine-tuned on the SQuAD dataset with one of our fine-tuning scripts. In order to reproduce the training, you may use the following command:
83
+ ```
84
+ python -m torch.distributed.launch --nproc_per_node=8 ./examples/question-answering/run_qa.py \
85
+ --model_name_or_path bert-large-cased-whole-word-masking \
86
+ --dataset_name squad \
87
+ --do_train \
88
+ --do_eval \
89
+ --learning_rate 3e-5 \
90
+ --num_train_epochs 2 \
91
+ --max_seq_length 384 \
92
+ --doc_stride 128 \
93
+ --output_dir ./examples/models/wwm_cased_finetuned_squad/ \
94
+ --per_device_eval_batch_size=3 \
95
+ --per_device_train_batch_size=3 \
96
+ ```
97
+
98
+ ### BibTeX entry and citation info
99
+
100
+ ```bibtex
101
+ @article{DBLP:journals/corr/abs-1810-04805,
102
+ author = {Jacob Devlin and
103
+ Ming{-}Wei Chang and
104
+ Kenton Lee and
105
+ Kristina Toutanova},
106
+ title = {{BERT:} Pre-training of Deep Bidirectional Transformers for Language
107
+ Understanding},
108
+ journal = {CoRR},
109
+ volume = {abs/1810.04805},
110
+ year = {2018},
111
+ url = {http://arxiv.org/abs/1810.04805},
112
+ archivePrefix = {arXiv},
113
+ eprint = {1810.04805},
114
+ timestamp = {Tue, 30 Oct 2018 20:39:56 +0100},
115
+ biburl = {https://dblp.org/rec/journals/corr/abs-1810-04805.bib},
116
+ bibsource = {dblp computer science bibliography, https://dblp.org}
117
+ }
118
+ ```