batterydata commited on
Commit
3c2919a
1 Parent(s): c06e258

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
+ # BatterySciBERT-cased model
11
+
12
+ Pretrained model on a large corpus of battery research papers using a masked language modeling (MLM) objective, starting with the [SciBERT-cased](https://huggingface.co/allenai/scibert_scivocab_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 uncased: it does not make a difference
15
+ between english and English.
16
+
17
+ ## Model description
18
+
19
+ BatterySciBERT is a transformers model pretrained on a large corpus of battery research papers in a self-supervised fashion, starting with the [SciBERT-cased](https://huggingface.co/allenai/scibert_scivocab_cased) weights. 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
+ ## Training data
34
+
35
+ The BatterySciBERT model was pretrained on the full text of battery papers only, after initialized from the [SciBERT-cased](https://huggingface.co/allenai/scibert_scivocab_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).
36
+
37
+ ## Training procedure
38
+
39
+ ### Preprocessing
40
+
41
+ The texts are tokenized using WordPiece and a vocabulary size of 31,116. The inputs of the model are
42
+ then of the form:
43
+
44
+ ```
45
+ [CLS] Sentence A [SEP] Sentence B [SEP]
46
+ ```
47
+
48
+ The details of the masking procedure for each sentence are the following:
49
+ - 15% of the tokens are masked.
50
+ - In 80% of the cases, the masked tokens are replaced by `[MASK]`.
51
+ - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
52
+ - In the 10% remaining cases, the masked tokens are left as is.
53
+
54
+ ### Pretraining
55
+
56
+
57
+ 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,
58
+ learning rate warmup for 10,000 steps and linear decay of the learning rate after.
59
+
60
+ ## Intended uses & limitations
61
+
62
+ You can use the raw model for masked language modeling, but it's mostly intended to be fine-tuned on a downstream task.
63
+ See the [model hub](https://huggingface.co/models?filter=batterybert) to look for fine-tuned versions on a task that
64
+ interests you.
65
+
66
+ Note that this model is primarily aimed at being fine-tuned on tasks that use the whole sentence (potentially masked)
67
+ to make decisions, such as sequence classification, token classification or question answering. For tasks such as text
68
+ generation you should look at model like GPT2.
69
+
70
+ ### How to use
71
+
72
+ You can use this model directly with a pipeline for masked language modeling:
73
+
74
+ ```python
75
+ >>> from transformers import pipeline
76
+ >>> unmasker = pipeline('fill-mask', model='batterydata/batteryscibert-cased')
77
+ >>> unmasker("Hello I'm a <mask> model.")
78
+ ```
79
+
80
+ Here is how to use this model to get the features of a given text in PyTorch:
81
+
82
+ ```python
83
+ from transformers import BertTokenizer, BertModel
84
+ tokenizer = BertTokenizer.from_pretrained('batterydata/batteryscibert-cased')
85
+ model = BertModel.from_pretrained('batterydata/batteryscibert-cased')
86
+ text = "Replace me by any text you'd like."
87
+ encoded_input = tokenizer(text, return_tensors='pt')
88
+ output = model(**encoded_input)
89
+ ```
90
+
91
+ and in TensorFlow:
92
+
93
+ ```python
94
+ from transformers import BertTokenizer, TFBertModel
95
+ tokenizer = BertTokenizer.from_pretrained('batterydata/batteryscibert-cased')
96
+ model = TFBertModel.from_pretrained('batterydata/batteryscibert-cased')
97
+ text = "Replace me by any text you'd like."
98
+ encoded_input = tokenizer(text, return_tensors='tf')
99
+ output = model(encoded_input)
100
+ ```
101
+
102
+ ## Evaluation results
103
+
104
+ Final loss: 1.0505.
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