python 无法从Google colab上的“transformers”导入名称“ESMForMaskedLM”

xpszyzbs  于 2023-03-11  发布在  Python
关注(0)|答案(1)|浏览(383)

我正在用序列的fasta文件微调ESM facebook变压器。但是,我在运行cell时得到ImportError: cannot import name 'ESMForMaskedLM' from 'transformers',我一直在遵循:the hugging face model,但我还没有设法使导入工作,我正在使用谷歌Colab.帮助是非常感谢:
守则:

!pip install transformers
from transformers import ESMForMaskedLM, ESMTokenizer, pipeline
tokenizer = ESMTokenizer.from_pretrained("facebook/esm-1b", do_lower_case=False)
model = ESMForMaskedLM.from_pretrained("facebook/esm-1b")
unmasker = pipeline('fill-mask', model=model, tokenizer=tokenizer)
unmasker('QERLKSIVRILE<mask>SLGYNIVAT')
ccrfmcuu

ccrfmcuu1#

Esm现在被添加到拥抱脸,使用这个:

from transformers import AutoTokenizer, EsmForMaskedLM, pipeline

tokenizer = AutoTokenizer.from_pretrained("facebook/esm2_t6_8M_UR50D")
model = EsmForMaskedLM.from_pretrained("facebook/esm2_t6_8M_UR50D")

unmasker = pipeline('fill-mask', model=model, tokenizer=tokenizer)
g = unmasker('MQIFVKTLTGKTITLEVEPS<mask>TIENVKAKIQDKEGIPPDQQRLIFAGKQLEDGRTLSDYNIQKESTLHLVLRLRGG')

相关问题