Microbiome community foundation model pretrained on 263,302 samples, encoding genus abundance as ranked tokens for classification and generation.
No providers recorded yet. Browse all providers
Microbiome studies routinely collapse a community into an abundance table, then fit a supervised model to that one cohort. The approach breaks down at scale: taxonomic composition varies with geography, diet, and host genetics, and sequencing batch effects often dominate the biological signal, so a classifier trained in one country degrades sharply when applied in another. MGM — the Microbial General Model — was built to learn community structure once, from a corpus large enough that these idiosyncrasies average out, and then transfer.
Developed in Kang Ning's lab at Huazhong University of Science and Technology, MGM treats a microbiome sample as a sentence. Genera are ranked by their relative abundance within the sample and converted into an ordered sequence of discrete tokens, which a transformer decoder is trained to continue autoregressively. Rank-based encoding is the central design choice: it discards absolute abundance, which is precisely the quantity most distorted by sequencing protocol, while preserving the ordering that carries ecological meaning. Substituting centered log-ratio encoding under a masked objective lowered classification AUROC from 0.99 to 0.97.
MGM is the root of a family from the same lab. MGM 2.0 reframes microbiome samples as sentences and adds colonization prediction and donor selection for faecal microbiota transplantation; MGM2 scaled the corpus by nearly an order of magnitude while adding a sequence modality to each community token. The generative results below — prompt-guided synthesis and the Microbiome Turing Test — were reported in this model's journal version, which absorbed work that first appeared alongside MGM 2.0. Where Microbiome Self-Supervised Learning learns embeddings from abundance alone, MGM's autoregressive framing gives it a generative mode as well as a discriminative one.
MGM is a transformer decoder of eight blocks, each with eight attention heads, a feed-forward width of 1,024, and GELU activations, trained with causal language modeling in PyTorch via the HuggingFace Trainer API. Inputs are capped at 512 tokens, covering 99.99% of samples without truncation. The pretraining corpus, MicroCorpus-260K, comprises 263,302 quality-filtered samples drawn from all of MGnify up to June 2023. Downstream adaptation replaces the language modeling head with a task head and unfreezes the backbone for joint fine-tuning.
On cross-validated community classification over MicroCorpus-260K, fine-tuned MGM reached an average ROC-AUC of 0.99, against 0.68–0.97 for source tracking, classical machine learning, and deep learning baselines; an unpretrained MGM and DeepPhylo both reached 0.97, isolating pretraining as the source of the gain. On infant developmental-stage prediction, MGM matched a random forest on AUROC (0.90) but improved F-max from 0.52 to 0.60, while EXPERT and DeepPhylo trailed the random forest. A five-cancer tumour microbiome classifier reached a macro-average ROC of 0.97. Generated profiles were assessed with a purpose-built "Microbiome Turing Test" of ten statistical and ecological metrics, on eight of which MGM beat the GAN-based generator MB-GAN.
The model is aimed at researchers working with 16S amplicon abundance tables who need results that survive a change of cohort: microbiome-based disease diagnosis across geographic regions, source tracking, developmental trajectory analysis, and biomarker nomination through attention weights. The generative mode supports augmenting small clinical cohorts with synthetic disease-conditioned profiles, and the perturbation mode offers a cheap first pass at nominating genera for intervention.
MGM established that language modeling transfers to microbiome community data and that
rank encoding is a workable substitute for abundance normalization — both choices carried
forward into MGM2. The work appeared as a preprint at the start of 2025 and was published
in Advanced Science in 2026. Code is MIT-licensed, distributed on PyPI as
microformer-mgm, and ships a default MicroCorpus-260K checkpoint used by its fine-tuning
and prediction commands; the corpus itself is downloadable through the repository's
instructions. Evaluation is confined to genus-level amplicon profiles, so functional and
strain-level questions fall outside what the model represents.
Much of this page is generated or calculated automatically. Flag anything that looks off and we will re-run it.