ZhiyuanChen commited on
Commit
c65cf05
·
verified ·
1 Parent(s): ae6a94b

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: rna
3
+ tags:
4
+ - Biology
5
+ - RNA
6
+ license: agpl-3.0
7
+ datasets:
8
+ - multimolecule/bprna-spot
9
+ library_name: multimolecule
10
+ base_model: multimolecule/rnafm
11
+ pipeline_tag: fill-mask
12
+ mask_token: "<mask>"
13
+ widget:
14
+ - example_title: "HIV-1"
15
+ text: "GGUC<mask>CUCUGGUUAGACCAGAUCUGAGCCU"
16
+ output:
17
+ - label: "."
18
+ score: 0.2907504141330719
19
+ - label: "*"
20
+ score: 0.2359575480222702
21
+ - label: "I"
22
+ score: 0.19035066664218903
23
+ - label: "A"
24
+ score: 0.09356562793254852
25
+ - label: "U"
26
+ score: 0.08782266825437546
27
+ - example_title: "microRNA-21"
28
+ text: "UAGC<mask>UAUCAGACUGAUGUUG"
29
+ output:
30
+ - label: "."
31
+ score: 0.24210385978221893
32
+ - label: "*"
33
+ score: 0.19574487209320068
34
+ - label: "I"
35
+ score: 0.15285496413707733
36
+ - label: "A"
37
+ score: 0.12451102584600449
38
+ - label: "U"
39
+ score: 0.11860787868499756
40
+ ---
41
+
42
+ # RNA-FM
43
+
44
+ Pre-trained model on non-coding RNA (ncRNA) using a masked language modeling (MLM) objective.
45
+
46
+ ## Disclaimer
47
+
48
+ 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.
49
+
50
+ The OFFICIAL repository of RNA-FM is at [ml4bio/RNA-FM](https://github.com/ml4bio/RNA-FM).
51
+
52
+ > [!TIP]
53
+ > The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
54
+
55
+ **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.**
56
+
57
+ ## Model Details
58
+
59
+ 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.
60
+
61
+ ### Variants
62
+
63
+ - **[multimolecule/rnafm](https://huggingface.co/multimolecule/rnafm)**: The RNA-FM model pre-trained on non-coding RNA sequences.
64
+ - **[multimolecule/mrnafm](https://huggingface.co/multimolecule/mrnafm)**: The RNA-FM model pre-trained on messenger RNA sequences.
65
+
66
+ ### Model Specification
67
+
68
+ <table>
69
+ <thead>
70
+ <tr>
71
+ <th>Variants</th>
72
+ <th>Num Layers</th>
73
+ <th>Hidden Size</th>
74
+ <th>Num Heads</th>
75
+ <th>Intermediate Size</th>
76
+ <th>Num Parameters (M)</th>
77
+ <th>FLOPs (G)</th>
78
+ <th>MACs (G)</th>
79
+ <th>Max Num Tokens</th>
80
+ </tr>
81
+ </thead>
82
+ <tbody>
83
+ <tr>
84
+ <td>RNA-FM</td>
85
+ <td rowspan="2">12</td>
86
+ <td>640</td>
87
+ <td rowspan="2">20</td>
88
+ <td rowspan="2">5120</td>
89
+ <td>99.52</td>
90
+ <td>25.68</td>
91
+ <td>12.83</td>
92
+ <td rowspan="2">1024</td>
93
+ </tr>
94
+ <tr>
95
+ <td>mRNA-FM</td>
96
+ <td>1280</td>
97
+ <td>239.25</td>
98
+ <td>61.43</td>
99
+ <td>30.7</td>
100
+ </tr>
101
+ </tbody>
102
+ </table>
103
+
104
+ ### Links
105
+
106
+ - **Code**: [multimolecule.rnafm](https://github.com/DLS5-Omics/multimolecule/tree/master/multimolecule/models/rnafm)
107
+ - **Data**: [multimolecule/rnacentral](https://huggingface.co/datasets/multimolecule/rnacentral)
108
+ - **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)
109
+ - **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
110
+ - **Model type**: [BERT](https://huggingface.co/google-bert/bert-base-uncased) - [ESM](https://huggingface.co/facebook/esm2_t48_15B_UR50D)
111
+ - **Original Repository**: [ml4bio/RNA-FM](https://github.com/ml4bio/RNA-FM)
112
+
113
+ ## Usage
114
+
115
+ The model file depends on the [`multimolecule`](https://multimolecule.danling.org) library. You can install it using pip:
116
+
117
+ ```bash
118
+ pip install multimolecule
119
+ ```
120
+
121
+ ### Direct Use
122
+
123
+ #### RNA Secondary Structure Prediction
124
+
125
+ You can use this model directly with a pipeline for secondary structure prediction:
126
+
127
+ ```python
128
+ >>> import multimolecule # you must import multimolecule to register models
129
+ >>> from transformers import pipeline
130
+
131
+ >>> predictor = pipeline("rna-secondary-structure", model="multimolecule/rnafm-ss")
132
+ >>> predictor("GGUCUCUCUGGUUAGACCAGAUCUGAGCCU")
133
+ {'sequence': 'GGUCUCUCUGGUUAGACCAGAUCUGAGCCU',
134
+ 'secondary_structure': '.(.(((((((((...))))))...))))..'}
135
+ ```
136
+
137
+ ### Downstream Use
138
+
139
+ #### Extract Features
140
+
141
+ Here is how to use this model to get the features of a given sequence in PyTorch:
142
+
143
+ ```python
144
+ from multimolecule import RnaTokenizer, RnaFmModel
145
+
146
+
147
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnafm-ss")
148
+ model = RnaFmModel.from_pretrained("multimolecule/rnafm-ss")
149
+
150
+ text = "UAGCUUAUCAGACUGAUGUUG"
151
+ input = tokenizer(text, return_tensors="pt")
152
+
153
+ output = model(**input)
154
+ ```
155
+
156
+ #### Sequence Classification / Regression
157
+
158
+ > [!NOTE]
159
+ > 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.
160
+
161
+ Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
162
+
163
+ ```python
164
+ import torch
165
+ from multimolecule import RnaTokenizer, RnaFmForSequencePrediction
166
+
167
+
168
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnafm-ss")
169
+ model = RnaFmForSequencePrediction.from_pretrained("multimolecule/rnafm-ss")
170
+
171
+ text = "UAGCUUAUCAGACUGAUGUUG"
172
+ input = tokenizer(text, return_tensors="pt")
173
+ label = torch.tensor([1])
174
+
175
+ output = model(**input, labels=label)
176
+ ```
177
+
178
+ #### Token Classification / Regression
179
+
180
+ > [!NOTE]
181
+ > 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.
182
+
183
+ Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
184
+
185
+ ```python
186
+ import torch
187
+ from multimolecule import RnaTokenizer, RnaFmForTokenPrediction
188
+
189
+
190
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnafm-ss")
191
+ model = RnaFmForTokenPrediction.from_pretrained("multimolecule/rnafm-ss")
192
+
193
+ text = "UAGCUUAUCAGACUGAUGUUG"
194
+ input = tokenizer(text, return_tensors="pt")
195
+ label = torch.randint(2, (len(text), ))
196
+
197
+ output = model(**input, labels=label)
198
+ ```
199
+
200
+ #### Contact Classification / Regression
201
+
202
+ > [!NOTE]
203
+ > 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.
204
+
205
+ Here is how to use this model as backbone to fine-tune for a contact-level task in PyTorch:
206
+
207
+ ```python
208
+ import torch
209
+ from multimolecule import RnaTokenizer, RnaFmForContactPrediction
210
+
211
+
212
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnafm-ss")
213
+ model = RnaFmForContactPrediction.from_pretrained("multimolecule/rnafm-ss")
214
+
215
+ text = "UAGCUUAUCAGACUGAUGUUG"
216
+ input = tokenizer(text, return_tensors="pt")
217
+ label = torch.randint(2, (len(text), len(text)))
218
+
219
+ output = model(**input, labels=label)
220
+ ```
221
+
222
+ ## Training Details
223
+
224
+ 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.
225
+
226
+ ### Training Data
227
+
228
+ The RNA-FM model was pre-trained on [RNAcentral](https://multimolecule.danling.org/datasets/rnacentral).
229
+ 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.
230
+
231
+ 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.
232
+
233
+ RNA-FM preprocessed all tokens by replacing "U"s with "T"s.
234
+
235
+ 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`.
236
+
237
+ ### Training Procedure
238
+
239
+ #### Preprocessing
240
+
241
+ RNA-FM used masked language modeling (MLM) as the pre-training objective. The masking procedure is similar to the one used in BERT:
242
+
243
+ - 15% of the tokens are masked.
244
+ - In 80% of the cases, the masked tokens are replaced by `<mask>`.
245
+ - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
246
+ - In the 10% remaining cases, the masked tokens are left as is.
247
+
248
+ #### Pre-training
249
+
250
+ The model was trained on 8 NVIDIA A100 GPUs with 80GiB memories.
251
+
252
+ - Learning rate: 1e-4
253
+ - Learning rate scheduler: Inverse square root
254
+ - Learning rate warm-up: 10,000 steps
255
+ - Weight decay: 0.01
256
+
257
+ ## Citation
258
+
259
+ **BibTeX**:
260
+
261
+ ```bibtex
262
+ @article{chen2022interpretable,
263
+ title={Interpretable rna foundation model from unannotated data for highly accurate rna structure and function predictions},
264
+ 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},
265
+ journal={arXiv preprint arXiv:2204.00300},
266
+ year={2022}
267
+ }
268
+ ```
269
+
270
+ ## Contact
271
+
272
+ Please use GitHub issues of [MultiMolecule](https://github.com/DLS5-Omics/multimolecule/issues) for any questions or comments on the model card.
273
+
274
+ 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.
275
+
276
+ ## License
277
+
278
+ This model is licensed under the [AGPL-3.0 License](https://www.gnu.org/licenses/agpl-3.0.html).
279
+
280
+ ```spdx
281
+ SPDX-License-Identifier: AGPL-3.0-or-later
282
+ ```
config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RnaFmForSecondaryStructurePrediction"
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:e122c0b153ff14e536faa44107a77b8005e0a088312af3b7ca3ac406947d6728
3
+ size 408001076
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ac2dca7fe34ab663e6d55a956b76ece3cc9e23b1418923ea822917551bd987a0
3
+ size 408092814
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