Skip to content

Commit c437492

Browse files
Example script for PushToHubCallback (huggingface#15375)
* Example script for PushToHubCallback * Expanding description slightly
1 parent 8f6454b commit c437492

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/transformers/keras_callbacks.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,21 @@ def on_epoch_end(self, epoch, logs=None):
241241

242242
class PushToHubCallback(Callback):
243243
"""
244-
Callback that will save and push the model to the Hub regularly.
244+
Callback that will save and push the model to the Hub regularly. By default, it pushes once per epoch, but this can
245+
be changed with the `save_strategy` argument. Pushed models can be accessed like any other model on the hub, such
246+
as with the `from_pretrained` method.
247+
248+
```py
249+
from transformers.keras_callbacks import PushToHubCallback
250+
251+
push_to_hub_callback = PushToHubCallback(
252+
output_dir="./model_save",
253+
tokenizer=tokenizer,
254+
hub_model_id="gpt5-7xlarge",
255+
)
256+
257+
model.fit(train_dataset, callbacks=[push_to_hub_callback])
258+
```
245259
246260
Args:
247261
output_dir (`str`):

0 commit comments

Comments
 (0)