Model Overview
Model Features
Model Capabilities
Use Cases
🚀 RNABERT
A pre-trained model on non-coding RNA (ncRNA) using masked language modeling (MLM) and structural alignment learning (SAL) objectives.
🚀 Quick Start
RNABERT is a bert-style model pre-trained on a large corpus of non-coding RNA sequences in a self-supervised fashion. It can be used for various RNA-related tasks such as masked language modeling, feature extraction, and downstream task fine-tuning.
✨ Features
- Pre-trained on a large corpus of non-coding RNA sequences.
- Uses masked language modeling (MLM) and structural alignment learning (SAL) objectives.
- Can be used for multiple downstream tasks including feature extraction, sequence classification, token classification, and contact classification.
📦 Installation
The model file depends on the multimolecule
library. You can install it using pip:
pip install multimolecule
💻 Usage Examples
Basic Usage
You can use this model directly with a pipeline for masked language modeling:
>>> import multimolecule # you must import multimolecule to register models
>>> from transformers import pipeline
>>> unmasker = pipeline("fill-mask", model="multimolecule/rnabert")
>>> unmasker("gguc<mask>cucugguuagaccagaucugagccu")
[{'score': 0.03852083534002304,
'token': 24,
'token_str': '-',
'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'},
{'score': 0.03851056098937988,
'token': 10,
'token_str': 'N',
'sequence': 'G G U C N 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'},
{'score': 0.03849703073501587,
'token': 25,
'token_str': 'I',
'sequence': 'G G U C I 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'},
{'score': 0.03848597779870033,
'token': 3,
'token_str': '<unk>',
'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'},
{'score': 0.038484156131744385,
'token': 5,
'token_str': '<null>',
'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'}]
Advanced Usage
Extract Features
Here is how to use this model to get the features of a given sequence in PyTorch:
from multimolecule import RnaTokenizer, RnaBertModel
tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnabert")
model = RnaBertModel.from_pretrained("multimolecule/rnabert")
text = "UAGCUUAUCAGACUGAUGUUGA"
input = tokenizer(text, return_tensors="pt")
output = model(**input)
Sequence Classification / Regression
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.
import torch
from multimolecule import RnaTokenizer, RnaBertForSequencePrediction
tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnabert")
model = RnaBertForSequencePrediction.from_pretrained("multimolecule/rnabert")
text = "UAGCUUAUCAGACUGAUGUUGA"
input = tokenizer(text, return_tensors="pt")
label = torch.tensor([1])
output = model(**input, labels=label)
Token Classification / Regression
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.
import torch
from multimolecule import RnaTokenizer, RnaBertForTokenPrediction
tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnabert")
model = RnaBertForTokenPrediction.from_pretrained("multimolecule/rnabert")
text = "UAGCUUAUCAGACUGAUGUUGA"
input = tokenizer(text, return_tensors="pt")
label = torch.randint(2, (len(text), ))
output = model(**input, labels=label)
Contact Classification / Regression
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.
import torch
from multimolecule import RnaTokenizer, RnaBertForContactPrediction
tokenizer = RnaTokenizer.from_pretrained("multimolecule/rnabert")
model = RnaBertForContactPrediction.from_pretrained("multimolecule/rnabert")
text = "UAGCUUAUCAGACUGAUGUUGA"
input = tokenizer(text, return_tensors="pt")
label = torch.randint(2, (len(text), len(text)))
output = model(**input, labels=label)
📚 Documentation
Model Details
RNABERT is a bert-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.
Model Specification
Property | Details |
---|---|
Num Layers | 6 |
Hidden Size | 120 |
Num Heads | 12 |
Intermediate Size | 40 |
Num Parameters (M) | 0.48 |
FLOPs (G) | 0.15 |
MACs (G) | 0.08 |
Max Num Tokens | 440 |
Links
- Code: multimolecule.rnabert
- Weights: multimolecule/rnabert
- Data: RNAcentral
- Paper: Informative RNA base embedding for RNA structural alignment and clustering by deep representation learning
- Developed by: Manato Akiyama and Yasubumi Sakakibara
- Model type: BERT
- Original Repository: mana438/RNABERT
Training Details
RNABERT has two pre-training objectives: masked language modeling (MLM) and structural alignment learning (SAL).
Training Data
The RNABERT model was pre-trained on RNAcentral. RNABERT used a subset of 76, 237 human ncRNA sequences from RNAcentral for pre-training. RNABERT preprocessed all tokens by replacing "U"s with "T"s. Note that during model conversions, "T" is replaced with "U". [RnaTokenizer
][multimolecule.RnaTokenizer] will convert "T"s to "U"s for you, you may disable this behaviour by passing replace_T_with_U=False
.
Training Procedure
Preprocessing
RNABERT preprocess the dataset by applying 10 different mask patterns to the 72, 237 human ncRNA sequences. The final dataset contains 722, 370 sequences. The masking procedure is similar to the one used in BERT:
- 15% of the tokens are masked.
- In 80% of the cases, the masked tokens are replaced by
<mask>
. - In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
- In the 10% remaining cases, the masked tokens are left as is.
PreTraining
The model was trained on 1 NVIDIA V100 GPU.
🔧 Technical Details
RNABERT uses masked language modeling (MLM) and structural alignment learning (SAL) as pre-training objectives. MLM randomly masks 15% of the tokens in the input sequence and the model has to predict the masked tokens. SAL learns to predict the structural alignment of two RNA sequences using the Needleman - Wunsch algorithm.
📄 License
This model is licensed under the AGPL-3.0 License.
SPDX-License-Identifier: AGPL-3.0-or-later
⚠️ Important Note
The MultiMolecule team is aware of a potential risk in reproducing the results of RNABERT. The original implementation of RNABERT does not prepend
<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 setcls_token=None
andeos_token=None
explicitly in the tokenizer if you want the exact behavior of the original implementation.
💡 Usage Tip
The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
Citation
BibTeX:
@article{akiyama2022informative,
author = {Akiyama, Manato and Sakakibara, Yasubumi},
title = "{Informative RNA base embedding for RNA structural alignment and clustering by deep representation learning}",
journal = {NAR Genomics and Bioinformatics},
volume = {4},
number = {1},
pages = {lqac012},
year = {2022},
month = {02},
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.}",
issn = {2631-9268},
doi = {10.1093/nargab/lqac012},
url = {https://doi.org/10.1093/nargab/lqac012},
eprint = {https://academic.oup.com/nargab/article-pdf/4/1/lqac012/42577168/lqac012.pdf},
}
Contact
Please use GitHub issues of MultiMolecule for any questions or comments on the model card. Please contact the authors of the RNABERT paper for questions or comments on the paper/model.





