/ Модель

Характеристики

Контекст
514 токенов
Параметры
113 млн
Лицензия
MIT
Архитектура
bert_updated · dense
Библиотека
transformers
Опубликована
5 ноя 2026

structRFM

Заполнение пропусковТекст → текст3 профессии

BERT-модель для восстановления нуклеотидов и построения представлений последовательностей РНК с учётом вторичной структуры.

121скачиваний за 30 дней0лайковвеса обновлены5 ноя 2026

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

structRFM — модель для работы с последовательностями РНК, разработанная Zhu и перенесённая в формат Hugging Face Taykhoom Dalal. Это плотный BERT-энкодер с 12 слоями, 12 головами внимания и размерностью эмбеддингов 768; модель содержит 113,3 млн параметров и обучалась предсказывать замаскированные нуклеотиды с учётом вторичной структуры РНК.

Модель предназначена для восстановления нуклеотидов и получения представлений последовательностей, которые можно использовать для задач на уровне последовательности, нуклеотидов или пар оснований. Она обучена на примерно 21 млн последовательностей RNAcentral длиной до 512 нуклеотидов с предсказанными вторичными структурами. Токенизатор приводит вход к верхнему регистру, заменяет T на U и добавляет специальные токены; последовательности длиннее 512 нуклеотидов нужно разбивать на окна.

Модель принимает последовательности РНК в виде текста и выдаёт распределения вероятностей по токенам либо скрытые векторные представления. Репозиторий содержит неизменённые веса исходной модели в формате safetensors и исправляет предобработку токенизатора для использования через Transformers. Лицензия — MIT. README предупреждает, что pooler_output не был предобучен и требует дообучения перед использованием.

Сценарии применения

  • восстановление замаскированных нуклеотидов в последовательности РНК
  • получение эмбеддингов последовательностей РНК
  • подготовка признаков для классификации РНК
  • анализ нуклеотидов и пар оснований с помощью скрытых представлений

Ограничения

Максимальная длина последовательности — 512 нуклеотидов; более длинные последовательности нужно обрабатывать окнами. pooler_output случайно инициализирован и не подходит для использования без дообучения.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

structRFM

Minimal HuggingFace port of structRFM -- a structure-guided RNA foundation model: a BERT encoder pretrained with structure-guided masked language modeling on ~21M RNAcentral sequences paired with ensemble-predicted secondary structures.

Why this port?

heqin-zhu/structRFM ships the weights as a stock BertForMaskedLM, but its tokenizer has no post-processing template or normalizer. Upstream code builds the model input by hand ("[CLS]" + seq.upper().replace("T", "U") + "[SEP]"); calling its AutoTokenizer directly on a sequence silently:

  1. adds no [CLS] / [SEP] tokens, and
  2. maps T and every lowercase base to [UNK].

This repo's tokenizer applies the upstream preprocessing itself (uppercase, T->U, [CLS] ... [SEP]), so tokenizer(seq) produces exactly the token ids the model was pretrained on. It also adds flash_attention_2 support. The weights are unchanged and bit-exact with the upstream release (see Parity Verification).

Architecture

ParameterValue
Layers12
Attention heads12
Embedding dimension768
FFN hidden dimension3072 (GELU)
Vocabulary size10
Positional encodingLearned absolute
NormalizationLayerNorm (post-residual, eps=1e-12)
ArchitecturePost-LN BERT encoder
Max sequence length512 nt (514 tokens with [CLS] and [SEP])
Parameters85.5M (encoder) + 0.6M (MLM head)

Vocabulary: [UNK]=0, [CLS]=1, [SEP]=2, [PAD]=3, [MASK]=4, A=5, U=6, C=7, G=8, N=9. Input is uppercased and T is read as U; any other character (including whitespace) maps to [UNK], as upstream.

Pretraining

  • Objective: Structure-guided masked language modeling (SgMLM): each batch uses either standard 15% token masking or structure masking, where masking a paired base also masks its partner; the share of structure-masked batches is scheduled over training
  • Data: ~21M RNAcentral sequences (<= 512 nt) with secondary structures from MUSES, a multi-source ensemble of thermodynamic, probabilistic and deep-learning predictors
  • Source checkpoint: structRFM_checkpoint.tar.gz from the upstream v0.0.8 release (identical to heqin-zhu/structRFM)

Checkpoint selection

Upstream released two pretrained models: v0.0.3, pretrained on single-predictor (BPfold) structures, and v0.0.8, re-pretrained on MUSES ensemble structures. v0.0.8 replaced v0.0.3 on the Hub and is the base of every released downstream checkpoint, so it is the one ported here.

The released secondary-structure (structRFM_SSP_bpRNA1m.pt, structRFM_SSP_RNAStrAlign.pt), tertiary-structure and IRES checkpoints train a task head on detached encoder features, so their encoder weights are bit-identical to this model; use this repo for their embeddings.

Parity Verification

