Views
No views yet
[!CAUTION] The MultiMolecule team is aware of a potential risk in reproducing the results of RNABERT.The original implementation of RNABERT does not prepend<bos>(<cls>) and append<eos>tokens to the input sequence. This should not affect the performance of the model in most cases, but it can lead to unexpected behavior in some cases.Please setbos_token=None, eos_token=Nonein the tokenizer and setbos_token_id=None, eos_token_id=Nonein the model configuration if you want the exact behavior of the original implementation.
[!TIP] The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
| Num Layers | Hidden Size | Num Heads | Intermediate Size | Num Parameters (M) | FLOPs (G) | MACs (G) | Max Num Tokens |
|---|---|---|---|---|---|---|---|
| 6 | 120 | 12 | 40 | 0.48 | 0.96 | 0.46 | 440 |
multimolecule library. You can install it using pip:pip install multimolecule1import multimolecule # you must import multimolecule to register models
2from transformers import pipeline
3
4predictor = pipeline("fill-mask", model="multimolecule/rnabert")
5output = predictor("gguc<mask>cucugguuagaccagaucugagccu")1from multimolecule import RnaTokenizer, RnaBertModel
2
3
4tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnabert")
5model = RnaBertModel.from_pretrained("multimolecule/rnabert")
6
7text = "UAGCUUAUCAGACUGAUGUUG"
8input = tokenizer(text, return_tensors="pt")
9
10output = model(**input)[!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.
1import torch
2from multimolecule import RnaTokenizer, RnaBertForSequencePrediction
3
4
5tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnabert")
6model = RnaBertForSequencePrediction.from_pretrained("multimolecule/rnabert")
7
8text = "UAGCUUAUCAGACUGAUGUUG"
9input = tokenizer(text, return_tensors="pt")
10label = torch.tensor([1])
11
12output = model(**input, labels=label)[!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 token classification or regression.
1import torch
2from multimolecule import RnaTokenizer, RnaBertForTokenPrediction
3
4
5tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnabert")
6model = RnaBertForTokenPrediction.from_pretrained("multimolecule/rnabert")
7
8text = "UAGCUUAUCAGACUGAUGUUG"
9input = tokenizer(text, return_tensors="pt")
10label = torch.randint(2, (len(text), ))
11
12output = model(**input, labels=label)[!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.
1import torch
2from multimolecule import RnaTokenizer, RnaBertForContactPrediction
3
4
5tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnabert")
6model = RnaBertForContactPrediction.from_pretrained("multimolecule/rnabert")
7
8text = "UAGCUUAUCAGACUGAUGUUG"
9input = tokenizer(text, return_tensors="pt")
10label = torch.randint(2, (len(text), len(text)))
11
12output = model(**input, labels=label)RnaTokenizer][multimolecule.RnaTokenizer] will convert "T"s to "U"s for you, you may disable this behaviour by passing replace_T_with_U=False.<mask> for 80% of masked tokens1@article{akiyama2022informative,
2 author = {Akiyama, Manato and Sakakibara, Yasubumi},
3 title = "{Informative RNA base embedding for RNA structural alignment and clustering by deep representation learning}",
4 journal = {NAR Genomics and Bioinformatics},
5 volume = {4},
6 number = {1},
7 pages = {lqac012},
8 year = {2022},
9 month = {02},
10 abstract = "{Effective embedding is actively conducted by applying deep learning to biomolecular information. Obtaining better embeddings enhances the quality of downstream analyses, such as DNA sequence motif detection and protein function prediction. In this study, we adopt a pre-training algorithm for the effective embedding of RNA bases to acquire semantically rich representations and apply this algorithm to two fundamental RNA sequence problems: structural alignment and clustering. By using the pre-training algorithm to embed the four bases of RNA in a position-dependent manner using a large number of RNA sequences from various RNA families, a context-sensitive embedding representation is obtained. As a result, not only base information but also secondary structure and context information of RNA sequences are embedded for each base. We call this ‘informative base embedding’ and use it to achieve accuracies superior to those of existing state-of-the-art methods on RNA structural alignment and RNA family clustering tasks. Furthermore, upon performing RNA sequence alignment by combining this informative base embedding with a simple Needleman–Wunsch alignment algorithm, we succeed in calculating structural alignments with a time complexity of O(n2) instead of the O(n6) time complexity of the naive implementation of Sankoff-style algorithm for input RNA sequence of length n.}",
11 issn = {2631-9268},
12 doi = {10.1093/nargab/lqac012},
13 url = {https://doi.org/10.1093/nargab/lqac012},
14 eprint = {https://academic.oup.com/nargab/article-pdf/4/1/lqac012/42577168/lqac012.pdf},
15}[!NOTE] The artifacts distributed in this repository are part of the MultiMolecule project. If MultiMolecule supports your research, please cite the MultiMolecule project as follows:
1@software{chen_2024_12638419,
2 author = {Chen, Zhiyuan and Zhu, Sophia Y.},
3 title = {MultiMolecule},
4 doi = {10.5281/zenodo.12638419},
5 publisher = {Zenodo},
6 url = {https://doi.org/10.5281/zenodo.12638419},
7 year = 2024,
8 month = may,
9 day = 4
10}SPDX-License-Identifier: AGPL-3.0-or-later