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.
Release files for logfire-callback 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| logfire_callback-1.0.0.tar.gz | 555.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| logfire_callback-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:564.3 kB
Release files / logfire_callback-1.0.0.tar.gz
| Download URL | logfire_callback-1.0.0.tar.gz |
|---|---|
| Size | 555.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
31bfdc2c62c5f6ccf5f83732d7b00bd101957690ea95c1e744a46deb102711a2
|
|
BLAKE2b-256 checksum How to use checksums |
6fb84b97040ebe3b80cee786acf99533e112387bbed36ba654c640dabb692a00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.9
|
Release files / logfire_callback-1.0.0-py3-none-any.whl
| Download URL | logfire_callback-1.0.0-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d3bb02646ed7f7fcce476dc5f06b84abaff60cf12b1a1f21d04108e116036eb
|
|
BLAKE2b-256 checksum How to use checksums |
b432d13193c31edfeda2c43eecef764af94911b3b0eb1731163cea950d92fbec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.9
|