A callback for logging training events from Hugging Face's Transformers to Logfire 🤗
Project description
Logfire-callback, observability for Hugging Face's Transformers training loop 🤗
A callback for logging training events from Hugging Face's Transformers to Logfire 🤗
Overview
The logfire-callback package provides a seamless integration between Hugging Face's Transformers library and Logfire logging service. It allows you to track and monitor your model training progress, metrics, and events in real-time through Logfire's platform.
Installation
Install the package using pip:
pip install logfire-callback
Usage
First, ensure you have a Logfire API token and set it as an environment variable:
export LOGFIRE_TOKEN=your_logfire_token
Then use the callback in your training code:
from transformers import Trainer, TrainingArguments
from logfire_callback import LogfireCallback
# Initialize your model, dataset, etc.
training_args = TrainingArguments(
output_dir="./results",
num_train_epochs=3,
# ... other training arguments
)
trainer = Trainer(
model=model,
args=training_args,
train_dataset=train_dataset,
callbacks=[LogfireCallback()] # Add the Logfire callback here
)
trainer.train()
The callback will automatically log:
- Training start with configuration parameters
- Periodic training metrics (loss, learning rate, etc.)
- Evaluation metrics during validation
- Training completion
Development
Prerequisites
- Python 3.11 or higher
- uv for package management
Setting up the development environment
- Clone the repository:
git clone https://github.com/louisbrulenaudet/logfire-callback
cd logfire-callback
- Initialize the development environment:
make init
Available Make Commands
make test- Run the test suitemake check- Run code quality checksmake format- Format source codemake build- Build the projectmake upgrade- Update project dependenciesmake pre-commit- Run pre-commit checks
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Links
Requirements
- Python >= 3.11
- transformers >= 4.49.0
- logfire >= 3.9.0
Citing this project
If you use this code in your research, please use the following BibTeX entry.
@misc{louisbrulenaudet2025,
author = {Louis Brulé Naudet},
title = {Logfire callback, observability for Hugging Face's transformers training loop},
howpublished = {\url{https://huggingface.co/spaces/louisbrulenaudet/logfire-callback}},
year = {2025}
}
Feedback
If you have any feedback, please reach out at louisbrulenaudet@icloud.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file logfire_callback-1.0.0.tar.gz.
File metadata
- Download URL: logfire_callback-1.0.0.tar.gz
- Upload date:
- Size: 555.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31bfdc2c62c5f6ccf5f83732d7b00bd101957690ea95c1e744a46deb102711a2
|
|
| MD5 |
8b94d2a22d9a5e353f23992c1ad5e591
|
|
| BLAKE2b-256 |
6fb84b97040ebe3b80cee786acf99533e112387bbed36ba654c640dabb692a00
|
File details
Details for the file logfire_callback-1.0.0-py3-none-any.whl.
File metadata
- Download URL: logfire_callback-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d3bb02646ed7f7fcce476dc5f06b84abaff60cf12b1a1f21d04108e116036eb
|
|
| MD5 |
adbd05356fa781b5935b16af2b0a0bdf
|
|
| BLAKE2b-256 |
b432d13193c31edfeda2c43eecef764af94911b3b0eb1731163cea950d92fbec
|