Skip to content

Commit

Permalink
[AIR][Docs] Set logging_strategy="epoch" for HF (ray-project#27917)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan van der Kleij <[email protected]>
  • Loading branch information
Yard1 authored and Stefan van der Kleij committed Aug 18, 2022
1 parent 53197ac commit 952f401
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doc/source/ray-air/doc_code/hf_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def trainer_init_per_worker(train_dataset, eval_dataset, **config):
args = transformers.TrainingArguments(
output_dir=f"{model_checkpoint}-wikitext2",
evaluation_strategy="epoch",
save_strategy="epoch",
logging_strategy="epoch",
learning_rate=2e-5,
weight_decay=0.01,
no_cuda=True, # Set to False for GPU training
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"id": "sQbdfyWQhYbO"
},
"source": [
"Uncomment and run the following line in order to install all the necessary dependencies:"
"Uncomment and run the following line in order to install all the necessary dependencies (this notebook is being tested with `transformers==4.19.1`):"
]
},
{
Expand Down Expand Up @@ -747,6 +747,7 @@
" name,\n",
" evaluation_strategy=\"epoch\",\n",
" save_strategy=\"epoch\",\n",
" logging_strategy=\"epoch\",\n",
" learning_rate=2e-5,\n",
" per_device_train_batch_size=batch_size,\n",
" per_device_eval_batch_size=batch_size,\n",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Based on
# huggingface/notebooks/examples/language_modeling_from_scratch.ipynb

# This example is tested with transformers==4.19.1

import argparse
import tempfile

Expand Down Expand Up @@ -88,11 +90,12 @@ def train_function(train_dataset, eval_dataset=None, **config):
training_args = TrainingArguments(
training_dir,
evaluation_strategy="epoch",
save_strategy="epoch",
logging_strategy="epoch",
num_train_epochs=num_epochs,
learning_rate=2e-5,
weight_decay=0.01,
disable_tqdm=True,
save_strategy="epoch",
# Required to avoid an exception
no_cuda=not torch.cuda.is_available(),
)
Expand Down
2 changes: 2 additions & 0 deletions python/ray/train/huggingface/huggingface_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ def trainer_init_per_worker(train_dataset, eval_dataset, **config):
args = transformers.TrainingArguments(
output_dir=f"{model_checkpoint}-wikitext2",
evaluation_strategy="epoch",
save_strategy="epoch",
logging_strategy="epoch",
learning_rate=2e-5,
weight_decay=0.01,
)
Expand Down

0 comments on commit 952f401

Please sign in to comment.