Buckets:

hf-doc-build/doc-dev / hub /main /en /model-cards-co2.html
rtrm's picture
download
raw
17.1 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Displaying carbon emissions for your model&quot;,&quot;local&quot;:&quot;displaying-carbon-emissions-for-your-model&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Why is it beneficial to calculate the carbon emissions of my model?&quot;,&quot;local&quot;:&quot;why-is-it-beneficial-to-calculate-the-carbon-emissions-of-my-model&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;What information should I include about the carbon footprint of my model?&quot;,&quot;local&quot;:&quot;what-information-should-i-include-about-the-carbon-footprint-of-my-model&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Carbon footprint metadata&quot;,&quot;local&quot;:&quot;carbon-footprint-metadata&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;How is the carbon footprint of my model calculated? 🌎&quot;,&quot;local&quot;:&quot;how-is-the-carbon-footprint-of-my-model-calculated-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}">
<link href="/docs/hub/main/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload">
<link rel="modulepreload" href="/docs/hub/main/en/_app/immutable/entry/start.d0cd5065.js">
<link rel="modulepreload" href="/docs/hub/main/en/_app/immutable/chunks/scheduler.d6170356.js">
<link rel="modulepreload" href="/docs/hub/main/en/_app/immutable/chunks/singletons.d032f1eb.js">
<link rel="modulepreload" href="/docs/hub/main/en/_app/immutable/chunks/paths.752f1c6b.js">
<link rel="modulepreload" href="/docs/hub/main/en/_app/immutable/entry/app.b6abe3c1.js">
<link rel="modulepreload" href="/docs/hub/main/en/_app/immutable/chunks/index.fcd4cc08.js">
<link rel="modulepreload" href="/docs/hub/main/en/_app/immutable/nodes/0.f045427f.js">
<link rel="modulepreload" href="/docs/hub/main/en/_app/immutable/nodes/69.40758b73.js">
<link rel="modulepreload" href="/docs/hub/main/en/_app/immutable/chunks/CodeBlock.7b16bdef.js">
<link rel="modulepreload" href="/docs/hub/main/en/_app/immutable/chunks/EditOnGithub.da2b595c.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Displaying carbon emissions for your model&quot;,&quot;local&quot;:&quot;displaying-carbon-emissions-for-your-model&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Why is it beneficial to calculate the carbon emissions of my model?&quot;,&quot;local&quot;:&quot;why-is-it-beneficial-to-calculate-the-carbon-emissions-of-my-model&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;What information should I include about the carbon footprint of my model?&quot;,&quot;local&quot;:&quot;what-information-should-i-include-about-the-carbon-footprint-of-my-model&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Carbon footprint metadata&quot;,&quot;local&quot;:&quot;carbon-footprint-metadata&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;How is the carbon footprint of my model calculated? 🌎&quot;,&quot;local&quot;:&quot;how-is-the-carbon-footprint-of-my-model-calculated-&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <h1 class="relative group"><a id="displaying-carbon-emissions-for-your-model" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#displaying-carbon-emissions-for-your-model"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Displaying carbon emissions for your model</span></h1> <h2 class="relative group"><a id="why-is-it-beneficial-to-calculate-the-carbon-emissions-of-my-model" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#why-is-it-beneficial-to-calculate-the-carbon-emissions-of-my-model"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Why is it beneficial to calculate the carbon emissions of my model?</span></h2> <p data-svelte-h="svelte-1i3gone">Training ML models is often energy-intensive and can produce a substantial carbon footprint, as described by <a href="https://arxiv.org/abs/1906.02243" rel="nofollow">Strubell et al.</a>. It’s therefore important to <em>track</em> and <em>report</em> the emissions of models to get a better idea of the environmental impacts of our field.</p> <h2 class="relative group"><a id="what-information-should-i-include-about-the-carbon-footprint-of-my-model" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#what-information-should-i-include-about-the-carbon-footprint-of-my-model"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>What information should I include about the carbon footprint of my model?</span></h2> <p data-svelte-h="svelte-9iu39j">If you can, you should include information about:</p> <ul data-svelte-h="svelte-gs1h1v"><li>where the model was trained (in terms of location)</li> <li>the hardware used β€” e.g. GPU, TPU, or CPU, and how many</li> <li>training type: pre-training or fine-tuning</li> <li>the estimated carbon footprint of the model, calculated in real-time with the <a href="https://github.com/mlco2/codecarbon" rel="nofollow">Code Carbon</a> package or after training using the <a href="https://mlco2.github.io/impact/" rel="nofollow">ML CO2 Calculator</a>.</li></ul> <h2 class="relative group"><a id="carbon-footprint-metadata" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#carbon-footprint-metadata"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Carbon footprint metadata</span></h2> <p data-svelte-h="svelte-h6of1q">You can add the carbon footprint data to the model card metadata (in the README.md file). The structure of the metadata should be:</p> <div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-meta">---</span>
<span class="hljs-attr">co2_eq_emissions:</span>
<span class="hljs-attr">emissions:</span> <span class="hljs-string">number</span> <span class="hljs-string">(in</span> <span class="hljs-string">grams</span> <span class="hljs-string">of</span> <span class="hljs-string">CO2)</span>
<span class="hljs-attr">source:</span> <span class="hljs-string">&quot;source of the information, either directly from AutoTrain, code carbon or from a scientific article documenting the model&quot;</span>
<span class="hljs-attr">training_type:</span> <span class="hljs-string">&quot;pre-training or fine-tuning&quot;</span>
<span class="hljs-attr">geographical_location:</span> <span class="hljs-string">&quot;as granular as possible, for instance Quebec, Canada or Brooklyn, NY, USA. To check your compute&#x27;s electricity grid, you can check out https://app.electricitymap.org.&quot;</span>
<span class="hljs-attr">hardware_used:</span> <span class="hljs-string">&quot;how much compute and what kind, e.g. 8 v100 GPUs&quot;</span>
<span class="hljs-meta">---</span><!-- HTML_TAG_END --></pre></div> <h2 class="relative group"><a id="how-is-the-carbon-footprint-of-my-model-calculated-" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#how-is-the-carbon-footprint-of-my-model-calculated-"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>How is the carbon footprint of my model calculated? 🌎</span></h2> <p data-svelte-h="svelte-sv5yrv">Considering the computing hardware, location, usage, and training time, you can estimate how much CO<sub>2</sub> the model produced.</p> <p data-svelte-h="svelte-cvnnsr">The math is pretty simple! βž•</p> <p data-svelte-h="svelte-hvso7s">First, you take the <em>carbon intensity</em> of the electric grid used for the training β€” this is how much CO<sub>2</sub> is produced by KwH of electricity used. The carbon intensity depends on the location of the hardware and the <a href="https://electricitymap.org/" rel="nofollow">energy mix</a> used at that location β€” whether it’s renewable energy like solar 🌞, wind 🌬️ and hydro πŸ’§, or non-renewable energy like coal ⚫ and natural gas πŸ’¨. The more renewable energy gets used for training, the less carbon-intensive it is!</p> <p data-svelte-h="svelte-1pggfps">Then, you take the power consumption of the GPU during training using the <code>pynvml</code> library.</p> <p data-svelte-h="svelte-1yog6xb">Finally, you multiply the power consumption and carbon intensity by the training time of the model, and you have an estimate of the CO<sub>2</sub> emission.</p> <p data-svelte-h="svelte-15bb5ar">Keep in mind that this isn’t an exact number because other factors come into play β€” like the energy used for data center heating and cooling β€” which will increase carbon emissions. But this will give you a good idea of the scale of CO<sub>2</sub> emissions that your model is producing!</p> <p data-svelte-h="svelte-1cu37zl">To add <strong>Carbon Emissions</strong> metadata to your models:</p> <ol data-svelte-h="svelte-6mrtts"><li>If you are using <strong>AutoTrain</strong>, this is tracked for you πŸ”₯</li> <li>Otherwise, use a tracker like Code Carbon in your training code, then specify</li></ol> <div class="code-block relative"><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-attr">co2_eq_emissions:</span>
<span class="hljs-attr">emissions:</span> <span class="hljs-number">1.2345</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-9qidv">in your model card metadata, where <code>1.2345</code> is the emissions value in <strong>grams</strong>.</p> <p data-svelte-h="svelte-1b25bdn">To learn more about the carbon footprint of Transformers, check out the <a href="https://www.youtube.com/watch?v=ftWlj4FBHTg" rel="nofollow">video</a>, part of the Hugging Face Course!</p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/hub-docs/blob/main/docs/hub/model-cards-co2.md" target="_blank"><span data-svelte-h="svelte-1kd6by1">&lt;</span> <span data-svelte-h="svelte-x0xyl0">&gt;</span> <span data-svelte-h="svelte-1dajgef"><span class="underline ml-1.5">Update</span> on GitHub</span></a> <p></p>
<script>
{
__sveltekit_1vatp3t = {
assets: "/docs/hub/main/en",
base: "/docs/hub/main/en",
env: {}
};
const element = document.currentScript.parentElement;
const data = [null,null];
Promise.all([
import("/docs/hub/main/en/_app/immutable/entry/start.d0cd5065.js"),
import("/docs/hub/main/en/_app/immutable/entry/app.b6abe3c1.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 69],
data,
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
17.1 kB
Β·
Xet hash:
5e75c148108c2d01dd2ee68ce7f70bb38d1f17e4904d8b487436dc9b69412aa7

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.