RiNALMo
Pre-trained model on non-coding RNA (ncRNA) using a masked language modeling (MLM) objective.
Disclaimer
This is an UNOFFICIAL implementation of the RiNALMo: General-Purpose RNA Language Models Can Generalize Well on Structure Prediction Tasks by Rafael Josip Penić, et al.
The OFFICIAL repository of RiNALMo is at lbcb-sci/RiNALMo.
The MultiMolecule team has confirmed that the provided model and checkpoints are producing the same intermediate representations as the original implementation.
The team releasing RiNALMo did not write this model card for this model so this model card has been written by the MultiMolecule team.
Model Details
RiNALMo 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. Please refer to the Training Details section for more information on the training process.
Variants
- multimolecule/rinalmo-giga: The RiNALMo model with 650 million parameters.
- multimolecule/rinalmo-mega: The RiNALMo model with 150 million parameters.
- multimolecule/rinalmo-micro: The RiNALMo model with 30 million parameters.
Model Specification
Variants | Num Layers | Hidden Size | Num Heads | Intermediate Size | Num Parameters (M) | FLOPs (G) | MACs (G) | Max Num Tokens |
---|---|---|---|---|---|---|---|---|
RiNALMo-Giga | 33 | 1280 | 20 | 5120 | 650.88 | 168.92 | 84.43 | 1022 |
RiNALMo-Mega | 30 | 640 | 2560 | 148.04 | 39.03 | 19.5 | ||
RiNALMo-Micro | 12 | 480 | 1920 | 33.48 | 8.88 | 4.44 |
Links
- Code: multimolecule.rinalmo
- Data: multimolecule/rnacentral
- Paper: RiNALMo: General-Purpose RNA Language Models Can Generalize Well on Structure Prediction Tasks
- Developed by: Rafael Josip Penić, Tin Vlašić, Roland G. Huber, Yue Wan, Mile Šikić
- Model type: BERT
- Original Repository: lbcb-sci/RiNALMo
Usage
The model file depends on the multimolecule
library. You can install it using pip:
pip install multimolecule
Direct Use
Masked Language Modeling
You can use this model directly with a pipeline for masked language modeling:
<<<<<<< HEAD
import multimolecule # you must import multimolecule to register models
from transformers import pipeline
predictor = pipeline("fill-mask", model="multimolecule/rinalmo")
output = predictor("gguc<mask>cucugguuagaccagaucugagccu")
=======
>>> import multimolecule # you must import multimolecule to register models
>>> from transformers import pipeline
>>> unmasker = pipeline("fill-mask", model="multimolecule/rinalmo-giga")
>>> unmasker("gguc<mask>cucugguuagaccagaucugagccu")
[{'score': 0.9774785041809082,
'token': 6,
'token_str': 'A',
'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'},
{'score': 0.004996326752007008,
'token': 22,
'token_str': 'X',
'sequence': 'G G U C X 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.0035297079011797905,
'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.002614670665934682,
'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.00249761575832963,
'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'}]
>>>>>>> 6fbb6942... update RiNALMo models
Downstream Use
Extract Features
Here is how to use this model to get the features of a given sequence in PyTorch:
from multimolecule import RnaTokenizer, RiNALMoModel
tokenizer = RnaTokenizer.from_pretrained("multimolecule/rinalmo-giga")
model = RiNALMoModel.from_pretrained("multimolecule/rinalmo-giga")
text = "UAGCUUAUCAGACUGAUGUUG"
input = tokenizer(text, return_tensors="pt")
output = model(**input)
Sequence Classification / Regression
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.
Here is how to use this model as backbone to fine-tune for a sequence-level task in PyTorch:
import torch
from multimolecule import RnaTokenizer, RiNALMoForSequencePrediction
tokenizer = RnaTokenizer.from_pretrained("multimolecule/rinalmo-giga")
model = RiNALMoForSequencePrediction.from_pretrained("multimolecule/rinalmo-giga")
text = "UAGCUUAUCAGACUGAUGUUG"
input = tokenizer(text, return_tensors="pt")
label = torch.tensor([1])
output = model(**input, labels=label)
Token Classification / Regression
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.
Here is how to use this model as backbone to fine-tune for a nucleotide-level task in PyTorch:
import torch
from multimolecule import RnaTokenizer, RiNALMoForTokenPrediction
tokenizer = RnaTokenizer.from_pretrained("multimolecule/rinalmo-giga")
model = RiNALMoForTokenPrediction.from_pretrained("multimolecule/rinalmo-giga")
text = "UAGCUUAUCAGACUGAUGUUG"
input = tokenizer(text, return_tensors="pt")
label = torch.randint(2, (len(text), ))
output = model(**input, labels=label)
Contact Classification / Regression
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.
Here is how to use this model as backbone to fine-tune for a contact-level task in PyTorch:
import torch
from multimolecule import RnaTokenizer, RiNALMoForContactPrediction
tokenizer = RnaTokenizer.from_pretrained("multimolecule/rinalmo-giga")
model = RiNALMoForContactPrediction.from_pretrained("multimolecule/rinalmo-giga")
text = "UAGCUUAUCAGACUGAUGUUG"
input = tokenizer(text, return_tensors="pt")
label = torch.randint(2, (len(text), len(text)))
output = model(**input, labels=label)
Training Details
RiNALMo 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.
Training Data
The RiNALMo model was pre-trained on a cocktail of databases including RNAcentral, Rfam, Ensembl Genome Browser, and Nucleotide. The training data contains 36 million unique ncRNA sequences.
To ensure sequence diversity in each training batch, RiNALMo clustered the sequences with MMSeqs2 into 17 million clusters and then sampled each sequence in the batch from a different cluster.
RiNALMo 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
RiNALMo used masked language modeling (MLM) as the pre-training objective. 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.
Pre-training
The model was trained on 7 NVIDIA A100 GPUs with 80GiB memories.
- Batch Size: 1344
- Epochs: 6
- Learning rate: 5e-5
- Learning rate scheduler: Cosine
- Learning rate warm-up: 2,000 steps
- Learning rate minimum: 1e-5
- Dropout: 0.1
Citation
BibTeX:
@ARTICLE{Penic2025-qf,
title = "{RiNALMo}: general-purpose {RNA} language models can generalize
well on structure prediction tasks",
author = "Peni{\'c}, Rafael Josip and Vla{\v s}i{\'c}, Tin and Huber,
Roland G and Wan, Yue and {\v S}iki{\'c}, Mile",
abstract = "While RNA has recently been recognized as an interesting
small-molecule drug target, many challenges remain to be
addressed before we take full advantage of it. This emphasizes
the necessity to improve our understanding of its structures and
functions. Over the years, sequencing technologies have produced
an enormous amount of unlabeled RNA data, which hides a huge
potential. Motivated by the successes of protein language
models, we introduce RiboNucleic Acid Language Model (RiNALMo)
to unveil the hidden code of RNA. RiNALMo is the largest RNA
language model to date, with 650M parameters pre-trained on 36M
non-coding RNA sequences from several databases. It can extract
hidden knowledge and capture the underlying structure
information implicitly embedded within the RNA sequences.
RiNALMo achieves state-of-the-art results on several downstream
tasks. Notably, we show that its generalization capabilities
overcome the inability of other deep learning methods for
secondary structure prediction to generalize on unseen RNA
families.",
journal = "Nature Communications",
publisher = "Springer Science and Business Media LLC",
volume = 16,
number = 1,
pages = "5671",
month = jul,
year = 2025,
copyright = "https://creativecommons.org/licenses/by-nc-nd/4.0",
language = "en"
}
Contact
Please use GitHub issues of MultiMolecule for any questions or comments on the model card.
Please contact the authors of the RiNALMo paper for questions or comments on the paper/model.
License
This model is licensed under the AGPL-3.0 License.
SPDX-License-Identifier: AGPL-3.0-or-later
- Downloads last month
- 521