Downloads · 30 days
126
77% of all-time downloads
Taykhoom/GENA-LM-bert-base
GENA-LM-bert-base is a fill-mask model from Taykhoom. Use it when you need the model to fill a missing word. It is set up for transformers. The card lists the license as mit.
Minimal HuggingFace port of the bert-base variant of GENA-LM -- a transformer masked language model for long human / multi-species DNA sequences, using byte-pair (BPE) tokenization.
Downloads · 30 days
126
77% of all-time downloads
All-time downloads
163
Public
Parameters
111M
443 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors443 MB · 100%
From the Hugging Face model README
Minimal HuggingFace port of the bert-base variant of GENA-LM -- a transformer masked language model for long human / multi-species DNA sequences, using byte-pair (BPE) tokenization.
| Parameter | Value |
|---|---|
| Layers | 12 |
| Attention heads | 12 |
| Embedding dimension | 768 |
| FFN hidden dimension | 3072 (GELU) |
| Vocabulary size | 32000 |
| Positional encoding | learned absolute |
| Normalization | Pre-LayerNorm (eps=1e-12); final-layer LayerNorm: No |
| Architecture | Pre-LayerNorm BERT (without a final-layer LayerNorm) |
| Max sequence length | 512 BPE tokens (~4608 nucleotides) |
Vocabulary: 32,000 BPE tokens trained on DNA, including [CLS], [SEP], [PAD],
[UNK], and [MASK].
AIRI-Institute/gena-lm-bert-baseAll 13 representation levels (embedding + 12 transformer blocks) and the
masked-LM logits were verified to be bit-exact (max abs diff = 0.00) against the
original AIRI-Institute/gena-lm-bert-base weights, for the eager backend. The added sdpa and
flash_attention_2 backends agree with eager up to the expected fused-kernel
floating-point tolerance. Verified on GPU with PyTorch 2.7 / CUDA 12.9.
See the full GENA-LM collection.
| Model | Parameters | Notes |
|---|---|---|
| GENA-LM-bert-base | 110M | 12L / 768d, 512 ctx (this model) |
| GENA-LM-t2t-bert-base | 110M | 12L / 768d, 512 ctx |
| GENA-LM-t2t-multi-species-bert-base | 110M | 12L / 768d, 512 ctx |
| GENA-LM-t2t-lastln-base | 110M | 12L / 768d, 512 ctx |
| GENA-LM-t2t-bert-large | 336M | 24L / 1024d, 512 ctx |
| GENA-LM-t2t-bigbird-base | 110M | 12L / 768d, 4096 ctx |
| GENA-LM-t2t-sparse-bigbird-base | 110M | 12L / 768d, 4096 ctx |
| GENA-LM-sparse-bigbird-base | 110M | 12L / 768d, 4096 ctx |
import torch
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("Taykhoom/GENA-LM-bert-base", trust_remote_code=True)
model = AutoModel.from_pretrained("Taykhoom/GENA-LM-bert-base", trust_remote_code=True)
model.eval()
sequences = ["ACGTACGTACGTACGT", "TTACGGGCATACGACGT"]
enc = tokenizer(sequences, return_tensors="pt", padding=True)
with torch.no_grad():
out = model(**enc)
cls_emb = out.last_hidden_state[:, 0, :] # (batch, dim) -- CLS token
token_emb = out.last_hidden_state # (batch, seq_len, dim)
# Intermediate layers
out_all = model(**enc, output_hidden_states=True)
layer6_emb = out_all.hidden_states[6]
from transformers import AutoTokenizer, AutoModelForMaskedLM
tokenizer = AutoTokenizer.from_pretrained("Taykhoom/GENA-LM-bert-base", trust_remote_code=True)
model = AutoModelForMaskedLM.from_pretrained("Taykhoom/GENA-LM-bert-base", trust_remote_code=True)
model.eval()
enc = tokenizer(["ACGT[MASK]CGTACGT"], return_tensors="pt")
with torch.no_grad():
logits = model(**enc).logits # (1, seq_len, vocab_size)
# SDPA (PyTorch 2.0+) -- recommended for production
model = AutoModel.from_pretrained("Taykhoom/GENA-LM-bert-base", trust_remote_code=True,
attn_implementation="sdpa")
# Flash Attention 2 (requires flash-attn) -- fastest on long sequences
import torch
model = AutoModel.from_pretrained("Taykhoom/GENA-LM-bert-base", trust_remote_code=True,
attn_implementation="flash_attention_2",
dtype=torch.bfloat16)
Standard HuggingFace conventions. For sequence-level tasks, pool over non-padding
positions or use the [CLS] token embedding as input to a prediction head.
This is a minimal, self-contained reimplementation of the GENA-LM pre-LayerNorm BERT
backbone. The only behavioural additions over the original (eager-only) code are the
sdpa and flash_attention_2 attention backends, selectable via attn_implementation;
the eager backend reproduces the original outputs bit-for-bit. The original NSP head
and pooler are not included, since this port targets embedding and masked-LM use.
AutoModel returns the backbone without a pooler; use the [CLS] hidden state or
masked mean pooling for sequence embeddings. The input embeddings and MLM decoder are tied.
@article{fishman2025_genalm,
title = {{GENA-LM}: a family of open-source foundational {DNA} language models for long sequences},
author = {Fishman, Veniamin and Kuratov, Yuri and Shmelev, Aleksei and Petrov, Maxim and Penzar, Dmitry and Shepelin, Denis and Chekanov, Nikolay and Kardymon, Olga and Burtsev, Mikhail},
journal = {Nucleic Acids Research},
volume = {53},
number = {2},
pages = {gkae1310},
year = {2025},
doi = {10.1093/nar/gkae1310}
}
Original model and code by Fishman, Kuratov, et al. (AIRI Institute). Source: GitHub. Hugging Face port maintained by Taykhoom Dalal.
MIT, following the original repository.