training_args = TrainingArguments(
     output_dir="my_awesome_eli5_clm-model",
     evaluation_strategy="epoch",
     learning_rate=2e-5,
     weight_decay=0.01,
     push_to_hub=True,
 )
trainer = Trainer(
     model=model,
     args=training_args,
     train_dataset=lm_dataset["train"],
     eval_dataset=lm_dataset["test"],
     data_collator=data_collator,
 )
trainer.train()

Once training is completed, use the [~transformers.Trainer.evaluate] method to evaluate your model and get its perplexity: