ZhiyuanChen commited on
Commit
77292c9
·
verified ·
1 Parent(s): 693dd44

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: "HIV-1"
14
+ text: "GGUC<mask>CUCUGGUUAGACCAGAUCUGAGCCU"
15
+ output:
16
+ - label: "A"
17
+ score: 0.32839149236679077
18
+ - label: "U"
19
+ score: 0.3044775426387787
20
+ - label: "C"
21
+ score: 0.09914574027061462
22
+ - label: "-"
23
+ score: 0.09502048045396805
24
+ - label: "."
25
+ score: 0.06993662565946579
26
+ - example_title: "microRNA-21"
27
+ text: "UAGC<mask>UAUCAGACUGAUGUUG"
28
+ output:
29
+ - label: "A"
30
+ score: 0.28607121109962463
31
+ - label: "U"
32
+ score: 0.24161304533481598
33
+ - label: "G"
34
+ score: 0.12279549986124039
35
+ - label: "C"
36
+ score: 0.10425350069999695
37
+ - label: "-"
38
+ score: 0.09150994569063187
39
+ ---
40
+
41
+ # ERNIE-RNA
42
+
43
+ Pre-trained model on non-coding RNA (ncRNA) using a masked language modeling (MLM) objective.
44
+
45
+ ## Disclaimer
46
+
47
+ 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.
48
+
49
+ The OFFICIAL repository of ERNIE-RNA is at [Bruce-ywj/ERNIE-RNA](https://github.com/Bruce-ywj/ERNIE-RNA).
50
+
51
+ > [!TIP]
52
+ > The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
53
+
54
+ **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.**
55
+
56
+ ## Model Details
57
+
58
+ 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.
59
+
60
+ ### Variations
61
+
62
+ - **[multimolecule/ernierna](https://huggingface.co/multimolecule/ernierna)**: The ERNIE-RNA model pre-trained on non-coding RNA sequences.
63
+ - **[multimolecule/ernierna-ss](https://huggingface.co/multimolecule/ernierna-ss)**: The ERNIE-RNA model fine-tuned on RNA secondary structure prediction.
64
+
65
+ ### Model Specification
66
+
67
+ | Num Layers | Hidden Size | Num Heads | Intermediate Size | Num Parameters (M) | FLOPs (G) | MACs (G) | Max Num Tokens |
68
+ | ---------- | ----------- | --------- | ----------------- | ------------------ | --------- | -------- | -------------- |
69
+ | 12 | 768 | 12 | 3072 | 85.67 | 22.37 | 11.18 | 1024 |
70
+
71
+ ### Links
72
+
73
+ - **Code**: [multimolecule.ernierna](https://github.com/DLS5-Omics/multimolecule/tree/master/multimolecule/models/ernierna)
74
+ - **Data**: [multimolecule/rnacentral](https://huggingface.co/datasets/multimolecule/rnacentral)
75
+ - **Paper**: [ERNIE-RNA: An RNA Language Model with Structure-enhanced Representations](https://doi.org/10.1101/2024.03.17.585376)
76
+ - **Developed by**: Weijie Yin, Zhaoyu Zhang, Liang He, Rui Jiang, Shuo Zhang, Gan Liu, Xuegong Zhang, Tao Qin, Zhen Xie
77
+ - **Model type**: [BERT](https://huggingface.co/google-bert/bert-base-uncased) - [ERNIE](https://huggingface.co/nghuyong/ernie-3.0-base-zh)
78
+ - **Original Repository**: [Bruce-ywj/ERNIE-RNA](https://github.com/Bruce-ywj/ERNIE-RNA)
79
+
80
+ ## Usage
81
+
82
+ The model file depends on the [`multimolecule`](https://multimolecule.danling.org) library. You can install it using pip:
83
+
84
+ ```bash
85
+ pip install multimolecule
86
+ ```
87
+
88
+ ### Direct Use
89
+
90
+ You can use this model directly with a pipeline for masked language modeling:
91
+
92
+ ```python
93
+ >>> import multimolecule # you must import multimolecule to register models
94
+ >>> from transformers import pipeline
95
+
96
+ >>> unmasker = pipeline("fill-mask", model="multimolecule/ernierna")
97
+ >>> unmasker("gguc<mask>cucugguuagaccagaucugagccu")
98
+ [{'score': 0.32839149236679077,
99
+ 'token': 6,
100
+ 'token_str': 'A',
101
+ 'sequence': 'G G U C A C U C U G G U U A G A C C A G A U C U G A G C C U'},
102
+ {'score': 0.3044775426387787,
103
+ 'token': 9,
104
+ 'token_str': 'U',
105
+ 'sequence': 'G G U C U C U C U G G U U A G A C C A G A U C U G A G C C U'},
106
+ {'score': 0.09914574027061462,
107
+ 'token': 7,
108
+ 'token_str': 'C',
109
+ 'sequence': 'G G U C C C U C U G G U U A G A C C A G A U C U G A G C C U'},
110
+ {'score': 0.09502048045396805,
111
+ 'token': 24,
112
+ 'token_str': '-',
113
+ 'sequence': 'G G U C - C U C U G G U U A G A C C A G A U C U G A G C C U'},
114
+ {'score': 0.06993662565946579,
115
+ 'token': 21,
116
+ 'token_str': '.',
117
+ 'sequence': 'G G U C. C U C U G G U U A G A C C A G A U C U G A G C C U'}]
118
+ ```
119
+
120
+ ### Downstream Use
121
+
122
+ #### Extract Features
123
+
124
+ Here is how to use this model to get the features of a given sequence in PyTorch:
125
+
126
+ ```python
127
+ from multimolecule import RnaTokenizer, ErnieRnaModel
128
+
129
+
130
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/ernierna")
131
+ model = ErnieRnaModel.from_pretrained("multimolecule/ernierna")
132
+
133
+ text = "UAGCUUAUCAGACUGAUGUUG"
134
+ input = tokenizer(text, return_tensors="pt")
135
+
136
+ output = model(**input)
137
+ ```
138
+
139
+ #### Sequence Classification / Regression
140
+
141
+ > [!NOTE]
142
+ > 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.
143
+
144
+ Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
145
+
146
+ ```python
147
+ import torch
148
+ from multimolecule import RnaTokenizer, ErnieRnaForSequencePrediction
149
+
150
+
151
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/ernierna")
152
+ model = ErnieRnaForSequencePrediction.from_pretrained("multimolecule/ernierna")
153
+
154
+ text = "UAGCUUAUCAGACUGAUGUUG"
155
+ input = tokenizer(text, return_tensors="pt")
156
+ label = torch.tensor([1])
157
+
158
+ output = model(**input, labels=label)
159
+ ```
160
+
161
+ #### Token Classification / Regression
162
+
163
+ > [!NOTE]
164
+ > 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.
165
+
166
+ Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
167
+
168
+ ```python
169
+ import torch
170
+ from multimolecule import RnaTokenizer, ErnieRnaForTokenPrediction
171
+
172
+
173
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/ernierna")
174
+ model = ErnieRnaForTokenPrediction.from_pretrained("multimolecule/ernierna")
175
+
176
+ text = "UAGCUUAUCAGACUGAUGUUG"
177
+ input = tokenizer(text, return_tensors="pt")
178
+ label = torch.randint(2, (len(text), ))
179
+
180
+ output = model(**input, labels=label)
181
+ ```
182
+
183
+ #### Contact Classification / Regression
184
+
185
+ > [!NOTE]
186
+ > 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.
187
+
188
+ Here is how to use this model as backbone to fine-tune for a contact-level task in PyTorch:
189
+
190
+ ```python
191
+ import torch
192
+ from multimolecule import RnaTokenizer, ErnieRnaForContactPrediction
193
+
194
+
195
+ tokenizer = RnaTokenizer.from_pretrained("multimolecule/ernierna")
196
+ model = ErnieRnaForContactPrediction.from_pretrained("multimolecule/ernierna")
197
+
198
+ text = "UAGCUUAUCAGACUGAUGUUG"
199
+ input = tokenizer(text, return_tensors="pt")
200
+ label = torch.randint(2, (len(text), len(text)))
201
+
202
+ output = model(**input, labels=label)
203
+ ```
204
+
205
+ ## Training Details
206
+
207
+ 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.
208
+
209
+ ### Training Data
210
+
211
+ The ERNIE-RNA model was pre-trained on [RNAcentral](https://multimolecule.danling.org/datasets/rnacentral).
212
+ 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.
213
+
214
+ 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.
215
+ ERNIE-RNA preprocessed all tokens by replacing "T"s with "S"s.
216
+
217
+ 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`.
218
+
219
+ ### Training Procedure
220
+
221
+ #### Preprocessing
222
+
223
+ ERNIE-RNA used masked language modeling (MLM) as the pre-training objective. The masking procedure is similar to the one used in BERT:
224
+
225
+ - 15% of the tokens are masked.
226
+ - In 80% of the cases, the masked tokens are replaced by `<mask>`.
227
+ - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
228
+ - In the 10% remaining cases, the masked tokens are left as is.
229
+
230
+ #### Pre-training
231
+
232
+ The model was trained on 24 NVIDIA V100 GPUs with 32GiB memories.
233
+
234
+ - Learning rate: 1e-4
235
+ - Learning rate warm-up: 20,000 steps
236
+ - Weight decay: 0.01
237
+
238
+ ## Citation
239
+
240
+ **BibTeX**:
241
+
242
+ ```bibtex
243
+ @article {Yin2024.03.17.585376,
244
+ 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},
245
+ title = {ERNIE-RNA: An RNA Language Model with Structure-enhanced Representations},
246
+ elocation-id = {2024.03.17.585376},
247
+ year = {2024},
248
+ doi = {10.1101/2024.03.17.585376},
249
+ publisher = {Cold Spring Harbor Laboratory},
250
+ 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.},
251
+ URL = {https://www.biorxiv.org/content/early/2024/03/17/2024.03.17.585376},
252
+ eprint = {https://www.biorxiv.org/content/early/2024/03/17/2024.03.17.585376.full.pdf},
253
+ journal = {bioRxiv}
254
+ }
255
+ ```
256
+
257
+ ## Contact
258
+
259
+ Please use GitHub issues of [MultiMolecule](https://github.com/DLS5-Omics/multimolecule/issues) for any questions or comments on the model card.
260
+
261
+ 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.
262
+
263
+ ## License
264
+
265
+ This model is licensed under the [AGPL-3.0 License](https://www.gnu.org/licenses/agpl-3.0.html).
266
+
267
+ ```spdx
268
+ SPDX-License-Identifier: AGPL-3.0-or-later
269
+ ```
config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ErnieRnaForPreTraining"
4
+ ],
5
+ "attention_dropout": 0.1,
6
+ "bos_token_id": 1,
7
+ "eos_token_id": 2,
8
+ "head": null,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout": 0.1,
11
+ "hidden_size": 768,
12
+ "id2label": null,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 3072,
15
+ "label2id": null,
16
+ "layer_norm_eps": 1e-12,
17
+ "lm_head": null,
18
+ "mask_token_id": 4,
19
+ "max_position_embeddings": 1026,
20
+ "model_type": "ernierna",
21
+ "null_token_id": 5,
22
+ "num_attention_heads": 12,
23
+ "num_hidden_layers": 12,
24
+ "num_labels": 1,
25
+ "output_attention_biases": false,
26
+ "pad_token_id": 0,
27
+ "pairwise_alpha": 0.8,
28
+ "position_embedding_type": "sinusoidal",
29
+ "torch_dtype": "float32",
30
+ "transformers_version": "4.50.0",
31
+ "type_vocab_size": 2,
32
+ "unk_token_id": 3,
33
+ "use_cache": true,
34
+ "vocab_size": 26
35
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c0c4fbae374beb086dbdbb7b1a1d9e3bab29c090d35f6337a51d1c882b0c94d4
3
+ size 345066240
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:314f5082950957440a335157870a189710c7a418575dd90c974a88d7c0fad7a7
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,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