ZhiyuanChen commited on
Commit
20fed0e
1 Parent(s): 187fea5

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: rna
3
+ tags:
4
+ - Biology
5
+ - RNA
6
+ license: agpl-3.0
7
+ datasets:
8
+ - multimolecule/ucsc-genome-browser
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: "A"
17
+ score: 0.09350304305553436
18
+ - label: "W"
19
+ score: 0.08757384121417999
20
+ - label: "U"
21
+ score: 0.08202056586742401
22
+ - label: "H"
23
+ score: 0.07025782763957977
24
+ - label: "M"
25
+ score: 0.06502506136894226
26
+ ---
27
+
28
+ # SpliceBERT
29
+
30
+ Pre-trained model on messenger RNA precursor (pre-mRNA) using a masked language modeling (MLM) objective.
31
+
32
+ ## Disclaimer
33
+
34
+ This is an UNOFFICIAL implementation of the [Self-supervised learning on millions of pre-mRNA sequences improves sequence-based RNA splicing prediction](https://doi.org/10.1101/2023.01.31.526427) by Ken Chen, et al.
35
+
36
+ The OFFICIAL repository of SpliceBERT is at [chenkenbio/SpliceBERT](https://github.com/chenkenbio/SpliceBERT).
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 SpliceBERT 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
+ SpliceBERT is a [bert](https://huggingface.co/google-bert/bert-base-uncased)-style model pre-trained on a large corpus of messenger RNA precursor 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/splicebert`](https://huggingface.co/multimolecule/splicebert)**: The SpliceBERT model.
50
+ - **[`multimolecule/splicebert.510nt`](https://huggingface.co/multimolecule/splicebert.510nt)**: The intermediate SpliceBERT model.
51
+ - **[`multimolecule/splicebert-human.510nt`](https://huggingface.co/multimolecule/splicebert-human.510nt)**: The intermediate SpliceBERT model pre-trained on human data only.
52
+
53
+ ### Model Specification
54
+
55
+ <table>
56
+ <thead>
57
+ <tr>
58
+ <th>Variants</th>
59
+ <th>Num Layers</th>
60
+ <th>Hidden Size</th>
61
+ <th>Num Heads</th>
62
+ <th>Intermediate Size</th>
63
+ <th>Num Parameters (M)</th>
64
+ <th>FLOPs (G)</th>
65
+ <th>MACs (G)</th>
66
+ <th>Max Num Tokens</th>
67
+ </tr>
68
+ </thead>
69
+ <tbody>
70
+ <tr>
71
+ <td>splicebert</td>
72
+ <td rowspan="3">6</td>
73
+ <td rowspan="3">512</td>
74
+ <td rowspan="3">16</td>
75
+ <td rowspan="3">2048</td>
76
+ <td>19.72</td>
77
+ <td rowspan="3">5.04</td>
78
+ <td rowspan="3">2.52</td>
79
+ <td>1024</td>
80
+ </tr>
81
+ <tr>
82
+ <td>splicebert.510nt</td>
83
+ <td rowspan="2">19.45</td>
84
+ <td rowspan="2">510</td>
85
+ </tr>
86
+ <tr>
87
+ <td>splicebert-human.510nt</td>
88
+ </tr>
89
+ </tbody>
90
+ </table>
91
+
92
+ ### Links
93
+
94
+ - **Code**: [multimolecule.splicebert](https://github.com/DLS5-Omics/multimolecule/tree/master/multimolecule/models/splicebert)
95
+ - **Data**: [UCSC Genome Browser](https://genome.ucsc.edu)
96
+ - **Paper**: [Self-supervised learning on millions of pre-mRNA sequences improves sequence-based RNA splicing prediction](https://doi.org/10.1101/2023.01.31.526427)
97
+ - **Developed by**: Ken Chen, Yue Zhou, Maolin Ding, Yu Wang, Zhixiang Ren, Yuedong Yang
98
+ - **Model type**: [BERT](https://huggingface.co/google-bert/bert-base-uncased) - [FlashAttention](https://huggingface.co/docs/text-generation-inference/en/conceptual/flash_attention)
99
+ - **Original Repository**: [https://github.com/chenkenbio/SpliceBERT](https://github.com/chenkenbio/SpliceBERT)
100
+
101
+ ## Usage
102
+
103
+ The model file depends on the [`multimolecule`](https://multimolecule.danling.org) library. You can install it using pip:
104
+
105
+ ```bash
106
+ pip install multimolecule
107
+ ```
108
+
109
+ ### Direct Use
110
+
111
+ You can use this model directly with a pipeline for masked language modeling:
112
+
113
+ ```python
114
+ >>> import multimolecule # you must import multimolecule to register models
115
+ >>> from transformers import pipeline
116
+ >>> unmasker = pipeline('fill-mask', model='multimolecule/splicebert')
117
+ >>> unmasker("uagc<mask>uaucagacugauguuga")
118
+
119
+ [{'score': 0.09350304305553436,
120
+ 'token': 6,
121
+ 'token_str': 'A',
122
+ 'sequence': 'U A G C A U A U C A G A C U G A U G U U G A'},
123
+ {'score': 0.08757384121417999,
124
+ 'token': 14,
125
+ 'token_str': 'W',
126
+ 'sequence': 'U A G C W U A U C A G A C U G A U G U U G A'},
127
+ {'score': 0.08202056586742401,
128
+ 'token': 9,
129
+ 'token_str': 'U',
130
+ 'sequence': 'U A G C U U A U C A G A C U G A U G U U G A'},
131
+ {'score': 0.07025782763957977,
132
+ 'token': 19,
133
+ 'token_str': 'H',
134
+ 'sequence': 'U A G C H U A U C A G A C U G A U G U U G A'},
135
+ {'score': 0.06502506136894226,
136
+ 'token': 16,
137
+ 'token_str': 'M',
138
+ 'sequence': 'U A G C M U A U C A G A C U G A U G U U G A'}]
139
+ ```
140
+
141
+ ### Downstream Use
142
+
143
+ #### Extract Features
144
+
145
+ Here is how to use this model to get the features of a given sequence in PyTorch:
146
+
147
+ ```python
148
+ from multimolecule import RnaTokenizer, SpliceBertModel
149
+
150
+
151
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/splicebert')
152
+ model = SpliceBertModel.from_pretrained('multimolecule/splicebert')
153
+
154
+ text = "UAGCUUAUCAGACUGAUGUUGA"
155
+ input = tokenizer(text, return_tensors='pt')
156
+
157
+ output = model(**input)
158
+ ```
159
+
160
+ #### Sequence Classification / Regression
161
+
162
+ **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.
163
+
164
+ Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
165
+
166
+ ```python
167
+ import torch
168
+ from multimolecule import RnaTokenizer, SpliceBertForSequencePrediction
169
+
170
+
171
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/splicebert')
172
+ model = SpliceBertForSequencePrediction.from_pretrained('multimolecule/splicebert')
173
+
174
+ text = "UAGCUUAUCAGACUGAUGUUGA"
175
+ input = tokenizer(text, return_tensors='pt')
176
+ label = torch.tensor([1])
177
+
178
+ output = model(**input, labels=label)
179
+ ```
180
+
181
+ #### Nucleotide Classification / Regression
182
+
183
+ **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.
184
+
185
+ Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
186
+
187
+ ```python
188
+ import torch
189
+ from multimolecule import RnaTokenizer, SpliceBertForNucleotidePrediction
190
+
191
+
192
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/splicebert')
193
+ model = SpliceBertForNucleotidePrediction.from_pretrained('multimolecule/splicebert')
194
+
195
+ text = "UAGCUUAUCAGACUGAUGUUGA"
196
+ input = tokenizer(text, return_tensors='pt')
197
+ label = torch.randint(2, (len(text), ))
198
+
199
+ output = model(**input, labels=label)
200
+ ```
201
+
202
+ #### Contact Classification / Regression
203
+
204
+ **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.
205
+
206
+ Here is how to use this model as backbone to fine-tune for a contact-level task in PyTorch:
207
+
208
+ ```python
209
+ import torch
210
+ from multimolecule import RnaTokenizer, SpliceBertForContactPrediction
211
+
212
+
213
+ tokenizer = RnaTokenizer.from_pretrained('multimolecule/splicebert')
214
+ model = SpliceBertForContactPrediction.from_pretrained('multimolecule/splicebert')
215
+
216
+ text = "UAGCUUAUCAGACUGAUGUUGA"
217
+ input = tokenizer(text, return_tensors='pt')
218
+ label = torch.randint(2, (len(text), len(text)))
219
+
220
+ output = model(**input, labels=label)
221
+ ```
222
+
223
+ ## Training Details
224
+
225
+ SpliceBERT 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.
226
+
227
+ ### Training Data
228
+
229
+ The SpliceBERT model was pre-trained on messenger RNA precursor sequences from [UCSC Genome Browser](https://genome.ucsc.edu).
230
+ UCSC Genome Browser provides visualization, analysis, and download of comprehensive vertebrate genome data with aligned annotation tracks (known genes, predicted genes, ESTs, mRNAs, CpG islands, etc.).
231
+
232
+ SpliceBERT collected reference genomes and gene annotations from the UCSC Genome Browser for 72 vertebrate species. It applied [bedtools getfasta](https://bedtools.readthedocs.io/en/latest/content/tools/getfasta.html) to extract pre-mRNA sequences from the reference genomes based on the gene annotations. The pre-mRNA sequences are then used to pre-train SpliceBERT. The pre-training data contains 2 million pre-mRNA sequences with a total length of 65 billion nucleotides.
233
+
234
+ Note [`RnaTokenizer`][multimolecule.RnaTokenizer] will convert "T"s to "U"s for you, you may disable this behaviour by passing `replace_T_with_U=False`.
235
+
236
+ ### Training Procedure
237
+
238
+ #### Preprocessing
239
+
240
+ SpliceBERT used masked language modeling (MLM) as the pre-training objective. The masking procedure is similar to the one used in BERT:
241
+
242
+ - 15% of the tokens are masked.
243
+ - In 80% of the cases, the masked tokens are replaced by `<mask>`.
244
+ - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
245
+ - In the 10% remaining cases, the masked tokens are left as is.
246
+
247
+ #### PreTraining
248
+
249
+ The model was trained on 8 NVIDIA V100 GPUs.
250
+
251
+ - Learning rate: 1e-4
252
+ - Learning rate scheduler: ReduceLROnPlateau(patience=3)
253
+ - Optimizer: AdamW
254
+
255
+ SpliceBERT trained model in a two-stage training process:
256
+
257
+ 1. Pre-train with sequences of a fixed length of 510 nucleotides.
258
+ 2. Pre-train with sequences of a variable length between 64 and 1024 nucleotides.
259
+
260
+ The intermediate model after the first stage is available as `multimolecule/splicebert.510nt`.
261
+
262
+ SpliceBERT also pre-trained a model on human data only to validate the contribution of multi-species pre-training. The intermediate model after the first stage is available as `multimolecule/splicebert-human.510nt`.
263
+
264
+ ## Citation
265
+
266
+ **BibTeX**:
267
+
268
+ ```bibtex
269
+ @article {chen2023self,
270
+ author = {Chen, Ken and Zhou, Yue and Ding, Maolin and Wang, Yu and Ren, Zhixiang and Yang, Yuedong},
271
+ title = {Self-supervised learning on millions of pre-mRNA sequences improves sequence-based RNA splicing prediction},
272
+ elocation-id = {2023.01.31.526427},
273
+ year = {2023},
274
+ doi = {10.1101/2023.01.31.526427},
275
+ publisher = {Cold Spring Harbor Laboratory},
276
+ abstract = {RNA splicing is an important post-transcriptional process of gene expression in eukaryotic cells. Predicting RNA splicing from primary sequences can facilitate the interpretation of genomic variants. In this study, we developed a novel self-supervised pre-trained language model, SpliceBERT, to improve sequence-based RNA splicing prediction. Pre-training on pre-mRNA sequences from vertebrates enables SpliceBERT to capture evolutionary conservation information and characterize the unique property of splice sites. SpliceBERT also improves zero-shot prediction of variant effects on splicing by considering sequence context information, and achieves superior performance for predicting branchpoint in the human genome and splice sites across species. Our study highlighted the importance of pre-training genomic language models on a diverse range of species and suggested that pre-trained language models were promising for deciphering the sequence logic of RNA splicing.Competing Interest StatementThe authors have declared no competing interest.},
277
+ URL = {https://www.biorxiv.org/content/early/2023/05/09/2023.01.31.526427},
278
+ eprint = {https://www.biorxiv.org/content/early/2023/05/09/2023.01.31.526427.full.pdf},
279
+ journal = {bioRxiv}
280
+ }
281
+ ```
282
+
283
+ ## Contact
284
+
285
+ Please use GitHub issues of [MultiMolecule](https://github.com/DLS5-Omics/multimolecule/issues) for any questions or comments on the model card.
286
+
287
+ Please contact the authors of the [SpliceBERT paper](https://doi.org/10.1101/2023.01.31.526427) for questions or comments on the paper/model.
288
+
289
+ ## License
290
+
291
+ This model is licensed under the [AGPL-3.0 License](https://www.gnu.org/licenses/agpl-3.0.html).
292
+
293
+ ```spdx
294
+ SPDX-License-Identifier: AGPL-3.0-or-later
295
+ ```
config.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SpliceBertForPreTraining"
4
+ ],
5
+ "attention_dropout": 0.1,
6
+ "bos_token_id": 1,
7
+ "classifier_dropout": null,
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": 512,
24
+ "initializer_range": 0.02,
25
+ "intermediate_size": 2048,
26
+ "layer_norm_eps": 1e-12,
27
+ "lm_head": {
28
+ "act": null,
29
+ "bias": true,
30
+ "dropout": 0.0,
31
+ "hidden_size": 512,
32
+ "layer_norm_eps": 1e-12,
33
+ "output_name": null,
34
+ "transform": "nonlinear",
35
+ "transform_act": "gelu"
36
+ },
37
+ "mask_token_id": 4,
38
+ "max_position_embeddings": 512,
39
+ "model_type": "splicebert",
40
+ "null_token_id": 5,
41
+ "num_attention_heads": 16,
42
+ "num_hidden_layers": 6,
43
+ "output_hidden_states": true,
44
+ "pad_token_id": 0,
45
+ "position_embedding_type": "absolute",
46
+ "torch_dtype": "float32",
47
+ "transformers_version": "4.44.0",
48
+ "type_vocab_size": 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:9ce8476fdb62cab6995fcdab027182703abf22fb321c1839bfbc9608dcecc2f1
3
+ size 77834792
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bb5c301d31dde79ba7abb23d460f66e11ac17ba07b8c60eba4f300a67feba495
3
+ size 77857586
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": 512,
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