File size: 517 Bytes
8f10943
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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()