Fill-Mask
PyTorch
Safetensors
rna
multimolecule
rinalmo
Biology
RNA
ZhiyuanChen commited on
Commit
8f53fe5
1 Parent(s): 589b7af

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.28896641731262207
21
+ - label: "U"
22
+ score: 0.27602624893188477
23
+ - label: "X"
24
+ score: 0.18329711258411407
25
+ - label: "C"
26
+ score: 0.1668907254934311
27
+ - label: "G"
28
+ score: 0.08479981869459152
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
+ !!! Success "Reproducibility"
42
+
43
+ The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
44
+
45
+ **The team releasing RiNALMo did not write this model card for this model so this model card has been written by the MultiMolecule team.**
46
+
47
+ ## Model Details
48
+
49
+ 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.
50
+
51
+ ### Model Specification
52
+
53
+ | Num Layers | Hidden Size | Num Heads | Intermediate Size | Num Parameters (M) | FLOPs (G) | MACs (G) | Max Num Tokens |
54
+ | ---------- | ----------- | --------- | ----------------- | ------------------ | --------- | -------- | -------------- |
55
+ | 33 | 1280 | 20 | 5120 | 650.88 | 168.92 | 84.43 | 1022 |
56
+
57
+ ### Links
58
+
59
+ - **Code**: [multimolecule.rinalmo](https://github.com/DLS5-Omics/multimolecule/tree/master/multimolecule/models/rinalmo)
60
+ - **Weights**: [`multimolecule/rinalmo`](https://huggingface.co/multimolecule/rinalmo)
61
+ - **Data**: [RNAcentral](https://rnacentral.org)
62
+ - **Paper**: [RiNALMo: General-Purpose RNA Language Models Can Generalize Well on Structure Prediction Tasks](https://doi.org/10.48550/arXiv.2403.00043)
63
+ - **Developed by**: Rafael Josip Penić, Tin Vlašić, Roland G. Huber, Yue Wan, Mile Šikić
64
+ - **Model type**: [BERT](https://huggingface.co/google-bert/bert-base-uncased)
65
+ - **Original Repository**: [https://github.com/lbcb-sci/RiNALMo](https://github.com/lbcb-sci/RiNALMo)
66
+
67
+ ## Usage
68
+
69
+ The model file depends on the [`multimolecule`](https://multimolecule.danling.org) library. You can install it using pip:
70
+
71
+ ```bash
72
+ pip install multimolecule
73
+ ```
74
+
75
+ ### Direct Use
76
+
77
+ You can use this model directly with a pipeline for masked language modeling:
78
+
79
+ ```python
80
+ >>> import multimolecule # you must import multimolecule to register models
81
+ >>> from transformers import pipeline
82
+ >>> unmasker = pipeline('fill-mask', model='multimolecule/rinalmo')
83
+ >>> unmasker("uagc<mask>uaucagacugauguuga")
84
+
85
+ [{'score': 0.28896641731262207,
86
+ 'token': 6,
87
+ 'token_str': 'A',
88
+ 'sequence': 'U A G C A U A U C A G A C U G A U G U U G A'},
89
+ {'score': 0.27602624893188477,
90
+ 'token': 9,
91
+ 'token_str': 'U',
92
+ 'sequence': 'U A G C U U A U C A G A C U G A U G U U G A'},
93
+ {'score': 0.18329711258411407,
94
+ 'token': 12,
95
+ 'token_str': 'X',
96
+ 'sequence': 'U A G C X U A U C A G A C U G A U G U U G A'},
97
+ {'score': 0.1668907254934311,
98
+ 'token': 7,
99
+ 'token_str': 'C',
100
+ 'sequence': 'U A G C C U A U C A G A C U G A U G U U G A'},
101
+ {'score': 0.08479981869459152,
102
+ 'token': 8,
103
+ 'token_str': 'G',
104
+ 'sequence': 'U A G C G U A U C A G A C U G A U G U U G A'}]
105
+ ```
106
+
107
+ ### Downstream Use
108
+
109
+ #### Extract Features
110
+
111
+ Here is how to use this model to get the features of a given sequence in PyTorch:
112
+
113
+ ```python
114
+ from multimolecule import RnaTokenizer, RiNALMoModel
115
+
116
+
117
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/rinalmo')
118
+ model = RiNALMoModel.from_pretrained('multimolecule/rinalmo')
119
+
120
+ text = "UAGCUUAUCAGACUGAUGUUGA"
121
+ input = tokenizer(text, return_tensors='pt')
122
+
123
+ output = model(**input)
124
+ ```
125
+
126
+ #### Sequence Classification / Regression
127
+
128
+ **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.
129
+
130
+ Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
131
+
132
+ ```python
133
+ import torch
134
+ from multimolecule import RnaTokenizer, RiNALMoForSequencePrediction
135
+
136
+
137
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/rinalmo')
138
+ model = RiNALMoForSequencePrediction.from_pretrained('multimolecule/rinalmo')
139
+
140
+ text = "UAGCUUAUCAGACUGAUGUUGA"
141
+ input = tokenizer(text, return_tensors='pt')
142
+ label = torch.tensor([1])
143
+
144
+ output = model(**input, labels=label)
145
+ ```
146
+
147
+ #### Nucleotide Classification / Regression
148
+
149
+ **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.
150
+
151
+ Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
152
+
153
+ ```python
154
+ import torch
155
+ from multimolecule import RnaTokenizer, RiNALMoForNucleotidePrediction
156
+
157
+
158
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/rinalmo')
159
+ model = RiNALMoForNucleotidePrediction.from_pretrained('multimolecule/rinalmo')
160
+
161
+ text = "UAGCUUAUCAGACUGAUGUUGA"
162
+ input = tokenizer(text, return_tensors='pt')
163
+ label = torch.randint(2, (len(text), ))
164
+
165
+ output = model(**input, labels=label)
166
+ ```
167
+
168
+ #### Contact Classification / Regression
169
+
170
+ **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.
171
+
172
+ Here is how to use this model as backbone to fine-tune for a contact-level task in PyTorch:
173
+
174
+ ```python
175
+ import torch
176
+ from multimolecule import RnaTokenizer, RiNALMoForContactPrediction
177
+
178
+
179
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/rinalmo')
180
+ model = RiNALMoForContactPrediction.from_pretrained('multimolecule/rinalmo')
181
+
182
+ text = "UAGCUUAUCAGACUGAUGUUGA"
183
+ input = tokenizer(text, return_tensors='pt')
184
+ label = torch.randint(2, (len(text), len(text)))
185
+
186
+ output = model(**input, labels=label)
187
+ ```
188
+
189
+ ## Training Details
190
+
191
+ 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.
192
+
193
+ ### Training Data
194
+
195
+ 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). 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.41.2",
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:6178bea61680dca91a6c9789dabedc86b4cda2752b7b2127c82050dba761fdeb
3
+ size 2603718476
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f152a1ba9b94cd54cdd289bce3a37aa5cd9cc647cb619552490d05b45f3a8593
3
+ size 2603829422
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,4 @@
 
 
 
 
 
1
+ {
2
+ "tokenizer_class": "RnaTokenizer",
3
+ "clean_up_tokenization_spaces": true
4
+ }