Views
No views yet
| Parameter | Value |
|---|---|
| Layers | 12 |
| Attention heads | 20 |
| Embedding dimension | 640 |
| FFN hidden dimension | 5120 (GELU) |
| Vocabulary size | 25 |
| Positional encoding | Learned |
| Normalization | LayerNorm (embedding, pre-attention/pre-FFN, and final) |
| Architecture | ESM-1b-style pre-LN Transformer encoder |
| Max sequence length | 1024 total tokens (1022 nucleotides plus CLS/EOS) |
<cls>, <pad>, <eos>, <unk>, A, C, G, U, R, Y, K, M, S, W, B, D, H, V, N, -, and 4 null-padding tokens, <mask>.RNA-FM_pretrained.pth from cuhkaih/rnafm| Model | Training data | Embedding dim | Notes |
|---|---|---|---|
| RNA-FM | 23.7 M ncRNA | 640 | This model |
| mRNA-FM | 45 M CDS | 1280 | Codon (3-mer) tokenisation |
1import torch
2from transformers import AutoTokenizer, AutoModel
3
4tokenizer = AutoTokenizer.from_pretrained("Taykhoom/RNA-FM", trust_remote_code=True)
5model = AutoModel.from_pretrained("Taykhoom/RNA-FM", trust_remote_code=True)
6model.eval()
7
8sequences = [
9 "GGGUGCGAUCAUACCAGCACUAAUGCCCUCCUGGGAAGUCCUCGUGUUGCACCCCU",
10 "AUCGGGCUUAGCAUAGCUU",
11]
12# RNA-FM was trained on RNA sequences (U not T). T is not in the vocabulary.
13# If your sequences use DNA notation, convert first:
14# sequences = [s.replace("T", "U") for s in sequences]
15enc = tokenizer(sequences, return_tensors="pt", padding=True)
16
17with torch.no_grad():
18 out = model(**enc)
19
20cls_emb = out.last_hidden_state[:, 0, :] # (batch, 640) -- CLS token
21token_emb = out.last_hidden_state # (batch, seq_len, 640) -- per-token
22
23# Intermediate layers
24out_all = model(**enc, output_hidden_states=True)
25layer6_emb = out_all.hidden_states[6] # layer 0 = embedding, 1-12 = transformer layers1import torch
2from transformers import AutoTokenizer, AutoModelForMaskedLM
3
4tokenizer = AutoTokenizer.from_pretrained("Taykhoom/RNA-FM", trust_remote_code=True)
5model = AutoModelForMaskedLM.from_pretrained("Taykhoom/RNA-FM", trust_remote_code=True)
6model.eval()
7
8enc = tokenizer(["GGG<mask>GCGAU"], return_tensors="pt")
9with torch.no_grad():
10 logits = model(**enc).logits # (1, seq_len, 25)out.last_hidden_state[:, 0, :]) as
input to a classification or regression head for sequence-level tasks.F.multi_head_attention_forward (eager). This HF port adds
attn_implementation="sdpa" and attn_implementation="flash_attention_2" support, which were
not part of the original codebase.1@article{chen2022_rnafm,
2 title = {Interpretable {RNA} Foundation Model from Unannotated Data for Highly Accurate {RNA} Structure and Function Predictions},
3 author = {Chen, Jiayang and Hu, Zhihang and Sun, Siqi and Tan, Qingxiong and Wang, Yixuan and Yu, Qinze and Zong, Licheng and Hong, Liang and Xiao, Jin and Shen, Tao and King, Irwin and Li, Yu},
4 journal = {arXiv preprint arXiv:2204.00300},
5 year = {2022},
6 doi = {10.48550/arXiv.2204.00300}
7}