birgermoell
commited on
Commit
·
6f16f5b
1
Parent(s):
f371a05
Eval script
Browse files- evaluate.py +14 -0
evaluate.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoTokenizer, AutoModelForMaskedLM
|
2 |
+
from transformers import RobertaTokenizer, RobertaForMaskedLM, pipeline
|
3 |
+
import torch
|
4 |
+
|
5 |
+
def pt_evaluate():
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained("flax-community/nordic-roberta-wiki")
|
7 |
+
|
8 |
+
model = AutoModelForMaskedLM.from_pretrained("flax-community/nordic-roberta-wiki")
|
9 |
+
|
10 |
+
my_unmasker_pipeline = pipeline('fill-mask', model=model, tokenizer=tokenizer)
|
11 |
+
output = my_unmasker_pipeline("Meningen med livet är <mask> i Sverige.")
|
12 |
+
print(output)
|
13 |
+
|
14 |
+
pt_evaluate()
|