ZhiyuanChen commited on
Commit
faebe15
1 Parent(s): 9ba1fa1

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: "microRNA-21"
14
+ text: "UAGC<mask>UAUCAGACUGAUGUUGA"
15
+ output:
16
+ - label: "U"
17
+ score: 0.22777850925922394
18
+ - label: "A"
19
+ score: 0.21105751395225525
20
+ - label: "C"
21
+ score: 0.18962091207504272
22
+ - label: "G"
23
+ score: 0.11191495507955551
24
+ - label: "."
25
+ score: 0.09583593904972076
26
+ ---
27
+
28
+ # ERNIE-RNA
29
+
30
+ Pre-trained model on non-coding RNA (ncRNA) using a masked language modeling (MLM) objective.
31
+
32
+ ## Disclaimer
33
+
34
+ This is an UNOFFICIAL implementation of the [ERNIE-RNA: An RNA Language Model with Structure-enhanced Representations](https://doi.org/10.1101/2024.03.17.585376) by Weijie Yin, Zhaoyu Zhang, Liang He, et al.
35
+
36
+ The OFFICIAL repository of ERNIE-RNA is at [Bruce-ywj/ERNIE-RNA](https://github.com/Bruce-ywj/ERNIE-RNA).
37
+
38
+ > [!TIP]
39
+ > The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
40
+
41
+ **The team releasing ERNIE-RNA did not write this model card for this model so this model card has been written by the MultiMolecule team.**
42
+
43
+ ## Model Details
44
+
45
+ ERNIE-RNA 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.
46
+
47
+ ### Variations
48
+
49
+ - **[`multimolecule/ernierna`](https://huggingface.co/multimolecule/ernierna)**: The ERNIE-RNA model pre-trained on non-coding RNA sequences.
50
+ - **[`multimolecule/ernierna.ss`](https://huggingface.co/multimolecule/ernierna.ss)**: The ERNIE-RNA model fine-tuned on RNA secondary structure prediction.
51
+
52
+ ### Model Specification
53
+
54
+ | Num Layers | Hidden Size | Num Heads | Intermediate Size | Num Parameters (M) | FLOPs (G) | MACs (G) | Max Num Tokens |
55
+ | ---------- | ----------- | --------- | ----------------- | ------------------ | --------- | -------- | -------------- |
56
+ | 12 | 768 | 12 | 3072 | 85.67 | 22.36 | 11.17 | 1024 |
57
+
58
+ ### Links
59
+
60
+ - **Code**: [multimolecule.ernierna](https://github.com/DLS5-Omics/multimolecule/tree/master/multimolecule/models/ernierna)
61
+ - **Data**: [RNAcentral](https://rnacentral.org)
62
+ - **Paper**: [ERNIE-RNA: An RNA Language Model with Structure-enhanced Representations](https://doi.org/10.1101/2024.03.17.585376)
63
+ - **Developed by**: Weijie Yin, Zhaoyu Zhang, Liang He, Rui Jiang, Shuo Zhang, Gan Liu, Xuegong Zhang, Tao Qin, Zhen Xie
64
+ - **Model type**: [BERT](https://huggingface.co/google-bert/bert-base-uncased) - [ERNIE](https://huggingface.co/nghuyong/ernie-3.0-base-zh)
65
+ - **Original Repository**: [https://github.com/Bruce-ywj/ERNIE-RNA](https://github.com/Bruce-ywj/ERNIE-RNA)
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/ernierna')
83
+ >>> unmasker("uagc<mask>uaucagacugauguuga")
84
+
85
+ [{'score': 0.22777850925922394,
86
+ 'token': 9,
87
+ 'token_str': 'U',
88
+ 'sequence': 'U A G C U U A U C A G A C U G A U G U U G A'},
89
+ {'score': 0.21105751395225525,
90
+ 'token': 6,
91
+ 'token_str': 'A',
92
+ 'sequence': 'U A G C A U A U C A G A C U G A U G U U G A'},
93
+ {'score': 0.18962091207504272,
94
+ 'token': 7,
95
+ 'token_str': 'C',
96
+ 'sequence': 'U A G C C U A U C A G A C U G A U G U U G A'},
97
+ {'score': 0.11191495507955551,
98
+ 'token': 8,
99
+ 'token_str': 'G',
100
+ 'sequence': 'U A G C G U A U C A G A C U G A U G U U G A'},
101
+ {'score': 0.09583593904972076,
102
+ 'token': 21,
103
+ 'token_str': '.',
104
+ 'sequence': 'U A G C. 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, ErnieRnaModel
115
+
116
+
117
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/ernierna')
118
+ model = ErnieRnaModel.from_pretrained('multimolecule/ernierna')
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, ErnieRnaForSequencePrediction
135
+
136
+
137
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/ernierna')
138
+ model = ErnieRnaForSequencePrediction.from_pretrained('multimolecule/ernierna')
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, ErnieRnaForNucleotidePrediction
156
+
157
+
158
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/ernierna')
159
+ model = ErnieRnaForNucleotidePrediction.from_pretrained('multimolecule/ernierna')
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, ErnieRnaForContactPrediction
177
+
178
+
179
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/ernierna')
180
+ model = ErnieRnaForContactPrediction.from_pretrained('multimolecule/ernierna')
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
+ ERNIE-RNA 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 ERNIE-RNA model was pre-trained on [RNAcentral](https://multimolecule.danling.org/datasets/rnacentral/).
196
+ RNAcentral is a free, public resource that offers integrated access to a comprehensive and up-to-date set of non-coding RNA sequences provided by a collaborating group of [Expert Databases](https://rnacentral.org/expert-databases) representing a broad range of organisms and RNA types.
197
+
198
+ ERNIE-RNA 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, resulting 25 million unique sequences. Sequences longer than 1024 nucleotides were subsequently excluded. The final dataset contains 20.4 million non-redundant RNA sequences.
199
+ ERNIE-RNA preprocessed all tokens by replacing "T"s with "S"s.
200
+
201
+ Note that [`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
+ ERNIE-RNA 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 24 NVIDIA V100 GPUs with 32GiB memories.
217
+
218
+ - Learning rate: 1e-4
219
+ - Weight decay: 0.01
220
+ - Learning rate warm-up: 20,000 steps
221
+
222
+ ## Citation
223
+
224
+ **BibTeX**:
225
+
226
+ ```bibtex
227
+ @article {Yin2024.03.17.585376,
228
+ author = {Yin, Weijie and Zhang, Zhaoyu and He, Liang and Jiang, Rui and Zhang, Shuo and Liu, Gan and Zhang, Xuegong and Qin, Tao and Xie, Zhen},
229
+ title = {ERNIE-RNA: An RNA Language Model with Structure-enhanced Representations},
230
+ elocation-id = {2024.03.17.585376},
231
+ year = {2024},
232
+ doi = {10.1101/2024.03.17.585376},
233
+ publisher = {Cold Spring Harbor Laboratory},
234
+ abstract = {With large amounts of unlabeled RNA sequences data produced by high-throughput sequencing technologies, pre-trained RNA language models have been developed to estimate semantic space of RNA molecules, which facilities the understanding of grammar of RNA language. However, existing RNA language models overlook the impact of structure when modeling the RNA semantic space, resulting in incomplete feature extraction and suboptimal performance across various downstream tasks. In this study, we developed a RNA pre-trained language model named ERNIE-RNA (Enhanced Representations with base-pairing restriction for RNA modeling) based on a modified BERT (Bidirectional Encoder Representations from Transformers) by incorporating base-pairing restriction with no MSA (Multiple Sequence Alignment) information. We found that the attention maps from ERNIE-RNA with no fine-tuning are able to capture RNA structure in the zero-shot experiment more precisely than conventional methods such as fine-tuned RNAfold and RNAstructure, suggesting that the ERNIE-RNA can provide comprehensive RNA structural representations. Furthermore, ERNIE-RNA achieved SOTA (state-of-the-art) performance after fine-tuning for various downstream tasks, including RNA structural and functional predictions. In summary, our ERNIE-RNA model provides general features which can be widely and effectively applied in various subsequent research tasks. Our results indicate that introducing key knowledge-based prior information in the BERT framework may be a useful strategy to enhance the performance of other language models.Competing Interest StatementOne patent based on the study was submitted by Z.X. and W.Y., which is entitled as "A Pre-training Approach for RNA Sequences and Its Applications"(application number, no 202410262527.5). The remaining authors declare no competing interests.},
235
+ URL = {https://www.biorxiv.org/content/early/2024/03/17/2024.03.17.585376},
236
+ eprint = {https://www.biorxiv.org/content/early/2024/03/17/2024.03.17.585376.full.pdf},
237
+ journal = {bioRxiv}
238
+ }
239
+ ```
240
+
241
+ ## Contact
242
+
243
+ Please use GitHub issues of [MultiMolecule](https://github.com/DLS5-Omics/multimolecule/issues) for any questions or comments on the model card.
244
+
245
+ Please contact the authors of the [ERNIE-RNA paper](https://doi.org/10.1101/2024.03.17.585376) for questions or comments on the paper/model.
246
+
247
+ ## License
248
+
249
+ This model is licensed under the [AGPL-3.0 License](https://www.gnu.org/licenses/agpl-3.0.html).
250
+
251
+ ```spdx
252
+ SPDX-License-Identifier: AGPL-3.0-or-later
253
+ ```
config.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ErnieRnaForPreTraining"
4
+ ],
5
+ "attention_dropout": 0.1,
6
+ "bos_token_id": 1,
7
+ "eos_token_id": 2,
8
+ "head": {
9
+ "act": null,
10
+ "bias": true,
11
+ "dropout": 0.0,
12
+ "hidden_size": null,
13
+ "layer_norm_eps": 1e-12,
14
+ "num_labels": null,
15
+ "output_name": null,
16
+ "problem_type": null,
17
+ "transform": null,
18
+ "transform_act": "gelu"
19
+ },
20
+ "hidden_act": "gelu",
21
+ "hidden_dropout": 0.1,
22
+ "hidden_size": 768,
23
+ "initializer_range": 0.02,
24
+ "intermediate_size": 3072,
25
+ "layer_norm_eps": 1e-12,
26
+ "lm_head": {
27
+ "act": null,
28
+ "bias": true,
29
+ "dropout": 0.0,
30
+ "hidden_size": 768,
31
+ "layer_norm_eps": 1e-12,
32
+ "output_name": null,
33
+ "transform": "nonlinear",
34
+ "transform_act": "gelu"
35
+ },
36
+ "mask_token_id": 4,
37
+ "max_position_embeddings": 1026,
38
+ "model_type": "ernierna",
39
+ "null_token_id": 5,
40
+ "num_attention_heads": 12,
41
+ "num_hidden_layers": 12,
42
+ "pad_token_id": 0,
43
+ "pairwise_alpha": 0.8,
44
+ "position_embedding_type": "sinusoidal",
45
+ "torch_dtype": "float32",
46
+ "transformers_version": "4.44.0",
47
+ "type_vocab_size": 2,
48
+ "unk_token_id": 3,
49
+ "use_cache": true,
50
+ "vocab_size": 26
51
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4b950ecd0250ab1d7faf4407a8d505c49b3be99cef9213ba73d5a410e99d319
3
+ size 345066240
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:604bbfade90ca5a446c9ea06c6addab1fa9a6d1e32b25662a3f8f28b160c0d8c
3
+ size 345110150
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": 1000000000000000019884624838656,
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