forked from axolotl-ai-cloud/axolotl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
12 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
"""Vessl module for trainer callbacks""" | ||
import logging | ||
from typing import Dict, List | ||
from typing import Dict | ||
|
||
import vessl | ||
from transformers import TrainerCallback, TrainerControl, TrainerState | ||
from transformers.training_args import TrainingArguments | ||
|
||
LOG = logging.getLogger("axolotl.callbacks") | ||
|
||
|
||
class VesslLogMetricsCallback(TrainerCallback): | ||
"""Callback to send training metrics to VESSL AI""" | ||
|
||
def __init__(self, credential_path: str) -> None: | ||
vessl.configure(credentials_file=credential_path) | ||
|
||
def on_log(self, args: TrainingArguments, state: TrainerState, control: TrainerControl, logs: Dict[str, float] = None, **kwargs): | ||
def on_log( | ||
self, | ||
args: TrainingArguments, # pylint: disable=unused-argument | ||
state: TrainerState, | ||
control: TrainerControl, # pylint: disable=unused-argument | ||
logs: Dict[str, float], | ||
**kwargs # pylint: disable=unused-argument | ||
): | ||
if state.is_world_process_zero: | ||
vessl.log(logs, state.global_step) | ||
|