Views
No views yet
Evolla-10B-hf directly using the standard Hugging Face API. Please ensure that your aa_seq and foldseek sequences have the exact same length.1import torch
2from transformers import EvollaProcessor, EvollaForProteinText2Text
3
4model_id = "westlake-repl/Evolla-10B-hf"
5
6# Load processor and model
7processor = EvollaProcessor.from_pretrained(model_id)
8model = EvollaForProteinText2Text.from_pretrained(
9 model_id,
10 device_map="auto",
11 torch_dtype=torch.bfloat16
12).eval()
13
14# 1. Prepare protein structural information
15# Note: aa_seq should have the same length as foldseek.
16# Use '#' for low-confidence foldseek tokens.
17protein_inputs = [
18 {
19 "aa_seq": "MATGGRRG...",
20 "foldseek": "###lqpfd..."
21 }
22]
23
24# 2. Prepare chat messages
25messages_list = [
26 [
27 {"role": "system", "content": "You are an AI expert that can answer any questions about protein."},
28 {"role": "user", "content": "What is the function of this protein?"}
29 ]
30]
31
32# 3. Process inputs
33inputs = processor(
34 proteins=protein_inputs,
35 messages_list=messages_list,
36 return_tensors="pt",
37 text_max_length=512,
38 protein_max_length=1024
39).to(model.device)
40
41# 4. Generate response
42with torch.no_grad():
43 generated_ids = model.generate(**inputs, max_new_tokens=256)
44
45generated_texts = processor.batch_decode(generated_ids, skip_special_tokens=True)
46print(generated_texts)transformers installed:pip install --upgrade transformers1@article{zhou2025decoding,
2 title={Decoding the molecular language of proteins with evolla},
3 author={Zhou, Xibin and Han, Chenchen and Zhang, Yingqi and Du, Huan and Tian, Jiayuan and Su, Jin and Liu, Renju and Zhuang, Kai and Jiang, Shiyu and Gitter, Anthony and others},
4 journal={bioRxiv},
5 pages={2025--01},
6 year={2025},
7 publisher={Cold Spring Harbor Laboratory}
8}