Commit ·
30fff05
1
Parent(s): bcabd38
Add script to test mr MLM predictions
Browse files- test_marathi_model.py +15 -0
test_marathi_model.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
import pprint
|
| 3 |
+
|
| 4 |
+
from transformers import pipeline, AutoTokenizer, RobertaForMaskedLM
|
| 5 |
+
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained("/home/nipunsadvilkar/roberta-base-mr/checkpoint_45000/")
|
| 7 |
+
model = RobertaForMaskedLM.from_pretrained("/home/nipunsadvilkar/roberta-base-mr/checkpoint_45000/", from_flax=True)
|
| 8 |
+
|
| 9 |
+
nlp = pipeline("fill-mask", model=model, tokenizer=tokenizer)
|
| 10 |
+
# masked_input = "माझा नाव <mask> आहे"
|
| 11 |
+
# masked_input = "वाढदिवसाच्या <mask> शुभेच्छा!"
|
| 12 |
+
masked_input = sys.argv[1]
|
| 13 |
+
|
| 14 |
+
print(masked_input)
|
| 15 |
+
pprint.pprint(nlp(masked_input))
|