InstaDeepAI/ntv3
𧬠NTv3 β Foundation Models for Long-Range Genomics
This Space is the companion hub for NTv3 checkpoints on the Hugging Face Hub. It provides PyTorch notebooks and minimal examples for inference, sequence-to-function prediction (functional tracks), genome annotation, fine-tuning, model interpretation and sequence generation.
π About NTv3
NTv3 is a multi-species genomic foundation model family that unifies representation learning, functional-track prediction, genome annotation, and controllable sequence generation within a single U-Net-style backbone. It models up to 1 Mb of DNA at single-base resolution, using a convβTransformerβdeconv architecture that efficiently captures both local motifs and long-range regulatory dependencies. NTv3 is first pretrained on ~9T base pairs from the OpenGenome2 corpus spanning >128k species using masked language modeling, and then post-trained with a joint objective on ~16k functional tracks and annotation labels across 24 animal and plant species, enabling state-of-the-art cross-species functional prediction and base-resolution genome annotation.
Beyond prediction, NTv3 can be fine-tuned into a controllable generative model via masked-diffusion language modeling, allowing targeted design of regulatory sequences (for example, enhancers with specified activity and promoter selectivity) that have been validated experimentally.
π Notebooks
Notebooks live in ./notebooks/:
- π
00_quickstart_inference.ipynbβ load a checkpoint + run inference - π
01_tracks_prediction.ipynbβ sequence β functional tracks (+ plotting) - π·οΈ
02_genome_annotation_segmentation.ipynbβ sequence β annotation - π―
03_finetune_head.ipynbβ fine-tune on bigwig tracks - π
04_model_interpretation.ipynbβ interpretation of post-trained model - π§ͺ
05_sequence_generation.ipynbβ fine-tune NTv3 to generate enhancer sequences
π¦ Install
pip install torch transformers accelerate safetensors huggingface_hub numpyπ€ Load a pre-trained model
from transformers import AutoTokenizer, AutoModelForMaskedLM
repo = "InstaDeepAI/NTv3_650M_pre"
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForMaskedLM.from_pretrained(repo, trust_remote_code=True)
batch = tok(["ATCGNATCG", "ACGT"], add_special_tokens=False, padding=True, pad_to_multiple_of=128, return_tensors="pt")
out = model(**batch, output_hidden_states=True, output_attentions=True)
print(out.logits.shape) # (B, L, V = 11)
print(len(out.hidden_states)) # convs + transformers + deconvs
print(len(out.attentions)) # equals transformer layers = 12π» Pipelines
Here is a quick example of how to use the post-trained NTv3 650M model on a human genomic window.
from transformers import AutoConfig
model_name = "InstaDeepAI/NTv3_100M"
# Load track prediction pipeline
cfg = AutoConfig.from_pretrained(model_name, trust_remote_code=True, force_download=True)
pipe = cfg.load_tracks_pipeline(model_name, device="auto") # or "cpu"/"cuda"/"mps"
# Run track prediction
out = pipe(
{
"chrom": "chr19",
"start": 6_700_000,
"end": 6_831_072,
"species": "human"
}
)
print(out.bigwig_tracks_logits.shape) # functional track predictions
print(out.bed_tracks_logits.shape) # genome annotation predictions
print(out.mlm_logits.shape) # MLM logits: (B, L, V = 11)π€ Checkpoints
π¦ Pre-trained: InstaDeepAI/NTv3_8M_pre, InstaDeepAI/NTv3_100M_pre, InstaDeepAI/NTv3_650M_pre
π― Post-trained: InstaDeepAI/NTv3_100M, InstaDeepAI/NTv3_650M
π Links
- π Paper: (add link)
- π» JAX research code (GitHub): https://github.com/instadeepai/nucleotide-transformer
- π NTv3 benchmark leaderboard: (add link)
π Citation
@article{ntv3,
title = {A foundational model for joint sequence-function multi-species modeling at scale for long-range genomic prediction},
author = {β¦},
journal = {β¦},
year = {β¦}
}π License
Code & notebooks in this Space: (choose and add, e.g., Apache-2.0)
Model weights: see the license specified in each model repository
