added water consumption, its impact estimation and equivalences, expert mode, edited methodology page for grammatical errors
Browse files- data/electricity_mix.csv +4 -1
- src/__pycache__/__init__.cpython-311.pyc +0 -0
- src/__pycache__/calculator.cpython-311.pyc +0 -0
- src/__pycache__/constants.cpython-311.pyc +0 -0
- src/__pycache__/content.cpython-311.pyc +0 -0
- src/__pycache__/electricity_mix.cpython-311.pyc +0 -0
- src/__pycache__/expert.cpython-311.pyc +0 -0
- src/__pycache__/impacts.cpython-311.pyc +0 -0
- src/__pycache__/models.cpython-311.pyc +0 -0
- src/__pycache__/token_estimator.cpython-311.pyc +0 -0
- src/__pycache__/utils.cpython-311.pyc +0 -0
- src/calculator.py +3 -3
- src/content.py +54 -30
- src/data/electricity_mix.csv +5 -2
- src/electricity_mix.py +7 -3
- src/expert.py +74 -16
- src/impacts.py +64 -13
- src/utils.py +74 -2
data/electricity_mix.csv
CHANGED
|
@@ -1,4 +1,7 @@
|
|
| 1 |
name,unit,source,WOR,EEE,ZWE,ZMB,ZAF,YEM,VNM,VEN,UZB,URY,USA,UKR,TZA,TWN,TTO,TUR,TUN,TKM,TJK,THA,TGO,SYR,SLV,SEN,SVK,SVN,SGP,SWE,SDN,SAU,RUS,SCG,ROU,QAT,PRY,PRT,POL,PAK,PHL,PER,PAN,OMN,NZL,NPL,NOR,NLD,NIC,NGA,NAM,MOZ,MYS,MEX,MLT,MNG,MMR,MKD,MDA,MAR,LBY,LVA,LUX,LTU,LKA,LBN,KAZ,KWT,KOR,PRK,KHM,KGZ,KEN,JPN,JOR,JAM,ITA,ISL,IRN,IRQ,IND,ISR,IRL,IDN,HUN,HTI,HRV,HND,HKG,GTM,GRC,GIB,GHA,GEO,GBR,GAB,FRA,FIN,ETH,ESP,ERI,EGY,EST,ECU,DZA,DOM,DNK,DEU,CZE,CYP,CUB,CRI,COL,CHN,CMR,CHL,CIV,CHE,COG,COD,CAN,BLR,BWA,BRA,BOL,BRN,BEN,BHR,BGR,BEL,BGD,BIH,AZE,AUS,AUT,ARG,AGO,ANT,ARM,ALB,ARE
|
| 2 |
adpe,kg éq. Sb,ADEME Base IMPACTS ®,0.0000000737708,0.0000000642317,0.000000109502,0.000000162193,0.0000000862445,0.0000000163908,0.0000000945573,0.000000112811,0.000000103681,0.000000104586,0.0000000985548,0.0000000647907,0.000000132261,0.0000000578088,0.000000064552,0.0000000749765,0.0000000177021,0.000000131822,0.000000152621,0.0000000569593,0.000000134255,0.0000000268396,0.0000000472135,0.0000000470662,0.0000000606109,0.0000000992283,0.0000000198459,0.0000000777062,0.0000000955701,0.0000000134206,0.0000000960312,0.000000132772,0.0000000981761,0.00000001324,0.000000149181,0.0000000341863,0.000000101946,0.0000000842952,0.0000000595304,0.0000000952688,0.0000000790553,0.0000000374073,0.0000000720474,0.000000238273,0.000000127486,0.0000000329318,0.0000000414983,0.0000000621,0.000000128285,0.000000148382,0.000000044938,0.0000000578358,0.000000049475,0.000000176361,0.000000152699,0.000000119873,0.000000110674,0.0000000641089,0.0000000206592,0.000000153757,0.000000105692,0.0000000294596,0.0000000986932,0.0000000182134,0.000000135386,0.0000000141168,0.0000000518017,0.000000117457,0.0000000319202,0.000000181827,0.0000000958533,0.0000000596578,0.0000000147031,0.0000000196047,0.00000005439,0.0000000781905,0.0000000220304,0.0000000404306,0.000000100099,0.0000000610194,0.0000000219257,0.0000000610451,0.0000000644587,0.0000000937057,0.000000153989,0.0000000649373,0.0000000816213,0.0000000803251,0.0000000691645,0.0000000286211,0.000000156003,0.000000137999,0.0000000370973,0.000000113843,0.0000000485798,0.0000000805114,0.000000174161,0.0000000518326,0.0000000512406,0.000000033925,0.0000000990171,0.000000127168,0.0000000216438,0.0000000429285,0.0000000157411,0.0000000878733,0.0000000817565,0.0000000448771,0.0000000299542,0.0000000863908,0.000000122031,0.0000000851552,0.000000146313,0.000000105851,0.0000000949004,0.000000100467,0.000000265575,0.000000174647,0.0000000993179,0.0000000840478,0.0000000866014,0.00000010962,0.0000000969793,0.0000000185641,0.0000000239702,0.0000000135014,0.0000000823611,0.0000000337201,0.0000000394158,0.000000148007,0.000000092567,0.0000000790846,0.000000141124,0.0000000768612,0.000000124074,0.0000000449103,0.0000000854245,0.000000229556,0.0000000141548
|
| 3 |
pe,MJ,ADPf / (1-%renewable_energy),9.988,12.873,16.122,1.798,11.732,16.250,11.238,15.163,17.367,107.570,11.358,12.936,9.305,11.439,14.289,16.150,12.902,23.300,19.165,10.414,21.978,16.989,13.012,14.516,11.680,12.146,10.477,11.026,29.629,14.058,13.200,14.242,15.585,11.916,0.020,14.153,13.178,16.175,11.120,8.211,16.364,22.306,24.731,0.396,4.952,8.511,24.696,11.279,468.150,0.206,12.268,11.775,19.374,15.114,14.132,19.120,18.429,11.702,19.116,8.249,10.128,21.043,12.116,12.341,13.260,12.753,10.199,32.793,34.655,15.380,68.996,10.718,13.677,14.799,12.656,0.013,15.022,20.372,20.363,10.023,10.706,11.603,11.784,20.167,18.548,15.762,,14.340,14.487,,10.097,10.425,13.579,28.341,11.289,11.275,36.133,12.090,13.289,10.195,16.334,20.908,16.376,12.412,16.824,16.260,12.517,13.118,17.317,45.996,7.312,14.119,10.807,11.348,14.783,11.782,34.147,0.097,11.987,13.194,19.642,9.031,11.587,15.689,14.337,14.036,14.375,10.776,12.935,21.705,12.831,16.908,11.036,10.049,16.972,,13.380,0.201,19.032
|
| 4 |
-
gwp,kg éq. CO2,ADEME Base IMPACTS ®,0.590478,0.509427,0.842811,0.0141304,1.17562,1.06777,0.555572,0.497373,0.81178,0.296953,0.67978,0.646745,0.475635,0.845351,0.933059,0.706988,0.80722,1.38296,0.0426743,0.646174,0.545455,1.08778,0.473128,1.1195,0.309341,0.498523,0.655825,0.0464664,1.12472,0.913677,0.66131,1.07808,0.664245,0.722125,0.241601,0.571172,1.15075,0.748727,0.761317,0.284364,0.53403,1.41292,0.293397,0.0841323,0.023754,0.544803,0.941626,0.693123,0.357253,0.00880732,0.832206,0.739214,1.31149,1.47192,0.48193,1.24074,1.04213,0.933694,1.35361,0.234273,0.490016,0.154229,0.709185,0.883627,1.128,0.885084,0.599585,0.797361,1.41054,0.156039,0.589603,0.540891,0.781372,1.07345,0.621329,0.0194609,0.930385,1.48728,1.58299,0.901842,0.648118,0.875394,0.541558,1.3858,0.535759,0.692837,0.95888,0.645801,1.13127,0.977477,0.540126,0.132046,0.602137,0.732511,0.0813225,0.322068,0.251299,0.467803,1.13153,0.587775,1.51492,0.627714,1.02318,0.909252,0.633534,0.657374,0.799077,0.978041,1.28325,0.224471,0.214014,1.05738,0.456622,0.574415,0.928583,0.0448568,0.904053,0.0613102,0.238191,0.795697,2.12572,0.278647,0.585131,0.997577,1.19128,0.804567,0.827087,0.256537,0.795168,1.56025,0.726126,1.12326,0.245573,0.476811,0.412014,1.13161,0.252002,0.0207635,1.09088
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
name,unit,source,WOR,EEE,ZWE,ZMB,ZAF,YEM,VNM,VEN,UZB,URY,USA,UKR,TZA,TWN,TTO,TUR,TUN,TKM,TJK,THA,TGO,SYR,SLV,SEN,SVK,SVN,SGP,SWE,SDN,SAU,RUS,SCG,ROU,QAT,PRY,PRT,POL,PAK,PHL,PER,PAN,OMN,NZL,NPL,NOR,NLD,NIC,NGA,NAM,MOZ,MYS,MEX,MLT,MNG,MMR,MKD,MDA,MAR,LBY,LVA,LUX,LTU,LKA,LBN,KAZ,KWT,KOR,PRK,KHM,KGZ,KEN,JPN,JOR,JAM,ITA,ISL,IRN,IRQ,IND,ISR,IRL,IDN,HUN,HTI,HRV,HND,HKG,GTM,GRC,GIB,GHA,GEO,GBR,GAB,FRA,FIN,ETH,ESP,ERI,EGY,EST,ECU,DZA,DOM,DNK,DEU,CZE,CYP,CUB,CRI,COL,CHN,CMR,CHL,CIV,CHE,COG,COD,CAN,BLR,BWA,BRA,BOL,BRN,BEN,BHR,BGR,BEL,BGD,BIH,AZE,AUS,AUT,ARG,AGO,ANT,ARM,ALB,ARE
|
| 2 |
adpe,kg éq. Sb,ADEME Base IMPACTS ®,0.0000000737708,0.0000000642317,0.000000109502,0.000000162193,0.0000000862445,0.0000000163908,0.0000000945573,0.000000112811,0.000000103681,0.000000104586,0.0000000985548,0.0000000647907,0.000000132261,0.0000000578088,0.000000064552,0.0000000749765,0.0000000177021,0.000000131822,0.000000152621,0.0000000569593,0.000000134255,0.0000000268396,0.0000000472135,0.0000000470662,0.0000000606109,0.0000000992283,0.0000000198459,0.0000000777062,0.0000000955701,0.0000000134206,0.0000000960312,0.000000132772,0.0000000981761,0.00000001324,0.000000149181,0.0000000341863,0.000000101946,0.0000000842952,0.0000000595304,0.0000000952688,0.0000000790553,0.0000000374073,0.0000000720474,0.000000238273,0.000000127486,0.0000000329318,0.0000000414983,0.0000000621,0.000000128285,0.000000148382,0.000000044938,0.0000000578358,0.000000049475,0.000000176361,0.000000152699,0.000000119873,0.000000110674,0.0000000641089,0.0000000206592,0.000000153757,0.000000105692,0.0000000294596,0.0000000986932,0.0000000182134,0.000000135386,0.0000000141168,0.0000000518017,0.000000117457,0.0000000319202,0.000000181827,0.0000000958533,0.0000000596578,0.0000000147031,0.0000000196047,0.00000005439,0.0000000781905,0.0000000220304,0.0000000404306,0.000000100099,0.0000000610194,0.0000000219257,0.0000000610451,0.0000000644587,0.0000000937057,0.000000153989,0.0000000649373,0.0000000816213,0.0000000803251,0.0000000691645,0.0000000286211,0.000000156003,0.000000137999,0.0000000370973,0.000000113843,0.0000000485798,0.0000000805114,0.000000174161,0.0000000518326,0.0000000512406,0.000000033925,0.0000000990171,0.000000127168,0.0000000216438,0.0000000429285,0.0000000157411,0.0000000878733,0.0000000817565,0.0000000448771,0.0000000299542,0.0000000863908,0.000000122031,0.0000000851552,0.000000146313,0.000000105851,0.0000000949004,0.000000100467,0.000000265575,0.000000174647,0.0000000993179,0.0000000840478,0.0000000866014,0.00000010962,0.0000000969793,0.0000000185641,0.0000000239702,0.0000000135014,0.0000000823611,0.0000000337201,0.0000000394158,0.000000148007,0.000000092567,0.0000000790846,0.000000141124,0.0000000768612,0.000000124074,0.0000000449103,0.0000000854245,0.000000229556,0.0000000141548
|
| 3 |
pe,MJ,ADPf / (1-%renewable_energy),9.988,12.873,16.122,1.798,11.732,16.250,11.238,15.163,17.367,107.570,11.358,12.936,9.305,11.439,14.289,16.150,12.902,23.300,19.165,10.414,21.978,16.989,13.012,14.516,11.680,12.146,10.477,11.026,29.629,14.058,13.200,14.242,15.585,11.916,0.020,14.153,13.178,16.175,11.120,8.211,16.364,22.306,24.731,0.396,4.952,8.511,24.696,11.279,468.150,0.206,12.268,11.775,19.374,15.114,14.132,19.120,18.429,11.702,19.116,8.249,10.128,21.043,12.116,12.341,13.260,12.753,10.199,32.793,34.655,15.380,68.996,10.718,13.677,14.799,12.656,0.013,15.022,20.372,20.363,10.023,10.706,11.603,11.784,20.167,18.548,15.762,,14.340,14.487,,10.097,10.425,13.579,28.341,11.289,11.275,36.133,12.090,13.289,10.195,16.334,20.908,16.376,12.412,16.824,16.260,12.517,13.118,17.317,45.996,7.312,14.119,10.807,11.348,14.783,11.782,34.147,0.097,11.987,13.194,19.642,9.031,11.587,15.689,14.337,14.036,14.375,10.776,12.935,21.705,12.831,16.908,11.036,10.049,16.972,,13.380,0.201,19.032
|
| 4 |
+
gwp,kg éq. CO2,ADEME Base IMPACTS ®,0.590478,0.509427,0.842811,0.0141304,1.17562,1.06777,0.555572,0.497373,0.81178,0.296953,0.67978,0.646745,0.475635,0.845351,0.933059,0.706988,0.80722,1.38296,0.0426743,0.646174,0.545455,1.08778,0.473128,1.1195,0.309341,0.498523,0.655825,0.0464664,1.12472,0.913677,0.66131,1.07808,0.664245,0.722125,0.241601,0.571172,1.15075,0.748727,0.761317,0.284364,0.53403,1.41292,0.293397,0.0841323,0.023754,0.544803,0.941626,0.693123,0.357253,0.00880732,0.832206,0.739214,1.31149,1.47192,0.48193,1.24074,1.04213,0.933694,1.35361,0.234273,0.490016,0.154229,0.709185,0.883627,1.128,0.885084,0.599585,0.797361,1.41054,0.156039,0.589603,0.540891,0.781372,1.07345,0.621329,0.0194609,0.930385,1.48728,1.58299,0.901842,0.648118,0.875394,0.541558,1.3858,0.535759,0.692837,0.95888,0.645801,1.13127,0.977477,0.540126,0.132046,0.602137,0.732511,0.0813225,0.322068,0.251299,0.467803,1.13153,0.587775,1.51492,0.627714,1.02318,0.909252,0.633534,0.657374,0.799077,0.978041,1.28325,0.224471,0.214014,1.05738,0.456622,0.574415,0.928583,0.0448568,0.904053,0.0613102,0.238191,0.795697,2.12572,0.278647,0.585131,0.997577,1.19128,0.804567,0.827087,0.256537,0.795168,1.56025,0.726126,1.12326,0.245573,0.476811,0.412014,1.13161,0.252002,0.0207635,1.09088
|
| 5 |
+
water_wwf,L/kWh,World Resource Institute Guidance for Calculating Water Use Embedded in Purchased Electricity 2020 ,2216,2705.4,,,,,,,,,386,942,,,,1374,,,,833,,,,,1033,14807,,3777,,,2067,,454,,,1472,216,,,,,,1741,,8285,696,,,,,2472,469,87,,,,,,,7525,1393,3051,,,,,257,,,,,1855,,,3524,,,,2373,,212,1605,1525,,,,,,519,,,,167,,2464,2161,,295,,,765,,,,1374,1419,791,57,,,,606,,458,,8331,,,2850,,,893,,,,,379,621,,,,155,14145,1.291,,,,,0
|
| 6 |
+
water_wcf,L/kWh,World Resource Institute Guidance for Calculating Water Use Embedded in Purchased Electricity 2020,5.04,4.48,,,,,,,,,3.14,2.12,,,,4.92,,,,2.88,,,,,5.79,2.99,,6.02,,,3.44,,7.34,,,9.58,2.5,,,,,,14.95,,6.66,3.44,,,,,1.67,5.3,1.14,,,,,,,2.54,12.79,5.9,,,,,1.89,,,,,2.31,,,4.84,,,,3.44,,1.48,2.27,3.67,,,,,,5.15,,,,2.35,,3.67,4.54,,6.21,,,2.2,,,,3.18,1.93,3.22,1.29,,,,6.02,,10.52,,5.68,,,8.18,,,18.58,,,,,4.62,2.61,,,,4.73,5.72,11.47,,,,,0
|
| 7 |
+
|
src/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (651 Bytes). View file
|
|
|
src/__pycache__/calculator.cpython-311.pyc
ADDED
|
Binary file (6.41 kB). View file
|
|
|
src/__pycache__/constants.cpython-311.pyc
ADDED
|
Binary file (2.7 kB). View file
|
|
|
src/__pycache__/content.cpython-311.pyc
ADDED
|
Binary file (20.6 kB). View file
|
|
|
src/__pycache__/electricity_mix.cpython-311.pyc
ADDED
|
Binary file (6.26 kB). View file
|
|
|
src/__pycache__/expert.cpython-311.pyc
ADDED
|
Binary file (16.6 kB). View file
|
|
|
src/__pycache__/impacts.cpython-311.pyc
ADDED
|
Binary file (12.5 kB). View file
|
|
|
src/__pycache__/models.cpython-311.pyc
ADDED
|
Binary file (5.24 kB). View file
|
|
|
src/__pycache__/token_estimator.cpython-311.pyc
ADDED
|
Binary file (2.15 kB). View file
|
|
|
src/__pycache__/utils.cpython-311.pyc
ADDED
|
Binary file (12.2 kB). View file
|
|
|
src/calculator.py
CHANGED
|
@@ -21,7 +21,7 @@ def calculator_mode():
|
|
| 21 |
label = 'Provider',
|
| 22 |
options = [x for x in df['provider_clean'].unique()],
|
| 23 |
index = 7
|
| 24 |
-
)
|
| 25 |
|
| 26 |
with col2:
|
| 27 |
model = st.selectbox(
|
|
@@ -60,13 +60,13 @@ def calculator_mode():
|
|
| 60 |
|
| 61 |
st.markdown('<h3 align = "center">Environmental impacts</h3>', unsafe_allow_html=True)
|
| 62 |
st.markdown('<p align = "center">To understand how the environmental impacts are computed go to the 📖 Methodology tab.</p>', unsafe_allow_html=True)
|
| 63 |
-
display_impacts(impacts)
|
| 64 |
|
| 65 |
with st.container(border=True):
|
| 66 |
|
| 67 |
st.markdown('<h3 align = "center">That\'s equivalent to ...</h3>', unsafe_allow_html=True)
|
| 68 |
st.markdown('<p align = "center">Making this request to the LLM is equivalent to the following actions :</p>', unsafe_allow_html=True)
|
| 69 |
-
display_equivalent(impacts)
|
| 70 |
|
| 71 |
except Exception as e:
|
| 72 |
st.error('Could not find the model in the repository. Please try another model.')
|
|
|
|
| 21 |
label = 'Provider',
|
| 22 |
options = [x for x in df['provider_clean'].unique()],
|
| 23 |
index = 7
|
| 24 |
+
) #une liste de proviseurs à selectioner
|
| 25 |
|
| 26 |
with col2:
|
| 27 |
model = st.selectbox(
|
|
|
|
| 60 |
|
| 61 |
st.markdown('<h3 align = "center">Environmental impacts</h3>', unsafe_allow_html=True)
|
| 62 |
st.markdown('<p align = "center">To understand how the environmental impacts are computed go to the 📖 Methodology tab.</p>', unsafe_allow_html=True)
|
| 63 |
+
display_impacts(impacts, provider, location="🌎 World")
|
| 64 |
|
| 65 |
with st.container(border=True):
|
| 66 |
|
| 67 |
st.markdown('<h3 align = "center">That\'s equivalent to ...</h3>', unsafe_allow_html=True)
|
| 68 |
st.markdown('<p align = "center">Making this request to the LLM is equivalent to the following actions :</p>', unsafe_allow_html=True)
|
| 69 |
+
display_equivalent(impacts, provider, location="🌎 World")
|
| 70 |
|
| 71 |
except Exception as e:
|
| 72 |
st.error('Could not find the model in the repository. Please try another model.')
|
src/content.py
CHANGED
|
@@ -72,7 +72,7 @@ ABOUT_TEXT = r"""
|
|
| 72 |
The rapid evolution of generative AI is reshaping numerous industries and aspects of our daily lives. While these
|
| 73 |
advancements offer some benefits, they also **pose substantial environmental challenges that cannot be overlooked**.
|
| 74 |
Plus the issue of AI's environmental footprint has been mainly discussed at training stage but rarely at the inference
|
| 75 |
-
stage. That is an issue because **inference impacts for LLMs can largely overcome the training impacts when deployed
|
| 76 |
at large scales**.
|
| 77 |
At **[GenAI Impact](https://genai-impact.org/) we are dedicated to understanding and mitigating the environmental
|
| 78 |
impacts of generative AI** through rigorous research, innovative tools, and community engagement. Especially, in early
|
|
@@ -146,38 +146,56 @@ Leaderboard.
|
|
| 146 |
For general question on the project, please use the [GitHub thread](https://github.com/genai-impact/ecologits/discussions/45).
|
| 147 |
Otherwise use our contact form on [genai-impact.org/contact](https://genai-impact.org/contact/).
|
| 148 |
"""
|
| 149 |
-
|
|
|
|
| 150 |
|
| 151 |
METHODOLOGY_TEXT = r"""
|
| 152 |
## 📖 Methodology
|
| 153 |
We have developed a methodology to **estimate the energy consumption and environmental impacts for an LLM inference**
|
| 154 |
based on request parameters and hypotheses on the data center location, the hardware used, the model architecture and
|
| 155 |
more.
|
| 156 |
-
In this section we will only cover the principles of the methodology related to the 🧮 **EcoLogits Calculator**. If
|
| 157 |
-
you
|
| 158 |
🌱 [EcoLogits documentation page](https://ecologits.ai/methodology/).
|
| 159 |
### Modeling impacts of an LLM request
|
| 160 |
-
The environmental impacts of an LLM inference are split into
|
| 161 |
-
electricity consumption and
|
| 162 |
-
manufacturing and transportation.
|
| 163 |
$$ I_{request} = I_{request}^u + I_{request}^e $$
|
| 164 |
$$ I_{request} = E_{request}*F_{em}+\frac{\Delta T}{\Delta L}*I_{server}^e $$
|
| 165 |
-
|
| 166 |
* $E_{request}$ the estimated energy consumption of the server and its cooling system.
|
| 167 |
* $F_{em}$ the electricity mix that depends on the country and time.
|
| 168 |
* $\frac{\Delta T}{\Delta L}$ the hardware usage ratio i.e. the computation time over the lifetime of the hardware.
|
| 169 |
* $I_{server}^e$ the embodied impacts of the server.
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
### Principles, Data and Hypotheses
|
| 178 |
-
We use a **bottom-up methodology** to model impacts, meaning that we
|
| 179 |
-
components to then estimate the impacts at software level (in
|
| 180 |
-
Cycle Approach (LCA) proxies
|
| 181 |
If you are interested in this approach we recommend you to read the following [Boavizta](https://boavizta.org/)
|
| 182 |
resources.
|
| 183 |
* [Digital & environment: How to evaluate server manufacturing footprint, beyond greenhouse gas emissions?](https://boavizta.org/en/blog/empreinte-de-la-fabrication-d-un-serveur)
|
|
@@ -189,14 +207,16 @@ and latency based on the model architecture and number of output tokens.
|
|
| 189 |
* [Boavizta API](https://github.com/Boavizta/boaviztapi) to estimate server embodied impacts and base energy
|
| 190 |
consumption.
|
| 191 |
* [ADEME Base Empreinte®](https://base-empreinte.ademe.fr/) for electricity mix impacts per country.
|
|
|
|
|
|
|
| 192 |
Finally here are the **main hypotheses** we have made to compute the impacts.
|
| 193 |
* ⚠️ **We *"guesstimate"* the model architecture of proprietary LLMs when not disclosed by the provider.**
|
| 194 |
* Production setup: quantized models running on data center grade servers and GPUs such as A100.
|
| 195 |
* Electricity mix does not depend on time (help us enhance EcoLogits and work on this [issue](https://github.com/genai-impact/ecologits/issues/42))
|
| 196 |
-
*
|
| 197 |
## Equivalents
|
| 198 |
We have integrated impact equivalents to help people better understand the impacts and have reference points for
|
| 199 |
-
standard use cases
|
| 200 |
### Request impacts
|
| 201 |
These equivalents are computed based on the request impacts only.
|
| 202 |
#### 🚶♂️➡️ Walking or 🏃♂️➡️ running distance
|
|
@@ -206,8 +226,8 @@ physical activity (for someone weighing 70kg):
|
|
| 206 |
* 🚶♂️➡️ walking: $ 196\ kJ/km $ (speed of $ 3\ km/h $)
|
| 207 |
* 🏃♂️➡️ running: $ 294\ kJ/km $ (speed of $ 10\ km/h $)
|
| 208 |
We divide the request energy consumption by these values to compute the distance traveled.
|
| 209 |
-
#### 🔋 Electric
|
| 210 |
-
We compare the ⚡️ direct energy consumption with the energy consumer by
|
| 211 |
[selectra.info](https://selectra.info/energie/actualites/insolite/consommation-vehicules-electriques-france-2040) or
|
| 212 |
[tesla.com](https://www.tesla.com/fr_fr/support/power-consumption) we consider an average value of energy consumed per
|
| 213 |
kilometer of: $ 0.17\ kWh/km $.
|
|
@@ -217,37 +237,41 @@ We compare the 🌍 GHG emissions of the request and of streaming a video. From
|
|
| 217 |
[impactco2.fr](https://impactco2.fr/outils/comparateur?value=1&comparisons=streamingvideo), we consider that
|
| 218 |
$ 1\ kgCO2eq $ is equivalent to $ 15.6\ h $ of streaming.
|
| 219 |
We multiply that value by the GHG emissions of the request to get an equivalent in hours of video streaming.
|
|
|
|
|
|
|
| 220 |
### Scaled impacts
|
| 221 |
These equivalents are computed based on the request impacts scaled to a worldwide adoption use case. We imply that the
|
| 222 |
-
same request is done 1% of the
|
| 223 |
$$
|
| 224 |
-
I_{scaled} = I_{request} * [1
|
| 225 |
$$
|
| 226 |
#### Number of 💨 wind turbines or ☢️ nuclear plants
|
| 227 |
-
We compare the ⚡️ direct energy consumption
|
| 228 |
plants. From [ecologie.gouv.fr](https://www.ecologie.gouv.fr/eolien-terrestre) we consider that a $ 2\ MW $ wind
|
| 229 |
turbine produces $ 4.2\ GWh $ a year. And from [edf.fr](https://www.edf.fr/groupe-edf/espaces-dedies/jeunes-enseignants/pour-les-jeunes/lenergie-de-a-a-z/produire-de-lelectricite/le-nucleaire-en-chiffres)
|
| 230 |
we learn that a $ 900\ MW $ nuclear power plant produces $ 6\ TWh $ a year.
|
| 231 |
We divide the scaled energy consumption by these values to get the number of wind turbines or nuclear power plants
|
| 232 |
needed.
|
| 233 |
#### Multiplier of 🇮🇪 Ireland electricity consumption
|
| 234 |
-
We compare the ⚡️ direct energy consumption
|
| 235 |
[wikipedia.org](https://en.wikipedia.org/wiki/List_of_countries_by_electricity_consumption) we consider the Ireland
|
| 236 |
electricity consumption to be $ 33\ TWh $ a year for a population of 5M.
|
| 237 |
-
We divide the scaled energy consumption by this value to get the equivalent number of "
|
| 238 |
#### Number of ✈️ Paris ↔ New York City flights
|
| 239 |
-
We compare the 🌍 GHG emissions
|
| 240 |
[impactco2.fr](https://impactco2.fr/outils/comparateur?value=1&comparisons=&equivalent=avion-pny) we consider that a
|
| 241 |
return flight Paris → New York City → Paris for one passenger emits $ 1,770\ kgCO2eq $ and we consider an overall
|
| 242 |
average load of 100 passengers per flight.
|
| 243 |
We divide the scaled GHG emissions by this value to get the equivalent number of return flights.
|
| 244 |
-
|
|
|
|
|
|
|
| 245 |
#### If you are motivated to help us test and enhance this methodology [contact us](https://genai-impact.org/contact/)! 💪
|
| 246 |
"""
|
| 247 |
|
| 248 |
CITATION_LABEL = "BibTeX citation for EcoLogits Calculator and the EcoLogits library:"
|
| 249 |
CITATION_TEXT = r"""@misc{ecologits-calculator,
|
| 250 |
-
author={Samuel Rincé, Adrien Banse and
|
| 251 |
title={EcoLogits Calculator},
|
| 252 |
year={2025},
|
| 253 |
howpublished= {\url{https://huggingface.co/spaces/genai-impact/ecologits-calculator}},
|
|
|
|
| 72 |
The rapid evolution of generative AI is reshaping numerous industries and aspects of our daily lives. While these
|
| 73 |
advancements offer some benefits, they also **pose substantial environmental challenges that cannot be overlooked**.
|
| 74 |
Plus the issue of AI's environmental footprint has been mainly discussed at training stage but rarely at the inference
|
| 75 |
+
stage. That is an issue because **inference impacts for large langauge models (LLMs) can largely overcome the training impacts when deployed
|
| 76 |
at large scales**.
|
| 77 |
At **[GenAI Impact](https://genai-impact.org/) we are dedicated to understanding and mitigating the environmental
|
| 78 |
impacts of generative AI** through rigorous research, innovative tools, and community engagement. Especially, in early
|
|
|
|
| 146 |
For general question on the project, please use the [GitHub thread](https://github.com/genai-impact/ecologits/discussions/45).
|
| 147 |
Otherwise use our contact form on [genai-impact.org/contact](https://genai-impact.org/contact/).
|
| 148 |
"""
|
| 149 |
+
#TODO ajoute des mots sur water use. embodied vs per request use
|
| 150 |
+
#TODO ajuster la partie sur embodied electricité. c'est pas du tout clair
|
| 151 |
|
| 152 |
METHODOLOGY_TEXT = r"""
|
| 153 |
## 📖 Methodology
|
| 154 |
We have developed a methodology to **estimate the energy consumption and environmental impacts for an LLM inference**
|
| 155 |
based on request parameters and hypotheses on the data center location, the hardware used, the model architecture and
|
| 156 |
more.
|
| 157 |
+
In this section, we will only cover the principles of the methodology related to the 🧮 **EcoLogits Calculator**. If
|
| 158 |
+
you would like to learn more about the environmental impacts modeling of an LLM request, consider checking out the
|
| 159 |
🌱 [EcoLogits documentation page](https://ecologits.ai/methodology/).
|
| 160 |
### Modeling impacts of an LLM request
|
| 161 |
+
The environmental impacts of an LLM inference are split into **usage impacts** $I_{request}^u$ to account for
|
| 162 |
+
electricity consumption and **embodied impacts** $I_{request}^e$ that relate to resource extraction, hardware
|
| 163 |
+
manufacturing and transportation. It can be expressed as the following:
|
| 164 |
$$ I_{request} = I_{request}^u + I_{request}^e $$
|
| 165 |
$$ I_{request} = E_{request}*F_{em}+\frac{\Delta T}{\Delta L}*I_{server}^e $$
|
| 166 |
+
Where
|
| 167 |
* $E_{request}$ the estimated energy consumption of the server and its cooling system.
|
| 168 |
* $F_{em}$ the electricity mix that depends on the country and time.
|
| 169 |
* $\frac{\Delta T}{\Delta L}$ the hardware usage ratio i.e. the computation time over the lifetime of the hardware.
|
| 170 |
* $I_{server}^e$ the embodied impacts of the server.
|
| 171 |
+
|
| 172 |
+
Additionally, the environmental impacts are expressed in **four dimensions
|
| 173 |
+
(multi-criteria impacts)**:
|
| 174 |
+
* 🌍 **Global Warming Potential** (GWP): Potential impact on global warming in kilograms of CO2 equivalent,
|
| 175 |
+
or kgCO2eq, also commonly known as green house gases (GHG) or carbon emissions.
|
| 176 |
+
* 🪨 **Abiotic Depletion Potential for Elements** (ADPe): Mesures the impact on the depletion of non-organic resources such as
|
| 177 |
+
minerals or metals in kilograms of antimony equivalent. This is to say the impact equating to that amount of antimony extracted.
|
| 178 |
+
* ⛽️ **Primary Energy** (PE): Total energy consumed from primary sources in megajoules.
|
| 179 |
+
* 💧 **Water Use** : Water consumption from this request. The formula for quantifying this is:
|
| 180 |
+
$$
|
| 181 |
+
WCF_{request} = E_{\text{server}} \times \left( \text{WUE}_{\text{on-site}} + \text{PUE} \times \text{WUE}_{\text{off-site}} \right) + \color{orange}{\frac{\Delta T \times {WCF}_{embodied}}{\Delta L \times N_{requests}} }
|
| 182 |
+
$$
|
| 183 |
+
Where
|
| 184 |
+
* $WCF_{request}$ : Water consumption footprint for the request
|
| 185 |
+
* $E_{\text{server}}$ : Energy cost at the server for the request
|
| 186 |
+
* $WUE_{on-site}$ : Water usage efficiency at the data center
|
| 187 |
+
* $PUE$: Power usage efficiency at the data center
|
| 188 |
+
* $WUE_{off-site}$ : Water usage efficiency of the local electricity mix
|
| 189 |
+
* $\color{orange}{\Delta T}$ : Generation latency, or the time it takes for the server to process the request, in seconds
|
| 190 |
+
* $\color{orange}{\Delta L}$ : Server lifespan in seconds
|
| 191 |
+
* $\color{orange}{N_{requests}}$ : Number of simultanous reqeusts handled by the server
|
| 192 |
+
* $\color{orange}{WCF_{embodied}}$ : Embodied water consumption footprint for manufacturing the server
|
| 193 |
+
|
| 194 |
+
The variables in $\color{orange}{orange}$ represent the embodied water consumption and are not presently integrated into the calculations due to the lack of data. According to many sources, once integrated, they could double or more our water consumption estimation.
|
| 195 |
### Principles, Data and Hypotheses
|
| 196 |
+
We use a **bottom-up methodology** to model impacts, meaning that we estimate the impacts of low-level physical
|
| 197 |
+
components to then estimate the impacts at software level (in our case an LLM inference). We also rely on **Life
|
| 198 |
+
Cycle Approach (LCA) proxies** to model both usage and embodied phases with multi-criteria impacts.
|
| 199 |
If you are interested in this approach we recommend you to read the following [Boavizta](https://boavizta.org/)
|
| 200 |
resources.
|
| 201 |
* [Digital & environment: How to evaluate server manufacturing footprint, beyond greenhouse gas emissions?](https://boavizta.org/en/blog/empreinte-de-la-fabrication-d-un-serveur)
|
|
|
|
| 207 |
* [Boavizta API](https://github.com/Boavizta/boaviztapi) to estimate server embodied impacts and base energy
|
| 208 |
consumption.
|
| 209 |
* [ADEME Base Empreinte®](https://base-empreinte.ademe.fr/) for electricity mix impacts per country.
|
| 210 |
+
* [World Resource Institute](https://www.wri.org/research/guidance-calculating-water-use-embedded-purchased-electricity) for the water withdrawal factor (WWF) and water consumption factor (WCF) for different countries.
|
| 211 |
+
* [Various sources from companies' sustainability reports](https://docs.google.com/spreadsheets/d/1XvKNhqJJ3e0wlUlSOcv-HS8jIwjCJBEQYgNhkVwA7ac/edit?usp=sharing) for their on-site water usage efficiencies and power usage efficiencies.
|
| 212 |
Finally here are the **main hypotheses** we have made to compute the impacts.
|
| 213 |
* ⚠️ **We *"guesstimate"* the model architecture of proprietary LLMs when not disclosed by the provider.**
|
| 214 |
* Production setup: quantized models running on data center grade servers and GPUs such as A100.
|
| 215 |
* Electricity mix does not depend on time (help us enhance EcoLogits and work on this [issue](https://github.com/genai-impact/ecologits/issues/42))
|
| 216 |
+
* We are ignoring the following impacts: unused cloud resources, data center building, network and end-user devices... (for now)
|
| 217 |
## Equivalents
|
| 218 |
We have integrated impact equivalents to help people better understand the impacts and have reference points for
|
| 219 |
+
standard use cases in everyday activities.
|
| 220 |
### Request impacts
|
| 221 |
These equivalents are computed based on the request impacts only.
|
| 222 |
#### 🚶♂️➡️ Walking or 🏃♂️➡️ running distance
|
|
|
|
| 226 |
* 🚶♂️➡️ walking: $ 196\ kJ/km $ (speed of $ 3\ km/h $)
|
| 227 |
* 🏃♂️➡️ running: $ 294\ kJ/km $ (speed of $ 10\ km/h $)
|
| 228 |
We divide the request energy consumption by these values to compute the distance traveled.
|
| 229 |
+
#### 🔋 Electric vehicle distance
|
| 230 |
+
We compare the ⚡️ direct energy consumption with the energy consumer by an EV car. From
|
| 231 |
[selectra.info](https://selectra.info/energie/actualites/insolite/consommation-vehicules-electriques-france-2040) or
|
| 232 |
[tesla.com](https://www.tesla.com/fr_fr/support/power-consumption) we consider an average value of energy consumed per
|
| 233 |
kilometer of: $ 0.17\ kWh/km $.
|
|
|
|
| 237 |
[impactco2.fr](https://impactco2.fr/outils/comparateur?value=1&comparisons=streamingvideo), we consider that
|
| 238 |
$ 1\ kgCO2eq $ is equivalent to $ 15.6\ h $ of streaming.
|
| 239 |
We multiply that value by the GHG emissions of the request to get an equivalent in hours of video streaming.
|
| 240 |
+
#### 🚰 Bottled waters
|
| 241 |
+
We compare the water consumption to a standard 75cL water bottle.
|
| 242 |
### Scaled impacts
|
| 243 |
These equivalents are computed based on the request impacts scaled to a worldwide adoption use case. We imply that the
|
| 244 |
+
same request is done by 1% of the world population everyday for 1 year, and then compute impact equivalents.
|
| 245 |
$$
|
| 246 |
+
I_{scaled} = I_{request} * [1 \% \ \text{of 8 billion people on earth}] * 365\ \text{days}
|
| 247 |
$$
|
| 248 |
#### Number of 💨 wind turbines or ☢️ nuclear plants
|
| 249 |
+
We compare the ⚡️ scaled direct energy consumption by the energy production of wind turbines and nuclear power
|
| 250 |
plants. From [ecologie.gouv.fr](https://www.ecologie.gouv.fr/eolien-terrestre) we consider that a $ 2\ MW $ wind
|
| 251 |
turbine produces $ 4.2\ GWh $ a year. And from [edf.fr](https://www.edf.fr/groupe-edf/espaces-dedies/jeunes-enseignants/pour-les-jeunes/lenergie-de-a-a-z/produire-de-lelectricite/le-nucleaire-en-chiffres)
|
| 252 |
we learn that a $ 900\ MW $ nuclear power plant produces $ 6\ TWh $ a year.
|
| 253 |
We divide the scaled energy consumption by these values to get the number of wind turbines or nuclear power plants
|
| 254 |
needed.
|
| 255 |
#### Multiplier of 🇮🇪 Ireland electricity consumption
|
| 256 |
+
We compare the ⚡️ scaled direct energy consumption by the electricity consumption of Ireland per year. From
|
| 257 |
[wikipedia.org](https://en.wikipedia.org/wiki/List_of_countries_by_electricity_consumption) we consider the Ireland
|
| 258 |
electricity consumption to be $ 33\ TWh $ a year for a population of 5M.
|
| 259 |
+
We divide the scaled energy consumption by this value to get the equivalent number of "Irelands".
|
| 260 |
#### Number of ✈️ Paris ↔ New York City flights
|
| 261 |
+
We compare the 🌍 scaled GHG emissions of the request and of a return flight Paris ↔ New York City. From
|
| 262 |
[impactco2.fr](https://impactco2.fr/outils/comparateur?value=1&comparisons=&equivalent=avion-pny) we consider that a
|
| 263 |
return flight Paris → New York City → Paris for one passenger emits $ 1,770\ kgCO2eq $ and we consider an overall
|
| 264 |
average load of 100 passengers per flight.
|
| 265 |
We divide the scaled GHG emissions by this value to get the equivalent number of return flights.
|
| 266 |
+
#### Number of Olympic-sized swimming pools 🏊🏼
|
| 267 |
+
We compare the scaled water consumption to the number of Olympic-sized swimming pools it can fill. According to the [Phinizy Center for Water Sciences](https://phinizycenter.org/olympic-swimming-pools/),
|
| 268 |
+
an Olympic-sized swimming pool holds about 2.5 million liters of water.
|
| 269 |
#### If you are motivated to help us test and enhance this methodology [contact us](https://genai-impact.org/contact/)! 💪
|
| 270 |
"""
|
| 271 |
|
| 272 |
CITATION_LABEL = "BibTeX citation for EcoLogits Calculator and the EcoLogits library:"
|
| 273 |
CITATION_TEXT = r"""@misc{ecologits-calculator,
|
| 274 |
+
author={Samuel Rincé, Adrien Banse, Valentin Defour, and Chieh Hsu},
|
| 275 |
title={EcoLogits Calculator},
|
| 276 |
year={2025},
|
| 277 |
howpublished= {\url{https://huggingface.co/spaces/genai-impact/ecologits-calculator}},
|
src/data/electricity_mix.csv
CHANGED
|
@@ -1,4 +1,7 @@
|
|
| 1 |
name,unit,source,WOR,EEE,ZWE,ZMB,ZAF,YEM,VNM,VEN,UZB,URY,USA,UKR,TZA,TWN,TTO,TUR,TUN,TKM,TJK,THA,TGO,SYR,SLV,SEN,SVK,SVN,SGP,SWE,SDN,SAU,RUS,SCG,ROU,QAT,PRY,PRT,POL,PAK,PHL,PER,PAN,OMN,NZL,NPL,NOR,NLD,NIC,NGA,NAM,MOZ,MYS,MEX,MLT,MNG,MMR,MKD,MDA,MAR,LBY,LVA,LUX,LTU,LKA,LBN,KAZ,KWT,KOR,PRK,KHM,KGZ,KEN,JPN,JOR,JAM,ITA,ISL,IRN,IRQ,IND,ISR,IRL,IDN,HUN,HTI,HRV,HND,HKG,GTM,GRC,GIB,GHA,GEO,GBR,GAB,FRA,FIN,ETH,ESP,ERI,EGY,EST,ECU,DZA,DOM,DNK,DEU,CZE,CYP,CUB,CRI,COL,CHN,CMR,CHL,CIV,CHE,COG,COD,CAN,BLR,BWA,BRA,BOL,BRN,BEN,BHR,BGR,BEL,BGD,BIH,AZE,AUS,AUT,ARG,AGO,ANT,ARM,ALB,ARE
|
| 2 |
-
adpe,kg
|
| 3 |
pe,MJ,ADPf / (1-%renewable_energy),9.988,12.873,16.122,1.798,11.732,16.250,11.238,15.163,17.367,107.570,11.358,12.936,9.305,11.439,14.289,16.150,12.902,23.300,19.165,10.414,21.978,16.989,13.012,14.516,11.680,12.146,10.477,11.026,29.629,14.058,13.200,14.242,15.585,11.916,0.020,14.153,13.178,16.175,11.120,8.211,16.364,22.306,24.731,0.396,4.952,8.511,24.696,11.279,468.150,0.206,12.268,11.775,19.374,15.114,14.132,19.120,18.429,11.702,19.116,8.249,10.128,21.043,12.116,12.341,13.260,12.753,10.199,32.793,34.655,15.380,68.996,10.718,13.677,14.799,12.656,0.013,15.022,20.372,20.363,10.023,10.706,11.603,11.784,20.167,18.548,15.762,,14.340,14.487,,10.097,10.425,13.579,28.341,11.289,11.275,36.133,12.090,13.289,10.195,16.334,20.908,16.376,12.412,16.824,16.260,12.517,13.118,17.317,45.996,7.312,14.119,10.807,11.348,14.783,11.782,34.147,0.097,11.987,13.194,19.642,9.031,11.587,15.689,14.337,14.036,14.375,10.776,12.935,21.705,12.831,16.908,11.036,10.049,16.972,,13.380,0.201,19.032
|
| 4 |
-
gwp,kg
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
name,unit,source,WOR,EEE,ZWE,ZMB,ZAF,YEM,VNM,VEN,UZB,URY,USA,UKR,TZA,TWN,TTO,TUR,TUN,TKM,TJK,THA,TGO,SYR,SLV,SEN,SVK,SVN,SGP,SWE,SDN,SAU,RUS,SCG,ROU,QAT,PRY,PRT,POL,PAK,PHL,PER,PAN,OMN,NZL,NPL,NOR,NLD,NIC,NGA,NAM,MOZ,MYS,MEX,MLT,MNG,MMR,MKD,MDA,MAR,LBY,LVA,LUX,LTU,LKA,LBN,KAZ,KWT,KOR,PRK,KHM,KGZ,KEN,JPN,JOR,JAM,ITA,ISL,IRN,IRQ,IND,ISR,IRL,IDN,HUN,HTI,HRV,HND,HKG,GTM,GRC,GIB,GHA,GEO,GBR,GAB,FRA,FIN,ETH,ESP,ERI,EGY,EST,ECU,DZA,DOM,DNK,DEU,CZE,CYP,CUB,CRI,COL,CHN,CMR,CHL,CIV,CHE,COG,COD,CAN,BLR,BWA,BRA,BOL,BRN,BEN,BHR,BGR,BEL,BGD,BIH,AZE,AUS,AUT,ARG,AGO,ANT,ARM,ALB,ARE
|
| 2 |
+
adpe,kg eq. Sb,ADEME Base IMPACTS ®,0.0000000737708,0.0000000642317,0.000000109502,0.000000162193,0.0000000862445,0.0000000163908,0.0000000945573,0.000000112811,0.000000103681,0.000000104586,0.0000000985548,0.0000000647907,0.000000132261,0.0000000578088,0.000000064552,0.0000000749765,0.0000000177021,0.000000131822,0.000000152621,0.0000000569593,0.000000134255,0.0000000268396,0.0000000472135,0.0000000470662,0.0000000606109,0.0000000992283,0.0000000198459,0.0000000777062,0.0000000955701,0.0000000134206,0.0000000960312,0.000000132772,0.0000000981761,0.00000001324,0.000000149181,0.0000000341863,0.000000101946,0.0000000842952,0.0000000595304,0.0000000952688,0.0000000790553,0.0000000374073,0.0000000720474,0.000000238273,0.000000127486,0.0000000329318,0.0000000414983,0.0000000621,0.000000128285,0.000000148382,0.000000044938,0.0000000578358,0.000000049475,0.000000176361,0.000000152699,0.000000119873,0.000000110674,0.0000000641089,0.0000000206592,0.000000153757,0.000000105692,0.0000000294596,0.0000000986932,0.0000000182134,0.000000135386,0.0000000141168,0.0000000518017,0.000000117457,0.0000000319202,0.000000181827,0.0000000958533,0.0000000596578,0.0000000147031,0.0000000196047,0.00000005439,0.0000000781905,0.0000000220304,0.0000000404306,0.000000100099,0.0000000610194,0.0000000219257,0.0000000610451,0.0000000644587,0.0000000937057,0.000000153989,0.0000000649373,0.0000000816213,0.0000000803251,0.0000000691645,0.0000000286211,0.000000156003,0.000000137999,0.0000000370973,0.000000113843,0.0000000485798,0.0000000805114,0.000000174161,0.0000000518326,0.0000000512406,0.000000033925,0.0000000990171,0.000000127168,0.0000000216438,0.0000000429285,0.0000000157411,0.0000000878733,0.0000000817565,0.0000000448771,0.0000000299542,0.0000000863908,0.000000122031,0.0000000851552,0.000000146313,0.000000105851,0.0000000949004,0.000000100467,0.000000265575,0.000000174647,0.0000000993179,0.0000000840478,0.0000000866014,0.00000010962,0.0000000969793,0.0000000185641,0.0000000239702,0.0000000135014,0.0000000823611,0.0000000337201,0.0000000394158,0.000000148007,0.000000092567,0.0000000790846,0.000000141124,0.0000000768612,0.000000124074,0.0000000449103,0.0000000854245,0.000000229556,0.0000000141548
|
| 3 |
pe,MJ,ADPf / (1-%renewable_energy),9.988,12.873,16.122,1.798,11.732,16.250,11.238,15.163,17.367,107.570,11.358,12.936,9.305,11.439,14.289,16.150,12.902,23.300,19.165,10.414,21.978,16.989,13.012,14.516,11.680,12.146,10.477,11.026,29.629,14.058,13.200,14.242,15.585,11.916,0.020,14.153,13.178,16.175,11.120,8.211,16.364,22.306,24.731,0.396,4.952,8.511,24.696,11.279,468.150,0.206,12.268,11.775,19.374,15.114,14.132,19.120,18.429,11.702,19.116,8.249,10.128,21.043,12.116,12.341,13.260,12.753,10.199,32.793,34.655,15.380,68.996,10.718,13.677,14.799,12.656,0.013,15.022,20.372,20.363,10.023,10.706,11.603,11.784,20.167,18.548,15.762,,14.340,14.487,,10.097,10.425,13.579,28.341,11.289,11.275,36.133,12.090,13.289,10.195,16.334,20.908,16.376,12.412,16.824,16.260,12.517,13.118,17.317,45.996,7.312,14.119,10.807,11.348,14.783,11.782,34.147,0.097,11.987,13.194,19.642,9.031,11.587,15.689,14.337,14.036,14.375,10.776,12.935,21.705,12.831,16.908,11.036,10.049,16.972,,13.380,0.201,19.032
|
| 4 |
+
gwp,kg eq. CO2,ADEME Base IMPACTS ®,0.590478,0.509427,0.842811,0.0141304,1.17562,1.06777,0.555572,0.497373,0.81178,0.296953,0.67978,0.646745,0.475635,0.845351,0.933059,0.706988,0.80722,1.38296,0.0426743,0.646174,0.545455,1.08778,0.473128,1.1195,0.309341,0.498523,0.655825,0.0464664,1.12472,0.913677,0.66131,1.07808,0.664245,0.722125,0.241601,0.571172,1.15075,0.748727,0.761317,0.284364,0.53403,1.41292,0.293397,0.0841323,0.023754,0.544803,0.941626,0.693123,0.357253,0.00880732,0.832206,0.739214,1.31149,1.47192,0.48193,1.24074,1.04213,0.933694,1.35361,0.234273,0.490016,0.154229,0.709185,0.883627,1.128,0.885084,0.599585,0.797361,1.41054,0.156039,0.589603,0.540891,0.781372,1.07345,0.621329,0.0194609,0.930385,1.48728,1.58299,0.901842,0.648118,0.875394,0.541558,1.3858,0.535759,0.692837,0.95888,0.645801,1.13127,0.977477,0.540126,0.132046,0.602137,0.732511,0.0813225,0.322068,0.251299,0.467803,1.13153,0.587775,1.51492,0.627714,1.02318,0.909252,0.633534,0.657374,0.799077,0.978041,1.28325,0.224471,0.214014,1.05738,0.456622,0.574415,0.928583,0.0448568,0.904053,0.0613102,0.238191,0.795697,2.12572,0.278647,0.585131,0.997577,1.19128,0.804567,0.827087,0.256537,0.795168,1.56025,0.726126,1.12326,0.245573,0.476811,0.412014,1.13161,0.252002,0.0207635,1.09088
|
| 5 |
+
water_wwf,L/kWh,World Resource Institute Guidance for Calculating Water Use Embedded in Purchased Electricity 2020 ,2216,2705.4,,,,,,,,,386,942,,,,1374,,,,833,,,,,1033,14807,,3777,,,2067,,454,,,1472,216,,,,,,1741,,8285,696,,,,,2472,469,87,,,,,,,7525,1393,3051,,,,,257,,,,,1855,,,3524,,,,2373,,212,1605,1525,,,,,,519,,,,167,,2464,2161,,295,,,765,,,,1374,1419,791,57,,,,606,,458,,8331,,,2850,,,893,,,,,379,621,,,,155,14145,1.291,,,,,0
|
| 6 |
+
water_wcf,L/kWh,World Resource Institute Guidance for Calculating Water Use Embedded in Purchased Electricity 2020,5.04,4.48,,,,,,,,,3.14,2.12,,,,4.92,,,,2.88,,,,,5.79,2.99,,6.02,,,3.44,,7.34,,,9.58,2.5,,,,,,14.95,,6.66,3.44,,,,,1.67,5.3,1.14,,,,,,,2.54,12.79,5.9,,,,,1.89,,,,,2.31,,,4.84,,,,3.44,,1.48,2.27,3.67,,,,,,5.15,,,,2.35,,3.67,4.54,,6.21,,,2.2,,,,3.18,1.93,3.22,1.29,,,,6.02,,10.52,,5.68,,,8.18,,,18.58,,,,,4.62,2.61,,,,4.73,5.72,11.47,,,,,0
|
| 7 |
+
|
src/electricity_mix.py
CHANGED
|
@@ -2,6 +2,8 @@ from csv import DictReader
|
|
| 2 |
import pandas as pd
|
| 3 |
|
| 4 |
PATH = "src/data/electricity_mix.csv"
|
|
|
|
|
|
|
| 5 |
|
| 6 |
COUNTRY_CODES = [
|
| 7 |
("🌎 World", "WOR"),
|
|
@@ -145,7 +147,8 @@ COUNTRY_CODES = [
|
|
| 145 |
("🇦🇪 United Arab Emirates", "ARE")
|
| 146 |
]
|
| 147 |
|
| 148 |
-
|
|
|
|
| 149 |
def find_electricity_mix(code: str):
|
| 150 |
# TODO: Maybe more optimal to construct database at the beginning of the app
|
| 151 |
# in the same fashion as find_model
|
|
@@ -153,7 +156,7 @@ def find_electricity_mix(code: str):
|
|
| 153 |
with open(PATH) as fd:
|
| 154 |
csv = DictReader(fd)
|
| 155 |
for row in csv:
|
| 156 |
-
res += [
|
| 157 |
return res
|
| 158 |
|
| 159 |
def dataframe_electricity_mix(countries: list):
|
|
@@ -172,4 +175,5 @@ def dataframe_electricity_mix(countries: list):
|
|
| 172 |
index='country',
|
| 173 |
values='value')
|
| 174 |
|
| 175 |
-
return df
|
|
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
|
| 4 |
PATH = "src/data/electricity_mix.csv"
|
| 5 |
+
#ATTENTION ! Il a deux fichiers avec le même nom, un dans data/electricity_mix.csv et l'autre dans src/data/electricity_mix.csv
|
| 6 |
+
#vérifie que je modifie le bon fichier
|
| 7 |
|
| 8 |
COUNTRY_CODES = [
|
| 9 |
("🌎 World", "WOR"),
|
|
|
|
| 147 |
("🇦🇪 United Arab Emirates", "ARE")
|
| 148 |
]
|
| 149 |
|
| 150 |
+
#faut que j'acquris plus de données sur ça. on manque des données sur beacoup de pays
|
| 151 |
+
#pour les pays qui manquent des centres de données, comme beaucoup en Afrique, qui mène leurs requêts ?
|
| 152 |
def find_electricity_mix(code: str):
|
| 153 |
# TODO: Maybe more optimal to construct database at the beginning of the app
|
| 154 |
# in the same fashion as find_model
|
|
|
|
| 156 |
with open(PATH) as fd:
|
| 157 |
csv = DictReader(fd)
|
| 158 |
for row in csv:
|
| 159 |
+
res += [row[code]]
|
| 160 |
return res
|
| 161 |
|
| 162 |
def dataframe_electricity_mix(countries: list):
|
|
|
|
| 175 |
index='country',
|
| 176 |
values='value')
|
| 177 |
|
| 178 |
+
return df
|
| 179 |
+
|
src/expert.py
CHANGED
|
@@ -82,12 +82,28 @@ def expert_mode():
|
|
| 82 |
col4, col5, col6 = st.columns(3)
|
| 83 |
|
| 84 |
with col4:
|
| 85 |
-
|
|
|
|
| 86 |
#disp_ranges = st.toggle('Display impact ranges', False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
with col5:
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
with col6:
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
impacts = compute_llm_impacts(model_active_parameter_count=active_params,
|
| 93 |
model_total_parameter_count=total_params,
|
|
@@ -104,7 +120,7 @@ def expert_mode():
|
|
| 104 |
|
| 105 |
st.markdown('<h3 align="center">Environmental Impacts</h2>', unsafe_allow_html = True)
|
| 106 |
|
| 107 |
-
display_impacts(impacts)
|
| 108 |
|
| 109 |
with st.expander('⚖️ Usage vs Embodied'):
|
| 110 |
|
|
@@ -121,9 +137,11 @@ def expert_mode():
|
|
| 121 |
names = ['usage', 'embodied'],
|
| 122 |
title = 'GHG emissions',
|
| 123 |
color_discrete_sequence=["#00BF63", "#0B3B36"],
|
| 124 |
-
width =
|
| 125 |
)
|
| 126 |
-
fig_gwp.update_layout(
|
|
|
|
|
|
|
| 127 |
|
| 128 |
st.plotly_chart(fig_gwp)
|
| 129 |
|
|
@@ -133,10 +151,11 @@ def expert_mode():
|
|
| 133 |
names = ['usage', 'embodied'],
|
| 134 |
title = 'Abiotic depletion',
|
| 135 |
color_discrete_sequence=["#0B3B36","#00BF63"],
|
| 136 |
-
width =
|
|
|
|
| 137 |
fig_adpe.update_layout(
|
| 138 |
showlegend=False,
|
| 139 |
-
title_x=0.
|
| 140 |
|
| 141 |
st.plotly_chart(fig_adpe)
|
| 142 |
|
|
@@ -146,8 +165,11 @@ def expert_mode():
|
|
| 146 |
names = ['usage', 'embodied'],
|
| 147 |
title = 'Primary energy',
|
| 148 |
color_discrete_sequence=["#00BF63", "#0B3B36"],
|
| 149 |
-
width =
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
st.plotly_chart(fig_pe)
|
| 153 |
|
|
@@ -165,23 +187,59 @@ def expert_mode():
|
|
| 165 |
|
| 166 |
df_comp = dataframe_electricity_mix(countries_to_compare)
|
| 167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
impact_type = st.selectbox(
|
| 169 |
label='Select an impact type to compare',
|
| 170 |
-
options=[x for x in
|
| 171 |
-
index=1
|
|
|
|
| 172 |
|
| 173 |
-
|
|
|
|
|
|
|
| 174 |
|
| 175 |
fig_2 = px.bar(
|
| 176 |
df_comp,
|
| 177 |
x = df_comp.index,
|
| 178 |
-
y =
|
| 179 |
-
text =
|
| 180 |
-
color =
|
| 181 |
)
|
| 182 |
|
| 183 |
st.plotly_chart(fig_2)
|
| 184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
except:
|
| 186 |
|
| 187 |
st.warning("Can't display chart with no values.")
|
|
|
|
| 82 |
col4, col5, col6 = st.columns(3)
|
| 83 |
|
| 84 |
with col4:
|
| 85 |
+
try:
|
| 86 |
+
mix_gwp = st.number_input('Electricity mix - GHG emissions [kgCO2eq / kWh]', float(find_electricity_mix([x[1] for x in COUNTRY_CODES if x[0] ==location][0])[2]), format="%0.6f")
|
| 87 |
#disp_ranges = st.toggle('Display impact ranges', False)
|
| 88 |
+
|
| 89 |
+
except:
|
| 90 |
+
mix_gwp = st.number_input('Electricity mix - GHG emissions [kgCO2eq / kWh]', float(find_electricity_mix(["WOR"][0])[2]), format="%0.6f")
|
| 91 |
+
st.warning(f"Lacking data on {location}, showing global average data.")
|
| 92 |
+
|
| 93 |
with col5:
|
| 94 |
+
try:
|
| 95 |
+
mix_adpe = st.number_input('Electricity mix - Abiotic resources [kgSbeq / kWh]', float(find_electricity_mix([x[1] for x in COUNTRY_CODES if x[0] ==location][0])[0]), format="%0.13f")
|
| 96 |
+
except:
|
| 97 |
+
mix_adpe = st.number_input('Electricity mix - Abiotic resources [kgSbeq / kWh]', float(find_electricity_mix(["WOR"][0])[0]), format="%0.13f")
|
| 98 |
+
st.warning(f"Lacking data on {location}, showing global average data.")
|
| 99 |
+
|
| 100 |
with col6:
|
| 101 |
+
try:
|
| 102 |
+
mix_pe = st.number_input('Electricity mix - Primary energy [MJ / kWh]', float(find_electricity_mix([x[1] for x in COUNTRY_CODES if x[0] ==location][0])[1]), format="%0.3f")
|
| 103 |
+
except:
|
| 104 |
+
mix_pe = st.number_input('Electricity mix - Primary energy [MJ / kWh]', float(find_electricity_mix(["WOR"][0])[1]), format="%0.3f")
|
| 105 |
+
st.warning(f"Lacking data on {location}, showing global average data.")
|
| 106 |
+
|
| 107 |
|
| 108 |
impacts = compute_llm_impacts(model_active_parameter_count=active_params,
|
| 109 |
model_total_parameter_count=total_params,
|
|
|
|
| 120 |
|
| 121 |
st.markdown('<h3 align="center">Environmental Impacts</h2>', unsafe_allow_html = True)
|
| 122 |
|
| 123 |
+
display_impacts(impacts, provider_exp, location)
|
| 124 |
|
| 125 |
with st.expander('⚖️ Usage vs Embodied'):
|
| 126 |
|
|
|
|
| 137 |
names = ['usage', 'embodied'],
|
| 138 |
title = 'GHG emissions',
|
| 139 |
color_discrete_sequence=["#00BF63", "#0B3B36"],
|
| 140 |
+
width = 400
|
| 141 |
)
|
| 142 |
+
fig_gwp.update_layout(
|
| 143 |
+
showlegend=False,
|
| 144 |
+
title_x=0.25)
|
| 145 |
|
| 146 |
st.plotly_chart(fig_gwp)
|
| 147 |
|
|
|
|
| 151 |
names = ['usage', 'embodied'],
|
| 152 |
title = 'Abiotic depletion',
|
| 153 |
color_discrete_sequence=["#0B3B36","#00BF63"],
|
| 154 |
+
width = 400
|
| 155 |
+
)
|
| 156 |
fig_adpe.update_layout(
|
| 157 |
showlegend=False,
|
| 158 |
+
title_x=0.25)
|
| 159 |
|
| 160 |
st.plotly_chart(fig_adpe)
|
| 161 |
|
|
|
|
| 165 |
names = ['usage', 'embodied'],
|
| 166 |
title = 'Primary energy',
|
| 167 |
color_discrete_sequence=["#00BF63", "#0B3B36"],
|
| 168 |
+
width = 400
|
| 169 |
+
)
|
| 170 |
+
fig_pe.update_layout(
|
| 171 |
+
showlegend=False,
|
| 172 |
+
title_x=0.25)
|
| 173 |
|
| 174 |
st.plotly_chart(fig_pe)
|
| 175 |
|
|
|
|
| 187 |
|
| 188 |
df_comp = dataframe_electricity_mix(countries_to_compare)
|
| 189 |
|
| 190 |
+
|
| 191 |
+
impact_metrices = [
|
| 192 |
+
"Abiotic Depletion Potential for Elements (Kilograms of antimony equivalent)",
|
| 193 |
+
"Primary energy demand (Megajoules)",
|
| 194 |
+
"Global Warming Potential (Kilograms of CO2 equivalent)",
|
| 195 |
+
"Water Withdrawal Factor (Liters/Kilowatt-hour)",
|
| 196 |
+
"Water Consumption Factor (Liters/Kilowatt-hour)"
|
| 197 |
+
]
|
| 198 |
+
|
| 199 |
+
impact_labels = {
|
| 200 |
+
impact_metrices[0] : "adpe (kg eq. Sb)",
|
| 201 |
+
impact_metrices[1] : "pe (MJ)",
|
| 202 |
+
impact_metrices[2] : "gwp (kg eq. CO2)",
|
| 203 |
+
impact_metrices[3] : "water_wwf (L/kWh)",
|
| 204 |
+
impact_metrices[4] : "water_wcf (L/kWh)"
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
impact_type = st.selectbox(
|
| 208 |
label='Select an impact type to compare',
|
| 209 |
+
options=[x for x in impact_labels], # les noms affichés à l'utilisateur
|
| 210 |
+
index=1
|
| 211 |
+
)
|
| 212 |
|
| 213 |
+
impact_type_used = impact_labels[impact_type]
|
| 214 |
+
|
| 215 |
+
df_comp.sort_values(by = impact_type_used, inplace = True)
|
| 216 |
|
| 217 |
fig_2 = px.bar(
|
| 218 |
df_comp,
|
| 219 |
x = df_comp.index,
|
| 220 |
+
y = impact_type_used,
|
| 221 |
+
text = impact_type_used,
|
| 222 |
+
color = impact_type_used
|
| 223 |
)
|
| 224 |
|
| 225 |
st.plotly_chart(fig_2)
|
| 226 |
|
| 227 |
+
impact_explanations = {
|
| 228 |
+
impact_metrices[0]:
|
| 229 |
+
"Measures the depletion of non-renewable resources (metals, minerals), expressed in kg of antimony equivalent (Sb). \
|
| 230 |
+
The enviornmental impact equates to that amount of antimony being extracted.",
|
| 231 |
+
impact_metrices[1]:
|
| 232 |
+
"Total amount of primary energy used (both renewable and non-renewable), expressed in megajoules (MJ).",
|
| 233 |
+
impact_metrices[2]:
|
| 234 |
+
"Potential contribution to climate change over a 100-year time horizon, expressed in kilograms of CO₂ equivalent.",
|
| 235 |
+
impact_metrices[3]:
|
| 236 |
+
"Total volume of water withdrawn throughout the process, expressed in liters (L).",
|
| 237 |
+
impact_metrices[4]:
|
| 238 |
+
"Volume of water actually consumed (not returned to the source), expressed in liters (L)."
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
st.info(impact_explanations[impact_type])
|
| 242 |
+
|
| 243 |
except:
|
| 244 |
|
| 245 |
st.warning("Can't display chart with no values.")
|
src/impacts.py
CHANGED
|
@@ -7,9 +7,16 @@ from src.utils import (
|
|
| 7 |
format_energy_eq_physical_activity,
|
| 8 |
format_gwp_eq_airplane_paris_nyc,
|
| 9 |
format_gwp_eq_streaming,
|
|
|
|
|
|
|
| 10 |
PhysicalActivity,
|
| 11 |
-
EnergyProduction
|
|
|
|
|
|
|
|
|
|
| 12 |
)
|
|
|
|
|
|
|
| 13 |
|
| 14 |
############################################################################################################
|
| 15 |
|
|
@@ -20,7 +27,7 @@ def get_impacts(model, active_params, total_params, mix_ghg, mix_adpe, mix_pe):
|
|
| 20 |
############################################################################################################
|
| 21 |
|
| 22 |
|
| 23 |
-
def display_impacts(impacts):
|
| 24 |
|
| 25 |
st.divider()
|
| 26 |
|
|
@@ -46,14 +53,43 @@ def display_impacts(impacts):
|
|
| 46 |
st.latex(f'\Large {impacts.pe.magnitude:.3g} \ \large {impacts.pe.units}')
|
| 47 |
st.markdown(f'<p align="center"><i>Evaluates the use of energy resources<i></p>', unsafe_allow_html = True)
|
| 48 |
|
| 49 |
-
|
|
|
|
| 50 |
st.markdown('<h4 align="center">🚰 Water</h4>', unsafe_allow_html = True)
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
st.markdown(f'<p align="center"><i>Evaluates the use of water<i></p>', unsafe_allow_html = True)
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
############################################################################################################
|
| 55 |
|
| 56 |
-
def display_equivalent(impacts):
|
| 57 |
|
| 58 |
st.divider()
|
| 59 |
|
|
@@ -61,7 +97,7 @@ def display_equivalent(impacts):
|
|
| 61 |
|
| 62 |
streaming_eq = format_gwp_eq_streaming(impacts.gwp)
|
| 63 |
|
| 64 |
-
col1, col2, col3 = st.columns(
|
| 65 |
|
| 66 |
with col1:
|
| 67 |
physical_activity, distance = format_energy_eq_physical_activity(impacts.energy)
|
|
@@ -86,14 +122,22 @@ def display_equivalent(impacts):
|
|
| 86 |
st.latex(f'\Large {streaming_eq.magnitude:.3g} \ \large {streaming_eq.units}')
|
| 87 |
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
st.divider()
|
| 90 |
|
| 91 |
st.markdown('<h3 align="center">What if 1% of the planet does this request everyday for 1 year ?</h3>', unsafe_allow_html = True)
|
| 92 |
st.markdown('<p align="center">If this use case is largely deployed around the world, the equivalent impacts would be the impacts of this request x 1% of 8 billion people x 365 days in a year.</p>', unsafe_allow_html = True)
|
| 93 |
|
| 94 |
-
|
| 95 |
|
| 96 |
-
with
|
| 97 |
|
| 98 |
electricity_production, count = format_energy_eq_electricity_production(impacts.energy)
|
| 99 |
if electricity_production == EnergyProduction.NUCLEAR:
|
|
@@ -102,15 +146,22 @@ def display_equivalent(impacts):
|
|
| 102 |
if electricity_production == EnergyProduction.WIND:
|
| 103 |
emoji = "💨️ "
|
| 104 |
name = "Wind turbines"
|
| 105 |
-
st.markdown(f'<h4 align="center">{emoji} {count.magnitude:.0f} {name} (yearly)</h4>', unsafe_allow_html = True)
|
| 106 |
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 107 |
|
| 108 |
-
with
|
| 109 |
ireland_count = format_energy_eq_electricity_consumption_ireland(impacts.energy)
|
| 110 |
-
st.markdown(f'<h4 align="center">🇮🇪 {ireland_count.magnitude:.3f} x
|
| 111 |
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 112 |
|
| 113 |
-
with
|
| 114 |
paris_nyc_airplane = format_gwp_eq_airplane_paris_nyc(impacts.gwp)
|
| 115 |
st.markdown(f'<h4 align="center">✈️ {round(paris_nyc_airplane.magnitude):,} Paris ↔ NYC</h4>', unsafe_allow_html = True)
|
| 116 |
-
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
format_energy_eq_physical_activity,
|
| 8 |
format_gwp_eq_airplane_paris_nyc,
|
| 9 |
format_gwp_eq_streaming,
|
| 10 |
+
format_water_eq_bottled_waters,
|
| 11 |
+
format_water_eq_olympic_sized_swimming_pool,
|
| 12 |
PhysicalActivity,
|
| 13 |
+
EnergyProduction,
|
| 14 |
+
AI_COMPANY_TO_DATA_CENTER_PROVIDER,
|
| 15 |
+
PROVIDER_PUE,
|
| 16 |
+
PROVIDER_WUE_ONSITE
|
| 17 |
)
|
| 18 |
+
from src.electricity_mix import COUNTRY_CODES, find_electricity_mix, dataframe_electricity_mix
|
| 19 |
+
|
| 20 |
|
| 21 |
############################################################################################################
|
| 22 |
|
|
|
|
| 27 |
############################################################################################################
|
| 28 |
|
| 29 |
|
| 30 |
+
def display_impacts(impacts, provider, location):
|
| 31 |
|
| 32 |
st.divider()
|
| 33 |
|
|
|
|
| 53 |
st.latex(f'\Large {impacts.pe.magnitude:.3g} \ \large {impacts.pe.units}')
|
| 54 |
st.markdown(f'<p align="center"><i>Evaluates the use of energy resources<i></p>', unsafe_allow_html = True)
|
| 55 |
|
| 56 |
+
|
| 57 |
+
with col_water: #je sais pas où se trouve magnitude ou impact, donc j'ai commencé par une approche locale
|
| 58 |
st.markdown('<h4 align="center">🚰 Water</h4>', unsafe_allow_html = True)
|
| 59 |
+
water = water_impact(impacts, provider, location)
|
| 60 |
+
if water >= 1 :
|
| 61 |
+
st.latex(f'\Large {water:.3g} \ \large {"Liters"}')
|
| 62 |
+
else :
|
| 63 |
+
st.latex(f'\Large {water * 1000 :.3g} \ \large {"mLiters"}')
|
| 64 |
st.markdown(f'<p align="center"><i>Evaluates the use of water<i></p>', unsafe_allow_html = True)
|
| 65 |
|
| 66 |
+
|
| 67 |
+
# WCF = E_server * [WUE_on-site + PUE * WUE_off-site] + embodied (embodied not yet implemented, embodied = T * WCF_embodied / lifetime)
|
| 68 |
+
# WCF : Water Consumption Footprint for the request
|
| 69 |
+
# E_server : energy cost at the server for the request
|
| 70 |
+
# WUE_on-site : Water usage efficiency at the data center
|
| 71 |
+
# PUE: Power usage efficiency at the data center
|
| 72 |
+
# WUE_off-site: Water usage efficiency of the local electricity mix
|
| 73 |
+
def water_impact(impacts, provider, location):
|
| 74 |
+
energy = impacts.energy.magnitude
|
| 75 |
+
PUE = PROVIDER_PUE[AI_COMPANY_TO_DATA_CENTER_PROVIDER[provider.lower()]]
|
| 76 |
+
WUE_onsite = PROVIDER_WUE_ONSITE[AI_COMPANY_TO_DATA_CENTER_PROVIDER[provider.lower()]]
|
| 77 |
+
#WUE_on-site =
|
| 78 |
+
#pas de variation régionale pour le simulateur simple mais oui pour le simulateur expert mode
|
| 79 |
+
try:
|
| 80 |
+
WUE_offsite = float(find_electricity_mix([x[1] for x in COUNTRY_CODES if x[0] ==location][0])[4])
|
| 81 |
+
except :
|
| 82 |
+
WUE_offsite = float(find_electricity_mix(["WOR"][0])[4])
|
| 83 |
+
st.warning(f"Lacking data on {location}, showing global average data.")
|
| 84 |
+
|
| 85 |
+
water_consumption = energy * (WUE_onsite + PUE * WUE_offsite) /1000 #5.04 est la valeur WUF moyenne du globe
|
| 86 |
+
|
| 87 |
+
#/1000 parce que les WUE et PUE sont en kWh
|
| 88 |
+
return water_consumption
|
| 89 |
+
|
| 90 |
############################################################################################################
|
| 91 |
|
| 92 |
+
def display_equivalent(impacts, provider, location):
|
| 93 |
|
| 94 |
st.divider()
|
| 95 |
|
|
|
|
| 97 |
|
| 98 |
streaming_eq = format_gwp_eq_streaming(impacts.gwp)
|
| 99 |
|
| 100 |
+
col1, col2, col3, col4 = st.columns(4)
|
| 101 |
|
| 102 |
with col1:
|
| 103 |
physical_activity, distance = format_energy_eq_physical_activity(impacts.energy)
|
|
|
|
| 122 |
st.latex(f'\Large {streaming_eq.magnitude:.3g} \ \large {streaming_eq.units}')
|
| 123 |
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|
| 124 |
|
| 125 |
+
with col4:
|
| 126 |
+
water = water_impact(impacts, provider, location)
|
| 127 |
+
water_eq = format_water_eq_bottled_waters(water)
|
| 128 |
+
st.markdown(f'<h4 align="center">🚰 Bottled waters</h4>', unsafe_allow_html = True)
|
| 129 |
+
st.latex(f'\Large {water_eq:.3g} \ \large {"bottles"}')
|
| 130 |
+
st.markdown(f'<p align="center"><i>Based on water consumption, measured in 0.75 L bottles.<i></p>', unsafe_allow_html = True)
|
| 131 |
+
|
| 132 |
+
|
| 133 |
st.divider()
|
| 134 |
|
| 135 |
st.markdown('<h3 align="center">What if 1% of the planet does this request everyday for 1 year ?</h3>', unsafe_allow_html = True)
|
| 136 |
st.markdown('<p align="center">If this use case is largely deployed around the world, the equivalent impacts would be the impacts of this request x 1% of 8 billion people x 365 days in a year.</p>', unsafe_allow_html = True)
|
| 137 |
|
| 138 |
+
col5, col6, col7, col8 = st.columns(4)
|
| 139 |
|
| 140 |
+
with col5:
|
| 141 |
|
| 142 |
electricity_production, count = format_energy_eq_electricity_production(impacts.energy)
|
| 143 |
if electricity_production == EnergyProduction.NUCLEAR:
|
|
|
|
| 146 |
if electricity_production == EnergyProduction.WIND:
|
| 147 |
emoji = "💨️ "
|
| 148 |
name = "Wind turbines"
|
| 149 |
+
st.markdown(f'<h4 align="center">{emoji} {count.magnitude:.0f} {name} <span style="font-size: 12px">\n (yearly ⚡️ production)</span></h2></h4>', unsafe_allow_html = True)
|
| 150 |
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 151 |
|
| 152 |
+
with col6:
|
| 153 |
ireland_count = format_energy_eq_electricity_consumption_ireland(impacts.energy)
|
| 154 |
+
st.markdown(f'<h4 align="center">🇮🇪 {ireland_count.magnitude:.3f} x Irelands <span style="font-size: 12px">\n (yearly ⚡️ consumption)</span></h2></h4>', unsafe_allow_html = True)
|
| 155 |
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 156 |
|
| 157 |
+
with col7:
|
| 158 |
paris_nyc_airplane = format_gwp_eq_airplane_paris_nyc(impacts.gwp)
|
| 159 |
st.markdown(f'<h4 align="center">✈️ {round(paris_nyc_airplane.magnitude):,} Paris ↔ NYC</h4>', unsafe_allow_html = True)
|
| 160 |
+
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|
| 161 |
+
|
| 162 |
+
with col8:
|
| 163 |
+
water = water_impact(impacts, provider, location)
|
| 164 |
+
water_eq = format_water_eq_olympic_sized_swimming_pool(water)
|
| 165 |
+
st.markdown(f'<h4 align="center">🏊🏼 {round(water_eq):,} Olympic-sized swimming pools</h4>', unsafe_allow_html = True)
|
| 166 |
+
st.markdown(f'<p align="center"><i>Based on water consumption<i></p>', unsafe_allow_html = True)
|
| 167 |
+
|
src/utils.py
CHANGED
|
@@ -27,6 +27,9 @@ u.define('km = kilometer')
|
|
| 27 |
u.define('s = second')
|
| 28 |
u.define('min = minute')
|
| 29 |
u.define('h = hour')
|
|
|
|
|
|
|
|
|
|
| 30 |
q = u.Quantity
|
| 31 |
|
| 32 |
@dataclass
|
|
@@ -35,6 +38,7 @@ class QImpacts:
|
|
| 35 |
gwp: Quantity
|
| 36 |
adpe: Quantity
|
| 37 |
pe: Quantity
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
class PhysicalActivity(str, Enum):
|
|
@@ -69,6 +73,8 @@ EV_ENERGY_EQ = q("0.17 kWh / km")
|
|
| 69 |
# From https://impactco2.fr/outils/comparateur?value=1&comparisons=streamingvideo
|
| 70 |
STREAMING_GWP_EQ = q("15.6 h / kgCO2eq")
|
| 71 |
|
|
|
|
|
|
|
| 72 |
# From https://ourworldindata.org/population-growth
|
| 73 |
ONE_PERCENT_WORLD_POPULATION = 80_000_000
|
| 74 |
|
|
@@ -90,6 +96,57 @@ IRELAND_POPULATION_MILLION = 5
|
|
| 90 |
# From https://impactco2.fr/outils/comparateur?value=1&comparisons=&equivalent=avion-pny
|
| 91 |
AIRPLANE_PARIS_NYC_GWP_EQ = q("177000 kgCO2eq")
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
#####################################################################################
|
| 94 |
### IMPACTS FORMATING
|
| 95 |
#####################################################################################
|
|
@@ -115,6 +172,10 @@ def format_pe(pe: PE) -> Quantity:
|
|
| 115 |
val = val.to("kJ")
|
| 116 |
return val
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
def format_impacts(impacts: Impacts) -> QImpacts:
|
| 119 |
|
| 120 |
try:
|
|
@@ -126,7 +187,7 @@ def format_impacts(impacts: Impacts) -> QImpacts:
|
|
| 126 |
energy=format_energy(impacts.energy),
|
| 127 |
gwp=format_gwp(impacts.gwp),
|
| 128 |
adpe=format_adpe(impacts.adpe),
|
| 129 |
-
pe=format_pe(impacts.pe)
|
| 130 |
), impacts.usage, impacts.embodied
|
| 131 |
except: #when no range
|
| 132 |
return QImpacts(
|
|
@@ -199,6 +260,11 @@ def format_gwp_eq_streaming(gwp: Quantity) -> Quantity:
|
|
| 199 |
streaming_eq = streaming_eq.to("s")
|
| 200 |
return streaming_eq
|
| 201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
def format_energy_eq_electricity_production(energy: Quantity) -> tuple[EnergyProduction, Quantity]:
|
| 203 |
electricity_eq = energy * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
|
| 204 |
electricity_eq = electricity_eq.to("TWh")
|
|
@@ -216,4 +282,10 @@ def format_energy_eq_electricity_consumption_ireland(energy: Quantity) -> Quanti
|
|
| 216 |
def format_gwp_eq_airplane_paris_nyc(gwp: Quantity) -> Quantity:
|
| 217 |
gwp_eq = gwp * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
|
| 218 |
gwp_eq = gwp_eq.to("kgCO2eq")
|
| 219 |
-
return gwp_eq / AIRPLANE_PARIS_NYC_GWP_EQ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
u.define('s = second')
|
| 28 |
u.define('min = minute')
|
| 29 |
u.define('h = hour')
|
| 30 |
+
# u.define('L = liters')
|
| 31 |
+
# u.define('mL = milliliters')
|
| 32 |
+
# u.define('bottled waters')
|
| 33 |
q = u.Quantity
|
| 34 |
|
| 35 |
@dataclass
|
|
|
|
| 38 |
gwp: Quantity
|
| 39 |
adpe: Quantity
|
| 40 |
pe: Quantity
|
| 41 |
+
# water: Quantity
|
| 42 |
|
| 43 |
|
| 44 |
class PhysicalActivity(str, Enum):
|
|
|
|
| 73 |
# From https://impactco2.fr/outils/comparateur?value=1&comparisons=streamingvideo
|
| 74 |
STREAMING_GWP_EQ = q("15.6 h / kgCO2eq")
|
| 75 |
|
| 76 |
+
BOTTLED_WATERS_EQ = 0.75
|
| 77 |
+
|
| 78 |
# From https://ourworldindata.org/population-growth
|
| 79 |
ONE_PERCENT_WORLD_POPULATION = 80_000_000
|
| 80 |
|
|
|
|
| 96 |
# From https://impactco2.fr/outils/comparateur?value=1&comparisons=&equivalent=avion-pny
|
| 97 |
AIRPLANE_PARIS_NYC_GWP_EQ = q("177000 kgCO2eq")
|
| 98 |
|
| 99 |
+
# From https://www.patagoniaalliance.org/wp-content/uploads/2014/08/How-much-water-does-an-Olympic-sized-swimming-pool-hold.pdf
|
| 100 |
+
OLYMPIC_SWIMMING_POOL = 2500000 #2.5 million
|
| 101 |
+
|
| 102 |
+
# From https://docs.google.com/spreadsheets/d/1uj8yA601uBtJ7GSf7k96Lv1NoQBfsCnVmTCII2HgZvo/edit?gid=0#gid=0
|
| 103 |
+
# Google : https://www.gstatic.com/gumdrop/sustainability/google-2025-environmental-report.pdf
|
| 104 |
+
# Meta: https://sustainability.atmeta.com/wp-content/uploads/2024/08/Meta-2024-Sustainability-Report.pdf
|
| 105 |
+
# Microsoft: https://azure.microsoft.com/en-us/blog/how-microsoft-measures-datacenter-water-and-energy-use-to-improve-azure-cloud-sustainability/
|
| 106 |
+
# OVHCloud: https://corporate.ovhcloud.com/en/sustainability/environment/
|
| 107 |
+
# Scaleway: https://www-uploads.scaleway.com/Impact_Report2024_A4_EN_e63efcae20.pdf
|
| 108 |
+
# AWS: https://sustainability.aboutamazon.com/2023-report
|
| 109 |
+
# Equinix: https://www.equinix.com/resources/infopapers/2023-corporate-sustainability-report
|
| 110 |
+
PROVIDER_WUE_ONSITE = { #Water use efficiency on-site, as opposed to off-site generated energy
|
| 111 |
+
"Google" : 0.916,
|
| 112 |
+
"Meta": 0.18, # L/kWh, 2023
|
| 113 |
+
"Microsoft": 0.49, #2022
|
| 114 |
+
"OVHCloud": 0.37, #2024
|
| 115 |
+
"Scaleway": 0.216, #2023
|
| 116 |
+
"AWS" : 0.18, #2023
|
| 117 |
+
"Equinix" : 1.07 #2023
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
# Google https://www.gstatic.com/gumdrop/sustainability/google-2025-environmental-report.pdf
|
| 122 |
+
# Meta https://sustainability.atmeta.com/data-centers/#:~:text=Meta's%20operational%20data%20centers%2C%20on,Effectiveness%20(WUE)%20of%200.20.
|
| 123 |
+
# Microsoft https://azure.microsoft.com/en-us/blog/how-microsoft-measures-datacenter-water-and-energy-use-to-improve-azure-cloud-sustainability/
|
| 124 |
+
# OVHCloud https://corporate.ovhcloud.com/en/sustainability/environment/
|
| 125 |
+
# Scaleway https://www-uploads.scaleway.com/Impact_Report2024_A4_EN_e63efcae20.pdf
|
| 126 |
+
# AWS https://sustainability.aboutamazon.com/products-services/aws-cloud
|
| 127 |
+
# Equinix https://www.equinix.com/content/dam/eqxcorp/en_us/documents/resources/infopapers/ip_2023_sustainability_en.pdf
|
| 128 |
+
PROVIDER_PUE = { #Power use efficiency
|
| 129 |
+
"Google" : 1.09,
|
| 130 |
+
"Meta" : 1.09,
|
| 131 |
+
"Microsoft" : 1.18,
|
| 132 |
+
"OVHCloud" : 1.26,
|
| 133 |
+
"Scaleway" : 1.37,
|
| 134 |
+
"AWS" : 1.15,
|
| 135 |
+
"Equinix" : 1.42
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
AI_COMPANY_TO_DATA_CENTER_PROVIDER = { #A list that draws the connection between AI companies and their data center providers
|
| 139 |
+
"anthropic" : "Google",
|
| 140 |
+
"mistralai" : "OVHCloud",
|
| 141 |
+
"cohere" : "AWS",
|
| 142 |
+
"databricks" : "Microsoft",
|
| 143 |
+
"meta" : "Meta",
|
| 144 |
+
"google" : "Google",
|
| 145 |
+
"microsoft" : "Microsoft",
|
| 146 |
+
"openai" : "Microsoft"
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
|
| 150 |
#####################################################################################
|
| 151 |
### IMPACTS FORMATING
|
| 152 |
#####################################################################################
|
|
|
|
| 172 |
val = val.to("kJ")
|
| 173 |
return val
|
| 174 |
|
| 175 |
+
# def format_water(water: PE) -> Quantity:
|
| 176 |
+
# val = q(water.value, water.unit)
|
| 177 |
+
# return val
|
| 178 |
+
|
| 179 |
def format_impacts(impacts: Impacts) -> QImpacts:
|
| 180 |
|
| 181 |
try:
|
|
|
|
| 187 |
energy=format_energy(impacts.energy),
|
| 188 |
gwp=format_gwp(impacts.gwp),
|
| 189 |
adpe=format_adpe(impacts.adpe),
|
| 190 |
+
pe=format_pe(impacts.pe),
|
| 191 |
), impacts.usage, impacts.embodied
|
| 192 |
except: #when no range
|
| 193 |
return QImpacts(
|
|
|
|
| 260 |
streaming_eq = streaming_eq.to("s")
|
| 261 |
return streaming_eq
|
| 262 |
|
| 263 |
+
def format_water_eq_bottled_waters(water):
|
| 264 |
+
#water = water.to("bottled waters")
|
| 265 |
+
bottled_water_eq = water / BOTTLED_WATERS_EQ
|
| 266 |
+
return bottled_water_eq
|
| 267 |
+
|
| 268 |
def format_energy_eq_electricity_production(energy: Quantity) -> tuple[EnergyProduction, Quantity]:
|
| 269 |
electricity_eq = energy * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
|
| 270 |
electricity_eq = electricity_eq.to("TWh")
|
|
|
|
| 282 |
def format_gwp_eq_airplane_paris_nyc(gwp: Quantity) -> Quantity:
|
| 283 |
gwp_eq = gwp * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
|
| 284 |
gwp_eq = gwp_eq.to("kgCO2eq")
|
| 285 |
+
return gwp_eq / AIRPLANE_PARIS_NYC_GWP_EQ
|
| 286 |
+
|
| 287 |
+
def format_water_eq_olympic_sized_swimming_pool(water):
|
| 288 |
+
water_eq = water * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
|
| 289 |
+
return water_eq / OLYMPIC_SWIMMING_POOL
|
| 290 |
+
|
| 291 |
+
####################################################################################### MODELS PARAMETER####################################################################################
|