赞
踩
使用transformer加载预训练模型
- from transformers import BertTokenizer, BertModel
- tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
- model = BertModel.from_pretrained("bert-base-uncased")
- text = "Replace me by any text you'd like."
- encoded_input = tokenizer(text, return_tensors='pt')
- output = model(**encoded_input)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。