Hugging FaceSasha Luccioni, Zachary Mueller, Nate RawTutorial
CO2 Emissions and the 🤗 Hub: Leading the Charge
Summary
Training and deploying machine learning models produces greenhouse gas emissions determined by infrastructure runtime, hardware type, and energy grid carbon intensity. Hugging Face introduced mechanisms to measure, report, and filter models based on their carbon footprint to improve ecological transparency. Using the huggingface_hub library, practitioners can query HfApi.list_models with an emissions_thresholds parameter to filter models by maximum or minimum carbon emissions measured in grams. In addition, installing the codecarbon package enables the Transformers Trainer to automatically attach CodeCarbonCallback and log training emissions to an emissions.csv file. Users can then publish these measured values directly into model card metadata under co2_eq_emissions for public tracking.
Context
Training and deploying machine learning models emits carbon dioxide due to the energy consumed by computing hardware, including GPUs and storage. Total emissions depend on runtime, hardware type, and the carbon intensity of the energy source, creating a need for standardized tracking, reporting, and model selection mechanisms.
Approach / What changed
The huggingface_hub library introduces an emissions_thresholds parameter in HfApi.list_models to search models within specific carbon gram limits. Additionally, integrating the codecarbon library with the Transformers Trainer activates CodeCarbonCallback to write training emissions into an emissions.csv file, which can then be documented in the model card metadata under co2_eq_emissions.
Takeaways
The huggingface_hub HfApi.list_models method supports an emissions_thresholds parameter to search models based on minimum or maximum carbon emission gram ranges.
Installing codecarbon allows the Transformers Trainer to automatically load CodeCarbonCallback and track emissions during training.
Emissions data logged during training runs is written to an emissions.csv file and can be published in model cards under the co2_eq_emissions metadata field.
Source and freshness
- Source
- huggingface.co
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.