1. Learn
  2. /
  3. Courses
  4. /
  5. Deep Learning for Text with PyTorch

Connected

Exercise

Language translation with pretrained PyTorch model

Your team at PyBooks is working on an AI project that involves translation from one language to another. They want to leverage pre-trained models for this task, which can save a lot of training time and resources. The task for this exercise is to set up a translation model from HuggingFace's Transformers library, specifically the T5 (Text-To-Text Transfer Transformer) model, and use it to translate an English phrase to French.

T5Tokenizer, T5ForConditionalGeneration have been loaded for you.

Instructions

100 XP
  • Initialize the tokenizer and model from the pretrained "t5-small" model.
  • Encode the input prompt using the tokenizer, making sure to return PyTorch tensors.
  • Translate the input prompt using model and generate the translated output.