{"id":26661324,"url":"https://github.com/louisbrulenaudet/logfire-callback","last_synced_at":"2025-10-24T05:39:38.003Z","repository":{"id":283969881,"uuid":"953395363","full_name":"louisbrulenaudet/logfire-callback","owner":"louisbrulenaudet","description":"A callback for logging training events from Hugging Face's Transformers to Logfire 🤗","archived":false,"fork":false,"pushed_at":"2025-03-23T12:12:03.000Z","size":510,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T12:19:58.106Z","etag":null,"topics":["callback","huggingface","huggingface-transformers","logfire","logfire-callback","logging","pydantic","trainer","training","transformers"],"latest_commit_sha":null,"homepage":"https://louisbrulenaudet.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/louisbrulenaudet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"louisbrulenaudet"}},"created_at":"2025-03-23T09:07:30.000Z","updated_at":"2025-03-23T12:12:06.000Z","dependencies_parsed_at":"2025-03-23T12:30:05.090Z","dependency_job_id":null,"html_url":"https://github.com/louisbrulenaudet/logfire-callback","commit_stats":null,"previous_names":["louisbrulenaudet/logfire-callback"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/louisbrulenaudet%2Flogfire-callback","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/louisbrulenaudet%2Flogfire-callback/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/louisbrulenaudet%2Flogfire-callback/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/louisbrulenaudet%2Flogfire-callback/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/louisbrulenaudet","download_url":"https://codeload.github.com/louisbrulenaudet/logfire-callback/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245467621,"owners_count":20620216,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["callback","huggingface","huggingface-transformers","logfire","logfire-callback","logging","pydantic","trainer","training","transformers"],"created_at":"2025-03-25T13:16:23.363Z","updated_at":"2025-10-10T16:09:20.079Z","avatar_url":"https://github.com/louisbrulenaudet.png","language":"Python","funding_links":["https://github.com/sponsors/louisbrulenaudet"],"categories":[],"sub_categories":[],"readme":"![Plot](https://github.com/louisbrulenaudet/logfire-callback/blob/main/assets/thumbnail.png?raw=true)\n\n# Logfire-callback, observability for Hugging Face's Transformers training loop 🤗\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) ![Maintainer](https://img.shields.io/badge/maintainer-@louisbrulenaudet-blue) ![Python Version](https://img.shields.io/badge/python-3.11%2B-blue.svg) ![Code Style](https://img.shields.io/badge/code%20style-ruff-000000.svg) ![Package Manager](https://img.shields.io/badge/package%20manager-uv-purple.svg)\n\nA callback for logging training events from Hugging Face's Transformers to [Logfire](https://logfire.sh) 🤗\n\n## Overview\n\nThe `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.\n\n## Installation\n\nInstall the package using pip:\n\n```bash\npip install logfire-callback\n```\n\n## Usage\n\nFirst, ensure you have a Logfire API token and set it as an environment variable:\n\n```bash\nexport LOGFIRE_TOKEN=your_logfire_token\n```\n\nThen use the callback in your training code:\n\n```python\nfrom transformers import Trainer, TrainingArguments\nfrom logfire_callback import LogfireCallback\n\n# Initialize your model, dataset, etc.\n\ntraining_args = TrainingArguments(\n    output_dir=\"./results\",\n    num_train_epochs=3,\n    # ... other training arguments\n)\n\ntrainer = Trainer(\n    model=model,\n    args=training_args,\n    train_dataset=train_dataset,\n    callbacks=[LogfireCallback()]  # Add the Logfire callback here\n)\n\ntrainer.train()\n```\n\nThe callback will automatically log:\n- Training start with configuration parameters\n- Periodic training metrics (loss, learning rate, etc.)\n- Evaluation metrics during validation\n- Training completion\n\n## Development\n\n### Prerequisites\n\n- Python 3.11 or higher\n- [uv](https://github.com/astral-sh/uv) for package management\n\n### Setting up the development environment\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/louisbrulenaudet/logfire-callback\ncd logfire-callback\n```\n\n2. Initialize the development environment:\n```bash\nmake init\n```\n\n### Available Make Commands\n\n- `make test` - Execute test suite\n- `make init` - Initialize development environment\n- `make install-dev` - Install development dependencies\n- `make run` - Run the application\n- `make check` - Run code quality checks\n- `make format` - Format source code\n- `make upgrade` - Update project dependencies\n- `make pre-commit` - Run pre-commit checks\n- `make build` - Build the project\n- `make publish` - Publish the project\n- `make coverage` - Run tests with coverage\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n\n## Links\n\n- [GitHub Repository](https://github.com/louisbrulenaudet/logfire-callback)\n- [Issue Tracker](https://github.com/louisbrulenaudet/logfire-callback/issues)\n\n## Requirements\n\n- Python \u003e= 3.11\n- transformers \u003e= 4.49.0\n- logfire \u003e= 3.9.0\n\n## Citing this project\nIf you use this code in your research, please use the following BibTeX entry.\n\n```BibTeX\n@misc{louisbrulenaudet2025,\n\tauthor = {Louis Brulé Naudet},\n\ttitle = {Logfire callback, observability for Hugging Face's transformers training loop},\n\thowpublished = {\\url{https://huggingface.co/spaces/louisbrulenaudet/logfire-callback}},\n\tyear = {2025}\n}\n\n```\n## Feedback\nIf you have any feedback, please reach out at [louisbrulenaudet@icloud.com](mailto:louisbrulenaudet@icloud.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flouisbrulenaudet%2Flogfire-callback","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flouisbrulenaudet%2Flogfire-callback","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flouisbrulenaudet%2Flogfire-callback/lists"}