Views
No views yet
xlm-roberta-base|||)1from transformers import AutoTokenizer, AutoModelForMaskedLM, pipeline
2
3checkpoint_path = "/path/to/mlm-pos-model/checkpoint-100000"
4tokenizer = AutoTokenizer.from_pretrained(checkpoint_path)
5model = AutoModelForMaskedLM.from_pretrained(checkpoint_path)
6
7mlm_pipeline = pipeline("fill-mask", model=model, tokenizer=tokenizer)
8
9result = mlm_pipeline("नेपाल इज गूड प्लेस टू बी। ||| Nepal is good place <mask> be.", top_k=8)
10for pred in result:
11 print(f"{pred['token_str']} ({pred['score']:.4f})")