fair-esm2
Skill này làm gì
Skill này dạy agent cách dùng mô hình ngôn ngữ protein ESM-2 của Meta. Skill tạo embedding theo từng residue và theo từng trình tự, chấm điểm đột biến bằng dự đoán có che, và dự đoán tiếp xúc giữa các residue.
Khi nào nên dùng
- ✓Khi nhà nghiên cứu cần embedding protein để đưa vào một mô hình học máy.
- ✓Khi nhà khoa học muốn chấm điểm tác động của một đột biến bằng mô hình ngôn ngữ.
- ✓Khi nhà nghiên cứu muốn các tiếp xúc dự đoán giữa các residue từ một trình tự.
Liên kết skill
https://github.com/aipoch/open-science/blob/main/resources/skills/fair-esm2/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Tạo embedding cho các trình tự protein này bằng ESM-2 để tôi huấn luyện một bộ phân loại trên chúng.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent nạp mô hình ESM-2, chuyển trình tự thành token, rồi chạy mô hình để lấy biểu diễn từ một lớp đã chọn. Sau đó agent lấy trung bình hoặc chấm điểm kết quả theo yêu cầu của tác vụ.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Đây có phải là cùng một thứ với ESMFold2 không?
Không. Skill nói fair-esm là gói của Meta, còn ESMFold2 là một thư viện khác.
Cần bao nhiêu bộ nhớ GPU?
Skill liệt kê 8 GB cho mô hình nhỏ và 16 GB cho mô hình 650 triệu tham số.
Giấy phép nào áp dụng?
Skill nói mã và trọng số ESM-2 theo giấy phép MIT.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 5.4k
- Vị trí xếp hạng
- #14860
- Giấy phép
- Apache-2.0
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
alphafold2
5.4kGiúp agent của bạn dự đoán cấu trúc 3D của protein từ trình tự của nó, kể cả phức hợp protein, bằng AlphaFold2 qua công cụ chạy ColabFold.
boltz
5.4kGiúp agent của bạn dự đoán cấu trúc của phức hợp protein, DNA, RNA và phân tử nhỏ bằng mô hình mã nguồn mở Boltz-2, với ước tính ái lực liên kết tùy chọn.
borzoi
5.4kGiúp agent của bạn dự đoán các track hoạt động trên toàn bộ genome, như biểu hiện gen và khả năng tiếp cận, từ trình tự DNA, và so sánh các biến thể theo tác động dự đoán.
chai1
5.4kGiúp agent của bạn dự đoán cấu trúc của phức hợp protein, axit nucleic và ligand từ một file FASTA, bằng mô hình Chai-1 được cấp phép Apache.
Skill tương tự
pytorch-patterns
280kGiúp agent của bạn dùng PyTorch cho các mô hình học máy. Áp dụng thực hành tốt nhất để huấn luyện mô hình hiệu quả và đảm bảo kết quả có thể lặp lại.
evm-token-decimals
280kGiúp agent tránh lỗi về số thập phân khi làm việc với các mạng blockchain khác nhau. Đảm bảo giá trị token chính xác trong giao dịch và phép tính.
ito-inference
280kGiúp agent kiểm tra xem các mô hình AI đã sẵn sàng để dùng chưa. Kết nối yêu cầu tài nguyên tính toán với dịch vụ mô hình đã sẵn sàng.