Edit on GitHub
Hugging Face Transformers
DVCLive allows you to add experiment tracking capabilities to your Hugging Face Transformers projects.
If you are using Hugging Face Accelerate, check the DVCLive - Hugging Face Accelerate page.
Usage
If you have dvclive
installed, the DVCLiveCallback
will be used for
tracking experiments and logging metrics, parameters, and plots automatically
for transformers>=4.36.0
.
To log the model, set HF_DVCLIVE_LOG_MODEL=true
in your environment.
os.environ["HF_DVCLIVE_LOG_MODEL"] = "true"
from transformers import TrainingArguments, Trainer
# optional, `report_to` defaults to "all"
args = TrainingArguments(..., report_to="dvclive")
trainer = Trainer(..., args=args)
To customize tracking, include the DVCLiveCallback
in the callbacks list
passed to your
Trainer
,
along with a Live
instance including additonal arguments:
from dvclive import Live
from transformers.integrations import DVCLiveCallback
...
trainer = Trainer(...)
trainer.add_callback(DVCLiveCallback(Live(dir="custom_dir")))
trainer.train()
For transformers<4.36.0
, import the callback from dvclive
instead of
transformers
:
from dvclive.huggingface import DVCLiveCallback
...
trainer = Trainer(...)
trainer.add_callback(DVCLiveCallback())
trainer.train()