본문으로 건너뛰기
Skillpedia
머신러닝5.4k · #14860

fair-esm2

하는 일

이 스킬은 Meta의 ESM-2 단백질 언어 모델을 사용하는 방법을 에이전트에게 가르칩니다. 잔기별과 서열별 임베딩을 만들고, 마스크 예측으로 돌연변이를 점수화하며, 잔기 간 접촉을 예측합니다.

사용하는 경우

  • ✓연구자가 기계 학습 모델에 넣을 단백질 임베딩이 필요할 때.
  • ✓과학자가 언어 모델로 돌연변이의 효과를 점수화하고 싶을 때.
  • ✓연구자가 서열로부터 잔기 사이의 예측된 접촉을 원하는 경우.

스킬 링크

https://github.com/aipoch/open-science/blob/main/resources/skills/fair-esm2/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/aipoch/open-science/blob/main/resources/skills/fair-esm2/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 단백질 서열들의 임베딩을 ESM-2로 만들어서, 분류기를 학습할 수 있게 해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 ESM-2 모델을 불러오고, 서열을 토큰으로 바꾼 뒤, 선택한 층에서 표현을 얻도록 모델을 실행합니다. 작업에 따라 결과를 평균하거나 점수화합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

fair-esm2 — ESM-2 (Meta AI)

ESM-2 code and weights are MIT (Meta AI, github.com/facebookresearch/esm).

Package disambiguation. pip install fair-esm gives you import esm with esm.pretrained.* (ESM-1/2). Biohub's github.com/Biohub/esm fork (MIT) gives you from esm.models.esmfold2 import ESMFold2InputBuilder — see the esmfold2 skill. Both share the esm namespace but are different libraries. This skill covers fair-esm (the Meta package).

Prerequisites

Requirement Minimum Recommended
Python 3.8+ 3.11
CUDA 11.7+ 12.x
GPU VRAM 8 GB (8M), 16 GB (650M) 24 GB+ (650M / 3B)

How to run

Embeddings

import torch, esm

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

_, _, toks = bc([("ubq", "MQIFVKTLTGKTITLEVEPSDTIENVK")])
with torch.no_grad():
    out = model(toks.cuda(), repr_layers=[33])
emb = out["representations"][33]      # (1, L+2, 1280) — includes BOS/EOS
seq_emb = emb[0, 1:-1].mean(0)        # per-sequence mean

Masked-LM scoring

with torch.no_grad():
    out = model(toks.cuda(), repr_layers=[33])
logits = out["logits"][0, 1:-1]       # (L, |vocab|)
# WT marginal log-likelihood; for mutation scoring, mask the position and
# compare logit[mut] − logit[wt].

Contact prediction

with torch.no_grad():
    out = model(toks.cuda(), repr_layers=[33], return_contacts=True)
contacts = out["contacts"][0]         # (L, L)

Models

Name Layers Dim Params Use
esm2_t6_8M_UR50D 6 320 8 M Fast smoke / tiny embeddings
esm2_t33_650M_UR50D 33 1280 650 M Default embedding model
esm2_t36_3B_UR50D 36 2560 3 B Best embeddings, 24 GB+

Output format

out["representations"][layer] is (B, L_max+2, D), where L_max is the longest tokenized residue sequence in the batch. ESM-2 adds BOS/EOS and pads shorter sequences after EOS. The single-sequence 1:-1 slice above is valid without padding; in a mixed-length batch it includes EOS and may include padding for shorter sequences.

For a batch, count non-padding tokens separately for each sequence, then remove BOS/EOS before pooling. Here toks and out must come from the same batch:

token_lengths = (toks != alphabet.padding_idx).sum(1).tolist()  # includes BOS/EOS
emb = out["representations"][33]
residue_embs = [emb[i, 1 : token_length - 1] for i, token_length in enumerate(token_lengths)]
seq_embs = torch.stack([residues.mean(0) for residues in residue_embs])  # (B, D)

Use nonempty protein sequences. Keep the batch order when associating embeddings with sequence IDs. out["contacts"] (when return_contacts=True) has shape (B, L_max, L_max); for sequence i, retain only out["contacts"][i, : token_lengths[i] - 2, : token_lengths[i] - 2].

Remote compute

Needs ≥16 GB VRAM (650M model) and either pre-cached .pt checkpoints or egress to dl.fbaipublicfiles.com. Read compute_details({provider, mode:'read'}) for an environment with fair-esm and a torch-hub weight cache, then:

c = host.compute.create(provider)
job = c.submitJob(
    intent="ESM-2 650M embeddings for 200 sequences — 1×GPU, ~2 min",
    inputs=[
        {"src": "seqs.fasta", "dstFilename": "seqs.fasta"},
        {"src": "embed_esm2.py", "dstFilename": "embed_esm2.py"},
    ],
    command="python3 embed_esm2.py",
    environment=...,   # env name from compute_details
    outputs=["embeddings.pt"],
    timeoutSeconds=1800,
)
print(job.job_id)   # cell ends here — kernel never blocks on compute

Retain the exact returned job_id. Query that saved ID with the non-blocking c.attachJob(job_id).status() or .result() when its state or result is relevant; do not scan Job history. A final .result() read reports whether its follow-up was suppressed or had already been committed; otherwise the app starts the later analysis turn for an unread final result. See the remote-compute-ssh skill for details.

Inside embed_esm2.py, set TORCH_HOME to the provider's torch-hub cache mount (path is in compute_details

자주 묻는 질문

ESMFold2와 같은 것인가요?

아닙니다. 스킬은 fair-esm이 Meta 패키지이고, ESMFold2는 다른 라이브러리라고 설명합니다.

GPU 메모리는 얼마나 필요한가요?

스킬은 작은 모델에 8GB, 6억 5천만 파라미터 모델에 16GB를 나열합니다.

어떤 라이선스가 적용되나요?

스킬은 ESM-2 코드와 가중치가 MIT 라이선스라고 설명합니다.

상세 정보

작성자의 원본 설명

Embed proteins with Meta AI's ESM-2 (`fair-esm` package). Use this skill when: (1) Extracting per-residue or per-sequence embeddings for downstream ML, (2) Masked-LM likelihood / mutation effect scoring, (3) Contact prediction from a sequence.

repo: aipoch/open-science

인기도

GitHub 스타
5.4k
순위
#14860
라이선스
Apache-2.0
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