| 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}") |