ZhiyuanChen commited on
Commit
b5b6025
·
verified ·
1 Parent(s): 5841024

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,276 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 on the number of 2A3 and DMS Illumina sequencer read counts from Ribonanza.
109
+
110
+ You can use this model directly to predict the experimental dropout 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.logits_2a3.squeeze()
120
+ tensor([5.8581, 4.6132, 3.3275, 3.5843, 4.2395, 6.0112, 3.0144, 4.9608, 7.2260,
121
+ 7.8455, 6.9927, 7.2180, 4.3897, 3.4101, 2.6565, 5.2316, 4.9018, 3.0297],
122
+ grad_fn=<SqueezeBackward0>)
123
+
124
+ >>> output.logits_dms.squeeze()
125
+ tensor([8.8506, 3.6883, 6.5249, 6.5681, 3.9503, 4.6431, 5.1649, 7.2691, 4.2269,
126
+ 4.8830, 7.0784, 5.6316, 4.5210, 4.4669, 5.3768, 4.2098, 6.8370, 6.4024],
127
+ grad_fn=<SqueezeBackward0>)
128
+ ```
129
+
130
+ ### Downstream Use
131
+
132
+ #### Extract Features
133
+
134
+ Here is how to use this model to get the features of a given sequence in PyTorch:
135
+
136
+ ```python
137
+ from multimolecule import RnaTokenizer, RibonanzaNetModel
138
+
139
+
140
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/ribonanzanet")
141
+ model = RibonanzaNetModel.from_pretrained("multimolecule/ribonanzanet")
142
+
143
+ text = "UAGCUUAUCAGACUGAUGUUG"
144
+ input = tokenizer(text, return_tensors="pt")
145
+
146
+ output = model(**input)
147
+ ```
148
+
149
+ #### Sequence Classification / Regression
150
+
151
+ > [!NOTE]
152
+ > 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.
153
+
154
+ Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
155
+
156
+ ```python
157
+ import torch
158
+ from multimolecule import RnaTokenizer, RibonanzaNetForSequencePrediction
159
+
160
+
161
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/ribonanzanet")
162
+ model = RibonanzaNetForSequencePrediction.from_pretrained("multimolecule/ribonanzanet")
163
+
164
+ text = "UAGCUUAUCAGACUGAUGUUG"
165
+ input = tokenizer(text, return_tensors="pt")
166
+ label = torch.tensor([1])
167
+
168
+ output = model(**input, labels=label)
169
+ ```
170
+
171
+ #### Token Classification / Regression
172
+
173
+ > [!NOTE]
174
+ > 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.
175
+
176
+ Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
177
+
178
+ ```python
179
+ import torch
180
+ from multimolecule import RnaTokenizer, RibonanzaNetForTokenPrediction
181
+
182
+
183
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/ribonanzanet")
184
+ model = RibonanzaNetForTokenPrediction.from_pretrained("multimolecule/ribonanzanet")
185
+
186
+ text = "UAGCUUAUCAGACUGAUGUUG"
187
+ input = tokenizer(text, return_tensors="pt")
188
+ label = torch.randint(2, (len(text), ))
189
+
190
+ output = model(**input, labels=label)
191
+ ```
192
+
193
+ #### Contact Classification / Regression
194
+
195
+ > [!NOTE]
196
+ > 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.
197
+
198
+ Here is how to use this model as backbone to fine-tune for a contact-level task in PyTorch:
199
+
200
+ ```python
201
+ import torch
202
+ from multimolecule import RnaTokenizer, RibonanzaNetForContactPrediction
203
+
204
+
205
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/ribonanzanet")
206
+ model = RibonanzaNetForContactPrediction.from_pretrained("multimolecule/ribonanzanet")
207
+
208
+ text = "UAGCUUAUCAGACUGAUGUUG"
209
+ input = tokenizer(text, return_tensors="pt")
210
+ label = torch.randint(2, (len(text), len(text)))
211
+
212
+ output = model(**input, labels=label)
213
+ ```
214
+
215
+ ## Training Details
216
+
217
+ 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.
218
+
219
+ ### Training Data
220
+
221
+ 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.
222
+
223
+ ### Training Procedure
224
+
225
+ RibonanzaNet was trained using a three-stage process:
226
+
227
+ #### Initial Training
228
+
229
+ 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.
230
+
231
+ #### Pre-training
232
+
233
+ 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.
234
+ 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).
235
+
236
+ #### Final Training
237
+
238
+ 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.
239
+ 2. Experimental Determined Data: The model was then further annelaed on the true training labels.
240
+
241
+ The model was trained on 10 NVIDIA L40S GPUs with 48GiB memories.
242
+
243
+ Sequence flip augmentation was applied to the training data.
244
+
245
+ ## Citation
246
+
247
+ **BibTeX**:
248
+
249
+ ```bibtex
250
+ @article{He2024.02.24.581671,
251
+ 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},
252
+ title = {Ribonanza: deep learning of RNA structure through dual crowdsourcing},
253
+ elocation-id = {2024.02.24.581671},
254
+ year = {2024},
255
+ doi = {10.1101/2024.02.24.581671},
256
+ publisher = {Cold Spring Harbor Laboratory},
257
+ 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.},
258
+ url = {https://www.biorxiv.org/content/early/2024/06/11/2024.02.24.581671},
259
+ eprint = {https://www.biorxiv.org/content/early/2024/06/11/2024.02.24.581671.full.pdf},
260
+ journal = {bioRxiv}
261
+ }
262
+ ```
263
+
264
+ ## Contact
265
+
266
+ Please use GitHub issues of [MultiMolecule](https://github.com/DLS5-Omics/multimolecule/issues) for any questions or comments on the model card.
267
+
268
+ 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.
269
+
270
+ ## License
271
+
272
+ This model is licensed under the [AGPL-3.0 License](https://www.gnu.org/licenses/agpl-3.0.html).
273
+
274
+ ```spdx
275
+ SPDX-License-Identifier: AGPL-3.0-or-later
276
+ ```
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RibonanzaNetForSequenceDropoutPrediction"
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:166264c95e8570e3e40cf33baa67e6972e0c0eb89a641ef7321182c27111f3a6
3
+ size 45285104
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:512db8ba00f771cb4054f4755f6e2cb58c041e2265ec3c5be6764458713fdc3b
3
+ size 45408082
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