Tranformer models in Hugging Face
Everything you saw in this chapter can be condensed in to a ready-to-use Hugging Face transformer model.
With Hugging Face, you can implement machine translation in three lines of code!
Open Multi_Head_Attention_Sub_Layer.ipynb
in Google Colaboratory. Save the notebook in your Google Drive (make sure you have a Gmail account). Go to the two last cells.
We first ensure that Hugging Face transformers are installed:
!pip -q install transformers
The first cell imports the Hugging Face pipeline that contains several transformer usages:
#@title Retrieve pipeline of modules and choose English to French translation
from transformers import pipeline
We then implement the Hugging Face pipeline, which contains ready-to-use functions. In our case, to illustrate the Transformer model of this chapter, we activate the translator model and enter a sentence to translate from English to French:
translator = pipeline("translation_en_to_fr...