开始使用免费开始使用

Set up the Trainer

Your model will replace complex phrases with simpler, more accessible paraphrases to improve the readability of translations. For example, it can simplify the original phrase "The inclement weather conditions precipitated the postponement of the outdoor event" with "The bad weather caused the outdoor event to be delayed." Build the Trainer to prepare training your language translation service! The exercise will take some time to run with the call to trainer.train().

Some data has been pre-loaded:

  • model is a Transformer model
  • dataset contains the MRPC dataset of sentence paraphrases
  • compute_metrics function returns accuracy and F1 score
  • You've defined training_args in a prior exercise

本练习是课程的一部分

Efficient AI Model Training with PyTorch

查看课程

练习说明

  • Pass in the model to the Trainer() class.
  • Input the training arguments in the Trainer() class.
  • Pass in a function to compute metrics to the Trainer() class.
  • Print the device that the trainer chooses.

交互式实操练习

通过完成这段示例代码来试试这个练习。

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.____)
编辑并运行代码