ZhiyuanChen commited on
Commit
2a98c38
·
verified ·
1 Parent(s): 362b0a9

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: "."
17
+ score: 0.2752501964569092
18
+ - label: "*"
19
+ score: 0.22108642756938934
20
+ - label: "I"
21
+ score: 0.18201279640197754
22
+ - label: "U"
23
+ score: 0.10875876247882843
24
+ - label: "A"
25
+ score: 0.08898332715034485
26
+ - example_title: "microRNA-21"
27
+ text: "UAGC<mask>UAUCAGACUGAUGUUG"
28
+ output:
29
+ - label: "."
30
+ score: 0.2275155633687973
31
+ - label: "*"
32
+ score: 0.18255384266376495
33
+ - label: "I"
34
+ score: 0.14644214510917664
35
+ - label: "A"
36
+ score: 0.1262909322977066
37
+ - label: "U"
38
+ score: 0.12270607799291611
39
+ ---
40
+
41
+ # RNA-FM
42
+
43
+ Pre-trained model on non-coding RNA (ncRNA) using a masked language modeling (MLM) objective.
44
+
45
+ ## Disclaimer
46
+
47
+ This is an UNOFFICIAL implementation of the [Interpretable RNA Foundation Model from Unannotated Data for Highly Accurate RNA Structure and Function Predictions](https://doi.org/10.1101/2022.08.06.503062) by Jiayang Chen, Zhihang Hue, Siqi Sun, et al.
48
+
49
+ The OFFICIAL repository of RNA-FM is at [ml4bio/RNA-FM](https://github.com/ml4bio/RNA-FM).
50
+
51
+ > [!TIP]
52
+ > The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
53
+
54
+ **The team releasing RNA-FM did not write this model card for this model so this model card has been written by the MultiMolecule team.**
55
+
56
+ ## Model Details
57
+
58
+ RNA-FM 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.
59
+
60
+ ### Variants
61
+
62
+ - **[multimolecule/rnafm](https://huggingface.co/multimolecule/rnafm)**: The RNA-FM model pre-trained on non-coding RNA sequences.
63
+ - **[multimolecule/mrnafm](https://huggingface.co/multimolecule/mrnafm)**: The RNA-FM model pre-trained on messenger RNA sequences.
64
+
65
+ ### Model Specification
66
+
67
+ <table>
68
+ <thead>
69
+ <tr>
70
+ <th>Variants</th>
71
+ <th>Num Layers</th>
72
+ <th>Hidden Size</th>
73
+ <th>Num Heads</th>
74
+ <th>Intermediate Size</th>
75
+ <th>Num Parameters (M)</th>
76
+ <th>FLOPs (G)</th>
77
+ <th>MACs (G)</th>
78
+ <th>Max Num Tokens</th>
79
+ </tr>
80
+ </thead>
81
+ <tbody>
82
+ <tr>
83
+ <td>RNA-FM</td>
84
+ <td rowspan="2">12</td>
85
+ <td>640</td>
86
+ <td rowspan="2">20</td>
87
+ <td rowspan="2">5120</td>
88
+ <td>99.52</td>
89
+ <td>25.68</td>
90
+ <td>12.83</td>
91
+ <td rowspan="2">1024</td>
92
+ </tr>
93
+ <tr>
94
+ <td>mRNA-FM</td>
95
+ <td>1280</td>
96
+ <td>239.25</td>
97
+ <td>61.43</td>
98
+ <td>30.7</td>
99
+ </tr>
100
+ </tbody>
101
+ </table>
102
+
103
+ ### Links
104
+
105
+ - **Code**: [multimolecule.rnafm](https://github.com/DLS5-Omics/multimolecule/tree/master/multimolecule/models/rnafm)
106
+ - **Data**: [multimolecule/rnacentral](https://huggingface.co/datasets/multimolecule/rnacentral)
107
+ - **Paper**: [Interpretable RNA Foundation Model from Unannotated Data for Highly Accurate RNA Structure and Function Predictions](https://doi.org/10.1101/2022.08.06.503062)
108
+ - **Developed by**: Jiayang Chen, Zhihang Hu, Siqi Sun, Qingxiong Tan, Yixuan Wang, Qinze Yu, Licheng Zong, Liang Hong, Jin Xiao, Tao Shen, Irwin King, Yu Li
109
+ - **Model type**: [BERT](https://huggingface.co/google-bert/bert-base-uncased) - [ESM](https://huggingface.co/facebook/esm2_t48_15B_UR50D)
110
+ - **Original Repository**: [ml4bio/RNA-FM](https://github.com/ml4bio/RNA-FM)
111
+
112
+ ## Usage
113
+
114
+ The model file depends on the [`multimolecule`](https://multimolecule.danling.org) library. You can install it using pip:
115
+
116
+ ```bash
117
+ pip install multimolecule
118
+ ```
119
+
120
+ ### Direct Use
121
+
122
+ #### Masked Language Modeling
123
+
124
+ You can use this model directly with a pipeline for masked language modeling:
125
+
126
+ ```python
127
+ >>> import multimolecule # you must import multimolecule to register models
128
+ >>> from transformers import pipeline
129
+
130
+ >>> unmasker = pipeline("fill-mask", model="multimolecule/rnafm")
131
+ >>> unmasker("gguc<mask>cucugguuagaccagaucugagccu")
132
+ [{'score': 0.2752501964569092,
133
+ 'token': 21,
134
+ 'token_str': '.',
135
+ 'sequence': 'G G U C. 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'},
136
+ {'score': 0.22108642756938934,
137
+ 'token': 23,
138
+ 'token_str': '*',
139
+ 'sequence': 'G G U C * 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'},
140
+ {'score': 0.18201279640197754,
141
+ 'token': 25,
142
+ 'token_str': 'I',
143
+ 'sequence': 'G G U C I 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'},
144
+ {'score': 0.10875876247882843,
145
+ 'token': 9,
146
+ 'token_str': 'U',
147
+ 'sequence': 'G G U C U 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'},
148
+ {'score': 0.08898332715034485,
149
+ 'token': 6,
150
+ 'token_str': 'A',
151
+ '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'}]
152
+ ```
153
+
154
+ ### Downstream Use
155
+
156
+ #### Extract Features
157
+
158
+ Here is how to use this model to get the features of a given sequence in PyTorch:
159
+
160
+ ```python
161
+ from multimolecule import RnaTokenizer, RnaFmModel
162
+
163
+
164
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnafm")
165
+ model = RnaFmModel.from_pretrained("multimolecule/rnafm")
166
+
167
+ text = "UAGCUUAUCAGACUGAUGUUG"
168
+ input = tokenizer(text, return_tensors="pt")
169
+
170
+ output = model(**input)
171
+ ```
172
+
173
+ #### Sequence Classification / Regression
174
+
175
+ > [!NOTE]
176
+ > 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.
177
+
178
+ Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
179
+
180
+ ```python
181
+ import torch
182
+ from multimolecule import RnaTokenizer, RnaFmForSequencePrediction
183
+
184
+
185
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnafm")
186
+ model = RnaFmForSequencePrediction.from_pretrained("multimolecule/rnafm")
187
+
188
+ text = "UAGCUUAUCAGACUGAUGUUG"
189
+ input = tokenizer(text, return_tensors="pt")
190
+ label = torch.tensor([1])
191
+
192
+ output = model(**input, labels=label)
193
+ ```
194
+
195
+ #### Token Classification / Regression
196
+
197
+ > [!NOTE]
198
+ > 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.
199
+
200
+ Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
201
+
202
+ ```python
203
+ import torch
204
+ from multimolecule import RnaTokenizer, RnaFmForTokenPrediction
205
+
206
+
207
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnafm")
208
+ model = RnaFmForTokenPrediction.from_pretrained("multimolecule/rnafm")
209
+
210
+ text = "UAGCUUAUCAGACUGAUGUUG"
211
+ input = tokenizer(text, return_tensors="pt")
212
+ label = torch.randint(2, (len(text), ))
213
+
214
+ output = model(**input, labels=label)
215
+ ```
216
+
217
+ #### Contact Classification / Regression
218
+
219
+ > [!NOTE]
220
+ > 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.
221
+
222
+ Here is how to use this model as backbone to fine-tune for a contact-level task in PyTorch:
223
+
224
+ ```python
225
+ import torch
226
+ from multimolecule import RnaTokenizer, RnaFmForContactPrediction
227
+
228
+
229
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnafm")
230
+ model = RnaFmForContactPrediction.from_pretrained("multimolecule/rnafm")
231
+
232
+ text = "UAGCUUAUCAGACUGAUGUUG"
233
+ input = tokenizer(text, return_tensors="pt")
234
+ label = torch.randint(2, (len(text), len(text)))
235
+
236
+ output = model(**input, labels=label)
237
+ ```
238
+
239
+ ## Training Details
240
+
241
+ RNA-FM 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.
242
+
243
+ ### Training Data
244
+
245
+ The RNA-FM model was pre-trained on [RNAcentral](https://multimolecule.danling.org/datasets/rnacentral).
246
+ 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.
247
+
248
+ RNA-FM applied [CD-HIT (CD-HIT-EST)](https://sites.google.com/view/cd-hit) with a cut-off at 100% sequence identity to remove redundancy from the RNAcentral. The final dataset contains 23.7 million non-redundant RNA sequences.
249
+
250
+ RNA-FM preprocessed all tokens by replacing "U"s with "T"s.
251
+
252
+ Note that during model conversions, "T" is replaced with "U". [`RnaTokenizer`][multimolecule.RnaTokenizer] will convert "T"s to "U"s for you, you may disable this behaviour by passing `replace_T_with_U=False`.
253
+
254
+ ### Training Procedure
255
+
256
+ #### Preprocessing
257
+
258
+ RNA-FM used masked language modeling (MLM) as the pre-training objective. The masking procedure is similar to the one used in BERT:
259
+
260
+ - 15% of the tokens are masked.
261
+ - In 80% of the cases, the masked tokens are replaced by `<mask>`.
262
+ - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
263
+ - In the 10% remaining cases, the masked tokens are left as is.
264
+
265
+ #### Pre-training
266
+
267
+ The model was trained on 8 NVIDIA A100 GPUs with 80GiB memories.
268
+
269
+ - Learning rate: 1e-4
270
+ - Learning rate scheduler: Inverse square root
271
+ - Learning rate warm-up: 10,000 steps
272
+ - Weight decay: 0.01
273
+
274
+ ## Citation
275
+
276
+ **BibTeX**:
277
+
278
+ ```bibtex
279
+ @article{chen2022interpretable,
280
+ title={Interpretable rna foundation model from unannotated data for highly accurate rna structure and function predictions},
281
+ author={Chen, Jiayang and Hu, Zhihang and Sun, Siqi and Tan, Qingxiong and Wang, Yixuan and Yu, Qinze and Zong, Licheng and Hong, Liang and Xiao, Jin and King, Irwin and others},
282
+ journal={arXiv preprint arXiv:2204.00300},
283
+ year={2022}
284
+ }
285
+ ```
286
+
287
+ ## Contact
288
+
289
+ Please use GitHub issues of [MultiMolecule](https://github.com/DLS5-Omics/multimolecule/issues) for any questions or comments on the model card.
290
+
291
+ Please contact the authors of the [RNA-FM paper](https://doi.org/10.1101/2022.08.06.503062) for questions or comments on the paper/model.
292
+
293
+ ## License
294
+
295
+ This model is licensed under the [AGPL-3.0 License](https://www.gnu.org/licenses/agpl-3.0.html).
296
+
297
+ ```spdx
298
+ SPDX-License-Identifier: AGPL-3.0-or-later
299
+ ```
config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RnaFmForPreTraining"
4
+ ],
5
+ "attention_dropout": 0.1,
6
+ "bos_token_id": 1,
7
+ "codon": false,
8
+ "embed_norm": true,
9
+ "eos_token_id": 2,
10
+ "head": null,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout": 0.1,
13
+ "hidden_size": 640,
14
+ "id2label": null,
15
+ "initializer_range": 0.02,
16
+ "intermediate_size": 5120,
17
+ "label2id": null,
18
+ "layer_norm_eps": 1e-12,
19
+ "lm_head": null,
20
+ "mask_token_id": 4,
21
+ "max_position_embeddings": 1026,
22
+ "model_type": "rnafm",
23
+ "null_token_id": 5,
24
+ "num_attention_heads": 20,
25
+ "num_hidden_layers": 12,
26
+ "num_labels": 1,
27
+ "pad_token_id": 0,
28
+ "position_embedding_type": "absolute",
29
+ "token_dropout": false,
30
+ "torch_dtype": "float32",
31
+ "transformers_version": "4.50.0",
32
+ "unk_token_id": 3,
33
+ "use_cache": true,
34
+ "vocab_size": 26
35
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1fccd0adf65340ebf246cb35c1ce7eb68e0830023092a7561cee26ee40261a19
3
+ size 398112460
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb64597c22d751fa32b0f0cacef4f8bd654de265e581890d6844003d0559922c
3
+ size 398156030
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": 1024,
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