lucidrains/alphagenome
About
Implementation of AlphaGenome, Deepmind's updated genomic attention model
AI & Machine LearningMeasured star growth
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- +1
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Original
AlphaGenome
Implementation of AlphaGenome, Deepmind's updated genomic attention model
The official code has been released!
This project is now being carried on by Anshul Kundaje's lab here!
Appreciation
Miquel Anglada-Girotto for contributing the organism, output embedding, loss functions, and all the splicing prediction heads!
Xinming Tu for aligning the architecture with the official JAX implementation, enabling pretrained weight compatibility, TFRecord dataset support, scoring and evaluation modules, and a test suite!
Install
pip install .
Or with uv (recommended):
uv pip install .
Environment Setup
To use pretrained weights from HuggingFace, create a .env file with your credentials:
cp .env.template .env
# Edit .env and add your HF_TOKEN
Required environment variables:
HF_TOKEN: Your HuggingFace API token (get one here)
Usage
The main unet transformer, without any heads
import torch
from alphagenome_pytorch import AlphaGenome
model = AlphaGenome()
dna = torch.randint(0, 4, (2, 8192))
# organism_index - 0 for human, 1 for mouse - can be changed with `num_organisms` on `AlphaGenome`
embeds_1bp, embeds_128bp, embeds_pair = model(dna, organism_index = 0) # (2, 8192, 1536), (2, 64, 3072), (2, 4, 4, 128)
Adding all types of output heads (thanks to @MiqG)
import torch
from alphagenome_pytorch import AlphaGenome, publication_heads_config
model = AlphaGenome()
model.add_heads(
'human',
num_tracks_1bp = 10,
num_tracks_128bp = 10,
num_tracks_contacts = 128,
num_splicing_contexts = 64, # 2 strands x num. CURIE conditions
)
dna = torch.randint(0, 4, (2, 8192))
organism_index = torch.tensor([0, 1]) # the organism that each sequence belongs to
splice_donor_idx = torch.tensor([[10, 100, 34], [24, 546, 870]])
splice_acceptor_idx = torch.tensor([[15, 103, 87], [56, 653, 900]])
# get sequence embeddings
embeddings_1bp, embeddings_128bp, embeddings_pair = model(dna, organism_index, return_embeds = True) # (2, 8192, 1536), (2, 64, 3072), (2, 4, 4, 128)
# get track predictions
out = model(
dna,
organism_index,
splice_donor_idx = splice_donor_idx,
splice_acceptor_idx = splice_acceptor_idx
)
for organism, outputs in out.items():
for out_head, out_values in outputs.items():
print(organism, out_head, out_values.shape)
# human 1bp_tracks torch.Size([2, 8192, 10])
# human 128bp_tracks torch.Size([2, 64, 10])
# human contact_head torch.Size([2, 4, 4, 128])
# human splice_logits torch.Size([2, 8192, 5])
# human splice_usage torch.Size([2, 8192, 64])
# human splice_juncs torch.Size([2, 3, 3, 64])
# initialize published AlphaGenome for human and mouse
model = AlphaGenome()
model.add_heads(**publication_heads_config['human'])
model.add_heads(**publication_heads_config['mouse'])
model.total_parameters # 259,459,534 (vs ~450 million trainable parameters)
Training
test minimal architecture
# loss quickly decreases and stabilizes at around 1349651
# this minimal model (576,444 parameters) can be run with cpu
python train_dummy.py --config_file=configs/dummy.yaml
Loading Pretrained Weights
Installation requirements
To use the conversion utilities, you will need to install the alphagenome-research package manually from GitHub
uv pip install git+https://github.com/google-deepmind/alphagenome_research.git
Loading and Converting
from alphagenome_pytorch import AlphaGenome
# Load AlphaGenome with official JAX weights
model = AlphaGenome()
model.add_reference_heads("human")
model.load_from_official_jax_model("all_folds")
model.eval()
Contributing
Development Setup
# Clone and install with dev dependencies using uv
git clone https://github.com/lucidrains/alphagenome.git
cd alphagenome
uv pip install -e '.[test,convert]'
# Set up environment variables
cp .env.template .env
# Edit .env and add your HF_TOKEN
Running Tests
# Run unit tests
uv run pytest tests/test_alphagenome.py -v
# Run regression tests (requires HF access)
ALPHAGENOME_RUN_INTEGRATION_TESTS=1 uv run pytest tests/test_regression.py -v
# Run full integration tests
ALPHAGENOME_RUN_INTEGRATION_TESTS=1 uv run pytest tests/test_integration_jax_torch.py -v
Regenerating Regression Data
If you modify the model architecture, regenerate the reference tensors:
uv run python tests/generate_regression_tensors.py
That's it. Vibe coding with some attention network is totally welcomed, if it works
Citations
@article {avsec2025alphagenome,
title = {AlphaGenome: advancing regulatory variant effect prediction with a unified DNA sequence model},
author = {Avsec, {\v Z}iga and Latysheva, Natasha and Cheng, Jun and Novati, Guido and Taylor, Kyle R. and Ward, Tom and Bycroft, Clare and Nicolaisen, Lauren and Arvaniti, Eirini and Pan, Joshua and Thomas, Raina and Dutordoir, Vincent and Perino, Matteo and De, Soham and Karollus, Alexander and Gayoso, Adam and Sargeant, Toby and Mottram, Anne and Wong, Lai Hong and Drot{\'a}r, Pavol and Kosiorek, Adam and Senior, Andrew and Tanburn, Richard and Applebaum, Taylor and Basu, Souradeep and Hassabis, Demis and Kohli, Pushmeet},
elocation-id = {2025.06.25.661532},
year = {2025},
doi = {10.1101/2025.06.25.661532},
publisher = {Cold Spring Harbor Laboratory},
URL = {https://www.biorxiv.org/content/early/2025/06/27/2025.06.25.661532},
eprint = {https://www.biorxiv.org/content/early/2025/06/27/2025.06.25.661532.full.pdf},
journal = {bioRxiv}
}
@misc{gopalakrishnan2025decouplingwhatwherepolar,
title = {Decoupling the "What" and "Where" With Polar Coordinate Positional Embeddings},
author = {Anand Gopalakrishnan and Robert Csordás and Jürgen Schmidhuber and Michael C. Mozer},
year = {2025},
eprint = {2509.10534},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2509.10534},
}
@misc{gayoso2026alphagenome2,
title = {AlphaGenome 2 predicts regulatory activity and variant effects across cell states},
author = {Gayoso, Adam and Mottram, Anne and Karollus, Alexander and Novati, Guido and Drot{\'a}r, Pavol and Reid, John and Meng-Papaxanthos, Laetitia and Kosiorek, Adam and Arvaniti, Eirini and Dutordoir, Vincent and De, Soham and Ward, Tom and Wong, Lai Hong and Perino, Matteo and Taylor, Kyle and Cheng, Jun and Latysheva, Natasha and Pan, Joshua and Hariharan, Dhavanthi and Bycroft, Clare and Nicolaisen, Lauren and Hassabis, Demis and Kohli, Pushmeet and Avsec, {\v Z}iga},
year = {2026}
}
@misc{kimiteam2026attentionresiduals,
title = {Attention Residuals},
author = {Kimi Team and Guangyu Chen and Yu Zhang and Jianlin Su and Weixin Xu and Siyuan Pan and Yaoyu Wang and Yucheng Wang and Guanduo Chen and Bohong Yin and Yutian Chen and Junjie Yan and Ming Wei and Y. Zhang and Fanqing Meng and Chao Hong and Xiaotong Xie and Shaowei Liu and Enzhe Lu and Yunpeng Tai and Yanru Chen and Xin Men and Haiqing Guo and Y. Charles and Haoyu Lu and Lin Sui and Jinguo Zhu and Zaida Zhou and Weiran He and Weixiao Huang and Xinran Xu and Yuzhi Wang and Guokun Lai and Yulun Du and Yuxin Wu and Zhilin Yang and Xinyu Zhou},
year = {2026},
eprint = {2603.15031},
archivePrefix = {arXiv},
primaryClass = {cs.CL},
url = {https://arxiv.org/abs/2603.15031},
}
@misc{luo2026multiheadattentionresiduals,
title = {Multi-Head Attention Residuals},
author = {Cheng Luo and Zefan Cai and Junjie Hu},
year = {2026},
eprint = {2607.27230},
archivePrefix = {arXiv},
primaryClass = {cs.AI},
url = {https://arxiv.org/abs/2607.27230},
}
@article{Liu2026XAttnRes,
title = {XAttnRes: Cross-Stage Attention Residuals for Medical Image Segmentation},
author = {Xinyu Liu and Qing Xu and Zhen Chen},
journal = {arXiv preprint arXiv:2604.03297},
year = {2026},
url = {https://arxiv.org/abs/2604.03297}
}
Explore related projects
Loading…