Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Introduction to LLMs in Python

Cursus bekijken

Oefeninstructies

  • Define the pipeline task for Spanish-to-English translation (es_to_en).
  • Translate the spanish_text using the model pipeline.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

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"])
Code bewerken en uitvoeren