IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Introduction to LLMs in Python

Visualizza il corso

Istruzioni dell'esercizio

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

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

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"])
Modifica ed esegui il codice