Preprint · Model · Demo · PyPI Minerva predicts coevolution using genome language models. Powered by Minerva-MLM, it delivers database-scale, alignment-free, interaction-specific predictions across prokaryotic genomes. Through adaptation on homologous loci, Minerva can discover additional interactions. Try it in the browser, no install needed: Minerva on Hugging Face Spaces. Install · Checkpoints · Quick start ·…
Minerva predicts coevolution using genome language models. Powered by Minerva-MLM, it delivers database-scale, alignment-free, interaction-specific predictions across prokaryotic genomes. Through adaptation on homologous loci, Minerva can discover additional interactions.
Minerva uses flash-attn automatically when it is installed. Otherwise it falls
back to PyTorch SDPA. Please install flash attention first for faster inference.
Pretrained Checkpoints
Minerva-MLM is a 650M parameter transformer trained for over 1.3 trillion tokens (~3.4 Terabases). Minerva-MLM is initialized from gLM2 650M and adopts the mixed-modality tokenization, and was trained at 4096 and 8192 context lengths.
Importing the class directly needs no trust_remote_code. Without the package
installed, use AutoModelForMaskedLM.from_pretrained(repo, trust_remote_code=True).
On Mac use .to("mps") instead of .cuda(). Keeping the model in float32 is
compatible with more systems.
Preparing inputs
Minerva reads a mixed protein + DNA sequence: coding regions are upper-case
amino acids, intergenic regions are lower-case nucleotides, and <+> / <->
markers denote strand.
Your own [{start, end, strand}] calls packaged, with genome↔token maps.
From unannotated sequence (gene calling)
If you only have a FASTA file or a raw nucleotide string, we use Pyrodigal to automatically call genes:
from minerva.gene_calling import build_minerva_input, fasta_to_minerva_inputs
# From a single nucleotide string
out = build_minerva_input(sequence) # dict: token_string + coord maps
token_string = out["token_string"]
# From a FASTA file (one result per record)
inputs = fasta_to_minerva_inputs("contigs.fasta")
Pyrodigal needs ≥ 20 kb to estimate gene-scoring statistics from a sequence;
shorter contigs use its pre-trained profiles, which meta=True forces
for metagenomic assemblies. token_to_genome / genome_to_token map character
index in token_string to genome position; for token index, use
minerva.sequence_utils.build_token_to_genome_map.
Context length & capping
Minerva’s context is 4096 (gbrixi/minerva-mlm) or 8192 tokens
(gbrixi/minerva-mlm-8k). One token is one amino acid, one nucleotide, or one
strand marker, so a typical (~88 % coding) bacterial genome packs to ~10 kb per
4096 tokens (~20 kb for the 8k model).
Pass max_tokens to the builders to cap a sequence.
out = build_minerva_input(sequence, max_tokens=4096) # <= 4096 tokens
To cover a whole genome, tile it instead with
minerva.sequence_utils.chunk_sequence_with_stride.
Translation tables
CDS translate with NCBI table 11 by default, but a GenBank feature’s own
/transl_table takes precedence. Override with translation_table= on the
builders or --translation_table on scripts/finetune.py.
See examples/ for runnable, end-to-end walkthroughs.
Using the model
These continue from the quick start, with model, tokenizer, tokens and
outputs already defined.
Interaction heads
To plot the interaction-head outputs:
from minerva.visualization import plot_contacts
token_list = tokenizer.convert_ids_to_tokens(tokens["input_ids"][0].tolist())
plot_contacts(outputs, tokens=token_list, track=True) # track=True adds a CDS / intergenic strip
plot_contacts takes the model outputs, a dict of head maps, or a Jacobian
FingerprintResult (below), and renders them all in the same palette. For a
zoomable view with hover values, plot_contacts_interactive takes the same
arguments and returns a Bokeh layout (pip install "minerva-dna[viz]").
Set interaction_layers=6 to use the six-layer interaction heads:
Use get_fingerprints when you want named interaction-pattern channels from a
sequence. It computes the required full categorical Jacobian internally and returns
a FingerprintResult; the large raw Jacobian is not kept unless requested.
For researchers studying eukaryotic RNAs, Minerva provides a RiNALMo-based checkpoint with base-pairing and repeat interaction heads. See eukaryotic RNA support for usage and finetuning.
Finetuning
scripts/finetune.py wraps HF Trainer + accelerate with Minerva’s MLM loss.
It supports full finetuning and LoRA, and ingests GenBank files directly.
from peft import PeftModel
from minerva import MinervaForMaskedLM
base = MinervaForMaskedLM.from_pretrained("gbrixi/minerva-mlm")
model = PeftModel.from_pretrained(base, "path/to/lora_ckpt")
A LOCUS longer than --max_seq_length is split into non-overlapping blocks,
each its own training example, see
minerva.finetuning.load_genbank_dataset.
@article{li2026minerva,
title = {Coevolutionary mining of prokaryotic non-coding elements with a genome language model},
author = {Li, David B. and Brixi, Garyk and Kim, Alexandra S. and Fiamenghi, Mateus B. and Driscoll, Claudia L. and Evans, Simone A. and Gao, Alex and Ivanova, Natalia N. and Kyrpides, Nikos C. and Deisseroth, Karl and Wilkinson, Max E. and Fischbach, Michael A. and Hie, Brian L.},
journal = {bioRxiv},
year = {2026},
doi = {10.64898/2026.09.22.753630},
url = {https://www.biorxiv.org/content/10.64898/2026.09.22.753630},
publisher = {Cold Spring Harbor Laboratory}
}
@article{zhang2024categoricaljacobian,
title = {Protein language models learn evolutionary statistics of interacting sequence motifs},
author = {Zhang, Z. and Wayment-Steele, H. K. and Brixi, G. and Wang, H. and Kern, D. and Ovchinnikov, S.},
journal = {Proceedings of the National Academy of Sciences},
volume = {121},
number = {45},
pages = {e2406285121},
year = {2024},
doi = {10.1073/pnas.2406285121}
}
License
Apache 2.0 — see LICENSE. Minerva-MLM is initialized from
gLM2 650M (Tatta Bio, Apache 2.0).
评论