Hugging Face Hub Carbon Emissions Tracking

Hugging Face has introduced a suite of tools and integrations to track, report, and filter machine learning models based on their carbon dioxide (CO2) emissions. These initiatives aim to increase transparency regarding the environmental impact of training and deploying AI models, which emit CO2 through the energy consumption of GPUs, storage, and other computing infrastructure.

Filtering Models by Carbon Footprint on the Hub

The huggingface_hub library now includes an emissions_threshold parameter that allows users to search for models based on their training emissions. This enables developers to prioritize eco-friendly, low-emission models during the selection process.

Users can specify a range of grams of CO2 to filter results. For example, using the HfApi class, a search for models with a maximum of 100 grams of emissions returns 191 models, including examples like esiebomajeremiah/autonlp-email-classification-657119381 (3.516 grams). Conversely, searching for models with a minimum threshold of 500 grams identifies larger models with higher footprints, such as Maltehb/aelaectra-danish-electra-small-cased (4009.5 grams).

Automated Emission Tracking with Transformers

To facilitate reporting, Hugging Face has integrated codecarbon into the transformers library. When codecarbon is installed on a system, the Trainer object automatically implements the CodeCarbonCallback during the training process.

This integration automatically generates an emissions.csv file within the output directory (e.g., codecarbon-text-classification). This file tracks carbon emissions across different training runs, allowing researchers to identify the specific emissions associated with the final model version.

Reporting Emissions in Model Cards

Transparency is achieved by including emission data directly in the model's metadata. Once training is completed and emissions are tracked via codecarbon, users can add the co2_eq_emissions value to the top of the model card.

This standardized metadata format allows the Hugging Face Hub to index the emissions data, making it searchable via the emissions_threshold parameter described above. Detailed guidelines for the metadata format can be found in the official Hub documentation.

Factors Influencing AI Carbon Emissions

The total amount of CO2 emitted during the lifecycle of a machine learning model is determined by three primary factors:

  1. Runtime: The duration of the training process.
  2. Hardware: The specific computing resources used (e.g., different GPU architectures).
  3. Carbon Intensity: The carbon footprint of the energy source powering the infrastructure.

Sources