ZhiyuanChen commited on
Commit
ebb6591
1 Parent(s): 04d1183

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ---
11
+
12
+ # RNA-FM
13
+
14
+ Pre-trained model on non-coding RNA (ncRNA) and mRNA CoDing Sequence (CDS) using a masked language modeling (MLM) objective.
15
+
16
+ ## Disclaimer
17
+
18
+ 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.
19
+
20
+ The OFFICIAL repository of RNA-FM is at [ml4bio/RNA-FM](https://github.com/ml4bio/RNA-FM).
21
+
22
+ **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.**
23
+
24
+ ## Model Details
25
+
26
+ 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.
27
+
28
+ ### Variations
29
+
30
+ - **[`multimolecule/rnafm`](https://huggingface.co/multimolecule/rnafm)**: The RNA-FM model pre-trained on non-coding RNA sequences.
31
+ - **[`multimolecule/mrnafm`](https://huggingface.co/multimolecule/mrnafm)**: The RNA-FM model pre-trained on mRNA coding sequences.
32
+
33
+ ### Model Specification
34
+
35
+ <table>
36
+ <thead>
37
+ <tr>
38
+ <th>Variants</th>
39
+ <th>Num Layers</th>
40
+ <th>Hidden Size</th>
41
+ <th>Num Heads</th>
42
+ <th>Intermediate Size</th>
43
+ <th>Num Parameters (M)</th>
44
+ <th>FLOPs (G)</th>
45
+ <th>MACs (G)</th>
46
+ <th>Max Num Tokens</th>
47
+ </tr>
48
+ </thead>
49
+ <tbody>
50
+ <tr>
51
+ <td>RNA-FM</td>
52
+ <td rowspan="2">12</td>
53
+ <td>640</td>
54
+ <td rowspan="2">20</td>
55
+ <td rowspan="2">5120</td>
56
+ <td>99.52</td>
57
+ <td>25.68</td>
58
+ <td>12.83</td>
59
+ <td rowspan="2">1024</td>
60
+ </tr>
61
+ <tr>
62
+ <td>mRNA-FM</td>
63
+ <td>1280</td>
64
+ <td>239.25</td>
65
+ <td>61.43</td>
66
+ <td>30.7</td>
67
+ </tr>
68
+ </tbody>
69
+ </table>
70
+
71
+ ### Links
72
+
73
+ - **Code**: [multimolecule.rnafm](https://github.com/DLS5-Omics/multimolecule/tree/master/multimolecule/models/rnafm)
74
+ - **Data**: [RNAcentral](https://rnacentral.org)
75
+ - **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)
76
+ - **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
77
+ - **Model type**: [BERT](https://huggingface.co/google-bert/bert-base-uncased) - [ESM](https://huggingface.co/facebook/esm2_t48_15B_UR50D)
78
+ - **Original Repository**: [https://github.com/ml4bio/RNA-FM](https://github.com/ml4bio/RNA-FM)
79
+
80
+ ## Usage
81
+
82
+ The model file depends on the [`multimolecule`](https://multimolecule.danling.org) library. You can install it using pip:
83
+
84
+ ```bash
85
+ pip install multimolecule
86
+ ```
87
+
88
+ ### Direct Use
89
+
90
+ You can use this model directly with a pipeline for masked language modeling:
91
+
92
+ ```python
93
+ >>> import multimolecule # you must import multimolecule to register models
94
+ >>> from transformers import pipeline
95
+ >>> unmasker = pipeline('fill-mask', model='multimolecule/rnafm')
96
+ >>> unmasker("uagc<mask>uaucagacugauguuga")
97
+
98
+ [{'score': 0.32435303926467896,
99
+ 'token': 24,
100
+ 'token_str': '*',
101
+ 'sequence': 'U A G C * U A U C A G A C U G A U G U U G A'},
102
+ {'score': 0.28287413716316223,
103
+ 'token': 11,
104
+ 'token_str': 'I',
105
+ 'sequence': 'U A G C I U A U C A G A C U G A U G U U G A'},
106
+ {'score': 0.11811278015375137,
107
+ 'token': 23,
108
+ 'token_str': '.',
109
+ 'sequence': 'U A G C. U A U C A G A C U G A U G U U G A'},
110
+ {'score': 0.08698639273643494,
111
+ 'token': 6,
112
+ 'token_str': 'A',
113
+ 'sequence': 'U A G C A U A U C A G A C U G A U G U U G A'},
114
+ {'score': 0.06751123070716858,
115
+ 'token': 9,
116
+ 'token_str': 'U',
117
+ 'sequence': 'U A G C U U A U C A G A C U G A U G U U G A'}]
118
+ ```
119
+
120
+ ### Downstream Use
121
+
122
+ #### Extract Features
123
+
124
+ Here is how to use this model to get the features of a given sequence in PyTorch:
125
+
126
+ ```python
127
+ from multimolecule import RnaTokenizer, RnaFmModel
128
+
129
+
130
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/rnafm')
131
+ model = RnaFmModel.from_pretrained('multimolecule/rnafm')
132
+
133
+ text = "UAGCUUAUCAGACUGAUGUUGA"
134
+ input = tokenizer(text, return_tensors='pt')
135
+
136
+ output = model(**input)
137
+ ```
138
+
139
+ #### Sequence Classification / Regression
140
+
141
+ **Note**: 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.
142
+
143
+ Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
144
+
145
+ ```python
146
+ import torch
147
+ from multimolecule import RnaTokenizer, RnaFmForSequencePrediction
148
+
149
+
150
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/rnafm')
151
+ model = RnaFmForSequencePrediction.from_pretrained('multimolecule/rnafm')
152
+
153
+ text = "UAGCUUAUCAGACUGAUGUUGA"
154
+ input = tokenizer(text, return_tensors='pt')
155
+ label = torch.tensor([1])
156
+
157
+ output = model(**input, labels=label)
158
+ ```
159
+
160
+ #### Nucleotide Classification / Regression
161
+
162
+ **Note**: 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 nucleotide classification or regression.
163
+
164
+ Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
165
+
166
+ ```python
167
+ import torch
168
+ from multimolecule import RnaTokenizer, RnaFmForNucleotidePrediction
169
+
170
+
171
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/rnafm')
172
+ model = RnaFmForNucleotidePrediction.from_pretrained('multimolecule/rnafm')
173
+
174
+ text = "UAGCUUAUCAGACUGAUGUUGA"
175
+ input = tokenizer(text, return_tensors='pt')
176
+ label = torch.randint(2, (len(text), ))
177
+
178
+ output = model(**input, labels=label)
179
+ ```
180
+
181
+ #### Contact Classification / Regression
182
+
183
+ **Note**: 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.
184
+
185
+ Here is how to use this model as backbone to fine-tune for a contact-level task in PyTorch:
186
+
187
+ ```python
188
+ import torch
189
+ from multimolecule import RnaTokenizer, RnaFmForContactPrediction
190
+
191
+
192
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/rnafm')
193
+ model = RnaFmForContactPrediction.from_pretrained('multimolecule/rnafm')
194
+
195
+ text = "UAGCUUAUCAGACUGAUGUUGA"
196
+ input = tokenizer(text, return_tensors='pt')
197
+ label = torch.randint(2, (len(text), len(text)))
198
+
199
+ output = model(**input, labels=label)
200
+ ```
201
+
202
+ ## Training Details
203
+
204
+ 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.
205
+
206
+ ### Training Data
207
+
208
+ The RNA-FM model was pre-trained on [RNAcentral](https://rnacentral.org). RNAcentral is a comprehensive database of non-coding RNA sequences from a wide range of species. It combines 47 different databases, adding up to around 27 million RNA sequences in total.
209
+
210
+ 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.
211
+
212
+ RNA-FM preprocessed all tokens by replacing "U"s with "T"s.
213
+
214
+ 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`.
215
+
216
+ ### Training Procedure
217
+
218
+ #### Preprocessing
219
+
220
+ RNA-FM used masked language modeling (MLM) as the pre-training objective. The masking procedure is similar to the one used in BERT:
221
+
222
+ - 15% of the tokens are masked.
223
+ - In 80% of the cases, the masked tokens are replaced by `<mask>`.
224
+ - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
225
+ - In the 10% remaining cases, the masked tokens are left as is.
226
+
227
+ #### PreTraining
228
+
229
+ The model was trained on 8 NVIDIA A100 GPUs with 80GiB memories.
230
+
231
+ - Learning rate: 1e-4
232
+ - Weight decay: 0.01
233
+ - Learning rate scheduler: inverse square root
234
+ - Learning rate warm-up: 10,000 steps
235
+
236
+ ## Citation
237
+
238
+ **BibTeX**:
239
+
240
+ ```bibtex
241
+ @article{chen2022interpretable,
242
+ title={Interpretable rna foundation model from unannotated data for highly accurate rna structure and function predictions},
243
+ 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},
244
+ journal={arXiv preprint arXiv:2204.00300},
245
+ year={2022}
246
+ }
247
+ ```
248
+
249
+ ## Contact
250
+
251
+ Please use GitHub issues of [MultiMolecule](https://github.com/DLS5-Omics/multimolecule/issues) for any questions or comments on the model card.
252
+
253
+ 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.
254
+
255
+ ## License
256
+
257
+ This model is licensed under the [AGPL-3.0 License](https://www.gnu.org/licenses/agpl-3.0.html).
258
+
259
+ ```spdx
260
+ SPDX-License-Identifier: AGPL-3.0-or-later
261
+ ```
config.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RnaFmForPreTraining"
4
+ ],
5
+ "attention_dropout": 0.1,
6
+ "bos_token_id": 1,
7
+ "codon": true,
8
+ "emb_layer_norm_before": true,
9
+ "eos_token_id": 2,
10
+ "head": {
11
+ "act": null,
12
+ "bias": true,
13
+ "dropout": 0.0,
14
+ "hidden_size": 640,
15
+ "layer_norm_eps": 1e-12,
16
+ "num_labels": 1,
17
+ "problem_type": null,
18
+ "transform": null,
19
+ "transform_act": "gelu"
20
+ },
21
+ "hidden_act": "gelu",
22
+ "hidden_dropout": 0.1,
23
+ "hidden_size": 640,
24
+ "id2label": {
25
+ "0": "LABEL_0"
26
+ },
27
+ "initializer_range": 0.02,
28
+ "intermediate_size": 5120,
29
+ "label2id": {
30
+ "LABEL_0": 0
31
+ },
32
+ "layer_norm_eps": 1e-12,
33
+ "lm_head": {
34
+ "act": null,
35
+ "bias": true,
36
+ "dropout": 0.0,
37
+ "hidden_size": 640,
38
+ "layer_norm_eps": 1e-12,
39
+ "transform": "nonlinear",
40
+ "transform_act": "gelu"
41
+ },
42
+ "mask_token_id": 4,
43
+ "max_position_embeddings": 1026,
44
+ "model_type": "rnafm",
45
+ "null_token_id": 5,
46
+ "num_attention_heads": 20,
47
+ "num_hidden_layers": 12,
48
+ "pad_token_id": 0,
49
+ "position_embedding_type": "absolute",
50
+ "token_dropout": true,
51
+ "torch_dtype": "float32",
52
+ "transformers_version": "4.39.3",
53
+ "unk_token_id": 3,
54
+ "use_cache": true,
55
+ "vocab_size": 26
56
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e65c527832dc33167d721cb008d04ac723f91a8191408eecc6245105ea8a9f50
3
+ size 399827000
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1cf0c468e1dee929a7f3181defa0fc75dde7cc2a744080e47823b4a9adc10a53
3
+ size 399872414
special_tokens_map.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "pad_token": {
3
+ "content": "<pad>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "<cls>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "<eos>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "unk_token": {
24
+ "content": "<unk>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "mask_token": {
31
+ "content": "<mask>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "null_token": {
38
+ "content": "<null>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ }
44
+ }
tokenizer_config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "tokenizer_class": "RnaTokenizer",
3
+ "clean_up_tokenization_spaces": true,
4
+ "model_max_length": 1024
5
+ }