import{s as _t,n as xt,o as Gt}from"../chunks/scheduler.d6170356.js";import{S as Bt,i as Lt,g as s,s as i,r as c,A as Wt,h as o,f as n,c as l,j as Jt,u as p,x as r,k as Ht,y as Yt,a,v as u,d as h,t as f,w as d}from"../chunks/index.fcd4cc08.js";import{C as It}from"../chunks/CodeBlock.db16bf50.js";import{H as Z,E as kt}from"../chunks/getInferenceSnippets.0f6acb26.js";function Pt(ut){let m,V,P,z,y,Q,b,N,w,ht='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.',F,g,E,M,ft="If you can, you should include information about:",X,T,dt='<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>',q,$,R,v,yt="You can add the carbon footprint data to the model card metadata (in the README.md file). The structure of the metadata should be:",O,U,A,j,D,C,bt="Considering the computing hardware, location, usage, and training time, you can estimate how much CO<sub>2</sub> the model produced.",K,J,wt="The math is pretty simple! ➕",tt,H,gt='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!',et,I,Mt="Then, you take the power consumption of the GPU during training using the <code>pynvml</code> library.",nt,_,Tt="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.",at,x,$t="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!",it,G,vt="To add <strong>Carbon Emissions</strong> metadata to your models:",lt,B,Ut="<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>",st,L,ot,W,jt="in your model card metadata, where <code>1.2345</code> is the emissions value in <strong>grams</strong>.",rt,Y,Ct='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!',mt,k,ct,S,pt;return y=new Z({props:{title:"Displaying carbon emissions for your model",local:"displaying-carbon-emissions-for-your-model",headingTag:"h1"}}),b=new Z({props:{title:"Why is it beneficial to calculate the carbon emissions of my model?",local:"why-is-it-beneficial-to-calculate-the-carbon-emissions-of-my-model",headingTag:"h2"}}),g=new Z({props:{title:"What information should I include about the carbon footprint of my model?",local:"what-information-should-i-include-about-the-carbon-footprint-of-my-model",headingTag:"h2"}}),$=new Z({props:{title:"Carbon footprint metadata",local:"carbon-footprint-metadata",headingTag:"h2"}}),U=new It({props:{code:"LS0tJTBBY28yX2VxX2VtaXNzaW9ucyUzQSUwQSUyMCUyMGVtaXNzaW9ucyUzQSUyMG51bWJlciUyMChpbiUyMGdyYW1zJTIwb2YlMjBDTzIpJTBBJTIwJTIwc291cmNlJTNBJTIwJTIyc291cmNlJTIwb2YlMjB0aGUlMjBpbmZvcm1hdGlvbiUyQyUyMGVpdGhlciUyMGRpcmVjdGx5JTIwZnJvbSUyMEF1dG9UcmFpbiUyQyUyMGNvZGUlMjBjYXJib24lMjBvciUyMGZyb20lMjBhJTIwc2NpZW50aWZpYyUyMGFydGljbGUlMjBkb2N1bWVudGluZyUyMHRoZSUyMG1vZGVsJTIyJTBBJTIwJTIwdHJhaW5pbmdfdHlwZSUzQSUyMCUyMnByZS10cmFpbmluZyUyMG9yJTIwZmluZS10dW5pbmclMjIlMEElMjAlMjBnZW9ncmFwaGljYWxfbG9jYXRpb24lM0ElMjAlMjJhcyUyMGdyYW51bGFyJTIwYXMlMjBwb3NzaWJsZSUyQyUyMGZvciUyMGluc3RhbmNlJTIwUXVlYmVjJTJDJTIwQ2FuYWRhJTIwb3IlMjBCcm9va2x5biUyQyUyME5ZJTJDJTIwVVNBLiUyMFRvJTIwY2hlY2slMjB5b3VyJTIwY29tcHV0ZSdzJTIwZWxlY3RyaWNpdHklMjBncmlkJTJDJTIweW91JTIwY2FuJTIwY2hlY2slMjBvdXQlMjBodHRwcyUzQSUyRiUyRmFwcC5lbGVjdHJpY2l0eW1hcC5vcmcuJTIyJTBBJTIwJTIwaGFyZHdhcmVfdXNlZCUzQSUyMCUyMmhvdyUyMG11Y2glMjBjb21wdXRlJTIwYW5kJTIwd2hhdCUyMGtpbmQlMkMlMjBlLmcuJTIwOCUyMHYxMDAlMjBHUFVzJTIyJTBBLS0t",highlighted:`<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>`,wrap:!1}}),j=new Z({props:{title:"How is the carbon footprint of my model calculated? 🌎",local:"how-is-the-carbon-footprint-of-my-model-calculated-",headingTag:"h2"}}),L=new It({props:{code:"Y28yX2VxX2VtaXNzaW9ucyUzQSUyMCUwQSUyMCUyMGVtaXNzaW9ucyUzQSUyMDEuMjM0NQ==",highlighted:`<span class="hljs-attr">co2_eq_emissions:</span> 
  <span class="hljs-attr">emissions:</span> <span class="hljs-number">1.2345</span>`,wrap:!1}}),k=new kt({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/model-cards-co2.md"}}),{c(){m=s("meta"),V=i(),P=s("p"),z=i(),c(y.$$.fragment),Q=i(),c(b.$$.fragment),N=i(),w=s("p"),w.innerHTML=ht,F=i(),c(g.$$.fragment),E=i(),M=s("p"),M.textContent=ft,X=i(),T=s("ul"),T.innerHTML=dt,q=i(),c($.$$.fragment),R=i(),v=s("p"),v.textContent=yt,O=i(),c(U.$$.fragment),A=i(),c(j.$$.fragment),D=i(),C=s("p"),C.innerHTML=bt,K=i(),J=s("p"),J.textContent=wt,tt=i(),H=s("p"),H.innerHTML=gt,et=i(),I=s("p"),I.innerHTML=Mt,nt=i(),_=s("p"),_.innerHTML=Tt,at=i(),x=s("p"),x.innerHTML=$t,it=i(),G=s("p"),G.innerHTML=vt,lt=i(),B=s("ol"),B.innerHTML=Ut,st=i(),c(L.$$.fragment),ot=i(),W=s("p"),W.innerHTML=jt,rt=i(),Y=s("p"),Y.innerHTML=Ct,mt=i(),c(k.$$.fragment),ct=i(),S=s("p"),this.h()},l(t){const e=Wt("svelte-u9bgzb",document.head);m=o(e,"META",{name:!0,content:!0}),e.forEach(n),V=l(t),P=o(t,"P",{}),Jt(P).forEach(n),z=l(t),p(y.$$.fragment,t),Q=l(t),p(b.$$.fragment,t),N=l(t),w=o(t,"P",{"data-svelte-h":!0}),r(w)!=="svelte-1i3gone"&&(w.innerHTML=ht),F=l(t),p(g.$$.fragment,t),E=l(t),M=o(t,"P",{"data-svelte-h":!0}),r(M)!=="svelte-9iu39j"&&(M.textContent=ft),X=l(t),T=o(t,"UL",{"data-svelte-h":!0}),r(T)!=="svelte-gs1h1v"&&(T.innerHTML=dt),q=l(t),p($.$$.fragment,t),R=l(t),v=o(t,"P",{"data-svelte-h":!0}),r(v)!=="svelte-h6of1q"&&(v.textContent=yt),O=l(t),p(U.$$.fragment,t),A=l(t),p(j.$$.fragment,t),D=l(t),C=o(t,"P",{"data-svelte-h":!0}),r(C)!=="svelte-sv5yrv"&&(C.innerHTML=bt),K=l(t),J=o(t,"P",{"data-svelte-h":!0}),r(J)!=="svelte-cvnnsr"&&(J.textContent=wt),tt=l(t),H=o(t,"P",{"data-svelte-h":!0}),r(H)!=="svelte-hvso7s"&&(H.innerHTML=gt),et=l(t),I=o(t,"P",{"data-svelte-h":!0}),r(I)!=="svelte-1pggfps"&&(I.innerHTML=Mt),nt=l(t),_=o(t,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1yog6xb"&&(_.innerHTML=Tt),at=l(t),x=o(t,"P",{"data-svelte-h":!0}),r(x)!=="svelte-15bb5ar"&&(x.innerHTML=$t),it=l(t),G=o(t,"P",{"data-svelte-h":!0}),r(G)!=="svelte-1cu37zl"&&(G.innerHTML=vt),lt=l(t),B=o(t,"OL",{"data-svelte-h":!0}),r(B)!=="svelte-6mrtts"&&(B.innerHTML=Ut),st=l(t),p(L.$$.fragment,t),ot=l(t),W=o(t,"P",{"data-svelte-h":!0}),r(W)!=="svelte-9qidv"&&(W.innerHTML=jt),rt=l(t),Y=o(t,"P",{"data-svelte-h":!0}),r(Y)!=="svelte-1b25bdn"&&(Y.innerHTML=Ct),mt=l(t),p(k.$$.fragment,t),ct=l(t),S=o(t,"P",{}),Jt(S).forEach(n),this.h()},h(){Ht(m,"name","hf:doc:metadata"),Ht(m,"content",St)},m(t,e){Yt(document.head,m),a(t,V,e),a(t,P,e),a(t,z,e),u(y,t,e),a(t,Q,e),u(b,t,e),a(t,N,e),a(t,w,e),a(t,F,e),u(g,t,e),a(t,E,e),a(t,M,e),a(t,X,e),a(t,T,e),a(t,q,e),u($,t,e),a(t,R,e),a(t,v,e),a(t,O,e),u(U,t,e),a(t,A,e),u(j,t,e),a(t,D,e),a(t,C,e),a(t,K,e),a(t,J,e),a(t,tt,e),a(t,H,e),a(t,et,e),a(t,I,e),a(t,nt,e),a(t,_,e),a(t,at,e),a(t,x,e),a(t,it,e),a(t,G,e),a(t,lt,e),a(t,B,e),a(t,st,e),u(L,t,e),a(t,ot,e),a(t,W,e),a(t,rt,e),a(t,Y,e),a(t,mt,e),u(k,t,e),a(t,ct,e),a(t,S,e),pt=!0},p:xt,i(t){pt||(h(y.$$.fragment,t),h(b.$$.fragment,t),h(g.$$.fragment,t),h($.$$.fragment,t),h(U.$$.fragment,t),h(j.$$.fragment,t),h(L.$$.fragment,t),h(k.$$.fragment,t),pt=!0)},o(t){f(y.$$.fragment,t),f(b.$$.fragment,t),f(g.$$.fragment,t),f($.$$.fragment,t),f(U.$$.fragment,t),f(j.$$.fragment,t),f(L.$$.fragment,t),f(k.$$.fragment,t),pt=!1},d(t){t&&(n(V),n(P),n(z),n(Q),n(N),n(w),n(F),n(E),n(M),n(X),n(T),n(q),n(R),n(v),n(O),n(A),n(D),n(C),n(K),n(J),n(tt),n(H),n(et),n(I),n(nt),n(_),n(at),n(x),n(it),n(G),n(lt),n(B),n(st),n(ot),n(W),n(rt),n(Y),n(mt),n(ct),n(S)),n(m),d(y,t),d(b,t),d(g,t),d($,t),d(U,t),d(j,t),d(L,t),d(k,t)}}}const St='{"title":"Displaying carbon emissions for your model","local":"displaying-carbon-emissions-for-your-model","sections":[{"title":"Why is it beneficial to calculate the carbon emissions of my model?","local":"why-is-it-beneficial-to-calculate-the-carbon-emissions-of-my-model","sections":[],"depth":2},{"title":"What information should I include about the carbon footprint of my model?","local":"what-information-should-i-include-about-the-carbon-footprint-of-my-model","sections":[],"depth":2},{"title":"Carbon footprint metadata","local":"carbon-footprint-metadata","sections":[],"depth":2},{"title":"How is the carbon footprint of my model calculated? 🌎","local":"how-is-the-carbon-footprint-of-my-model-calculated-","sections":[],"depth":2}],"depth":1}';function Zt(ut){return Gt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ft extends Bt{constructor(m){super(),Lt(this,m,Zt,Pt,_t,{})}}export{Ft as component};
