Views
No views yet
import torch
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("RaphaelMourad/Mistral-Peptide-v1-422M", trust_remote_code=True)
model = AutoModel.from_pretrained("RaphaelMourad/Mistral-Peptide-v1-422M", trust_remote_code=True)peptide = "MALWMRLLPLLALLALWG"
inputs = tokenizer(peptide, return_tensors = 'pt')["input_ids"]
hidden_states = model(inputs)[0] # [1, sequence_length, 256]
# embedding with max pooling
embedding_max = torch.max(hidden_states[0], dim=0)[0]
print(embedding_max.shape) # expect to be 256