batterydata commited on
Commit
0106ed8
1 Parent(s): 6c0c38a

Update README.md

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