training_args = Seq2SeqTrainingArguments( | |
output_dir="my_awesome_opus_books_model", | |
evaluation_strategy="epoch", | |
learning_rate=2e-5, | |
per_device_train_batch_size=16, | |
per_device_eval_batch_size=16, | |
weight_decay=0.01, | |
save_total_limit=3, | |
num_train_epochs=2, | |
predict_with_generate=True, | |
fp16=True, | |
push_to_hub=True, | |
) | |
trainer = Seq2SeqTrainer( | |
model=model, | |
args=training_args, | |
train_dataset=tokenized_books["train"], | |
eval_dataset=tokenized_books["test"], | |
tokenizer=tokenizer, | |
data_collator=data_collator, | |
compute_metrics=compute_metrics, | |
) | |
trainer.train() | |
Once training is completed, share your model to the Hub with the [~transformers.Trainer.push_to_hub] method so everyone can use your model: | |
trainer.push_to_hub() | |
If you aren't familiar with finetuning a model with Keras, take a look at the basic tutorial here! |