MulaiMulai sekarang secara 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.

Latihan ini adalah bagian dari kursus

Introduction to LLMs in Python

Lihat Kursus

Petunjuk latihan

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

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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"])
Edit dan Jalankan Kode