Trainer のセットアップ
このモデルは、翻訳の読みやすさを向上させるために、複雑なフレーズをよりシンプルで分かりやすい言い換えに置き換えます。たとえば、「The inclement weather conditions precipitated the postponement of the outdoor event」という表現を「The bad weather caused the outdoor event to be delayed.」に簡略化できます。言語翻訳サービスの学習を準備するために Trainer を構築しましょう。trainer.train() の呼び出しを含むため、実行に少し時間がかかります。
以下のデータは事前に読み込まれています。
model:Transformer モデルdataset:文の言い換えデータセットである MRPC データセットcompute_metrics:正解率と F1 スコアを返す関数training_args:前の演習で定義済み
この演習はコースの一部です
PyTorch による効率的な AI モデルトレーニング
演習の手順
modelをTrainer()クラスに渡してください。- 学習の引数を
Trainer()クラスに渡してください。 - メトリクスを計算する関数を
Trainer()クラスに渡してください。 trainerが選択したデバイスを出力してください。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
trainer = Trainer(
# Pass in the model
model=____,
# Input the training arguments
args=____,
train_dataset=dataset["train"],
eval_dataset=dataset["validation"],
# Pass in a function to compute metrics
compute_metrics=____,
)
trainer.train()
# Print the device that the trainer chooses
print(trainer.args.____)