| license: apache-2.0 | |
| # RNAElectra | |
| RNAElectra is a pretrained RNA language model for nucleotide-level sequence representation learning. | |
| ## Load model | |
| ```python | |
| import torch | |
| from transformers import AutoModel | |
| from tokenizer import NucEL_Tokenizer | |
| device = "cuda" if torch.cuda.is_available() else "cpu" | |
| model = AutoModel.from_pretrained( | |
| "FreakingPotato/RNAElectra", | |
| trust_remote_code=True | |
| ).to(device) | |
| tokenizer = NucEL_Tokenizer.from_pretrained( | |
| "FreakingPotato/RNAElectra", | |
| trust_remote_code=True | |
| ) | |
| sequence = "AUGCAUGCAUGCAUGC" | |
| inputs = tokenizer(sequence, return_tensors="pt") | |
| inputs = {k: v.to(device) for k, v in inputs.items()} | |
| with torch.no_grad(): | |
| outputs = model(**inputs) | |
| embeddings = outputs.last_hidden_state | |
| print(embeddings.shape) |