Shu Huang commited on
Commit
76be348
·
1 Parent(s): e7d0537

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +112 -0
README.md ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ tags:
4
+ - exbert
5
+ license: apache-2.0
6
+ datasets:
7
+ - batterypapers
8
+ ---
9
+
10
+ # BatteryOnlyBERT-cased model
11
+
12
+ Pretrained model on a large corpus of battery research papers using a masked language modeling (MLM) objective. It was introduced in
13
+ [this paper](paper_link) and first released in
14
+ [this repository](https://github.com/ShuHuang/batterybert). This model is case-sensitive: it
15
+ makes a difference between english and English.
16
+
17
+ ## Model description
18
+
19
+ BatteryOnlyBERT is a transformers model pretrained on a large corpus of battery research papers in a self-supervised fashion. This means
20
+ it was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of
21
+ publicly available data) with an automatic process to generate inputs and labels from those texts.
22
+
23
+ More precisely, it was pretrained with the Masked language modeling (MLM) objective. Taking a sentence, the model
24
+ randomly masks 15% of the words in the input then run the entire masked sentence through the model and has to predict
25
+ the masked words. This is different from traditional recurrent neural networks (RNNs) that usually see the words one
26
+ after the other, or from autoregressive models like GPT which internally mask the future tokens. It allows the model to
27
+ learn a bidirectional representation of the sentence.
28
+
29
+ This way, the model learns an inner representation of the English language that can then be used to extract features
30
+ useful for downstream tasks: if you have a dataset of labeled sentences for instance, you can train a standard
31
+ classifier using the features produced by the BERT model as inputs.
32
+
33
+ ## Intended uses & limitations
34
+
35
+ You can use the raw model for masked language modeling, but it's mostly intended to be fine-tuned on a downstream task.
36
+ See the [model hub](https://huggingface.co/models?filter=batterybert) to look for fine-tuned versions on a task that
37
+ interests you.
38
+
39
+ Note that this model is primarily aimed at being fine-tuned on tasks that use the whole sentence (potentially masked)
40
+ to make decisions, such as sequence classification, token classification or question answering. For tasks such as text
41
+ generation you should look at model like GPT2.
42
+
43
+ ### How to use
44
+
45
+ You can use this model directly with a pipeline for masked language modeling:
46
+
47
+ ```python
48
+ >>> from transformers import pipeline
49
+ >>> unmasker = pipeline('fill-mask', model='batterydata/batteryonlybert-cased')
50
+ >>> unmasker("Hello I'm a <mask> model.")
51
+ ```
52
+
53
+ Here is how to use this model to get the features of a given text in PyTorch:
54
+
55
+ ```python
56
+ from transformers import BertTokenizer, BertModel
57
+ tokenizer = BertTokenizer.from_pretrained('batterydata/batteryonlybert-cased')
58
+ model = BertModel.from_pretrained('batterydata/batteryonlybert-cased')
59
+ text = "Replace me by any text you'd like."
60
+ encoded_input = tokenizer(text, return_tensors='pt')
61
+ output = model(**encoded_input)
62
+ ```
63
+
64
+ and in TensorFlow:
65
+
66
+ ```python
67
+ from transformers import BertTokenizer, TFBertModel
68
+ tokenizer = BertTokenizer.from_pretrained('batterydata/batteryonlybert-cased')
69
+ model = TFBertModel.from_pretrained('batterydata/batteryonlybert-cased')
70
+ text = "Replace me by any text you'd like."
71
+ encoded_input = tokenizer(text, return_tensors='tf')
72
+ output = model(encoded_input)
73
+ ```
74
+
75
+ ## Training data
76
+
77
+ The BatteryOnlyBERT model was pretrained on the full text of battery papers only. The paper corpus contains a total of 400,366 battery research papers that are published from 2000 to June 2021, from the publishers Royal Society of Chemistry (RSC), Elsevier, and Springer. The list of DOIs can be found at [Github](https://github.com/ShuHuang/batterybert/blob/main/corpus.txt).
78
+
79
+ ## Training procedure
80
+
81
+ ### Preprocessing
82
+
83
+ The texts are lowercased and tokenized using WordPiece and a vocabulary size of 28,996. The inputs of the model are
84
+ then of the form:
85
+
86
+ ```
87
+ [CLS] Sentence A [SEP] Sentence B [SEP]
88
+ ```
89
+
90
+ The details of the masking procedure for each sentence are the following:
91
+ - 15% of the tokens are masked.
92
+ - In 80% of the cases, the masked tokens are replaced by `[MASK]`.
93
+ - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
94
+ - In the 10% remaining cases, the masked tokens are left as is.
95
+
96
+ ### Pretraining
97
+
98
+
99
+ The model was trained on 8 NVIDIA DGX A100 GPUs for 1,500,000 steps with a batch size of 256. The sequence length was limited to 512 tokens. The optimizer 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
+ ## Evaluation results
103
+
104
+ Final loss: 1.0614.
105
+
106
+ ## Authors
107
+ Shu Huang: `sh2009 [at] cam.ac.uk`
108
+
109
+ Jacqueline Cole: `jmc61 [at] cam.ac.uk`
110
+
111
+ ## Citation
112
+ BatteryBERT: A Pre-trained Language Model for Battery Database Enhancement