All 13 representation levels (embedding + 12 transformer blocks) and the MLM logits verified to be bit-exact (max abs diff = 0.00) against the original v0.0.8 weights run through the upstream structRFM code, with eager and sdpa attention, on padded and unpadded batches. The tokenizer reproduces the upstream token ids exactly. Verified on an NVIDIA H100 with PyTorch 2.7 / CUDA 12.9.

Related Models

See the full structRFM collection.

ModelParametersNotes
structRFM86MThis model

Usage

Embedding generation

import torch
from transformers import AutoTokenizer, AutoModel

tokenizer = AutoTokenizer.from_pretrained("Taykhoom/structRFM", trust_remote_code=True)
model = AutoModel.from_pretrained("Taykhoom/structRFM", trust_remote_code=True)
model.eval()

sequences = ["GUCCCAACUCUUGCGGGGAGGGAU", "ATGGCTACGTAG"]   # T is read as U
enc = tokenizer(sequences, return_tensors="pt", padding=True)

with torch.no_grad():
    out = model(**enc)

cls_emb   = out.last_hidden_state[:, 0, :]   # (batch, 768) -- CLS token
token_emb = out.last_hidden_state             # (batch, seq_len, 768)

# Mean over nucleotides only (drop [CLS], [SEP] and padding)
special = torch.isin(enc.input_ids, torch.tensor([tokenizer.cls_token_id, tokenizer.sep_token_id]))
mask = (enc.attention_mask.bool() & ~special).unsqueeze(-1)
mean_emb = (token_emb * mask).sum(1) / mask.sum(1)   # (batch, 768)

# Intermediate layers: hidden_states[0] is the embedding, [i] block i
out_all = model(**enc, output_hidden_states=True)
layer6_emb = out_all.hidden_states[6]

Sequences longer than 512 nt must be split into windows (e.g. 512 nt chunks) and the per-window embeddings pooled.

MLM logits

import torch
from transformers import AutoTokenizer, AutoModelForMaskedLM

tokenizer = AutoTokenizer.from_pretrained("Taykhoom/structRFM", trust_remote_code=True)
model = AutoModelForMaskedLM.from_pretrained("Taykhoom/structRFM", trust_remote_code=True)
model.eval()

enc = tokenizer(["GUCCCAAC[MASK]CUUGCGG"], return_tensors="pt")
with torch.no_grad():
    logits = model(**enc).logits   # (1, seq_len, 10)

Faster attention backends

# SDPA (PyTorch 2.0+) -- recommended for production
model = AutoModel.from_pretrained("Taykhoom/structRFM", trust_remote_code=True,
                                  attn_implementation="sdpa")

# Flash Attention 2 (requires flash-attn) -- fastest on long sequences
model = AutoModel.from_pretrained("Taykhoom/structRFM", trust_remote_code=True,
                                  attn_implementation="flash_attention_2",
                                  dtype=torch.bfloat16)
BackendStatus
eagerSupported; bit-exact with upstream eager
sdpaSupported; bit-exact with upstream (the upstream default backend)
flash_attention_2Supported (added by this port); requires fp16/bf16 weights

output_attentions=True falls back to eager under sdpa and flash_attention_2 and returns post-softmax attention probabilities (batch, heads, seq_len, seq_len).

Fine-tuning

Standard HF conventions. For sequence-level tasks, use the CLS embedding or a masked mean over nucleotide positions as input to a prediction head; for nucleotide- or pair-level tasks use last_hidden_state directly. gradient_checkpointing_enable() is supported.

Implementation Notes

This port reuses the shared BERT-updated runtime (identical to the stock transformers BERT architecture), which adds flash_attention_2 alongside eager and sdpa. The MLM decoder is tied to the input embeddings, as in the upstream checkpoint.

config.pad_token_id is 0 ([UNK]), the value in the upstream config, while the tokenizer pads with [PAD]=3. The config value only sets the embedding's padding_idx (no gradient into that row during fine-tuning) and is kept for fidelity; padding is controlled by attention_mask.

The pooler (pooler_output) is not part of the pretrained checkpoint and is randomly initialized; do not use it without fine-tuning.

Citation

@article{zhu2026_structrfm,
  title   = {An open structure-guided {RNA} foundation model for generalizable prediction},
  author  = {Zhu, Heqin and Li, Ruifeng and Chang, Ao and Chen, Haobin and Zhang, Feng and Tang, Fenghe and Ye, Tong and Li, Xin and Gu, Yunjie and Xiong, Peng and Zhou, S. Kevin},
  journal = {Nature},
  year    = {2026},
  doi     = {10.1038/s41586-026-11210-2}
}

Credits

Original model and code by Zhu et al. Source: GitHub, heqin-zhu/structRFM on the Hub. Hugging Face port maintained by Taykhoom Dalal.

License

MIT, following the original repository.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · transformers · fill-mask

Нельзя запустить

Модели нужен код из репозитория; запуск откроется после проверки совместимости.

Класс архитектуры
BertForMaskedLM
Ревизия весов
933cd85

0 моделей