█

AI/TLDR

Buy me a coffee
Buy me a coffee

ESM

Protein language models and structure prediction

Protein & Molecular StructureOpen source
Language
Python
$pip install fair-esm
IN SHORT

What is ESM?

ESM (Evolutionary Scale Modeling) is a collection of transformer-based protein language models with pretrained weights, developed by Meta's Fundamental AI Research Protein Team. The repository packages several models under a single Python library, from the general-purpose ESM-2 language model to the ESMFold structure predictor. It sits in the Protein & Molecular Structure category of the Science & Biomedical AI tools and is open-source, written in Python.

Overview

ESM (Evolutionary Scale Modeling) is a collection of transformer-based protein language models with pretrained weights, developed by Meta's Fundamental AI Research Protein Team. The repository packages several models under a single Python library, from the general-purpose ESM-2 language model to the ESMFold structure predictor.

ESM-2 is a protein language model available in a range of sizes, from 8M up to 15B parameters. It learns representations of protein sequences that can be used for tasks such as structure prediction, function prediction, and contact prediction. ESMFold builds on ESM-2 to predict a protein's 3D structure end to end directly from a single sequence.

Alongside these, the project includes ESM-1v for zero-shot prediction of the effects of mutations on protein function, ESM-IF1 for inverse folding (designing sequences from backbone structures), the MSA Transformer, and the earlier ESM-1b model. The library ships both a Python API and command-line tools for bulk embedding extraction and structure prediction.

What it does

  • ESM-2 general-purpose protein language model in sizes from 8M to 15B parameters
  • ESMFold, an end-to-end single-sequence 3D structure predictor built on ESM-2
  • ESM-1v for zero-shot prediction of the effects of mutations on protein function
  • ESM-IF1 inverse folding model for sequence design from backbone coordinates
  • esm-extract command-line tool for bulk embedding extraction from FASTA files
  • esm-fold command-line tool and a Python API, with models also loadable via PyTorch Hub

Getting started

Install the library with pip, then load a pretrained ESM-2 model to extract sequence representations, or use ESMFold to predict a 3D structure.

Install ESM

Install the base package with pip. To use ESMFold, install the esmfold extra, which pulls in the OpenFold dependencies.

bashbash
pip install fair-esm

# For ESMFold structure prediction:
pip install "fair-esm[esmfold]"

Load ESM-2 and extract representations

Load a pretrained ESM-2 model, tokenize your sequences with the batch converter, and run the model to get per-token representations.

pythonpython
import torch
import esm

model, alphabet = esm.pretrained.esm2_t33_650M_UR50D()
batch_converter = alphabet.get_batch_converter()
model.eval()

data = [
    ("protein1", "MKTVRQERLKSIVRILERSKEPVSGAQLAEELSVSRQVIVQDIAYLRSLGYNIVATPRGYVLAGG"),
]
batch_labels, batch_strs, batch_tokens = batch_converter(data)

with torch.no_grad():
    results = model(batch_tokens, repr_layers=[33], return_contacts=True)
token_representations = results["representations"][33]

Predict a structure with ESMFold

Load ESMFold and call infer_pdb on a single sequence to get a predicted 3D structure as a PDB string.

pythonpython
import torch
import esm

model = esm.pretrained.esmfold_v1()
model = model.eval().cuda()

sequence = "MKTVRQERLKSIVRILERSKEPVSGAQLAEELSVSRQVIVQDIAYLRSLGYNIVATPRGYVLAGG"

with torch.no_grad():
    output = model.infer_pdb(sequence)

with open("result.pdb", "w") as f:
    f.write(output)

Extract embeddings in bulk from the command line

Use the esm-extract tool to compute embeddings for every sequence in a FASTA file.

bashbash
esm-extract esm2_t33_650M_UR50D examples/data/some_proteins.fasta \
  examples/data/some_proteins_emb_esm2 --repr_layers 0 32 33 --include mean per_tok

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Generate learned embeddings of protein sequences with ESM-2 to feed into downstream machine learning models
  • Predict a protein's 3D structure directly from its sequence using ESMFold, without a multiple sequence alignment
  • Score the likely functional impact of mutations with ESM-1v using zero-shot variant effect prediction
  • Design candidate sequences for a given backbone structure with the ESM-IF1 inverse folding model

How ESM compares

ESM alongside other open-source protein & molecular structure tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
AlphaFold 3★ 8.8kDeepMind's AlphaFold 3 inference pipeline for predicting the joint 3D structure of proteins with DNA, RNA, ligands, and other biomolecules.
Boltz★ 4.4kOpen-source biomolecular interaction models for predicting the 3D structures of proteins and their complexes.
ESM★ 4.2kProtein language models and structure prediction
OpenFold★ 3.5kTrainable, memory-efficient, GPU-friendly PyTorch reproduction of AlphaFold 2 for protein structure prediction.
DiffDock★ 1.6kDiffusion generative model for molecular docking — predicting how small-molecule ligands bind to protein targets.
Uplifting Biomolecular Modeling★ 398Anthropic's 36 drop-in inference optimization kits for open structure-prediction, protein-design and genomics models, written by Claude.