$npx -y skills add K-Dense-AI/scientific-agent-skills --skill esmUse when working directly with the esm Python SDK, ESM3 or ESMC model IDs, Forge/Biohub inference clients, or ESMFold2 folding workflows.
| 1 | # ESM: Evolutionary Scale Modeling |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | ESM provides protein language models for understanding, generating, and designing proteins. Use this skill for current EvolutionaryScale/Biohub workflows: ESM3 for generative design, ESMC for representation learning and embeddings, hosted Forge/Biohub inference, and ESMFold2 all-atom structure prediction. |
| 6 | |
| 7 | ## Core Capabilities |
| 8 | |
| 9 | ### 1. Protein Sequence Generation with ESM3 |
| 10 | |
| 11 | Generate novel protein sequences with desired properties using multimodal generative modeling. |
| 12 | |
| 13 | **When to use:** |
| 14 | - Designing proteins with specific functional properties |
| 15 | - Completing partial protein sequences |
| 16 | - Generating variants of existing proteins |
| 17 | - Creating proteins with desired structural characteristics |
| 18 | |
| 19 | **Basic usage:** |
| 20 | |
| 21 | ```python |
| 22 | from esm.models.esm3 import ESM3 |
| 23 | from esm.sdk.api import ESM3InferenceClient, ESMProtein, GenerationConfig |
| 24 | |
| 25 | # Load local open weights after accepting the license on Hugging Face. |
| 26 | model: ESM3InferenceClient = ESM3.from_pretrained("esm3-open").to("cuda") |
| 27 | |
| 28 | # Create protein prompt |
| 29 | protein = ESMProtein(sequence="MPRT___KEND") # '_' represents masked positions |
| 30 | |
| 31 | # Generate completion |
| 32 | protein = model.generate(protein, GenerationConfig(track="sequence", num_steps=8)) |
| 33 | print(protein.sequence) |
| 34 | ``` |
| 35 | |
| 36 | **For remote/cloud usage via Forge API:** |
| 37 | |
| 38 | ```python |
| 39 | import os |
| 40 | import esm |
| 41 | from esm.sdk.api import ESMProtein, GenerationConfig |
| 42 | |
| 43 | # Same interface as local ESM3; token from ESM_API_KEY (see Authentication) |
| 44 | model = esm.sdk.client("esm3-medium-2024-08", token=os.environ["ESM_API_KEY"]) |
| 45 | |
| 46 | # Generate |
| 47 | protein = model.generate(protein, GenerationConfig(track="sequence", num_steps=8)) |
| 48 | ``` |
| 49 | |
| 50 | See `references/esm3-api.md` for detailed ESM3 model specifications, advanced generation configurations, and multimodal prompting examples. |
| 51 | |
| 52 | ### 2. Structure Prediction and Inverse Folding |
| 53 | |
| 54 | Use ESM3's structure track for structure prediction from sequence or inverse folding (sequence design from structure). |
| 55 | |
| 56 | **Structure prediction:** |
| 57 | |
| 58 | ```python |
| 59 | from esm.sdk.api import ESM3InferenceClient, ESMProtein, GenerationConfig |
| 60 | |
| 61 | # Predict structure from sequence |
| 62 | protein = ESMProtein(sequence="MPRTKEINDAGLIVHSP...") |
| 63 | protein_with_structure = model.generate( |
| 64 | protein, |
| 65 | GenerationConfig(track="structure", num_steps=protein.sequence.count("_")) |
| 66 | ) |
| 67 | |
| 68 | # Access predicted structure |
| 69 | coordinates = protein_with_structure.coordinates # 3D coordinates |
| 70 | pdb_string = protein_with_structure.to_pdb() |
| 71 | ``` |
| 72 | |
| 73 | **Inverse folding (sequence from structure):** |
| 74 | |
| 75 | ```python |
| 76 | # Design sequence for a target structure |
| 77 | protein_with_structure = ESMProtein.from_pdb("target_structure.pdb") |
| 78 | protein_with_structure.sequence = None # Remove sequence |
| 79 | |
| 80 | # Generate sequence that folds to this structure |
| 81 | designed_protein = model.generate( |
| 82 | protein_with_structure, |
| 83 | GenerationConfig(track="sequence", num_steps=50, temperature=0.7) |
| 84 | ) |
| 85 | ``` |
| 86 | |
| 87 | ### 3. Protein Embeddings with ESM C |
| 88 | |
| 89 | Generate high-quality embeddings for downstream tasks like function prediction, classification, or similarity analysis. |
| 90 | |
| 91 | **When to use:** |
| 92 | - Extracting protein representations for machine learning |
| 93 | - Computing sequence similarities |
| 94 | - Feature extraction for protein classification |
| 95 | - Transfer learning for protein-related tasks |
| 96 | |
| 97 | **Basic usage:** |
| 98 | |
| 99 | ```python |
| 100 | from esm.models.esmc import ESMC |
| 101 | from esm.sdk.api import ESMProtein, LogitsConfig |
| 102 | |
| 103 | # Load ESM C model |
| 104 | model = ESMC.from_pretrained("esmc_300m").to("cuda") |
| 105 | |
| 106 | # Get embeddings |
| 107 | protein = ESMProtein(sequence="MPRTKEINDAGLIVHSP...") |
| 108 | protein_tensor = model.encode(protein) |
| 109 | logits_output = model.logits( |
| 110 | protein_tensor, |
| 111 | LogitsConfig(sequence=True, return_embeddings=True), |
| 112 | ) |
| 113 | embeddings = logits_output.embeddings |
| 114 | ``` |
| 115 | |
| 116 | **Batch processing:** |
| 117 | |
| 118 | ```python |
| 119 | # Encode multiple proteins |
| 120 | proteins = [ |
| 121 | ESMProtein(sequence="MPRTKEIND..."), |
| 122 | ESMProtein(sequence="AGLIVHSPQ..."), |
| 123 | ESMProtein(sequence="KTEFLNDGR...") |
| 124 | ] |
| 125 | |
| 126 | embeddings_list = [ |
| 127 | model.logits( |
| 128 | model.encode(p), |
| 129 | LogitsConfig(sequence=True, return_embeddings=True), |
| 130 | ).embeddings |
| 131 | for p in proteins |
| 132 | ] |
| 133 | ``` |
| 134 | |
| 135 | See `references/esm-c-api.md` for ESM C model details, efficiency comparisons, and advanced embedding strategies. |
| 136 | |
| 137 | ### 4. Function Conditioning and Annotation |
| 138 | |
| 139 | Use ESM3's function track to generate proteins with specific functional annotations or predict function from sequence. |
| 140 | |
| 141 | **Function-conditioned generation:** |
| 142 | |
| 143 | ```python |
| 144 | from esm.sdk.api import ESMProtein, FunctionAnnotation, GenerationConfig |
| 145 | |
| 146 | # Create protein with desired function |
| 147 | protein = ESMProtein( |
| 148 | sequence="_" * 200, # Generate 200 residue protein |
| 149 | function_annotations=[ |
| 150 | FunctionAnnotation(label="fluorescent_protein", start=50, end=150) |
| 151 | ] |
| 152 | ) |
| 153 | |
| 154 | # Generate sequence with specified function |
| 155 | functional_protein = model.generate( |
| 156 | prot |