ESM-2
Protein language model · Meta AI · 2023

ESM-2

A bidirectional transformer trained to reconstruct masked amino acids from unaligned sequences. It produces contextual per-residue representations and amino-acid logits. Converting those representations into coordinates requires ESMFold, which is a separate model.

In plain language

A model that was trained by hiding amino acids and guessing them back. Doing that well forces it to learn what each position in a protein is for, and those internal numbers turn out to be useful for almost any protein task.

One way to picture it

Fill in the blanks, ten billion times, until you cannot help but understand the grammar. Nobody taught it chemistry. It learned which residues belong together by being asked to guess them.

Commonly misread as

It does not predict structure. It produces vectors. ESMFold is the model that turns those vectors into coordinates, and it is a separate download.

How it is put together

Select a component to read it
Token embeddings
Contextual representations
Per-residue vectors

Try it

Get an embedding for one sequence
import torch
from transformers import AutoTokenizer, AutoModel

name = "facebook/esm2_t33_650M_UR50D"
tok = AutoTokenizer.from_pretrained(name)
model = AutoModel.from_pretrained(name).eval()

seq = "MALWMRLLPLLALLALWGPDPAAA"
batch = tok(seq, return_tensors="pt")
with torch.no_grad():
    out = model(**batch).last_hidden_state

# drop the start and end tokens, then average over residues
per_residue = out[0, 1:-1]
sequence_vector = per_residue.mean(0)
print(per_residue.shape, sequence_vector.shape)

These snippets have not been executed here. Versions move; check the model card before trusting a line of it.

01 / Why it is here

Standing

The scaling study that made masked protein language models a standard component. Later work initialises other models from ESM-2 weights and uses its embeddings as features.

02 / What sets it apart

Distinctions

  • No alignment at inference. Evolutionary information lives in the weights.
  • Checkpoints from 8M to 15B parameters make the scaling behaviour visible.
  • Attention maps correlate with residue contacts although no structural term appears in the loss.
03 / Where it stops

Limits

It is an encoder. It does not generate structures, and its per-residue logits are a poor proxy for fitness in cases where function depends on more than sequence likelihood.

Weights and code

Checked against the registry, not from memory
RepositorySizeLicenceNote
facebook/esm2_t33_650M_UR50D650MMITThe default choice for embeddings
facebook/esm2_t12_35M_UR50D35MMITSmall enough for a laptop
facebook/esm2_t36_3B_UR50D3BMIT
facebook/esm2_t48_15B_UR50D15BMITRarely worth the memory over 3B

Sources

Each number above comes from one of these

Same task, other answers

Protein language model