Translating text
You've seen an example of English-to-Spanish translation. Now it's your turn to try it the other way around with Spanish-to-English translation.
pipeline
has been loaded for you.
This exercise is part of the course
Introduction to LLMs in Python
Exercise instructions
- Define the pipeline task for Spanish-to-English translation (
es_to_en
). - Translate the
spanish_text
using the model pipeline.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
spanish_text = "Este curso sobre LLMs se está poniendo muy interesante"
# Define the pipeline
translator = pipeline(task=____, model="Helsinki-NLP/opus-mt-es-en")
# Translate the Spanish text
translations = ____(____, clean_up_tokenization_spaces=True)
print(translations[0]["translation_text"])