ZhiyuanChen commited on
Commit
c9394ad
1 Parent(s): 1c59872

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: rna
3
+ tags:
4
+ - Biology
5
+ - RNA
6
+ license: agpl-3.0
7
+ datasets:
8
+ - multimolecule/rnacentral
9
+ - multimolecule/rfam
10
+ - multimolecule/ensembl-genome-browser
11
+ - multimolecule/nucleotide
12
+ library_name: multimolecule
13
+ pipeline_tag: fill-mask
14
+ mask_token: "<mask>"
15
+ widget:
16
+ - example_title: "microRNA-21"
17
+ text: "UAGC<mask>UAUCAGACUGAUGUUGA"
18
+ output:
19
+ - label: "A"
20
+ score: 0.2931748032569885
21
+ - label: "U"
22
+ score: 0.2710167169570923
23
+ - label: "X"
24
+ score: 0.18341825902462006
25
+ - label: "C"
26
+ score: 0.16714636981487274
27
+ - label: "G"
28
+ score: 0.08522326499223709
29
+ ---
30
+
31
+ # RiNALMo
32
+
33
+ Pre-trained model on non-coding RNA (ncRNA) using a masked language modeling (MLM) objective.
34
+
35
+ ## Disclaimer
36
+
37
+ This is an UNOFFICIAL implementation of the [RiNALMo: General-Purpose RNA Language Models Can Generalize Well on Structure Prediction Tasks](https://doi.org/10.48550/arXiv.2403.00043) by Rafael Josip Penić, et al.
38
+
39
+ The OFFICIAL repository of RiNALMo is at [lbcb-sci/RiNALMo](https://github.com/lbcb-sci/RiNALMo).
40
+
41
+ > [!TIP]
42
+ > The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
43
+
44
+ **The team releasing RiNALMo did not write this model card for this model so this model card has been written by the MultiMolecule team.**
45
+
46
+ ## Model Details
47
+
48
+ RiNALMo 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.
49
+
50
+ ### Model Specification
51
+
52
+ | Num Layers | Hidden Size | Num Heads | Intermediate Size | Num Parameters (M) | FLOPs (G) | MACs (G) | Max Num Tokens |
53
+ | ---------- | ----------- | --------- | ----------------- | ------------------ | --------- | -------- | -------------- |
54
+ | 33 | 1280 | 20 | 5120 | 650.88 | 168.92 | 84.43 | 1022 |
55
+
56
+ ### Links
57
+
58
+ - **Code**: [multimolecule.rinalmo](https://github.com/DLS5-Omics/multimolecule/tree/master/multimolecule/models/rinalmo)
59
+ - **Weights**: [`multimolecule/rinalmo`](https://huggingface.co/multimolecule/rinalmo)
60
+ - **Data**: [RNAcentral](https://rnacentral.org)
61
+ - **Paper**: [RiNALMo: General-Purpose RNA Language Models Can Generalize Well on Structure Prediction Tasks](https://doi.org/10.48550/arXiv.2403.00043)
62
+ - **Developed by**: Rafael Josip Penić, Tin Vlašić, Roland G. Huber, Yue Wan, Mile Šikić
63
+ - **Model type**: [BERT](https://huggingface.co/google-bert/bert-base-uncased)
64
+ - **Original Repository**: [https://github.com/lbcb-sci/RiNALMo](https://github.com/lbcb-sci/RiNALMo)
65
+
66
+ ## Usage
67
+
68
+ The model file depends on the [`multimolecule`](https://multimolecule.danling.org) library. You can install it using pip:
69
+
70
+ ```bash
71
+ pip install multimolecule
72
+ ```
73
+
74
+ ### Direct Use
75
+
76
+ You can use this model directly with a pipeline for masked language modeling:
77
+
78
+ ```python
79
+ >>> import multimolecule # you must import multimolecule to register models
80
+ >>> from transformers import pipeline
81
+ >>> unmasker = pipeline('fill-mask', model='multimolecule/rinalmo')
82
+ >>> unmasker("uagc<mask>uaucagacugauguuga")
83
+
84
+ [{'score': 0.2931748032569885,
85
+ 'token': 6,
86
+ 'token_str': 'A',
87
+ 'sequence': 'U A G C A U A U C A G A C U G A U G U U G A'},
88
+ {'score': 0.2710167169570923,
89
+ 'token': 9,
90
+ 'token_str': 'U',
91
+ 'sequence': 'U A G C U U A U C A G A C U G A U G U U G A'},
92
+ {'score': 0.18341825902462006,
93
+ 'token': 22,
94
+ 'token_str': 'X',
95
+ 'sequence': 'U A G C X U A U C A G A C U G A U G U U G A'},
96
+ {'score': 0.16714636981487274,
97
+ 'token': 7,
98
+ 'token_str': 'C',
99
+ 'sequence': 'U A G C C U A U C A G A C U G A U G U U G A'},
100
+ {'score': 0.08522326499223709,
101
+ 'token': 8,
102
+ 'token_str': 'G',
103
+ 'sequence': 'U A G C G U A U C A G A C U G A U G U U G A'}]
104
+ ```
105
+
106
+ ### Downstream Use
107
+
108
+ #### Extract Features
109
+
110
+ Here is how to use this model to get the features of a given sequence in PyTorch:
111
+
112
+ ```python
113
+ from multimolecule import RnaTokenizer, RiNALMoModel
114
+
115
+
116
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/rinalmo')
117
+ model = RiNALMoModel.from_pretrained('multimolecule/rinalmo')
118
+
119
+ text = "UAGCUUAUCAGACUGAUGUUGA"
120
+ input = tokenizer(text, return_tensors='pt')
121
+
122
+ output = model(**input)
123
+ ```
124
+
125
+ #### Sequence Classification / Regression
126
+
127
+ **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.
128
+
129
+ Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
130
+
131
+ ```python
132
+ import torch
133
+ from multimolecule import RnaTokenizer, RiNALMoForSequencePrediction
134
+
135
+
136
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/rinalmo')
137
+ model = RiNALMoForSequencePrediction.from_pretrained('multimolecule/rinalmo')
138
+
139
+ text = "UAGCUUAUCAGACUGAUGUUGA"
140
+ input = tokenizer(text, return_tensors='pt')
141
+ label = torch.tensor([1])
142
+
143
+ output = model(**input, labels=label)
144
+ ```
145
+
146
+ #### Nucleotide Classification / Regression
147
+
148
+ **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.
149
+
150
+ Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
151
+
152
+ ```python
153
+ import torch
154
+ from multimolecule import RnaTokenizer, RiNALMoForNucleotidePrediction
155
+
156
+
157
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/rinalmo')
158
+ model = RiNALMoForNucleotidePrediction.from_pretrained('multimolecule/rinalmo')
159
+
160
+ text = "UAGCUUAUCAGACUGAUGUUGA"
161
+ input = tokenizer(text, return_tensors='pt')
162
+ label = torch.randint(2, (len(text), ))
163
+
164
+ output = model(**input, labels=label)
165
+ ```
166
+
167
+ #### Contact Classification / Regression
168
+
169
+ **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.
170
+
171
+ Here is how to use this model as backbone to fine-tune for a contact-level task in PyTorch:
172
+
173
+ ```python
174
+ import torch
175
+ from multimolecule import RnaTokenizer, RiNALMoForContactPrediction
176
+
177
+
178
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/rinalmo')
179
+ model = RiNALMoForContactPrediction.from_pretrained('multimolecule/rinalmo')
180
+
181
+ text = "UAGCUUAUCAGACUGAUGUUGA"
182
+ input = tokenizer(text, return_tensors='pt')
183
+ label = torch.randint(2, (len(text), len(text)))
184
+
185
+ output = model(**input, labels=label)
186
+ ```
187
+
188
+ ## Training Details
189
+
190
+ RiNALMo 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.
191
+
192
+ ### Training Data
193
+
194
+ The RiNALMo model was pre-trained on a cocktail of databases including [RNAcentral](https://rnacentral.org), [Rfam](https://rfam.org), [Ensembl Genome Browser](https://ensembl.org), and [Nucleotide](https://ncbi.nlm.nih.gov/nucleotide).
195
+ The training data contains 36 million unique ncRNA sequences.
196
+
197
+ To ensure sequence diversity in each training batch, RiNALMo clustered the sequences with [MMSeqs2](https://github.com/soedinglab/MMseqs2) into 17 million clusters and then sampled each sequence in the batch from a different cluster.
198
+
199
+ RiNALMo preprocessed all tokens by replacing "U"s with "T"s.
200
+
201
+ 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`.
202
+
203
+ ### Training Procedure
204
+
205
+ #### Preprocessing
206
+
207
+ RiNALMo used masked language modeling (MLM) as the pre-training objective. The masking procedure is similar to the one used in BERT:
208
+
209
+ - 15% of the tokens are masked.
210
+ - In 80% of the cases, the masked tokens are replaced by `<mask>`.
211
+ - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
212
+ - In the 10% remaining cases, the masked tokens are left as is.
213
+
214
+ #### PreTraining
215
+
216
+ The model was trained on 7 NVIDIA A100 GPUs with 80GiB memories.
217
+
218
+ - Learning rate: 5e-5
219
+ - Learning rate scheduler: cosine
220
+ - Learning rate warm-up: 2,000 steps
221
+ - Learning rate minimum: 1e-5
222
+ - Epochs: 6
223
+ - Batch Size: 1344
224
+ - Dropout: 0.1
225
+
226
+ ## Citation
227
+
228
+ **BibTeX**:
229
+
230
+ ```bibtex
231
+ @article{penic2024rinalmo,
232
+ title={RiNALMo: General-Purpose RNA Language Models Can Generalize Well on Structure Prediction Tasks},
233
+ author={Penić, Rafael Josip and Vlašić, Tin and Huber, Roland G. and Wan, Yue and Šikić, Mile},
234
+ journal={arXiv preprint arXiv:2403.00043},
235
+ year={2024}
236
+ }
237
+ ```
238
+
239
+ ## Contact
240
+
241
+ Please use GitHub issues of [MultiMolecule](https://github.com/DLS5-Omics/multimolecule/issues) for any questions or comments on the model card.
242
+
243
+ Please contact the authors of the [RiNALMo paper](https://doi.org/10.48550/arXiv.2403.00043) for questions or comments on the paper/model.
244
+
245
+ ## License
246
+
247
+ This model is licensed under the [AGPL-3.0 License](https://www.gnu.org/licenses/agpl-3.0.html).
248
+
249
+ ```spdx
250
+ SPDX-License-Identifier: AGPL-3.0-or-later
251
+ ```
config.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RiNALMoForPreTraining"
4
+ ],
5
+ "attention_dropout": 0.1,
6
+ "bos_token_id": 1,
7
+ "emb_layer_norm_before": true,
8
+ "eos_token_id": 2,
9
+ "head": {
10
+ "act": null,
11
+ "bias": true,
12
+ "dropout": 0.0,
13
+ "hidden_size": null,
14
+ "layer_norm_eps": 1e-12,
15
+ "num_labels": null,
16
+ "output_name": null,
17
+ "problem_type": null,
18
+ "transform": null,
19
+ "transform_act": "gelu"
20
+ },
21
+ "hidden_act": "gelu",
22
+ "hidden_dropout": 0.1,
23
+ "hidden_size": 1280,
24
+ "initializer_range": 0.02,
25
+ "intermediate_size": 5120,
26
+ "layer_norm_eps": 1e-12,
27
+ "learnable_beta": true,
28
+ "lm_head": {
29
+ "act": null,
30
+ "bias": true,
31
+ "dropout": 0.0,
32
+ "hidden_size": 1280,
33
+ "layer_norm_eps": 1e-12,
34
+ "output_name": null,
35
+ "transform": "nonlinear",
36
+ "transform_act": "gelu"
37
+ },
38
+ "mask_token_id": 4,
39
+ "max_position_embeddings": 1024,
40
+ "model_type": "rinalmo",
41
+ "null_token_id": 5,
42
+ "num_attention_heads": 20,
43
+ "num_hidden_layers": 33,
44
+ "pad_token_id": 0,
45
+ "position_embedding_type": "rotary",
46
+ "token_dropout": true,
47
+ "torch_dtype": "float32",
48
+ "transformers_version": "4.44.0",
49
+ "unk_token_id": 3,
50
+ "use_cache": true,
51
+ "vocab_size": 26
52
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ee31d5955411ad1a763d22d766d01c94091af7b3c92f8e57dd349c88e9225bd
3
+ size 2603718476
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d79ba04c862cf82ffdb1c86aff284c958411f7780f3cbd95aea852588110873f
3
+ size 2603829422
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,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "mask_token": "<mask>",
61
+ "model_max_length": 1024,
62
+ "nmers": 1,
63
+ "pad_token": "<pad>",
64
+ "replace_T_with_U": true,
65
+ "sep_token": "<eos>",
66
+ "tokenizer_class": "RnaTokenizer",
67
+ "unk_token": "<unk>"
68
+ }
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