This notebook regroups the code sample of the video below, which is a part of the Hugging Face course.
#@title
from IPython.display import HTML
HTML('<iframe width="560" height="315" src="https://www.youtube.com/embed/0Oxphw4Q9fo?rel=0&controls=0&showinfo=0" frameborder="0" allowfullscreen></iframe>')
Install the Transformers and Datasets libraries to run this notebook.
! pip install datasets transformers[sentencepiece]
from transformers import pipeline
model_checkpoint = "distilbert-base-uncased"
fill_masker = pipeline("fill-mask", model=model_checkpoint)
fill_masker("This is a great [MASK].")
model_checkpoint = "huggingface-course/distilbert-base-uncased-finetuned-imdb"
fill_masker = pipeline("fill-mask", model=model_checkpoint)
fill_masker("This is a great [MASK].")
model_checkpoint = "Helsinki-NLP/opus-mt-en-fr"
translator = pipeline("translation", model=model_checkpoint)
translator("This plugin automatically translates emails.")
model_checkpoint = "huggingface-course/marian-finetuned-kde4-en-to-fr")
translator = pipeline("translation", model=model_checkpoint)
translator("This plugin automatically translates emails.")