birgermoell
commited on
Commit
•
23c8364
1
Parent(s):
1a893e3
Added eval code
Browse files- evaluate.py +11 -3
evaluate.py
CHANGED
@@ -1,5 +1,13 @@
|
|
1 |
from transformers import AutoTokenizer, AutoModel
|
2 |
-
|
3 |
-
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from transformers import AutoTokenizer, AutoModel
|
2 |
+
from transformers import RobertaTokenizer, RobertaForMaskedLM, pipeline
|
3 |
+
import torch
|
4 |
|
5 |
+
def pt_evaluate():
|
6 |
+
tokenizer = RobertaTokenizer.from_pretrained('birgermoell/roberta-swedish-scandi')
|
7 |
+
#model = RobertaForMaskedLM.from_pretrained('birgermoell/roberta-swedish-scandi')
|
8 |
+
model = RobertaForMaskedLM.from_pretrained("birgermoell/roberta-swedish-scandi", from_flax=True)
|
9 |
+
my_unmasker_pipeline = pipeline('fill-mask', model=model, tokenizer=tokenizer)
|
10 |
+
output = my_unmasker_pipeline("Huvudstaden i Sverige är <mask>.")
|
11 |
+
print(output)
|
12 |
+
|
13 |
+
pt_evaluate()
|