Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIR][Docs] Set logging_strategy="epoch" for HF (#27917) #27955

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -207,6 +207,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