ZhiyuanChen commited on
Commit
09bd529
1 Parent(s): c5c1e9e

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: "PRNP"
14
+ text: "CTG<mask>AAGCGGCCCACGCGGACTGACGGGCGGGGG"
15
+ output:
16
+ - label: "GAG"
17
+ score: 0.09500275552272797
18
+ - label: "GGC"
19
+ score: 0.09362148493528366
20
+ - label: "AAG"
21
+ score: 0.07337076216936111
22
+ - label: "GAC"
23
+ score: 0.07307938486337662
24
+ - label: "GUG"
25
+ score: 0.06616155058145523
26
+ ---
27
+
28
+ # mRNA-FM
29
+
30
+ Pre-trained model on mRNA CoDing Sequence (CDS) using a masked language modeling (MLM) objective.
31
+
32
+ ## Disclaimer
33
+
34
+ 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.
35
+
36
+ The OFFICIAL repository of RNA-FM is at [ml4bio/RNA-FM](https://github.com/ml4bio/RNA-FM).
37
+
38
+ !!! Success "Reproducibility"
39
+
40
+ The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
41
+
42
+ **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.**
43
+
44
+ ## Model Details
45
+
46
+ 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.
47
+
48
+ ### Variations
49
+
50
+ - **[`multimolecule/rnafm`](https://huggingface.co/multimolecule/rnafm)**: The RNA-FM model pre-trained on non-coding RNA sequences.
51
+ - **[`multimolecule/mrnafm`](https://huggingface.co/multimolecule/mrnafm)**: The RNA-FM model pre-trained on mRNA coding sequences.
52
+
53
+ ### Model Specification
54
+
55
+ <table>
56
+ <thead>
57
+ <tr>
58
+ <th>Variants</th>
59
+ <th>Num Layers</th>
60
+ <th>Hidden Size</th>
61
+ <th>Num Heads</th>
62
+ <th>Intermediate Size</th>
63
+ <th>Num Parameters (M)</th>
64
+ <th>FLOPs (G)</th>
65
+ <th>MACs (G)</th>
66
+ <th>Max Num Tokens</th>
67
+ </tr>
68
+ </thead>
69
+ <tbody>
70
+ <tr>
71
+ <td>RNA-FM</td>
72
+ <td rowspan="2">12</td>
73
+ <td>640</td>
74
+ <td rowspan="2">20</td>
75
+ <td rowspan="2">5120</td>
76
+ <td>99.52</td>
77
+ <td>25.68</td>
78
+ <td>12.83</td>
79
+ <td rowspan="2">1024</td>
80
+ </tr>
81
+ <tr>
82
+ <td>mRNA-FM</td>
83
+ <td>1280</td>
84
+ <td>239.25</td>
85
+ <td>61.43</td>
86
+ <td>30.7</td>
87
+ </tr>
88
+ </tbody>
89
+ </table>
90
+
91
+ ### Links
92
+
93
+ - **Code**: [multimolecule.rnafm](https://github.com/DLS5-Omics/multimolecule/tree/master/multimolecule/models/rnafm)
94
+ - **Data**: [RNAcentral](https://rnacentral.org)
95
+ - **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)
96
+ - **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
97
+ - **Model type**: [BERT](https://huggingface.co/google-bert/bert-base-uncased) - [ESM](https://huggingface.co/facebook/esm2_t48_15B_UR50D)
98
+ - **Original Repository**: [https://github.com/ml4bio/RNA-FM](https://github.com/ml4bio/RNA-FM)
99
+
100
+ ## Usage
101
+
102
+ The model file depends on the [`multimolecule`](https://multimolecule.danling.org) library. You can install it using pip:
103
+
104
+ ```bash
105
+ pip install multimolecule
106
+ ```
107
+
108
+ ### Direct Use
109
+
110
+ You can use this model directly with a pipeline for masked language modeling:
111
+
112
+ ```python
113
+ >>> import multimolecule # you must import multimolecule to register models
114
+ >>> from transformers import pipeline
115
+ >>> unmasker = pipeline('fill-mask', model='multimolecule/mrnafm')
116
+ >>> unmasker("ctg<mask>aagcggcccacgcggactgacgggcggggg")
117
+
118
+ [{'score': 0.09500275552272797,
119
+ 'token': 58,
120
+ 'token_str': 'GAG',
121
+ 'sequence': 'CUG GAG AAG CGG CCC ACG CGG ACU GAC GGG CGG GGG'},
122
+ {'score': 0.09362148493528366,
123
+ 'token': 67,
124
+ 'token_str': 'GGC',
125
+ 'sequence': 'CUG GGC AAG CGG CCC ACG CGG ACU GAC GGG CGG GGG'},
126
+ {'score': 0.07337076216936111,
127
+ 'token': 8,
128
+ 'token_str': 'AAG',
129
+ 'sequence': 'CUG AAG AAG CGG CCC ACG CGG ACU GAC GGG CGG GGG'},
130
+ {'score': 0.07307938486337662,
131
+ 'token': 57,
132
+ 'token_str': 'GAC',
133
+ 'sequence': 'CUG GAC AAG CGG CCC ACG CGG ACU GAC GGG CGG GGG'},
134
+ {'score': 0.06616155058145523,
135
+ 'token': 73,
136
+ 'token_str': 'GUG',
137
+ 'sequence': 'CUG GUG AAG CGG CCC ACG CGG ACU GAC GGG CGG GGG'}]
138
+ ```
139
+
140
+ ### Downstream Use
141
+
142
+ #### Extract Features
143
+
144
+ Here is how to use this model to get the features of a given sequence in PyTorch:
145
+
146
+ ```python
147
+ from multimolecule import RnaTokenizer, RnaFmModel
148
+
149
+
150
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/mrnafm')
151
+ model = RnaFmModel.from_pretrained('multimolecule/mrnafm')
152
+
153
+ text = "UAGCUUAUCAGACUGAUGUUGA"
154
+ input = tokenizer(text, return_tensors='pt')
155
+
156
+ output = model(**input)
157
+ ```
158
+
159
+ #### Sequence Classification / Regression
160
+
161
+ **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.
162
+
163
+ Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
164
+
165
+ ```python
166
+ import torch
167
+ from multimolecule import RnaTokenizer, RnaFmForSequencePrediction
168
+
169
+
170
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/mrnafm')
171
+ model = RnaFmForSequencePrediction.from_pretrained('multimolecule/mrnafm')
172
+
173
+ text = "UAGCUUAUCAGACUGAUGUUGA"
174
+ input = tokenizer(text, return_tensors='pt')
175
+ label = torch.tensor([1])
176
+
177
+ output = model(**input, labels=label)
178
+ ```
179
+
180
+ #### Nucleotide Classification / Regression
181
+
182
+ **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.
183
+
184
+ Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
185
+
186
+ ```python
187
+ import torch
188
+ from multimolecule import RnaTokenizer, RnaFmForNucleotidePrediction
189
+
190
+
191
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/mrnafm')
192
+ model = RnaFmForNucleotidePrediction.from_pretrained('multimolecule/mrnafm')
193
+
194
+ text = "UAGCUUAUCAGACUGAUGUUGA"
195
+ input = tokenizer(text, return_tensors='pt')
196
+ label = torch.randint(2, (len(text), ))
197
+
198
+ output = model(**input, labels=label)
199
+ ```
200
+
201
+ #### Contact Classification / Regression
202
+
203
+ **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.
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/mrnafm')
213
+ model = RnaFmForContactPrediction.from_pretrained('multimolecule/mrnafm')
214
+
215
+ text = "UAGCUUAUCAGACUGAUGUUGA"
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://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.
229
+
230
+ 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.
231
+
232
+ RNA-FM preprocessed all tokens by replacing "U"s with "T"s.
233
+
234
+ 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`.
235
+
236
+ ### Training Procedure
237
+
238
+ #### Preprocessing
239
+
240
+ RNA-FM used masked language modeling (MLM) as the pre-training objective. The masking procedure is similar to the one used in BERT:
241
+
242
+ - 15% of the tokens are masked.
243
+ - In 80% of the cases, the masked tokens are replaced by `<mask>`.
244
+ - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
245
+ - In the 10% remaining cases, the masked tokens are left as is.
246
+
247
+ #### PreTraining
248
+
249
+ The model was trained on 8 NVIDIA A100 GPUs with 80GiB memories.
250
+
251
+ - Learning rate: 1e-4
252
+ - Weight decay: 0.01
253
+ - Learning rate scheduler: inverse square root
254
+ - Learning rate warm-up: 10,000 steps
255
+
256
+ ## Citation
257
+
258
+ **BibTeX**:
259
+
260
+ ```bibtex
261
+ @article{chen2022interpretable,
262
+ title={Interpretable rna foundation model from unannotated data for highly accurate rna structure and function predictions},
263
+ 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},
264
+ journal={arXiv preprint arXiv:2204.00300},
265
+ year={2022}
266
+ }
267
+ ```
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 [RNA-FM paper](https://doi.org/10.1101/2022.08.06.503062) 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
+ ```
README.mrnafm.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: "PRNP"
14
+ text: "CTG<mask>AAGCGGCCCACGCGGACTGACGGGCGGGGG"
15
+ output:
16
+ - label: "GAG"
17
+ score: 0.09500275552272797
18
+ - label: "GGC"
19
+ score: 0.09362148493528366
20
+ - label: "AAG"
21
+ score: 0.07337076216936111
22
+ - label: "GAC"
23
+ score: 0.07307938486337662
24
+ - label: "GUG"
25
+ score: 0.06616155058145523
26
+ ---
27
+
28
+ # mRNA-FM
29
+
30
+ Pre-trained model on mRNA CoDing Sequence (CDS) using a masked language modeling (MLM) objective.
31
+
32
+ ## Disclaimer
33
+
34
+ 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.
35
+
36
+ The OFFICIAL repository of RNA-FM is at [ml4bio/RNA-FM](https://github.com/ml4bio/RNA-FM).
37
+
38
+ !!! Success "Reproducibility"
39
+
40
+ The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
41
+
42
+ **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.**
43
+
44
+ ## Model Details
45
+
46
+ 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.
47
+
48
+ ### Variations
49
+
50
+ - **[`multimolecule/rnafm`](https://huggingface.co/multimolecule/rnafm)**: The RNA-FM model pre-trained on non-coding RNA sequences.
51
+ - **[`multimolecule/mrnafm`](https://huggingface.co/multimolecule/mrnafm)**: The RNA-FM model pre-trained on mRNA coding sequences.
52
+
53
+ ### Model Specification
54
+
55
+ <table>
56
+ <thead>
57
+ <tr>
58
+ <th>Variants</th>
59
+ <th>Num Layers</th>
60
+ <th>Hidden Size</th>
61
+ <th>Num Heads</th>
62
+ <th>Intermediate Size</th>
63
+ <th>Num Parameters (M)</th>
64
+ <th>FLOPs (G)</th>
65
+ <th>MACs (G)</th>
66
+ <th>Max Num Tokens</th>
67
+ </tr>
68
+ </thead>
69
+ <tbody>
70
+ <tr>
71
+ <td>RNA-FM</td>
72
+ <td rowspan="2">12</td>
73
+ <td>640</td>
74
+ <td rowspan="2">20</td>
75
+ <td rowspan="2">5120</td>
76
+ <td>99.52</td>
77
+ <td>25.68</td>
78
+ <td>12.83</td>
79
+ <td rowspan="2">1024</td>
80
+ </tr>
81
+ <tr>
82
+ <td>mRNA-FM</td>
83
+ <td>1280</td>
84
+ <td>239.25</td>
85
+ <td>61.43</td>
86
+ <td>30.7</td>
87
+ </tr>
88
+ </tbody>
89
+ </table>
90
+
91
+ ### Links
92
+
93
+ - **Code**: [multimolecule.rnafm](https://github.com/DLS5-Omics/multimolecule/tree/master/multimolecule/models/rnafm)
94
+ - **Data**: [RNAcentral](https://rnacentral.org)
95
+ - **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)
96
+ - **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
97
+ - **Model type**: [BERT](https://huggingface.co/google-bert/bert-base-uncased) - [ESM](https://huggingface.co/facebook/esm2_t48_15B_UR50D)
98
+ - **Original Repository**: [https://github.com/ml4bio/RNA-FM](https://github.com/ml4bio/RNA-FM)
99
+
100
+ ## Usage
101
+
102
+ The model file depends on the [`multimolecule`](https://multimolecule.danling.org) library. You can install it using pip:
103
+
104
+ ```bash
105
+ pip install multimolecule
106
+ ```
107
+
108
+ ### Direct Use
109
+
110
+ You can use this model directly with a pipeline for masked language modeling:
111
+
112
+ ```python
113
+ >>> import multimolecule # you must import multimolecule to register models
114
+ >>> from transformers import pipeline
115
+ >>> unmasker = pipeline('fill-mask', model='multimolecule/mrnafm')
116
+ >>> unmasker("ctg<mask>aagcggcccacgcggactgacgggcggggg")
117
+
118
+ [{'score': 0.09500275552272797,
119
+ 'token': 58,
120
+ 'token_str': 'GAG',
121
+ 'sequence': 'CUG GAG AAG CGG CCC ACG CGG ACU GAC GGG CGG GGG'},
122
+ {'score': 0.09362148493528366,
123
+ 'token': 67,
124
+ 'token_str': 'GGC',
125
+ 'sequence': 'CUG GGC AAG CGG CCC ACG CGG ACU GAC GGG CGG GGG'},
126
+ {'score': 0.07337076216936111,
127
+ 'token': 8,
128
+ 'token_str': 'AAG',
129
+ 'sequence': 'CUG AAG AAG CGG CCC ACG CGG ACU GAC GGG CGG GGG'},
130
+ {'score': 0.07307938486337662,
131
+ 'token': 57,
132
+ 'token_str': 'GAC',
133
+ 'sequence': 'CUG GAC AAG CGG CCC ACG CGG ACU GAC GGG CGG GGG'},
134
+ {'score': 0.06616155058145523,
135
+ 'token': 73,
136
+ 'token_str': 'GUG',
137
+ 'sequence': 'CUG GUG AAG CGG CCC ACG CGG ACU GAC GGG CGG GGG'}]
138
+ ```
139
+
140
+ ### Downstream Use
141
+
142
+ #### Extract Features
143
+
144
+ Here is how to use this model to get the features of a given sequence in PyTorch:
145
+
146
+ ```python
147
+ from multimolecule import RnaTokenizer, RnaFmModel
148
+
149
+
150
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/mrnafm')
151
+ model = RnaFmModel.from_pretrained('multimolecule/mrnafm')
152
+
153
+ text = "UAGCUUAUCAGACUGAUGUUGA"
154
+ input = tokenizer(text, return_tensors='pt')
155
+
156
+ output = model(**input)
157
+ ```
158
+
159
+ #### Sequence Classification / Regression
160
+
161
+ **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.
162
+
163
+ Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
164
+
165
+ ```python
166
+ import torch
167
+ from multimolecule import RnaTokenizer, RnaFmForSequencePrediction
168
+
169
+
170
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/mrnafm')
171
+ model = RnaFmForSequencePrediction.from_pretrained('multimolecule/mrnafm')
172
+
173
+ text = "UAGCUUAUCAGACUGAUGUUGA"
174
+ input = tokenizer(text, return_tensors='pt')
175
+ label = torch.tensor([1])
176
+
177
+ output = model(**input, labels=label)
178
+ ```
179
+
180
+ #### Nucleotide Classification / Regression
181
+
182
+ **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.
183
+
184
+ Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
185
+
186
+ ```python
187
+ import torch
188
+ from multimolecule import RnaTokenizer, RnaFmForNucleotidePrediction
189
+
190
+
191
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/mrnafm')
192
+ model = RnaFmForNucleotidePrediction.from_pretrained('multimolecule/mrnafm')
193
+
194
+ text = "UAGCUUAUCAGACUGAUGUUGA"
195
+ input = tokenizer(text, return_tensors='pt')
196
+ label = torch.randint(2, (len(text), ))
197
+
198
+ output = model(**input, labels=label)
199
+ ```
200
+
201
+ #### Contact Classification / Regression
202
+
203
+ **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.
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/mrnafm')
213
+ model = RnaFmForContactPrediction.from_pretrained('multimolecule/mrnafm')
214
+
215
+ text = "UAGCUUAUCAGACUGAUGUUGA"
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://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.
229
+
230
+ 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.
231
+
232
+ RNA-FM preprocessed all tokens by replacing "U"s with "T"s.
233
+
234
+ 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`.
235
+
236
+ ### Training Procedure
237
+
238
+ #### Preprocessing
239
+
240
+ RNA-FM used masked language modeling (MLM) as the pre-training objective. The masking procedure is similar to the one used in BERT:
241
+
242
+ - 15% of the tokens are masked.
243
+ - In 80% of the cases, the masked tokens are replaced by `<mask>`.
244
+ - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
245
+ - In the 10% remaining cases, the masked tokens are left as is.
246
+
247
+ #### PreTraining
248
+
249
+ The model was trained on 8 NVIDIA A100 GPUs with 80GiB memories.
250
+
251
+ - Learning rate: 1e-4
252
+ - Weight decay: 0.01
253
+ - Learning rate scheduler: inverse square root
254
+ - Learning rate warm-up: 10,000 steps
255
+
256
+ ## Citation
257
+
258
+ **BibTeX**:
259
+
260
+ ```bibtex
261
+ @article{chen2022interpretable,
262
+ title={Interpretable rna foundation model from unannotated data for highly accurate rna structure and function predictions},
263
+ 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},
264
+ journal={arXiv preprint arXiv:2204.00300},
265
+ year={2022}
266
+ }
267
+ ```
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 [RNA-FM paper](https://doi.org/10.1101/2022.08.06.503062) 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,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RnaFmForPreTraining"
4
+ ],
5
+ "attention_dropout": 0.1,
6
+ "bos_token_id": 1,
7
+ "codon": false,
8
+ "emb_layer_norm_before": false,
9
+ "eos_token_id": 2,
10
+ "head": {
11
+ "act": null,
12
+ "bias": true,
13
+ "dropout": 0.0,
14
+ "hidden_size": 1280,
15
+ "layer_norm_eps": 1e-12,
16
+ "num_labels": 1,
17
+ "output_name": null,
18
+ "problem_type": null,
19
+ "transform": null,
20
+ "transform_act": "gelu"
21
+ },
22
+ "hidden_act": "gelu",
23
+ "hidden_dropout": 0.1,
24
+ "hidden_size": 1280,
25
+ "id2label": {
26
+ "0": "LABEL_0"
27
+ },
28
+ "initializer_range": 0.02,
29
+ "intermediate_size": 5120,
30
+ "label2id": {
31
+ "LABEL_0": 0
32
+ },
33
+ "layer_norm_eps": 1e-12,
34
+ "lm_head": {
35
+ "act": null,
36
+ "bias": true,
37
+ "dropout": 0.0,
38
+ "hidden_size": 1280,
39
+ "layer_norm_eps": 1e-12,
40
+ "output_name": null,
41
+ "transform": "nonlinear",
42
+ "transform_act": "gelu"
43
+ },
44
+ "mask_token_id": 4,
45
+ "max_position_embeddings": 1026,
46
+ "model_type": "rnafm",
47
+ "null_token_id": 5,
48
+ "num_attention_heads": 20,
49
+ "num_hidden_layers": 12,
50
+ "pad_token_id": 0,
51
+ "position_embedding_type": "absolute",
52
+ "token_dropout": false,
53
+ "torch_dtype": "float32",
54
+ "transformers_version": "4.41.2",
55
+ "unk_token_id": 3,
56
+ "use_cache": true,
57
+ "vocab_size": 131
58
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:12ba8754c757fe9451d643a4eb2d4fb1b7b597f02fb38f34fd6e7806d281a6f5
3
+ size 964287496
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c1d05f5357820e0d46c121b273faef93bd855bdde2eb6d071cc437b92ff38fe
3
+ size 964332182
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,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "tokenizer_class": "RnaTokenizer",
3
+ "clean_up_tokenization_spaces": true,
4
+ "model_max_length": 1024,
5
+ "codon": true
6
+ }