ZhiyuanChen commited on
Commit
b415e32
·
verified ·
1 Parent(s): 7c8b1bc

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: rna
3
+ tags:
4
+ - Biology
5
+ - RNA
6
+ license: agpl-3.0
7
+ datasets:
8
+ - multimolecule/rnacentral
9
+ library_name: multimolecule
10
+ pipeline_tag: fill-mask
11
+ mask_token: "<mask>"
12
+ widget:
13
+ - example_title: "HIV-1"
14
+ text: "GGUC<mask>CUCUGGUUAGACCAGAUCUGAGCCU"
15
+ output:
16
+ - label: "G"
17
+ score: 0.09252794831991196
18
+ - label: "R"
19
+ score: 0.09062391519546509
20
+ - label: "A"
21
+ score: 0.08875908702611923
22
+ - label: "V"
23
+ score: 0.07809742540121078
24
+ - label: "S"
25
+ score: 0.07325706630945206
26
+ - example_title: "microRNA-21"
27
+ text: "UAGC<mask>UAUCAGACUGAUGUUG"
28
+ output:
29
+ - label: "A"
30
+ score: 0.08444530516862869
31
+ - label: "R"
32
+ score: 0.07878861576318741
33
+ - label: "G"
34
+ score: 0.07351073622703552
35
+ - label: "V"
36
+ score: 0.07145819813013077
37
+ - label: "M"
38
+ score: 0.07045349478721619
39
+ ---
40
+
41
+ # RNAErnie
42
+
43
+ Pre-trained model on non-coding RNA (ncRNA) using a multi-stage masked language modeling (MLM) objective.
44
+
45
+ ## Statement
46
+
47
+ _Multi-purpose RNA language modelling with motif-aware pretraining and type-guided fine-tuning_ is published in [Nature Machine Intelligence](https://doi.org/10.1038/s42256-024-00836-4), which is a Closed Access / Author-Fee journal.
48
+
49
+ > Machine learning has been at the forefront of the movement for free and open access to research.
50
+ >
51
+ > We see no role for closed access or author-fee publication in the future of machine learning research and believe the adoption of these journals as an outlet of record for the machine learning community would be a retrograde step.
52
+
53
+ The MultiMolecule team is committed to the principles of open access and open science.
54
+
55
+ We do NOT endorse the publication of manuscripts in Closed Access / Author-Fee journals and encourage the community to support Open Access journals and conferences.
56
+
57
+ Please consider signing the [Statement on Nature Machine Intelligence](https://openaccess.engineering.oregonstate.edu).
58
+
59
+ ## Disclaimer
60
+
61
+ This is an UNOFFICIAL implementation of the RNAErnie: An RNA Language Model with Structure-enhanced Representations by Ning Wang, Jiang Bian,
62
+ Haoyi Xiong, et al.
63
+
64
+ The OFFICIAL repository of RNAErnie is at [CatIIIIIIII/RNAErnie](https://github.com/CatIIIIIIII/RNAErnie).
65
+
66
+ > [!WARNING]
67
+ > The MultiMolecule team is unable to confirm that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
68
+ > This is because
69
+ >
70
+ > The proposed method is published in a Closed Access / Author-Fee journal.
71
+
72
+ **The team releasing RNAErnie did not write this model card for this model so this model card has been written by the MultiMolecule team.**
73
+
74
+ ## Model Details
75
+
76
+ RNAErnie is a [bert](https://huggingface.co/google-bert/bert-base-uncased)-style model pre-trained on a large corpus of non-coding RNA sequences in a self-supervised fashion. This means that the model was trained on the raw nucleotides of RNA sequences only, with an automatic process to generate inputs and labels from those texts. Please refer to the [Training Details](#training-details) section for more information on the training process.
77
+
78
+ Note that during the conversion process, additional tokens such as `[IND]` and ncRNA class symbols are removed.
79
+
80
+ ### Model Specification
81
+
82
+ | Num Layers | Hidden Size | Num Heads | Intermediate Size | Num Parameters (M) | FLOPs (G) | MACs (G) | Max Num Tokens |
83
+ | ---------- | ----------- | --------- | ----------------- | ------------------ | --------- | -------- | -------------- |
84
+ | 12 | 768 | 12 | 3072 | 86.06 | 22.37 | 11.17 | 512 |
85
+
86
+ ### Links
87
+
88
+ - **Code**: [multimolecule.rnaernie](https://github.com/DLS5-Omics/multimolecule/tree/master/multimolecule/models/rnaernie)
89
+ - **Weights**: [multimolecule/rnaernie](https://huggingface.co/multimolecule/rnaernie)
90
+ - **Data**: [multimolecule/rnacentral](https://huggingface.co/datasets/multimolecule/rnacentral)
91
+ - **Paper**: Multi-purpose RNA language modelling with motif-aware pretraining and type-guided fine-tuning
92
+ - **Developed by**: Ning Wang, Jiang Bian, Yuchen Li, Xuhong Li, Shahid Mumtaz, Linghe Kong, Haoyi Xiong.
93
+ - **Model type**: [BERT](https://huggingface.co/google-bert/bert-base-uncased) - [ERNIE](https://huggingface.co/nghuyong/ernie-3.0-base-zh)
94
+ - **Original Repository**: [CatIIIIIIII/RNAErnie](https://github.com/CatIIIIIIII/RNAErnie)
95
+
96
+ ## Usage
97
+
98
+ The model file depends on the [`multimolecule`](https://multimolecule.danling.org) library. You can install it using pip:
99
+
100
+ ```bash
101
+ pip install multimolecule
102
+ ```
103
+
104
+ ### Direct Use
105
+
106
+ You can use this model directly with a pipeline for masked language modeling:
107
+
108
+ ```python
109
+ >>> import multimolecule # you must import multimolecule to register models
110
+ >>> from transformers import pipeline
111
+
112
+ >>> unmasker = pipeline("fill-mask", model="multimolecule/rnaernie")
113
+ >>> unmasker("gguc<mask>cucugguuagaccagaucugagccu")
114
+ [{'score': 0.09252794831991196,
115
+ 'token': 8,
116
+ 'token_str': 'G',
117
+ 'sequence': 'G G U C G C U C U G G U U A G A C C A G A U C U G A G C C U'},
118
+ {'score': 0.09062391519546509,
119
+ 'token': 11,
120
+ 'token_str': 'R',
121
+ 'sequence': 'G G U C R C U C U G G U U A G A C C A G A U C U G A G C C U'},
122
+ {'score': 0.08875908702611923,
123
+ 'token': 6,
124
+ 'token_str': 'A',
125
+ 'sequence': 'G G U C A C U C U G G U U A G A C C A G A U C U G A G C C U'},
126
+ {'score': 0.07809742540121078,
127
+ 'token': 20,
128
+ 'token_str': 'V',
129
+ 'sequence': 'G G U C V C U C U G G U U A G A C C A G A U C U G A G C C U'},
130
+ {'score': 0.07325706630945206,
131
+ 'token': 13,
132
+ 'token_str': 'S',
133
+ 'sequence': 'G G U C S C U C U G G U U A G A C C A G A U C U G A G C C U'}]
134
+ ```
135
+
136
+ ### Downstream Use
137
+
138
+ #### Extract Features
139
+
140
+ Here is how to use this model to get the features of a given sequence in PyTorch:
141
+
142
+ ```python
143
+ from multimolecule import RnaTokenizer, RnaErnieModel
144
+
145
+
146
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnaernie")
147
+ model = RnaErnieModel.from_pretrained("multimolecule/rnaernie")
148
+
149
+ text = "UAGCUUAUCAGACUGAUGUUG"
150
+ input = tokenizer(text, return_tensors="pt")
151
+
152
+ output = model(**input)
153
+ ```
154
+
155
+ #### Sequence Classification / Regression
156
+
157
+ > [!NOTE]
158
+ > This model is not fine-tuned for any specific task. You will need to fine-tune the model on a downstream task to use it for sequence classification or regression.
159
+
160
+ Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
161
+
162
+ ```python
163
+ import torch
164
+ from multimolecule import RnaTokenizer, RnaErnieForSequencePrediction
165
+
166
+
167
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnaernie")
168
+ model = RnaErnieForSequencePrediction.from_pretrained("multimolecule/rnaernie")
169
+
170
+ text = "UAGCUUAUCAGACUGAUGUUG"
171
+ input = tokenizer(text, return_tensors="pt")
172
+ label = torch.tensor([1])
173
+
174
+ output = model(**input, labels=label)
175
+ ```
176
+
177
+ #### Token Classification / Regression
178
+
179
+ > [!NOTE]
180
+ > This model is not fine-tuned for any specific task. You will need to fine-tune the model on a downstream task to use it for token classification or regression.
181
+
182
+ Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
183
+
184
+ ```python
185
+ import torch
186
+ from multimolecule import RnaTokenizer, RnaErnieForTokenPrediction
187
+
188
+
189
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnaernie")
190
+ model = RnaErnieForTokenPrediction.from_pretrained("multimolecule/rnaernie")
191
+
192
+ text = "UAGCUUAUCAGACUGAUGUUG"
193
+ input = tokenizer(text, return_tensors="pt")
194
+ label = torch.randint(2, (len(text), ))
195
+
196
+ output = model(**input, labels=label)
197
+ ```
198
+
199
+ #### Contact Classification / Regression
200
+
201
+ > [!NOTE]
202
+ > This model is not fine-tuned for any specific task. You will need to fine-tune the model on a downstream task to use it for contact classification or regression.
203
+
204
+ Here is how to use this model as backbone to fine-tune for a contact-level task in PyTorch:
205
+
206
+ ```python
207
+ import torch
208
+ from multimolecule import RnaTokenizer, RnaErnieForContactPrediction
209
+
210
+
211
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnaernie")
212
+ model = RnaErnieForContactPrediction.from_pretrained("multimolecule/rnaernie")
213
+
214
+ text = "UAGCUUAUCAGACUGAUGUUG"
215
+ input = tokenizer(text, return_tensors="pt")
216
+ label = torch.randint(2, (len(text), len(text)))
217
+
218
+ output = model(**input, labels=label)
219
+ ```
220
+
221
+ ## Training Details
222
+
223
+ RNAErnie used Masked Language Modeling (MLM) as the pre-training objective: taking a sequence, the model randomly masks 15% of the tokens in the input then runs the entire masked sentence through the model and has to predict the masked tokens. This is comparable to the Cloze task in language modeling.
224
+
225
+ ### Training Data
226
+
227
+ The RNAErnie model was pre-trained on [RNAcentral](https://multimolecule.danling.org/datasets/rnacentral).
228
+ RNAcentral is a free, public resource that offers integrated access to a comprehensive and up-to-date set of non-coding RNA sequences provided by a collaborating group of [Expert Databases](https://rnacentral.org/expert-databases) representing a broad range of organisms and RNA types.
229
+
230
+ RNAErnie used a subset of RNAcentral for pre-training. The subset contains 23 million sequences.
231
+ RNAErnie preprocessed all tokens by replacing "T"s with "S"s.
232
+
233
+ Note that [`RnaTokenizer`][multimolecule.RnaTokenizer] will convert "T"s to "U"s for you, you may disable this behaviour by passing `replace_T_with_U=False`.
234
+
235
+ ### Training Procedure
236
+
237
+ #### Preprocessing
238
+
239
+ RNAErnie used masked language modeling (MLM) as the pre-training objective. The masking procedure is similar to the one used in BERT:
240
+
241
+ - 15% of the tokens are masked.
242
+ - In 80% of the cases, the masked tokens are replaced by `<mask>`.
243
+ - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
244
+ - In the 10% remaining cases, the masked tokens are left as is.
245
+
246
+ #### Pre-training
247
+
248
+ RNAErnie used a special 3-stage training pipeline to pre-train the model, each with a different masking strategy:
249
+
250
+ Base-level Masking: The masking applies to each nucleotide in the sequence.
251
+ Subsequence-level Masking: The masking applies to subsequences of 4-8bp in the sequence.
252
+ Motif-level Masking: The model is trained on motif datasets.
253
+
254
+ The model was trained on 4 NVIDIA V100 GPUs with 32GiB memories.
255
+
256
+ - Batch size: 50
257
+ - Steps: 2,580,000
258
+ - Optimizer: AdamW
259
+ - Learning rate: 1e-4
260
+ - Learning rate warm-up: 129,000 steps
261
+ - Learning rate cool-down: 129,000 steps
262
+ - Minimum learning rate: 5e-5
263
+ - Weight decay: 0.01
264
+
265
+ ## Citation
266
+
267
+ Citation information is not available for papers published in Closed Access / Author-Fee journals.
268
+
269
+ ## Contact
270
+
271
+ Please use GitHub issues of [MultiMolecule](https://github.com/DLS5-Omics/multimolecule/issues) for any questions or comments on the model card.
272
+
273
+ Please contact the authors of the RNAErnie paper for questions or comments on the paper/model.
274
+
275
+ ## License
276
+
277
+ This model is licensed under the [AGPL-3.0 License](https://www.gnu.org/licenses/agpl-3.0.html).
278
+
279
+ ```spdx
280
+ SPDX-License-Identifier: AGPL-3.0-or-later
281
+ ```
config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RnaErnieForPreTraining"
4
+ ],
5
+ "attention_dropout": 0.1,
6
+ "bos_token_id": 1,
7
+ "eos_token_id": 2,
8
+ "head": null,
9
+ "hidden_act": "relu",
10
+ "hidden_dropout": 0.1,
11
+ "hidden_size": 768,
12
+ "id2label": null,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 3072,
15
+ "label2id": null,
16
+ "layer_norm_eps": 1e-12,
17
+ "lm_head": null,
18
+ "mask_token_id": 4,
19
+ "max_position_embeddings": 513,
20
+ "model_type": "rnaernie",
21
+ "null_token_id": 5,
22
+ "num_attention_heads": 12,
23
+ "num_hidden_layers": 12,
24
+ "num_labels": 1,
25
+ "pad_token_id": 0,
26
+ "position_embedding_type": "absolute",
27
+ "torch_dtype": "float32",
28
+ "transformers_version": "4.50.0",
29
+ "type_vocab_size": 2,
30
+ "unk_token_id": 3,
31
+ "use_cache": true,
32
+ "vocab_size": 26
33
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9cc7fb6e1c38b737d35c2a66fbcababb925c7af49c154d71d12576f60d38a4f7
3
+ size 346641488
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6ba5c274565c261f731acbdefabe1e3618324639045e161772862b1d53254c0b
3
+ size 346684922
special_tokens_map.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<null>"
4
+ ],
5
+ "bos_token": "<cls>",
6
+ "cls_token": "<cls>",
7
+ "eos_token": "<eos>",
8
+ "mask_token": "<mask>",
9
+ "pad_token": "<pad>",
10
+ "sep_token": "<eos>",
11
+ "unk_token": "<unk>"
12
+ }
tokenizer_config.json ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<pad>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<cls>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "<eos>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "<unk>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "4": {
36
+ "content": "<mask>",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ },
43
+ "5": {
44
+ "content": "<null>",
45
+ "lstrip": false,
46
+ "normalized": false,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": true
50
+ }
51
+ },
52
+ "additional_special_tokens": [
53
+ "<null>"
54
+ ],
55
+ "bos_token": "<cls>",
56
+ "clean_up_tokenization_spaces": true,
57
+ "cls_token": "<cls>",
58
+ "codon": false,
59
+ "eos_token": "<eos>",
60
+ "extra_special_tokens": {},
61
+ "mask_token": "<mask>",
62
+ "model_max_length": 513,
63
+ "nmers": 1,
64
+ "pad_token": "<pad>",
65
+ "replace_T_with_U": true,
66
+ "sep_token": "<eos>",
67
+ "tokenizer_class": "RnaTokenizer",
68
+ "unk_token": "<unk>"
69
+ }
vocab.txt ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <pad>
2
+ <cls>
3
+ <eos>
4
+ <unk>
5
+ <mask>
6
+ <null>
7
+ A
8
+ C
9
+ G
10
+ U
11
+ N
12
+ R
13
+ Y
14
+ S
15
+ W
16
+ K
17
+ M
18
+ B
19
+ D
20
+ H
21
+ V
22
+ .
23
+ X
24
+ *
25
+ -
26
+ I