Appearance
Hugging Face Transformers
Log Transformers Trainer metrics to a Rundial run.
Start Rundial and create an API key with the Quickstart. Keep the stack running and set RUNDIAL_API_KEY.
Install the packages:
bash
pip install rundial transformers torch accelerateAdd RundialCallback to a Trainer. This example uses a small randomly initialized model and synthetic data:
python
import torch
from transformers import BertConfig, BertForSequenceClassification, Trainer, TrainingArguments
from rundial.integrations import RundialCallback
model = BertForSequenceClassification(BertConfig(
vocab_size=100, hidden_size=32, num_hidden_layers=1,
num_attention_heads=2, intermediate_size=64,
))
data = [{"input_ids": torch.randint(0, 100, (16,)), "labels": torch.tensor(i % 2)}
for i in range(32)]
trainer = Trainer(
model=model,
args=TrainingArguments(output_dir="outputs", max_steps=10, logging_steps=1, report_to="none"),
train_dataset=data,
callbacks=[RundialCallback(workspace="default-workspace", project="default-project", name="transformers")],
)
trainer.train()Open the run's Metrics tab to view Trainer metrics. Checkpoints that the Trainer saves are uploaded to the run's Artifacts.