risha_testing / MASK.py
rishach's picture
Upload full fitnetuned model + tokenizer +generation config
9e5fc05 verified
Raw
History Blame Contribute Delete
872 Bytes
from transformers import pipeline
pipe = pipeline("fill-mask") # or pipeline("fill-mask", model="distilbert/distilroberta-base")
# ────────────────────────────────
# Let the code show you the correct mask token
# ────────────────────────────────
mask_token = pipe.tokenizer.mask_token
print(f"This model expects mask token β†’ {mask_token!r}")
# Usually prints: This model expects mask token β†’ '<mask>'
# Now build sentence dynamically
sentence = f"The most famous dish in Punjab is {mask_token} roti."
print("\nSentence being sent:", sentence)
results = pipe(sentence, top_k=10)
print("\nTop 10 predictions:")
for i, pred in enumerate(results, 1):
print(f"{i:2d}. {pred['token_str']:18} {pred['score']:.4f}")