始める無料で始める

テキストを翻訳する

英語→スペイン語の翻訳例を見ました。今度はスペイン語→英語の翻訳に挑戦してみましょう。

pipeline は読み込まれています。

この演習はコースの一部です

Pythonで学ぶ LLM 入門

コースを見る

演習の手順

  • スペイン語→英語翻訳(es_to_en)のパイプラインタスクを定義します。
  • モデルのパイプラインを使って、spanish_text を翻訳します。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

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"])
コードを編集して実行