fair-esm2
Fungsinya
Skill ini mengajari agent cara memakai model bahasa protein ESM-2 dari Meta. Skill ini membuat embedding per residu dan per urutan, menilai mutasi dengan prediksi bertopeng, dan memprediksi kontak antar residu.
Kapan dipakai
- βSaat peneliti memerlukan embedding protein untuk dimasukkan ke model pembelajaran mesin.
- βSaat ilmuwan ingin menilai efek mutasi dengan model bahasa.
- βSaat peneliti ingin kontak yang diprediksi antar residu dari sebuah urutan.
Link skill
https://github.com/aipoch/open-science/blob/main/resources/skills/fair-esm2/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βBuat embedding untuk urutan protein ini dengan ESM-2 agar saya bisa melatih pengklasifikasi di atasnya.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent memuat model ESM-2, mengubah urutan menjadi token, dan menjalankan model untuk mendapatkan representasi dari lapisan yang dipilih. Setelah itu agent merata-ratakan atau menilai hasilnya sesuai kebutuhan tugas.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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-esmgives youimport esmwithesm.pretrained.*(ESM-1/2). Biohub's github.com/Biohub/esm fork (MIT) gives youfrom esm.models.esmfold2 import ESMFold2InputBuilderβ see theesmfold2skill. Both share theesmnamespace 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
Pertanyaan umum
Apakah ini sama dengan ESMFold2?
Tidak. Skill ini menyebutkan fair-esm adalah paket Meta, sedangkan ESMFold2 adalah pustaka yang berbeda.
Berapa memori GPU yang dibutuhkan?
Skill ini mencantumkan 8 GB untuk model kecil dan 16 GB untuk model 650 juta parameter.
Lisensi apa yang berlaku?
Skill ini menyebutkan kode dan bobot ESM-2 berlisensi MIT.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 5.4k
- Peringkat
- #14860
- Lisensi
- Apache-2.0
- Diperbarui
- 2/11/2026
Komentar
- β¦
Skill lain dari repositori ini
alphafold2
5.4kMembantu agent Anda memprediksi struktur tiga dimensi protein dari urutannya, termasuk kompleks protein, dengan AlphaFold2 lewat runner ColabFold.
boltz
5.4kMembantu agent Anda memprediksi struktur kompleks protein, DNA, RNA, dan molekul kecil dengan model open-source Boltz-2, dengan estimasi afinitas pengikatan opsional.
borzoi
5.4kMembantu agent Anda memprediksi trek aktivitas seluruh genom, seperti ekspresi dan aksesibilitas, dari urutan DNA, dan membandingkan varian berdasarkan efek yang diprediksi.
chai1
5.4kMembantu agent Anda memprediksi struktur kompleks protein, asam nukleat, dan ligan dari satu file FASTA, dengan model Chai-1 berlisensi Apache.
Skill serupa
pytorch-patterns
280kMembantu agent Anda menggunakan PyTorch untuk model machine learning. Menerapkan praktik terbaik untuk pelatihan model yang efisien dan hasil yang dapat direproduksi.
evm-token-decimals
280kMembantu agent menghindari kesalahan angka desimal di berbagai jaringan blockchain. Memastikan nilai token akurat dalam transaksi dan perhitungan.
ito-inference
280kMemungkinkan agent Anda mengecek ketersediaan model AI untuk digunakan. Menghubungkan permintaan komputasi dengan layanan model yang siap.