Quick example
Methods
.embed()
Generate embeddings for one or more protein sequences.
str | Sequence[str]
required
A single amino acid sequence string or a list of sequences. Use
":" to separate chains in a multimer (e.g., "CHAIN_A:CHAIN_B").dict | None
default:"None"
Per-call configuration overrides. Only dynamic config keys can be set here — static keys raise
ValueError. See Configuration.ESM2Output (see Output below)
Output
TheESM2Output dataclass returned by .embed().
Always included
PredictionMetadata
Prediction metadata with timing information. See PredictionMetadata.
np.ndarray
Per-residue embeddings from the final transformer layer. Shape:
(batch, seq_len, embedding_dim).np.ndarray
Per-residue chain assignment. Shape:
(batch, seq_len).np.ndarray
Per-residue residue numbering. Shape:
(batch, seq_len).Optional
Embeddings from all intermediate transformer layers. Shape:
(batch, num_layers, seq_len, embedding_dim). Only included when include_fields contains "hidden_states" or "*".Model sizes
ESM-2 is available in 6 sizes. Set the model viaconfig={"model_name": "..."}.
The default model is
esm2_t33_650M_UR50D (650M parameters).
Configuration
These keys can be set viaconfig={} at initialization or options={} per call (unless marked static).
Multimer embedding
Separate chains with":" in the sequence string:
Hidden states
To retrieve embeddings from all intermediate transformer layers, include"hidden_states" in include_fields:
