ZhiyuanChen commited on
Commit
d2d0641
·
verified ·
1 Parent(s): 2d24e52

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: rna
3
+ tags:
4
+ - Biology
5
+ - RNA
6
+ license: agpl-3.0
7
+ datasets:
8
+ - multimolecule/ribonanza
9
+ library_name: multimolecule
10
+ base_model: multimolecule/ribonanzanet
11
+ ---
12
+
13
+ # RibonanzaNet
14
+
15
+ > [!IMPORTANT]
16
+ > This model is in a future release of MultiMolecule, and is under development.
17
+ > This model card is not final and will be updated in the future.
18
+
19
+ Pre-trained model on RNA chemical mapping for modeling RNA structure and other properties.
20
+
21
+ ## Disclaimer
22
+
23
+ This is an UNOFFICIAL implementation of the [Ribonanza: deep learning of RNA structure through dual crowdsourcing](https://doi.org/10.1101/2024.02.24.581671) by Shujun He, Rui Huang, et al.
24
+
25
+ The OFFICIAL repository of RibonanzaNet is at [Shujun-He/RibonanzaNet](https://github.com/Shujun-He/RibonanzaNet).
26
+
27
+ > [!WARNING]
28
+ > The MultiMolecule team is aware of a potential risk in reproducing the results of RibonanzaNet.
29
+ >
30
+ > The original implementation of RibonanzaNet does not prepend `<cls>` and append `<eos>` tokens to the input sequence.
31
+ > This should not affect the performance of the model in most cases, but it can lead to unexpected behavior in some cases.
32
+ >
33
+ > Please set `cls_token=None` and `eos_token=None` explicitly in the tokenizer and model configuration if you want the exact behavior of the original implementation.
34
+
35
+ > [!WARNING]
36
+ > The MultiMolecule team is aware of a potential risk in reproducing the results of RibonanzaNet.
37
+ >
38
+ > The original implementation of RibonanzaNet applied `dropout-residual-norm` path twice to the output of the Self-Attention layer.
39
+ >
40
+ > By default, the MultiMolecule follows the original implementation.
41
+ >
42
+ > You can set `fix_attention_norm=True` in the model configuration to apply the `dropout-residual-norm` path once.
43
+ >
44
+ > See more at [issue #3](https://github.com/Shujun-He/RibonanzaNet/issues/3)
45
+
46
+ > [!WARNING]
47
+ > The MultiMolecule team is aware of a potential risk in reproducing the results of RibonanzaNet.
48
+ >
49
+ > The original implementation of RibonanzaNet does not apply attention mask correctly.
50
+ >
51
+ > By default, the MultiMolecule follows the original implementation.
52
+ >
53
+ > You can set `fix_attention_mask=True` in the model configuration to apply the correct attention mask.
54
+ >
55
+ > See more at [issue #4](https://github.com/Shujun-He/RibonanzaNet/issues/4), [issue #5](https://github.com/Shujun-He/RibonanzaNet/issues/5), and [issue #7](https://github.com/Shujun-He/RibonanzaNet/issues/7)
56
+
57
+ > [!WARNING]
58
+ > The MultiMolecule team is aware of a potential risk in reproducing the results of RibonanzaNet.
59
+ >
60
+ > The original implementation of RibonanzaNet applies dropout in an axis different from the one described in the paper.
61
+ >
62
+ > By default, the MultiMolecule follows the original implementation.
63
+ >
64
+ > You can set `fix_pairwise_dropout=True` in the model configuration to follow the description in the paper.
65
+ >
66
+ > See more at [issue #6](https://github.com/Shujun-He/RibonanzaNet/issues/6)
67
+
68
+ > [!TIP]
69
+ > The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
70
+
71
+ **The team releasing RibonanzaNet did not write this model card for this model so this model card has been written by the MultiMolecule team.**
72
+
73
+ ## Model Details
74
+
75
+ RibonanzaNet is a [bert](https://huggingface.co/google-bert/bert-base-uncased)-style model.
76
+ RibonanzaNet follows the modification from the [RNAdegformer](https://academic.oup.com/bib/article/24/1/bbac581/6986359) where it introduces a 1D convolution with residual connection at the beginning of each encoder layer.
77
+ Different from RNAdegformer, RibonanzaNet does not apply deconvolution at the end of the encoder layers, and updates the pairwise representation through outer product mean and triangular update.
78
+
79
+ RibonanzaNet is pre-trained on a large corpus of RNA sequences with chemical mapping (2A3 and DMS) measurements.
80
+ Please refer to the [Training Details](#training-details) section for more information on the training process.
81
+
82
+ ### Model Specification
83
+
84
+ | Num Layers | Hidden Size | Num Heads | Intermediate Size | Num Parameters (M) | FLOPs (G) | MACs (G) | Max Num Tokens |
85
+ | ---------- | ----------- | --------- | ----------------- | ------------------ | --------- | -------- | -------------- |
86
+ | 9 | 256 | 8 | 1024 | 11.37 | 53.65 | 26.66 | inf |
87
+
88
+ ### Links
89
+
90
+ - **Code**: [multimolecule.ribonanzanet](https://github.com/DLS5-Omics/multimolecule/tree/master/multimolecule/models/ribonanzanet)
91
+ - **Weights**: [multimolecule/ribonanzanet](https://huggingface.co/multimolecule/ribonanzanet)
92
+ - **Data**: [multimolecule/ribonanza](https://multimolecule.danling.org/datasets/ribonanza)
93
+ - **Paper**: [Ribonanza: deep learning of RNA structure through dual crowdsourcing](https://doi.org/10.1101/2024.02.24.581671)
94
+ - **Developed by**: Shujun He, Rui Huang, Jill Townley, Rachael C. Kretsch, Thomas G. Karagianes, David B.T. Cox, Hamish Blair, Dmitry Penzar, Valeriy Vyaltsev, Elizaveta Aristova, Arsenii Zinkevich, Artemy Bakulin, Hoyeol Sohn, Daniel Krstevski, Takaaki Fukui, Fumiya Tatematsu, Yusuke Uchida, Donghoon Jang, Jun Seong Lee, Roger Shieh, Tom Ma, Eduard Martynov, Maxim V. Shugaev, Habib S.T. Bukhari, Kazuki Fujikawa, Kazuki Onodera, Christof Henkel, Shlomo Ron, Jonathan Romano, John J. Nicol, Grace P. Nye, Yuan Wu, Christian Choe, Walter Reade, Eterna participants, Rhiju Das
95
+ - **Model type**: [BERT](https://huggingface.co/google-bert/bert-base-uncased)
96
+ - **Original Repository**: [Shujun-He/RibonanzaNet](https://github.com/Shujun-He/RibonanzaNet)
97
+
98
+ ## Usage
99
+
100
+ The model file depends on the [`multimolecule`](https://multimolecule.danling.org) library. You can install it using pip:
101
+
102
+ ```bash
103
+ pip install multimolecule
104
+ ```
105
+
106
+ ### Direct Use
107
+
108
+ This model is fine-tuned for RNA degradation prediction.
109
+
110
+ You can use this model directly to predict the degradation of an RNA sequence:
111
+
112
+ ```python
113
+ >>> from multimolecule import RnaTokenizer, RibonanzaNetForDegradationPrediction
114
+
115
+ >>> tokenizer = RnaTokenizer.from_pretrained("multimolecule/ribonanzanet")
116
+ >>> model = RibonanzaNetForDegradationPrediction.from_pretrained("multimolecule/ribonanzanet")
117
+ >>> output = model(**tokenizer("agcagucauuauggcgaa", return_tensors="pt"))
118
+
119
+ >>> output.keys()
120
+ odict_keys(['logits_reactivity', 'logits_deg_Mg_pH10', 'logits_deg_pH10', 'logits_deg_Mg_50C', 'logits_deg_50C'])
121
+
122
+ >>> output.logits_reactivity.squeeze()
123
+ tensor([0.4037, 0.2204, 0.0287, 0.1867, 0.5964, 0.3698, 0.2202, 0.7558, 1.3360,
124
+ 0.6030, 0.6923, 0.4518, 0.2663, 0.2863, 0.1949, 0.4807, 0.5269, 1.1370],
125
+ grad_fn=<SqueezeBackward0>)
126
+ ```
127
+
128
+ ### Downstream Use
129
+
130
+ #### Extract Features
131
+
132
+ Here is how to use this model to get the features of a given sequence in PyTorch:
133
+
134
+ ```python
135
+ from multimolecule import RnaTokenizer, RibonanzaNetModel
136
+
137
+
138
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/ribonanzanet")
139
+ model = RibonanzaNetModel.from_pretrained("multimolecule/ribonanzanet")
140
+
141
+ text = "UAGCUUAUCAGACUGAUGUUG"
142
+ input = tokenizer(text, return_tensors="pt")
143
+
144
+ output = model(**input)
145
+ ```
146
+
147
+ #### Sequence Classification / Regression
148
+
149
+ > [!NOTE]
150
+ > 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.
151
+
152
+ Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
153
+
154
+ ```python
155
+ import torch
156
+ from multimolecule import RnaTokenizer, RibonanzaNetForSequencePrediction
157
+
158
+
159
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/ribonanzanet")
160
+ model = RibonanzaNetForSequencePrediction.from_pretrained("multimolecule/ribonanzanet")
161
+
162
+ text = "UAGCUUAUCAGACUGAUGUUG"
163
+ input = tokenizer(text, return_tensors="pt")
164
+ label = torch.tensor([1])
165
+
166
+ output = model(**input, labels=label)
167
+ ```
168
+
169
+ #### Token Classification / Regression
170
+
171
+ > [!NOTE]
172
+ > 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.
173
+
174
+ Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
175
+
176
+ ```python
177
+ import torch
178
+ from multimolecule import RnaTokenizer, RibonanzaNetForTokenPrediction
179
+
180
+
181
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/ribonanzanet")
182
+ model = RibonanzaNetForTokenPrediction.from_pretrained("multimolecule/ribonanzanet")
183
+
184
+ text = "UAGCUUAUCAGACUGAUGUUG"
185
+ input = tokenizer(text, return_tensors="pt")
186
+ label = torch.randint(2, (len(text), ))
187
+
188
+ output = model(**input, labels=label)
189
+ ```
190
+
191
+ #### Contact Classification / Regression
192
+
193
+ > [!NOTE]
194
+ > 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.
195
+
196
+ Here is how to use this model as backbone to fine-tune for a contact-level task in PyTorch:
197
+
198
+ ```python
199
+ import torch
200
+ from multimolecule import RnaTokenizer, RibonanzaNetForContactPrediction
201
+
202
+
203
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/ribonanzanet")
204
+ model = RibonanzaNetForContactPrediction.from_pretrained("multimolecule/ribonanzanet")
205
+
206
+ text = "UAGCUUAUCAGACUGAUGUUG"
207
+ input = tokenizer(text, return_tensors="pt")
208
+ label = torch.randint(2, (len(text), len(text)))
209
+
210
+ output = model(**input, labels=label)
211
+ ```
212
+
213
+ ## Training Details
214
+
215
+ RibonanzaNet used chemical mapping data as the training objective. The model takes an RNA sequence as input and predicts the chemical reactivity of each nucleotide.
216
+
217
+ ### Training Data
218
+
219
+ The RibonanzaNet model was trained on the Ribonanza dataset. Ribonanza is a dataset of chemical mapping measurements on two million diverse RNA sequences. The data was collected from the crowdsourced initiative Eterna, as well as expert databases such as [Rfam](https://huggingface.co/datasets/multimolecule/rfam), the PDB archive, Pseudobase, and the RNA Mapping Database.
220
+
221
+ ### Training Procedure
222
+
223
+ RibonanzaNet was trained using a three-stage process:
224
+
225
+ #### Initial Training
226
+
227
+ The initial model was trained using sequences that had either or both 2A3/DMS profiles with a signal-to-noise ratio (SNR) above 1.0. This dataset comprised 214,831 training sequences.
228
+
229
+ #### Pre-training
230
+
231
+ 1. Noisy Training Data: The model was first pre-trained on the data with a signal-to-noise ratio (SNR) below 1.0 using predictions from top 3 Kaggle models as pseudo-labels. This dataset comprised 563,796 sequences.
232
+ 2. Experimental Determined Data: The model was then further trained for 10 epochs using only the true labels of sequences with high SNR (either 2A3 or DMS profiles).
233
+
234
+ #### Final Training
235
+
236
+ 1. Noisy Training Data: The model was first pre-trained on all training and testing data using predictions from top 3 Kaggle models as pseudo-labels. This dataset comprised 1,907,619 sequences.
237
+ 2. Experimental Determined Data: The model was then further annelaed on the true training labels.
238
+
239
+ The model was trained on 10 NVIDIA L40S GPUs with 48GiB memories.
240
+
241
+ Sequence flip augmentation was applied to the training data.
242
+
243
+ ## Citation
244
+
245
+ **BibTeX**:
246
+
247
+ ```bibtex
248
+ @article{He2024.02.24.581671,
249
+ author = {He, Shujun and Huang, Rui and Townley, Jill and Kretsch, Rachael C. and Karagianes, Thomas G. and Cox, David B.T. and Blair, Hamish and Penzar, Dmitry and Vyaltsev, Valeriy and Aristova, Elizaveta and Zinkevich, Arsenii and Bakulin, Artemy and Sohn, Hoyeol and Krstevski, Daniel and Fukui, Takaaki and Tatematsu, Fumiya and Uchida, Yusuke and Jang, Donghoon and Lee, Jun Seong and Shieh, Roger and Ma, Tom and Martynov, Eduard and Shugaev, Maxim V. and Bukhari, Habib S.T. and Fujikawa, Kazuki and Onodera, Kazuki and Henkel, Christof and Ron, Shlomo and Romano, Jonathan and Nicol, John J. and Nye, Grace P. and Wu, Yuan and Choe, Christian and Reade, Walter and Eterna participants and Das, Rhiju},
250
+ title = {Ribonanza: deep learning of RNA structure through dual crowdsourcing},
251
+ elocation-id = {2024.02.24.581671},
252
+ year = {2024},
253
+ doi = {10.1101/2024.02.24.581671},
254
+ publisher = {Cold Spring Harbor Laboratory},
255
+ abstract = {Prediction of RNA structure from sequence remains an unsolved problem, and progress has been slowed by a paucity of experimental data. Here, we present Ribonanza, a dataset of chemical mapping measurements on two million diverse RNA sequences collected through Eterna and other crowdsourced initiatives. Ribonanza measurements enabled solicitation, training, and prospective evaluation of diverse deep neural networks through a Kaggle challenge, followed by distillation into a single, self-contained model called RibonanzaNet. When fine tuned on auxiliary datasets, RibonanzaNet achieves state-of-the-art performance in modeling experimental sequence dropout, RNA hydrolytic degradation, and RNA secondary structure, with implications for modeling RNA tertiary structure.Competing Interest StatementStanford University is filing patent applications based on concepts described in this paper. R.D. is a cofounder of Inceptive.},
256
+ url = {https://www.biorxiv.org/content/early/2024/06/11/2024.02.24.581671},
257
+ eprint = {https://www.biorxiv.org/content/early/2024/06/11/2024.02.24.581671.full.pdf},
258
+ journal = {bioRxiv}
259
+ }
260
+ ```
261
+
262
+ ## Contact
263
+
264
+ Please use GitHub issues of [MultiMolecule](https://github.com/DLS5-Omics/multimolecule/issues) for any questions or comments on the model card.
265
+
266
+ Please contact the authors of the [RibonanzaNet paper](https://doi.org/10.1101/2024.02.24.581671) for questions or comments on the paper/model.
267
+
268
+ ## License
269
+
270
+ This model is licensed under the [AGPL-3.0 License](https://www.gnu.org/licenses/agpl-3.0.html).
271
+
272
+ ```spdx
273
+ SPDX-License-Identifier: AGPL-3.0-or-later
274
+ ```
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RibonanzaNetForDegradationPrediction"
4
+ ],
5
+ "attention_dropout": 0.05,
6
+ "bos_token_id": 1,
7
+ "eos_token_id": 2,
8
+ "fix_attention_mask": false,
9
+ "fix_attention_norm": false,
10
+ "fix_pairwise_dropout": false,
11
+ "head": null,
12
+ "hidden_act": "gelu",
13
+ "hidden_dropout": 0.05,
14
+ "hidden_size": 256,
15
+ "id2label": null,
16
+ "initializer_range": 0.02,
17
+ "intermediate_size": 1024,
18
+ "kernel_size": 5,
19
+ "label2id": null,
20
+ "layer_norm_eps": 1e-12,
21
+ "lm_head": null,
22
+ "mask_token_id": 4,
23
+ "model_type": "ribonanzanet",
24
+ "null_token_id": 5,
25
+ "num_attention_heads": 8,
26
+ "num_hidden_layers": 9,
27
+ "num_labels": 1,
28
+ "output_pairwise_states": false,
29
+ "pad_token_id": 0,
30
+ "pairwise_attention_size": 32,
31
+ "pairwise_hidden_act": "relu",
32
+ "pairwise_intermediate_size": 256,
33
+ "pairwise_num_attention_heads": 4,
34
+ "pairwise_size": 64,
35
+ "torch_dtype": "float32",
36
+ "transformers_version": "4.48.2",
37
+ "type_vocab_size": 2,
38
+ "unk_token_id": 3,
39
+ "use_triangular_attention": false,
40
+ "vocab_size": 26
41
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5cf05a5f286e8d58277849fcd8d639a7867987b50097bbe18934dc8fd20e20be
3
+ size 45288748
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3979494e6cb9e0ff1a9209825ce8a7a47264501b9caf058688b9f35e468d7584
3
+ size 45413034
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": 1000000000000000019884624838656,
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