BALM
1.0.0
该存储库包含推理代码,用于使用生物启发的抗体语言模型准确预测抗体功能和结构
conda env create -f environment.yml
conda activate BALM
可以从Google Drive链接下载脂肪的预训练。
from modeling_balm import BALMForMaskedLM
from ba_position_embedding import get_anarci_pos
from transformers import EsmTokenizer
import torch
# an antibody sequence example
input_seq = "AVQLQESGGGLVQAGGSLRLSCTVSARTSSSHDMGWFRQAPGKEREFVAAISWSGGTTNYVDSVKGRFDISKDNAKNAVYLQMNSLKPEDTAVYYCAAKWRPLRYSDNPSNSDYNYWGQGTQVTVSS"
tokenizer = EsmTokenizer.from_pretrained("./tokenizer/vocab.txt", do_lower_case=False, model_max_length=168)
tokenizer_input = tokenizer(input_seq, truncation=True, padding="max_length", return_tensors="pt")
# generate position_ids
tokenizer_input.update(get_anarci_pos(input_seq))
with torch.no_grad():
# please download from Google drive link before
model = BALMForMaskedLM.from_pretrained("./pretrained-BALM/")
# on CPU device
outputs = model(**tokenizer_input, return_dict=True, output_hidden_states=True, output_attentions=True)
# final hidden layer representation [batch_sz * max_length * hidden_size]
final_hidden_layer = outputs.hidden_states[-1]
# final hidden layer sequence representation [batch_sz * hidden_size]
final_seq_embedding = final_hidden_layer[:, 0, :]
# final layer attention map [batch_sz * num_head * max_length * max_length]
final_attention_map = outputs.attentions[-1]
Balmfold基于BALM,以预测具有一级序列的抗体三级结构。在Balmfold Server可以免费获得在线服务器。尝试一下。 :)
如果您发现我们的模型对您有用,请引用为:
@article{jing2024accurate,
title={Accurate prediction of antibody function and structure using bio-inspired antibody language model},
author={Jing, Hongtai and Gao, Zhengtao and Xu, Sheng and Shen, Tao and Peng, Zhangzhi and He, Shwai and You, Tao and Ye, Shuang and Lin, Wei and Sun, Siqi},
journal={Briefings in Bioinformatics},
volume={25},
number={4},
pages={bbae245},
year={2024},
publisher={Oxford University Press}
}
香脂的体系结构和预训练过程建立在ESM上,并拥抱面部建模框架。我们非常感谢ESM的工作和拥抱面孔团队。
此源代码是根据此源树的根目录中的LICENSE文件中发现的MIT许可证的许可。