Downloads · 30 days
11
2% of all-time downloads
gbouras13/modernprost-base-deprecated
modernprost-base-deprecated is a machine learning model from gbouras13. 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 mit.
modernprost-base is a lightweight 48M parameter specialist protein language model (pLM) which predicts a protein's Foldseek 3Di encoding from its amino acid sequence. It is designed to be a lightweight replacement for…
Downloads · 30 days
11
2% of all-time downloads
All-time downloads
685
Public
Parameters
48.2M
386 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors193 MB · 100%
From the Hugging Face model README
modernprost-base is a lightweight 48M parameter specialist protein language model (pLM) which predicts a protein's Foldseek 3Di encoding from its amino acid sequence. It is designed to be a lightweight replacement for ProstT5 providing similar accurate in a more efficient and far smaller mode.
modernprost-base uses the ModernBERT architecture. It was trained using over 19M high quality protein structure predictions taken from AlphaFold Database, Big Fantastic Virus Database (BFVD), Phold's database and various metagenomic ColabFold database proteins.
Feature extraction:
import torch
from transformers import T5EncoderModel, T5Tokenizer, AutoModel, AutoTokenizer
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
# Load the tokenizer
tokenizer = AutoTokenizer.from_pretrained('gbouras13/modernprost-base',trust_remote_code=True)
# Load the model
model = AutoModel.from_pretrained('gbouras13/modernprost-base',trust_remote_code=True).to(device)
# prepare your protein sequences/structures as a list
sequence_examples = ["MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAED", "LQVGQVELGGGPGAGSLQPLALEGSLQKRGIVEQCCTSICSLYQLENYCN"]
# replace all rare/ambiguous amino acids by X
for seq in sequence_examples:
seq = seq.replace("U", "X").replace("Z", "X").replace("O", "X")
# tokenize seqs
tokenizer_kwargs = dict(
text=sequence_examples,
padding="longest",
truncation=False,
return_tensors="pt",
add_special_tokens=False
)
token_encoding = tokenizer(**tokenizer_kwargs).to(device)
attn_mask = token_encoding.attention_mask # [B, L]
# generate embeddings
with torch.no_grad():
outputs = model(
token_encoding.input_ids,
attention_mask=token_encoding.attention_mask,
)
# if you want the embeddings for the first sequence length 60
emb_0 = outputs.hidden_states[-1][0,0:59]
# if you want the embeddings for the second sequence length 50
emb_1 = outputs.hidden_states[-1][0,0:49]
# 3Di
logits = outputs.logits
tokenized_preds = torch.argmax(logits, dim=-1) # [B, L]
ss_mapping = {
0: "A", 1: "C", 2: "D", 3: "E", 4: "F",
5: "G", 6: "H", 7: "I", 8: "K", 9: "L",
10: "M", 11: "N", 12: "P", 13: "Q", 14: "R",
15: "S", 16: "T", 17: "V", 18: "W", 19: "Y", 20: "X"
}
for preds, mask in zip(tokenized_preds, attn_mask):
# keep only non-padding positions
valid_preds = preds[mask.bool()]
threedi = "".join(ss_mapping[int(tok.item())] for tok in valid_preds)
print(threedi)
Pre-training data (3Di+AA sequences for over 19M proteins)
Pre-training consists of predicting the Foldseek 3Di corresponding to the input amino acid. You can find all training scripts at https://github.com/gbouras13/distill_prostt5.
Predicting 3Di strings from AA input is extremely fast. On an AMD MI250x GPU, we were able to predict 3Di for 1 million proteins from Logan in just over 8 minutes. Pre-sorting proteins by length and batching is recommended for the best inference performance. Please see https://github.com/gbouras13/distill_prostt5 for a more feature-rich implementation.