Views
No views yet
facebook/esm2_t6_8M_UR50D) with Low-Rank Adaptation (LoRA) for protein function prediction. The encoder is kept frozen except for the injected LoRA matrices; a two-layer MLP classification head maps mean-pooled residue embeddings to per-GO-term sigmoid scores.facebook/esm2_t6_8M_UR50D1import torch
2import sys
3sys.path.insert(0, "src")
4
5from models.esm2_classifier import ESM2Classifier
6from transformers import AutoTokenizer
7
8model = ESM2Classifier.from_pretrained("AfzalHosaan-2005021/cafa6-esm2-lora-bpo")
9model.eval()
10
11tokenizer = AutoTokenizer.from_pretrained("facebook/esm2_t6_8M_UR50D")
12
13sequence = "MKTAYIAKQRQISFVKSHFSRQLEERLGLIEVQAPILSRVGDGTQDNLSGAEKAVQVKVKALPDAQFEVVHSLAKWKRQTLGQHDFSAGEGLYTHMKALRPDEDRLSPLHSVYVDQWDWERVMGDGERQFSTLKSTVEAIWAGIKATEAAVSEEFGLAPFLPDQIHFVHSQELLSRYPDLDAKGRERAIAKDLGAVFLVGIGGKLSDGHRHDVRAPDYDDWSTPSELGHAGLNGDILVWNPVLEDAFELSSMGIRVDADTLKHQLALTGDEDRLELEWHQALLRGEMPQTIGGGIGQSRLTMLLLQLPHIGQVQAGVWPAAVRESVPSLL"
14
15inputs = tokenizer(sequence, return_tensors="pt")
16with torch.no_grad():
17 out = model(inputs["input_ids"], inputs["attention_mask"])
18 scores = torch.sigmoid(out["logits"])[0]
19
20go_terms = model.config.go_terms
21threshold = 0.3
22predicted = [(go_terms[i], scores[i].item()) for i in range(len(go_terms)) if scores[i] > threshold]
23predicted.sort(key=lambda x: -x[1])
24for term, score in predicted[:10]:
25 print(f"{term} {score:.3f}")