Microbial General Model 2 (MGM2)
MGM2 is a multimodal foundation model for microbial community states and responses. Pretrained on 1.82 million microbiomes, it integrates sequence identity, abundance and community descriptions to produce community-level embeddings and contextual microbial representations.
Installation
Python 3.10 or later is required. Install the package and table-inference tools:
python -m pip install 'microformer-mgm2[tables,hub]'
mgm2-embed --help
The distribution is microformer-mgm2; the Python import is mgm2.
For GPU use, install the appropriate PyTorch build.
Model resources
Four pretrained encoders, sequence and taxonomy embedding banks, and the XLarge sparse autoencoder are available on Hugging Face.
from huggingface_hub import snapshot_download
snapshot_download("LudensZhang/MGM2", revision="v2.1.1", local_dir="MGM2-models")
Community embeddings
Provide a feature-by-sample CSV with OTU IDs in the first column:
mgm2-embed --model MGM2-models/models/small \
--table communities.csv \
--embeddings MGM2-models/embeddings/otus_99_embeddings.h5 \
--output outputs/communities.npz --device cpu
For taxonomic names, add
--fallback MGM2-models/embeddings/otus_99_taxonomy_fallback.h5.
Your own sequences
Encode representative FASTA sequences using legacy NTv3_650M_pre:
python -m pip install 'microformer-mgm2[ntv3]'
mgm2-encode-fasta --fasta representative_sequences.fasta \
--output outputs/asv_ntv3.h5 --device cuda:0 --trust-remote-code
Use the generated bank with mgm2-embed --embeddings outputs/asv_ntv3.h5.
See the sequence guide
for model access and local checkpoints.
Resources
- Code and documentation
- Getting-started notebook
- Sequence notebook
- Feature atlas
- SAE interpretation agent
- Preprint
License
MGM2 code uses the MIT License. Model weights and third-party resources retain their respective terms.
Metadata
Release files for microformer-mgm2 2.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| microformer_mgm2-2.1.1.tar.gz | 54.0 kB | Without provenance | Details for microformer_mgm2-2.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| microformer_mgm2-2.1.1-py3-none-any.whl | Python 3 | none | any | Details for microformer_mgm2-2.1.1-py3-none-any.whl |
Total release size: 85.6 kB
Release files / microformer_mgm2-2.1.1.tar.gz
| Download URL | microformer_mgm2-2.1.1.tar.gz |
|---|---|
| Size | 54.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad26efe3b20c7a1679f96a60aa7b3bb22d30c1d6e92dd53f81d151f5b3b73f43
|
|
BLAKE2b-256 checksum How to use checksums |
5b02a1bcfaa5d5b53c27201fb9cc9aebceed0cfe842205585889ef747ac29cc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.19
|
Release files / microformer_mgm2-2.1.1-py3-none-any.whl
| Download URL | microformer_mgm2-2.1.1-py3-none-any.whl |
|---|---|
| Size | 31.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fc9cebf2a493da6acfbe13d35c5cb0978f8ad7ba79cc4dfb12c764eca4700dd5
|
|
BLAKE2b-256 checksum How to use checksums |
260847f42c2c16c3255c83b0053065ccaa8eca21ee4e6ff9f7dded688e6221ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.19
|
Security for microformer-mgm2 2.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.