Downloads · 30 days
14
45% of all-time downloads
jinyuan22/ProGen2-xlarge
ProGen2-xlarge is a machine learning model from jinyuan22. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as bsd-3-clause.
HF mirror for ProGen2-small for Protein Engineering
Downloads · 30 days
14
45% of all-time downloads
All-time downloads
31
Public
Repo size
25.8 GB
Likes
0
Public
Click a slice to open those files.
.bin12.9 GB · 100%
From the Hugging Face model README
HF mirror for ProGen2-small for Protein Engineering
Official GitHub of ProGen2 by Nijkamp et al..
import torch
from faesm.progen2 import ProGenForCausalLM
from transformers import AutoTokenizer
device = 'cuda' if torch.cuda.is_available() else 'cpu'
model = ProGenForCausalLM.from_pretrained("jinyuan22/ProGen2-xlarge").to(torch.float16).to(device).eval()
tokenizer = AutoTokenizer.from_pretrained("jinyuan22/ProGen2-xlarge")
# sequence = "1" + "ACDEFGHIKLMNPQRSTVWY" * 50 + "2" # 1002 token
sequence = "2GFLPFRGADEGLAAREAATLAARGTAARAYREDSWAVPVPRGLLGDLTARVAALGAASPPPADPLAVTLDLHHVTAEVALTTVLDAATLVHGQTRVLSAEDAAEAATAAAAATEAYLERLQDFVLFMSASVRVWRRGNAAGATGPEWDQWYTVADRDALGSAPTHLAVLGRQADALCHFVLDRVAWGTCGTPLWSGDEDLGNVVATFAGYADRLATAPRDLIM1"
inputs = tokenizer(sequence, return_tensors="pt").to(device)
with torch.no_grad():
logits = model(inputs.input_ids, labels=inputs.input_ids).logits
logits = logits[0][:-1, ...]
target = inputs.input_ids[0, 1:]
# remove unused logits
first_token, last_token = 5, 29
logits = logits[:, first_token:(last_token+1)]
target = target - first_token
ce_eval = torch.nn.functional.cross_entropy(input=logits.view(-1, logits.size(-1)), target=target.view(-1), reduction="mean").item()
print(ce_eval)
assert abs(ce_eval - 1.0) < 0.1