from transformers import AutoTokenizer, AutoModelForMaskedLM | |
from transformers import RobertaTokenizer, RobertaForMaskedLM, pipeline | |
import torch | |
def pt_evaluate(): | |
tokenizer = AutoTokenizer.from_pretrained("flax-community/nordic-roberta-wiki") | |
model = AutoModelForMaskedLM.from_pretrained("flax-community/nordic-roberta-wiki") | |
my_unmasker_pipeline = pipeline('fill-mask', model=model, tokenizer=tokenizer) | |
output = my_unmasker_pipeline("Det är roligt att <mask>") | |
print(output) | |
pt_evaluate() |