Added water consumption
#7
by
WayToGoHe
- opened
- app.py +11 -3
- data/electricity_mix.csv +4 -1
- src/__pycache__/__init__.cpython-311.pyc +0 -0
- src/__pycache__/calculator.cpython-311.pyc +0 -0
- src/__pycache__/company.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 +25 -22
- src/company.py +119 -0
- src/content.py +49 -33
- src/data/electricity_mix.csv +5 -2
- src/electricity_mix.py +7 -3
- src/expert.py +118 -27
- src/impacts.py +558 -30
- src/models.py +5 -1
- src/utils.py +177 -7
app.py
CHANGED
|
@@ -4,7 +4,8 @@ from src.content import (
|
|
| 4 |
HERO_TEXT,
|
| 5 |
ABOUT_TEXT,
|
| 6 |
CITATION_LABEL,
|
| 7 |
-
|
|
|
|
| 8 |
LICENCE_TEXT,
|
| 9 |
INTRO_TEXT,
|
| 10 |
METHODOLOGY_TEXT
|
|
@@ -13,6 +14,7 @@ from src.content import (
|
|
| 13 |
from src.expert import expert_mode
|
| 14 |
from src.calculator import calculator_mode
|
| 15 |
from src.token_estimator import token_estimator
|
|
|
|
| 16 |
|
| 17 |
st.set_page_config(
|
| 18 |
layout="wide",
|
|
@@ -27,9 +29,10 @@ st.html(HERO_TEXT)
|
|
| 27 |
|
| 28 |
st.markdown(INTRO_TEXT)
|
| 29 |
|
| 30 |
-
tab_calculator, tab_expert, tab_token, tab_method, tab_about = st.tabs(
|
| 31 |
[
|
| 32 |
'🧮 Calculator',
|
|
|
|
| 33 |
'🤓 Expert Mode',
|
| 34 |
'🪙 Tokens estimator',
|
| 35 |
'📖 Methodology',
|
|
@@ -41,6 +44,10 @@ with tab_calculator:
|
|
| 41 |
|
| 42 |
calculator_mode()
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
with tab_expert:
|
| 45 |
|
| 46 |
expert_mode()
|
|
@@ -59,6 +66,7 @@ with tab_about:
|
|
| 59 |
|
| 60 |
with st.expander('📚 Citation'):
|
| 61 |
st.html(CITATION_LABEL)
|
| 62 |
-
st.html(
|
|
|
|
| 63 |
|
| 64 |
st.html(LICENCE_TEXT)
|
|
|
|
| 4 |
HERO_TEXT,
|
| 5 |
ABOUT_TEXT,
|
| 6 |
CITATION_LABEL,
|
| 7 |
+
CITATION_TEXT_CALCULATOR,
|
| 8 |
+
CITATION_TEXT_SOFTWARE,
|
| 9 |
LICENCE_TEXT,
|
| 10 |
INTRO_TEXT,
|
| 11 |
METHODOLOGY_TEXT
|
|
|
|
| 14 |
from src.expert import expert_mode
|
| 15 |
from src.calculator import calculator_mode
|
| 16 |
from src.token_estimator import token_estimator
|
| 17 |
+
from src.company import company_mode
|
| 18 |
|
| 19 |
st.set_page_config(
|
| 20 |
layout="wide",
|
|
|
|
| 29 |
|
| 30 |
st.markdown(INTRO_TEXT)
|
| 31 |
|
| 32 |
+
tab_calculator, tab_company, tab_expert, tab_token, tab_method, tab_about = st.tabs(
|
| 33 |
[
|
| 34 |
'🧮 Calculator',
|
| 35 |
+
'👩🏻💻 Companies',
|
| 36 |
'🤓 Expert Mode',
|
| 37 |
'🪙 Tokens estimator',
|
| 38 |
'📖 Methodology',
|
|
|
|
| 44 |
|
| 45 |
calculator_mode()
|
| 46 |
|
| 47 |
+
with tab_company:
|
| 48 |
+
|
| 49 |
+
company_mode()
|
| 50 |
+
|
| 51 |
with tab_expert:
|
| 52 |
|
| 53 |
expert_mode()
|
|
|
|
| 66 |
|
| 67 |
with st.expander('📚 Citation'):
|
| 68 |
st.html(CITATION_LABEL)
|
| 69 |
+
st.html(CITATION_TEXT_CALCULATOR)
|
| 70 |
+
st.html(CITATION_TEXT_SOFTWARE)
|
| 71 |
|
| 72 |
st.html(LICENCE_TEXT)
|
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.24 kB). View file
|
|
|
src/__pycache__/company.cpython-311.pyc
ADDED
|
Binary file (8.09 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 (19.7 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 (19 kB). View file
|
|
|
src/__pycache__/impacts.cpython-311.pyc
ADDED
|
Binary file (26.8 kB). View file
|
|
|
src/__pycache__/models.cpython-311.pyc
ADDED
|
Binary file (5.28 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 (18.6 kB). View file
|
|
|
src/calculator.py
CHANGED
|
@@ -2,7 +2,7 @@ import streamlit as st
|
|
| 2 |
|
| 3 |
from ecologits.tracers.utils import llm_impacts
|
| 4 |
from src.impacts import get_impacts, display_impacts, display_equivalent
|
| 5 |
-
from src.utils import format_impacts
|
| 6 |
from src.content import WARNING_CLOSED_SOURCE, WARNING_MULTI_MODAL, WARNING_BOTH
|
| 7 |
from src.models import load_models
|
| 8 |
|
|
@@ -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(
|
|
@@ -45,28 +45,31 @@ def calculator_mode():
|
|
| 45 |
if df_filtered['warning_arch'].values[0] and df_filtered['warning_multi_modal'].values[0]:
|
| 46 |
st.warning(WARNING_BOTH)
|
| 47 |
|
| 48 |
-
try:
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
impacts, _, _ = format_impacts(impacts)
|
| 58 |
-
|
| 59 |
-
with st.container(border=True):
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 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 |
-
|
|
|
|
| 2 |
|
| 3 |
from ecologits.tracers.utils import llm_impacts
|
| 4 |
from src.impacts import get_impacts, display_impacts, display_equivalent
|
| 5 |
+
from src.utils import format_impacts, range_percent_impact_one_sided
|
| 6 |
from src.content import WARNING_CLOSED_SOURCE, WARNING_MULTI_MODAL, WARNING_BOTH
|
| 7 |
from src.models import load_models
|
| 8 |
|
|
|
|
| 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(
|
|
|
|
| 45 |
if df_filtered['warning_arch'].values[0] and df_filtered['warning_multi_modal'].values[0]:
|
| 46 |
st.warning(WARNING_BOTH)
|
| 47 |
|
| 48 |
+
#try:
|
| 49 |
|
| 50 |
+
impacts = llm_impacts(
|
| 51 |
+
provider=provider_raw,
|
| 52 |
+
model_name=model_raw,
|
| 53 |
+
output_token_count=[x[1] for x in PROMPTS if x[0] == output_tokens][0],
|
| 54 |
+
request_latency=100000
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
range_percent_impact_one_sided_calculated = range_percent_impact_one_sided(impacts)
|
| 59 |
+
impacts, _, _ = format_impacts(impacts)
|
| 60 |
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
+
with st.container(border=True):
|
| 63 |
+
|
| 64 |
+
st.markdown('<h3 align = "center">Environmental impacts</h3>', unsafe_allow_html=True)
|
| 65 |
+
st.markdown('<p align = "center">To understand how the environmental impacts are computed go to the 📖 Methodology tab.</p>', unsafe_allow_html=True)
|
| 66 |
+
display_impacts(impacts, provider, range_percent_impact_one_sided_calculated, location="🌎 World" )
|
| 67 |
+
|
| 68 |
+
with st.container(border=True):
|
| 69 |
|
| 70 |
+
st.markdown('<h3 align = "center">That\'s equivalent to ...</h3>', unsafe_allow_html=True)
|
| 71 |
+
st.markdown('<p align = "center">Making this request to the LLM is equivalent to the following actions :</p>', unsafe_allow_html=True)
|
| 72 |
+
display_equivalent(impacts, provider, location="🌎 World")
|
|
|
|
|
|
|
| 73 |
|
| 74 |
+
# except Exception as e:
|
| 75 |
+
# st.error('Could not find the model in the repository. Please try another model.')
|
src/company.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
from ecologits.tracers.utils import llm_impacts
|
| 4 |
+
from src.impacts import get_impacts, display_impacts_company, display_equivalent_company
|
| 5 |
+
from src.utils import format_impacts, range_percent_impact_one_sided
|
| 6 |
+
from src.content import WARNING_CLOSED_SOURCE, WARNING_MULTI_MODAL, WARNING_BOTH
|
| 7 |
+
from src.models import load_models
|
| 8 |
+
|
| 9 |
+
from src.constants import PROMPTS
|
| 10 |
+
|
| 11 |
+
def company_mode():
|
| 12 |
+
|
| 13 |
+
st.markdown("### 👩🏻💻 Calculator for companies")
|
| 14 |
+
|
| 15 |
+
with st.container(border=True):
|
| 16 |
+
|
| 17 |
+
df = load_models(filter_main=True)
|
| 18 |
+
|
| 19 |
+
col1, col2, col3 = st.columns(3)
|
| 20 |
+
|
| 21 |
+
with col1:
|
| 22 |
+
provider = st.selectbox(
|
| 23 |
+
label = 'Provider',
|
| 24 |
+
options = [x for x in df['provider_clean'].unique()],
|
| 25 |
+
index = 7,
|
| 26 |
+
key = 61
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
with col2:
|
| 30 |
+
model = st.selectbox(
|
| 31 |
+
label = 'Model',
|
| 32 |
+
options = [x for x in df['name_clean'].unique() if x in df[df['provider_clean'] == provider]['name_clean'].unique()],
|
| 33 |
+
key = 62
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
with col3:
|
| 37 |
+
output_tokens = st.selectbox(
|
| 38 |
+
'Example prompt',
|
| 39 |
+
[x[0] for x in PROMPTS],
|
| 40 |
+
key = 63
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
# WARNING DISPLAY
|
| 44 |
+
provider_raw = df[(df['provider_clean'] == provider) & (df['name_clean'] == model)]['provider'].values[0]
|
| 45 |
+
model_raw = df[(df['provider_clean'] == provider) & (df['name_clean'] == model)]['name'].values[0]
|
| 46 |
+
|
| 47 |
+
df_filtered = df[(df['provider_clean'] == provider) & (df['name_clean'] == model)]
|
| 48 |
+
|
| 49 |
+
if df_filtered['warning_arch'].values[0] and not df_filtered['warning_multi_modal'].values[0]:
|
| 50 |
+
st.warning(WARNING_CLOSED_SOURCE)
|
| 51 |
+
if df_filtered['warning_multi_modal'].values[0] and not df_filtered['warning_arch'].values[0]:
|
| 52 |
+
st.warning(WARNING_MULTI_MODAL)
|
| 53 |
+
if df_filtered['warning_arch'].values[0] and df_filtered['warning_multi_modal'].values[0]:
|
| 54 |
+
st.warning(WARNING_BOTH)
|
| 55 |
+
|
| 56 |
+
col4, col5, col6 = st.columns(3)
|
| 57 |
+
|
| 58 |
+
with col4:
|
| 59 |
+
company_size = st.number_input(
|
| 60 |
+
label="Company size (in number of employees)",
|
| 61 |
+
min_value=1,
|
| 62 |
+
value=10, # valeur par défaut
|
| 63 |
+
step=1,
|
| 64 |
+
key = 64
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
#TODO : lire la literature pour comprendre des chiffres en moyen pour remplisser comme defaut
|
| 68 |
+
#par example, entre 400 - 800 > entreprise taille moyenne, frequence correspondant : ...
|
| 69 |
+
with col5:
|
| 70 |
+
use_percentage = st.number_input(
|
| 71 |
+
label = 'What percentage of employees use LLM daily (in %)?',
|
| 72 |
+
min_value=0,
|
| 73 |
+
max_value=100,
|
| 74 |
+
value=75, # valeur par défaut
|
| 75 |
+
step=5,
|
| 76 |
+
key = 65
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
#TODO : lire la literature pour comprendre des chiffres en moyen pour remplisser comme defaut
|
| 80 |
+
#par example, entre 400 - 800 > entreprise taille moyenne, frequence correspondant : ...
|
| 81 |
+
with col6:
|
| 82 |
+
request_frequency = st.number_input(
|
| 83 |
+
label = 'How frequently do the employees use LLM (times per day)?',
|
| 84 |
+
min_value=1,
|
| 85 |
+
value=20, # valeur par défaut
|
| 86 |
+
step=5,
|
| 87 |
+
key = 66
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
company_multiplier = company_size * use_percentage/100 * request_frequency
|
| 91 |
+
|
| 92 |
+
try:
|
| 93 |
+
|
| 94 |
+
impacts = llm_impacts(
|
| 95 |
+
provider=provider_raw,
|
| 96 |
+
model_name=model_raw,
|
| 97 |
+
output_token_count=[x[1] for x in PROMPTS if x[0] == output_tokens][0],
|
| 98 |
+
request_latency=100000
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
range_percent_impact_one_sided_calculated = range_percent_impact_one_sided(impacts)
|
| 102 |
+
impacts, _, _ = format_impacts(impacts)
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
with st.container(border=True):
|
| 107 |
+
|
| 108 |
+
st.markdown('<h3 align = "center">Environmental impacts</h3>', unsafe_allow_html=True)
|
| 109 |
+
st.markdown('<p align = "center">To understand how the environmental impacts are computed go to the 📖 Methodology tab.</p>', unsafe_allow_html=True)
|
| 110 |
+
display_impacts_company(impacts, provider, company_multiplier, range_percent_impact_one_sided_calculated, location="🌎 World")
|
| 111 |
+
|
| 112 |
+
with st.container(border=True):
|
| 113 |
+
#TODO : corriger ça
|
| 114 |
+
st.markdown('<h3 align = "center">That\'s equivalent to ...</h3>', unsafe_allow_html=True)
|
| 115 |
+
st.markdown('<p align = "center">On the scale of the company, making this request to the LLM over a day is equivalent to the following actions :</p>', unsafe_allow_html=True)
|
| 116 |
+
display_equivalent_company(impacts, provider, company_multiplier, location="🌎 World")
|
| 117 |
+
|
| 118 |
+
except Exception as e:
|
| 119 |
+
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,44 @@ 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 +195,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 +214,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,46 +225,54 @@ 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 |
-
|
| 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}},
|
| 254 |
}
|
|
|
|
|
|
|
|
|
|
| 255 |
@software{ecologits,
|
| 256 |
-
author = {Samuel Rincé, Adrien Banse, Vinh Nguyen and
|
| 257 |
publisher = {GenAI Impact},
|
| 258 |
title = {EcoLogits: track the energy consumption and environmental footprint of using generative AI models through APIs.},
|
| 259 |
-
}
|
|
|
|
| 260 |
|
| 261 |
LICENCE_TEXT = """<p xmlns:cc="http://creativecommons.org/ns#" >
|
| 262 |
This work is licensed under
|
|
|
|
| 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 Climate Change 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.
|
| 180 |
+
|
| 181 |
+
Again, if you are interested in seeing the detailed calculations we employ, please consider checking out the methodology page on our website for [ecologits]https://ecologits.ai/latest/methodology/llm_inference/)!
|
| 182 |
+
|
| 183 |
### Principles, Data and Hypotheses
|
| 184 |
+
We use a **bottom-up methodology** to model impacts, meaning that we estimate the impacts of low-level physical
|
| 185 |
+
components to then estimate the impacts at software level (in our case an LLM inference). We also rely on **Life
|
| 186 |
+
Cycle Approach (LCA) proxies** to model both usage and embodied phases with multi-criteria impacts.
|
| 187 |
If you are interested in this approach we recommend you to read the following [Boavizta](https://boavizta.org/)
|
| 188 |
resources.
|
| 189 |
* [Digital & environment: How to evaluate server manufacturing footprint, beyond greenhouse gas emissions?](https://boavizta.org/en/blog/empreinte-de-la-fabrication-d-un-serveur)
|
|
|
|
| 195 |
* [Boavizta API](https://github.com/Boavizta/boaviztapi) to estimate server embodied impacts and base energy
|
| 196 |
consumption.
|
| 197 |
* [ADEME Base Empreinte®](https://base-empreinte.ademe.fr/) for electricity mix impacts per country.
|
| 198 |
+
* [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.
|
| 199 |
+
* [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.
|
| 200 |
Finally here are the **main hypotheses** we have made to compute the impacts.
|
| 201 |
* ⚠️ **We *"guesstimate"* the model architecture of proprietary LLMs when not disclosed by the provider.**
|
| 202 |
* Production setup: quantized models running on data center grade servers and GPUs such as A100.
|
| 203 |
* Electricity mix does not depend on time (help us enhance EcoLogits and work on this [issue](https://github.com/genai-impact/ecologits/issues/42))
|
| 204 |
+
* We are ignoring the following impacts: unused cloud resources, data center building, network and end-user devices... (for now)
|
| 205 |
## Equivalents
|
| 206 |
We have integrated impact equivalents to help people better understand the impacts and have reference points for
|
| 207 |
+
standard use cases in everyday activities.
|
| 208 |
### Request impacts
|
| 209 |
These equivalents are computed based on the request impacts only.
|
| 210 |
#### 🚶♂️➡️ Walking or 🏃♂️➡️ running distance
|
|
|
|
| 214 |
* 🚶♂️➡️ walking: $ 196\ kJ/km $ (speed of $ 3\ km/h $)
|
| 215 |
* 🏃♂️➡️ running: $ 294\ kJ/km $ (speed of $ 10\ km/h $)
|
| 216 |
We divide the request energy consumption by these values to compute the distance traveled.
|
| 217 |
+
#### 🔋 Electric vehicle distance
|
| 218 |
+
We compare the ⚡️ direct energy consumption with the energy consumer by an EV car. From
|
| 219 |
[selectra.info](https://selectra.info/energie/actualites/insolite/consommation-vehicules-electriques-france-2040) or
|
| 220 |
[tesla.com](https://www.tesla.com/fr_fr/support/power-consumption) we consider an average value of energy consumed per
|
| 221 |
kilometer of: $ 0.17\ kWh/km $.
|
|
|
|
| 225 |
[impactco2.fr](https://impactco2.fr/outils/comparateur?value=1&comparisons=streamingvideo), we consider that
|
| 226 |
$ 1\ kgCO2eq $ is equivalent to $ 15.6\ h $ of streaming.
|
| 227 |
We multiply that value by the GHG emissions of the request to get an equivalent in hours of video streaming.
|
| 228 |
+
#### 🚰 Bottled waters
|
| 229 |
+
We compare the water consumption to a standard 75cL water bottle.
|
| 230 |
### Scaled impacts
|
| 231 |
These equivalents are computed based on the request impacts scaled to a worldwide adoption use case. We imply that the
|
| 232 |
+
same request is done by 1% of the world population everyday for 1 year, and then compute impact equivalents.
|
| 233 |
$$
|
| 234 |
+
I_{scaled} = I_{request} * [1 \% \ \text{of 8 billion people on earth}] * 365\ \text{days}
|
| 235 |
$$
|
| 236 |
#### Number of 💨 wind turbines or ☢️ nuclear plants
|
| 237 |
+
We compare the ⚡️ scaled direct energy consumption by the energy production of wind turbines and nuclear power
|
| 238 |
plants. From [ecologie.gouv.fr](https://www.ecologie.gouv.fr/eolien-terrestre) we consider that a $ 2\ MW $ wind
|
| 239 |
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)
|
| 240 |
we learn that a $ 900\ MW $ nuclear power plant produces $ 6\ TWh $ a year.
|
| 241 |
We divide the scaled energy consumption by these values to get the number of wind turbines or nuclear power plants
|
| 242 |
needed.
|
| 243 |
#### Multiplier of 🇮🇪 Ireland electricity consumption
|
| 244 |
+
We compare the ⚡️ scaled direct energy consumption by the electricity consumption of Ireland per year. From
|
| 245 |
[wikipedia.org](https://en.wikipedia.org/wiki/List_of_countries_by_electricity_consumption) we consider the Ireland
|
| 246 |
electricity consumption to be $ 33\ TWh $ a year for a population of 5M.
|
| 247 |
+
We divide the scaled energy consumption by this value to get the equivalent number of "Irelands".
|
| 248 |
#### Number of ✈️ Paris ↔ New York City flights
|
| 249 |
+
We compare the 🌍 scaled GHG emissions of the request and of a return flight Paris ↔ New York City. From
|
| 250 |
[impactco2.fr](https://impactco2.fr/outils/comparateur?value=1&comparisons=&equivalent=avion-pny) we consider that a
|
| 251 |
return flight Paris → New York City → Paris for one passenger emits $ 1,770\ kgCO2eq $ and we consider an overall
|
| 252 |
average load of 100 passengers per flight.
|
| 253 |
We divide the scaled GHG emissions by this value to get the equivalent number of return flights.
|
| 254 |
+
#### Number of Olympic-sized swimming pools 🏊🏼
|
| 255 |
+
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/),
|
| 256 |
+
an Olympic-sized swimming pool holds about 2.5 million liters of water.
|
| 257 |
#### If you are motivated to help us test and enhance this methodology [contact us](https://genai-impact.org/contact/)! 💪
|
| 258 |
"""
|
| 259 |
|
| 260 |
CITATION_LABEL = "BibTeX citation for EcoLogits Calculator and the EcoLogits library:"
|
| 261 |
+
CITATION_TEXT_CALCULATOR = r"""@misc{ecologits-calculator,
|
| 262 |
+
author={Samuel Rincé, Adrien Banse, Valentin Defour, and Chieh Hsu},
|
| 263 |
title={EcoLogits Calculator},
|
| 264 |
year={2025},
|
| 265 |
howpublished= {\url{https://huggingface.co/spaces/genai-impact/ecologits-calculator}},
|
| 266 |
}
|
| 267 |
+
"""
|
| 268 |
+
|
| 269 |
+
CITATION_TEXT_SOFTWARE = r"""
|
| 270 |
@software{ecologits,
|
| 271 |
+
author = {Samuel Rincé, Adrien Banse, Vinh Nguyen, Luc Berton, and Chieh Hsu},
|
| 272 |
publisher = {GenAI Impact},
|
| 273 |
title = {EcoLogits: track the energy consumption and environmental footprint of using generative AI models through APIs.},
|
| 274 |
+
}
|
| 275 |
+
"""
|
| 276 |
|
| 277 |
LICENCE_TEXT = """<p xmlns:cc="http://creativecommons.org/ns#" >
|
| 278 |
This work is licensed under
|
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
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from ecologits.impacts.llm import compute_llm_impacts
|
| 3 |
|
| 4 |
-
from src.utils import format_impacts, average_range_impacts
|
| 5 |
from src.impacts import display_impacts
|
| 6 |
from src.electricity_mix import COUNTRY_CODES, find_electricity_mix, dataframe_electricity_mix
|
| 7 |
from src.models import load_models
|
|
@@ -32,6 +32,8 @@ def expert_mode():
|
|
| 32 |
key = 1
|
| 33 |
)
|
| 34 |
|
|
|
|
|
|
|
| 35 |
with col2:
|
| 36 |
model_exp = st.selectbox(
|
| 37 |
label = 'Model',
|
|
@@ -79,15 +81,40 @@ def expert_mode():
|
|
| 79 |
|
| 80 |
location = st.selectbox('Location', [x[0] for x in COUNTRY_CODES])
|
| 81 |
|
| 82 |
-
col4, col5
|
| 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,
|
|
@@ -95,16 +122,20 @@ def expert_mode():
|
|
| 95 |
request_latency=100000,
|
| 96 |
if_electricity_mix_gwp=mix_gwp,
|
| 97 |
if_electricity_mix_adpe=mix_adpe,
|
| 98 |
-
if_electricity_mix_pe=mix_pe
|
|
|
|
|
|
|
| 99 |
)
|
| 100 |
|
|
|
|
|
|
|
| 101 |
impacts, usage, embodied = format_impacts(impacts)
|
| 102 |
|
| 103 |
with st.container(border = True):
|
| 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 |
|
|
@@ -112,18 +143,19 @@ def expert_mode():
|
|
| 112 |
|
| 113 |
st.markdown('The usage impacts account for the electricity consumption of the model while the embodied impacts account for resource extraction (e.g., minerals and metals), manufacturing, and transportation of the hardware.')
|
| 114 |
|
| 115 |
-
col_ghg_comparison, col_adpe_comparison, col_pe_comparison = st.columns(
|
| 116 |
|
| 117 |
with col_ghg_comparison:
|
| 118 |
-
|
| 119 |
fig_gwp = px.pie(
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
)
|
| 126 |
-
fig_gwp.update_layout(
|
|
|
|
|
|
|
| 127 |
|
| 128 |
st.plotly_chart(fig_gwp)
|
| 129 |
|
|
@@ -132,12 +164,18 @@ def expert_mode():
|
|
| 132 |
values = [average_range_impacts(usage.adpe.value), average_range_impacts(embodied.adpe.value)],
|
| 133 |
names = ['usage', 'embodied'],
|
| 134 |
title = 'Abiotic depletion',
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
fig_adpe.update_layout(
|
| 138 |
showlegend=False,
|
| 139 |
-
title_x=0.
|
| 140 |
-
|
|
|
|
| 141 |
st.plotly_chart(fig_adpe)
|
| 142 |
|
| 143 |
with col_pe_comparison:
|
|
@@ -146,11 +184,28 @@ 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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
with st.expander('🌍️ Location impact'):
|
| 155 |
|
| 156 |
st.markdown('<h4 align="center">How can location impact the footprint ?</h4>', unsafe_allow_html = True)
|
|
@@ -165,23 +220,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 |
-
df_comp.sort_values(by =
|
| 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.")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from ecologits.impacts.llm import compute_llm_impacts
|
| 3 |
|
| 4 |
+
from src.utils import format_impacts, average_range_impacts, range_percent_impact_one_sided
|
| 5 |
from src.impacts import display_impacts
|
| 6 |
from src.electricity_mix import COUNTRY_CODES, find_electricity_mix, dataframe_electricity_mix
|
| 7 |
from src.models import load_models
|
|
|
|
| 32 |
key = 1
|
| 33 |
)
|
| 34 |
|
| 35 |
+
provider_selected = st.session_state[1].lower()
|
| 36 |
+
|
| 37 |
with col2:
|
| 38 |
model_exp = st.selectbox(
|
| 39 |
label = 'Model',
|
|
|
|
| 81 |
|
| 82 |
location = st.selectbox('Location', [x[0] for x in COUNTRY_CODES])
|
| 83 |
|
| 84 |
+
col4, col5 = st.columns(2)
|
| 85 |
|
| 86 |
with col4:
|
| 87 |
+
try:
|
| 88 |
+
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")
|
| 89 |
#disp_ranges = st.toggle('Display impact ranges', False)
|
| 90 |
+
|
| 91 |
+
except:
|
| 92 |
+
mix_gwp = st.number_input('Electricity mix - GHG emissions [kgCO2eq / kWh]', float(find_electricity_mix(["WOR"][0])[2]), format="%0.6f")
|
| 93 |
+
st.warning(f"Lacking data on {location}, showing global average data.")
|
| 94 |
+
|
| 95 |
with col5:
|
| 96 |
+
try:
|
| 97 |
+
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")
|
| 98 |
+
except:
|
| 99 |
+
mix_adpe = st.number_input('Electricity mix - Abiotic resources [kgSbeq / kWh]', float(find_electricity_mix(["WOR"][0])[0]), format="%0.13f")
|
| 100 |
+
st.warning(f"Lacking data on {location}, showing global average data.")
|
| 101 |
+
|
| 102 |
+
col6, col7 = st.columns(2)
|
| 103 |
+
|
| 104 |
with col6:
|
| 105 |
+
try:
|
| 106 |
+
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")
|
| 107 |
+
except:
|
| 108 |
+
mix_pe = st.number_input('Electricity mix - Primary energy [MJ / kWh]', float(find_electricity_mix(["WOR"][0])[1]), format="%0.3f")
|
| 109 |
+
st.warning(f"Lacking data on {location}, showing global average data.")
|
| 110 |
+
|
| 111 |
+
with col7:
|
| 112 |
+
try:
|
| 113 |
+
mix_water = st.number_input('Electricity mix - Water consumption factor [L / kWh]', float(find_electricity_mix([x[1] for x in COUNTRY_CODES if x[0] ==location][0])[4]), format="%0.3f")
|
| 114 |
+
except:
|
| 115 |
+
mix_water = st.number_input('Electricity mix - Water consumption factor [L / kWh]', float(find_electricity_mix(["WOR"][0])[4]), format="%0.3f")
|
| 116 |
+
st.warning(f"Lacking data on {location}, showing global average data.")
|
| 117 |
+
|
| 118 |
|
| 119 |
impacts = compute_llm_impacts(model_active_parameter_count=active_params,
|
| 120 |
model_total_parameter_count=total_params,
|
|
|
|
| 122 |
request_latency=100000,
|
| 123 |
if_electricity_mix_gwp=mix_gwp,
|
| 124 |
if_electricity_mix_adpe=mix_adpe,
|
| 125 |
+
if_electricity_mix_pe=mix_pe,
|
| 126 |
+
if_electricity_mix_wcf=mix_water,
|
| 127 |
+
provider = provider_selected
|
| 128 |
)
|
| 129 |
|
| 130 |
+
|
| 131 |
+
range_percent_impact_one_sided_calculated = range_percent_impact_one_sided(impacts)
|
| 132 |
impacts, usage, embodied = format_impacts(impacts)
|
| 133 |
|
| 134 |
with st.container(border = True):
|
| 135 |
|
| 136 |
st.markdown('<h3 align="center">Environmental Impacts</h2>', unsafe_allow_html = True)
|
| 137 |
|
| 138 |
+
display_impacts(impacts, provider_exp, range_percent_impact_one_sided_calculated, location)
|
| 139 |
|
| 140 |
with st.expander('⚖️ Usage vs Embodied'):
|
| 141 |
|
|
|
|
| 143 |
|
| 144 |
st.markdown('The usage impacts account for the electricity consumption of the model while the embodied impacts account for resource extraction (e.g., minerals and metals), manufacturing, and transportation of the hardware.')
|
| 145 |
|
| 146 |
+
col_ghg_comparison, col_adpe_comparison, col_pe_comparison, col_water_comparison = st.columns(4)
|
| 147 |
|
| 148 |
with col_ghg_comparison:
|
|
|
|
| 149 |
fig_gwp = px.pie(
|
| 150 |
+
values = [average_range_impacts(usage.gwp.value), average_range_impacts(embodied.gwp.value)],
|
| 151 |
+
names = ['usage', 'embodied'],
|
| 152 |
+
title = 'GHG emissions',
|
| 153 |
+
color_discrete_sequence=["#00BF63", "#0B3B36"],
|
| 154 |
+
width = 300
|
| 155 |
)
|
| 156 |
+
fig_gwp.update_layout(
|
| 157 |
+
showlegend=False,
|
| 158 |
+
title_x=0.1)
|
| 159 |
|
| 160 |
st.plotly_chart(fig_gwp)
|
| 161 |
|
|
|
|
| 164 |
values = [average_range_impacts(usage.adpe.value), average_range_impacts(embodied.adpe.value)],
|
| 165 |
names = ['usage', 'embodied'],
|
| 166 |
title = 'Abiotic depletion',
|
| 167 |
+
color = ['usage', 'embodied'], # Associe chaque valeur à un label pour la couleur
|
| 168 |
+
color_discrete_map={
|
| 169 |
+
'usage': '#00BF63',
|
| 170 |
+
'embodied': '#0B3B36'
|
| 171 |
+
},
|
| 172 |
+
width = 300
|
| 173 |
+
)
|
| 174 |
fig_adpe.update_layout(
|
| 175 |
showlegend=False,
|
| 176 |
+
title_x=0.05
|
| 177 |
+
)
|
| 178 |
+
|
| 179 |
st.plotly_chart(fig_adpe)
|
| 180 |
|
| 181 |
with col_pe_comparison:
|
|
|
|
| 184 |
names = ['usage', 'embodied'],
|
| 185 |
title = 'Primary energy',
|
| 186 |
color_discrete_sequence=["#00BF63", "#0B3B36"],
|
| 187 |
+
width = 300
|
| 188 |
+
)
|
| 189 |
+
fig_pe.update_layout(
|
| 190 |
+
showlegend=False,
|
| 191 |
+
title_x=0.1)
|
| 192 |
|
| 193 |
st.plotly_chart(fig_pe)
|
| 194 |
|
| 195 |
+
with col_water_comparison:
|
| 196 |
+
fig_water = px.pie(
|
| 197 |
+
values = [average_range_impacts(usage.water.value), average_range_impacts(embodied.water.value)],
|
| 198 |
+
names = ['usage', 'embodied'],
|
| 199 |
+
title = 'Water',
|
| 200 |
+
color_discrete_sequence=["#00BF63", "#0B3B36"],
|
| 201 |
+
width = 300
|
| 202 |
+
)
|
| 203 |
+
fig_water.update_layout(
|
| 204 |
+
showlegend=False,
|
| 205 |
+
title_x=0.3)
|
| 206 |
+
|
| 207 |
+
st.plotly_chart(fig_water)
|
| 208 |
+
|
| 209 |
with st.expander('🌍️ Location impact'):
|
| 210 |
|
| 211 |
st.markdown('<h4 align="center">How can location impact the footprint ?</h4>', unsafe_allow_html = True)
|
|
|
|
| 220 |
|
| 221 |
df_comp = dataframe_electricity_mix(countries_to_compare)
|
| 222 |
|
| 223 |
+
|
| 224 |
+
impact_metrices = [
|
| 225 |
+
"Abiotic Depletion Potential for Elements (Kilograms of antimony equivalent)",
|
| 226 |
+
"Primary energy demand (Megajoules)",
|
| 227 |
+
"Global Warming Potential (Kilograms of CO2 equivalent)",
|
| 228 |
+
"Water Withdrawal Factor (Liters/Kilowatt-hour)",
|
| 229 |
+
"Water Consumption Factor (Liters/Kilowatt-hour)"
|
| 230 |
+
]
|
| 231 |
+
|
| 232 |
+
impact_labels = {
|
| 233 |
+
impact_metrices[0] : "adpe (kg eq. Sb)",
|
| 234 |
+
impact_metrices[1] : "pe (MJ)",
|
| 235 |
+
impact_metrices[2] : "gwp (kg eq. CO2)",
|
| 236 |
+
impact_metrices[3] : "water_wwf (L/kWh)",
|
| 237 |
+
impact_metrices[4] : "water_wcf (L/kWh)"
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
impact_type = st.selectbox(
|
| 241 |
label='Select an impact type to compare',
|
| 242 |
+
options=[x for x in impact_labels], # les noms affichés à l'utilisateur
|
| 243 |
+
index=1
|
| 244 |
+
)
|
| 245 |
+
|
| 246 |
+
impact_type_used = impact_labels[impact_type]
|
| 247 |
|
| 248 |
+
df_comp.sort_values(by = impact_type_used, inplace = True)
|
| 249 |
|
| 250 |
fig_2 = px.bar(
|
| 251 |
df_comp,
|
| 252 |
x = df_comp.index,
|
| 253 |
+
y = impact_type_used,
|
| 254 |
+
text = impact_type_used,
|
| 255 |
+
color = impact_type_used
|
| 256 |
)
|
| 257 |
|
| 258 |
st.plotly_chart(fig_2)
|
| 259 |
|
| 260 |
+
impact_explanations = {
|
| 261 |
+
impact_metrices[0]:
|
| 262 |
+
"Measures the depletion of non-renewable resources (metals, minerals), expressed in kg of antimony equivalent (Sb). \
|
| 263 |
+
The enviornmental impact equates to that amount of antimony being extracted.",
|
| 264 |
+
impact_metrices[1]:
|
| 265 |
+
"Total amount of primary energy used (both renewable and non-renewable), expressed in megajoules (MJ).",
|
| 266 |
+
impact_metrices[2]:
|
| 267 |
+
"Potential contribution to climate change over a 100-year time horizon, expressed in kilograms of CO₂ equivalent.",
|
| 268 |
+
impact_metrices[3]:
|
| 269 |
+
"Total volume of water withdrawn throughout the process, expressed in liters (L).",
|
| 270 |
+
impact_metrices[4]:
|
| 271 |
+
"Volume of water actually consumed (not returned to the source), expressed in liters (L)."
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
st.info(impact_explanations[impact_type])
|
| 275 |
+
|
| 276 |
except:
|
| 277 |
|
| 278 |
st.warning("Can't display chart with no values.")
|
src/impacts.py
CHANGED
|
@@ -7,9 +7,24 @@ 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,40 +35,309 @@ 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 |
|
| 27 |
col_energy, col_ghg, col_adpe, col_pe, col_water = st.columns(5)
|
| 28 |
|
| 29 |
with col_energy:
|
| 30 |
-
st.markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
st.latex(f'\Large {impacts.energy.magnitude:.3g} \ \large {impacts.energy.units}')
|
| 32 |
-
st.markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
with col_ghg:
|
| 35 |
-
st.markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
st.latex(f'\Large {impacts.gwp.magnitude:.3g} \ \large {impacts.gwp.units}')
|
| 37 |
-
st.markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
with col_adpe:
|
| 40 |
-
st.markdown(
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
with col_pe:
|
| 45 |
-
st.markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
st.latex(f'\Large {impacts.pe.magnitude:.3g} \ \large {impacts.pe.units}')
|
| 47 |
-
st.markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
with col_water:
|
| 50 |
-
st.markdown('<h4 align="center">🚰 Water</h4>', unsafe_allow_html = True)
|
| 51 |
-
st.latex('\Large Upcoming...')
|
| 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,39 +345,69 @@ 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)
|
| 68 |
if physical_activity == PhysicalActivity.WALKING:
|
| 69 |
-
|
|
|
|
| 70 |
if physical_activity == PhysicalActivity.RUNNING:
|
| 71 |
-
|
|
|
|
| 72 |
|
| 73 |
-
st.markdown(f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
st.latex(f'\Large {distance.magnitude:.3g} \ \large {distance.units}')
|
| 75 |
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 76 |
|
| 77 |
with col2:
|
| 78 |
ev_eq = format_energy_eq_electric_vehicle(impacts.energy)
|
| 79 |
-
st.markdown(f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
st.latex(f'\Large {ev_eq.magnitude:.3g} \ \large {ev_eq.units}')
|
| 81 |
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 82 |
|
| 83 |
with col3:
|
| 84 |
streaming_eq = format_gwp_eq_streaming(impacts.gwp)
|
| 85 |
-
st.markdown(f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 +416,229 @@ def display_equivalent(impacts):
|
|
| 102 |
if electricity_production == EnergyProduction.WIND:
|
| 103 |
emoji = "💨️ "
|
| 104 |
name = "Wind turbines"
|
| 105 |
-
st.markdown(f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
format_energy_eq_electricity_production_company,
|
| 13 |
+
format_energy_eq_electricity_consumption_ireland_company,
|
| 14 |
+
format_gwp_eq_airplane_paris_nyc_company,
|
| 15 |
+
format_water_eq_olympic_sized_swimming_pool_company,
|
| 16 |
+
format_energy_eq_physical_activity_company,
|
| 17 |
+
format_gwp_eq_streaming_company,
|
| 18 |
+
format_energy_eq_electric_vehicle_company,
|
| 19 |
+
format_water_eq_bottled_waters_company,
|
| 20 |
PhysicalActivity,
|
| 21 |
+
EnergyProduction,
|
| 22 |
+
AI_COMPANY_TO_DATA_CENTER_PROVIDER,
|
| 23 |
+
PROVIDER_PUE,
|
| 24 |
+
PROVIDER_WUE_ONSITE
|
| 25 |
)
|
| 26 |
+
from src.electricity_mix import COUNTRY_CODES, find_electricity_mix, dataframe_electricity_mix
|
| 27 |
+
|
| 28 |
|
| 29 |
############################################################################################################
|
| 30 |
|
|
|
|
| 35 |
############################################################################################################
|
| 36 |
|
| 37 |
|
| 38 |
+
def display_impacts(impacts, provider, range_percent_impact_one_sided_calculated, location):
|
| 39 |
|
| 40 |
st.divider()
|
| 41 |
|
| 42 |
col_energy, col_ghg, col_adpe, col_pe, col_water = st.columns(5)
|
| 43 |
|
| 44 |
with col_energy:
|
| 45 |
+
st.markdown("""
|
| 46 |
+
<div style="text-align: center;">
|
| 47 |
+
<div style="font-size: 30px;">⚡️</div>
|
| 48 |
+
<div style="font-size: 25px;">Energy</div>
|
| 49 |
+
</div>
|
| 50 |
+
""", unsafe_allow_html = True)
|
| 51 |
st.latex(f'\Large {impacts.energy.magnitude:.3g} \ \large {impacts.energy.units}')
|
| 52 |
+
st.markdown("""
|
| 53 |
+
<div style="height: 10px;"></div>
|
| 54 |
+
<div style="text-align: center;"><i>Evaluates the electricity consumption<i>
|
| 55 |
+
</div>
|
| 56 |
+
""", unsafe_allow_html = True)
|
| 57 |
+
st.markdown(f"""
|
| 58 |
+
<div style="text-align: center;">
|
| 59 |
+
<div style="font-size: 10px;">Error range</div>
|
| 60 |
+
<div style="font-size: 10px;">±{range_percent_impact_one_sided_calculated["energy"]} %</div>
|
| 61 |
+
</div>
|
| 62 |
+
""", unsafe_allow_html = True)
|
| 63 |
+
|
| 64 |
|
| 65 |
with col_ghg:
|
| 66 |
+
st.markdown("""
|
| 67 |
+
<div style="text-align: center;">
|
| 68 |
+
<div style="font-size: 30px;">🌍️</div>
|
| 69 |
+
<div style="font-size: 18px;">GHG Emissions</div>
|
| 70 |
+
</div>
|
| 71 |
+
""", unsafe_allow_html = True)
|
| 72 |
st.latex(f'\Large {impacts.gwp.magnitude:.3g} \ \large {impacts.gwp.units}')
|
| 73 |
+
st.markdown("""
|
| 74 |
+
<div style="text-align: center;"><i>Evaluates the effect on climate change<i>
|
| 75 |
+
</div>
|
| 76 |
+
""", unsafe_allow_html = True)
|
| 77 |
+
st.markdown(f"""
|
| 78 |
+
<div style="text-align: center;">
|
| 79 |
+
<div style="font-size: 10px;">Error range</div>
|
| 80 |
+
<div style="font-size: 10px;">±{range_percent_impact_one_sided_calculated["gwp"]} %</div>
|
| 81 |
+
</div>
|
| 82 |
+
""", unsafe_allow_html = True)
|
| 83 |
|
| 84 |
with col_adpe:
|
| 85 |
+
st.markdown("""
|
| 86 |
+
<div style="text-align: center;">
|
| 87 |
+
<div style="font-size: 30px;">🪨</div>
|
| 88 |
+
<div style="font-size: 16px;">Abiotic Resources</div>
|
| 89 |
+
</div>
|
| 90 |
+
""", unsafe_allow_html = True)
|
| 91 |
+
company_impact = impacts.adpe.magnitude
|
| 92 |
+
impacts_adpe_units = impacts.adpe.units
|
| 93 |
+
#errornique
|
| 94 |
+
if company_impact <= 1 and impacts_adpe_units == "kgSbeq":
|
| 95 |
+
company_impact *= 1000
|
| 96 |
+
impacts_adpe_units = "gSbeq"
|
| 97 |
+
if company_impact <= 1 and impacts_adpe_units == "gSbeq":
|
| 98 |
+
company_impact *= 1000
|
| 99 |
+
impacts_adpe_units = "mgSbeq"
|
| 100 |
+
if company_impact <= 1 and impacts_adpe_units == "mgSbeq":
|
| 101 |
+
company_impact *= 1000
|
| 102 |
+
impacts_adpe_units = "μSbeq"
|
| 103 |
+
################################################
|
| 104 |
+
if company_impact >= 1000 and impacts_adpe_units == "kgSbeq":
|
| 105 |
+
company_impact /= 1000
|
| 106 |
+
impacts_adpe_units = "tSbeq"
|
| 107 |
+
st.latex(f'\Large {company_impact:.3g} \ \large {impacts_adpe_units}')
|
| 108 |
+
st.markdown("""
|
| 109 |
+
<div style="text-align: center;"><i>Evaluates the use of metals and minerals<i>
|
| 110 |
+
</div>
|
| 111 |
+
""", unsafe_allow_html = True)
|
| 112 |
+
st.markdown(f"""
|
| 113 |
+
<div style="text-align: center;">
|
| 114 |
+
<div style="font-size: 10px;">Error range</div>
|
| 115 |
+
<div style="font-size: 10px;">±{range_percent_impact_one_sided_calculated["adpe"]} %</div>
|
| 116 |
+
</div>
|
| 117 |
+
""", unsafe_allow_html = True)
|
| 118 |
|
| 119 |
with col_pe:
|
| 120 |
+
st.markdown("""
|
| 121 |
+
<div style="text-align: center;">
|
| 122 |
+
<div style="font-size: 30px;">⛽️</div>
|
| 123 |
+
<div style="font-size: 18px;">Primary Energy</div>
|
| 124 |
+
</div>
|
| 125 |
+
""", unsafe_allow_html = True)
|
| 126 |
st.latex(f'\Large {impacts.pe.magnitude:.3g} \ \large {impacts.pe.units}')
|
| 127 |
+
st.markdown("""
|
| 128 |
+
<div style="height: 10px;"></div>
|
| 129 |
+
<div style="text-align: center;"><i>Evaluates the use of energy resources<i>
|
| 130 |
+
</div>
|
| 131 |
+
""", unsafe_allow_html = True)
|
| 132 |
+
st.markdown(f"""
|
| 133 |
+
<div style="text-align: center;">
|
| 134 |
+
<div style="font-size: 10px;">Error range</div>
|
| 135 |
+
<div style="font-size: 10px;">±{range_percent_impact_one_sided_calculated["pe"]} %</div>
|
| 136 |
+
</div>
|
| 137 |
+
""", unsafe_allow_html = True)
|
| 138 |
+
|
| 139 |
+
with col_water:
|
| 140 |
+
st.markdown("""
|
| 141 |
+
<div style="text-align: center;">
|
| 142 |
+
<div style="font-size: 30px;">🚰</div>
|
| 143 |
+
<div style="font-size: 25px;">Water</div>
|
| 144 |
+
</div>
|
| 145 |
+
""", unsafe_allow_html = True)
|
| 146 |
+
st.latex(f'\Large {impacts.water.magnitude:.3g} \ \large {impacts.water.units}')
|
| 147 |
+
st.markdown("""
|
| 148 |
+
<div style="text-align: center;"><i>Evaluates the use of water<i>
|
| 149 |
+
</div>
|
| 150 |
+
""", unsafe_allow_html = True)
|
| 151 |
+
st.markdown(f"""
|
| 152 |
+
<div style="text-align: center;">
|
| 153 |
+
<div style="font-size: 10px;">Error range</div>
|
| 154 |
+
<div style="font-size: 10px;">±{range_percent_impact_one_sided_calculated["water"]} %</div>
|
| 155 |
+
</div>
|
| 156 |
+
""", unsafe_allow_html = True)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
#################################################################################################
|
| 160 |
+
def display_impacts_company(impacts, provider, company_multiplier, range_percent_impact_one_sided_calculated, location):
|
| 161 |
+
|
| 162 |
+
st.divider()
|
| 163 |
+
|
| 164 |
+
col_energy, col_ghg, col_adpe, col_pe, col_water = st.columns(5)
|
| 165 |
+
|
| 166 |
+
with col_energy:
|
| 167 |
+
st.markdown("""
|
| 168 |
+
<div style="text-align: center;">
|
| 169 |
+
<div style="font-size: 30px;">⚡️</div>
|
| 170 |
+
<div style="font-size: 25px;">Energy</div>
|
| 171 |
+
</div>
|
| 172 |
+
""", unsafe_allow_html = True)
|
| 173 |
+
company_impact = impacts.energy.magnitude * company_multiplier
|
| 174 |
+
impacts_energy_units = impacts.energy.units
|
| 175 |
+
if company_impact >= 1000 and impacts_energy_units == "Wh":
|
| 176 |
+
company_impact /= 1000
|
| 177 |
+
impacts_energy_units = "kWh"
|
| 178 |
+
if company_impact >= 1000 and impacts_energy_units == "kWh":
|
| 179 |
+
company_impact /= 1000
|
| 180 |
+
impacts_energy_units = "MWh"
|
| 181 |
+
if company_impact >= 1000 and impacts_energy_units == "MWh":
|
| 182 |
+
company_impact /= 1000
|
| 183 |
+
impacts_energy_units = "GWh"
|
| 184 |
+
if company_impact >= 1000 and impacts_energy_units == "GWh":
|
| 185 |
+
company_impact /= 1000
|
| 186 |
+
impacts_energy_units = "TWh"
|
| 187 |
+
if company_impact >= 1000 and impacts_energy_units == "TWh":
|
| 188 |
+
company_impact /= 1000
|
| 189 |
+
impacts_energy_units = "PWh"
|
| 190 |
+
st.latex(f'\Large {company_impact:.3g} \ \large {impacts_energy_units}')
|
| 191 |
+
st.markdown("""
|
| 192 |
+
<div style="height: 10px;"></div>
|
| 193 |
+
<div style="text-align: center;"><i>Evaluates the electricity consumption<i>
|
| 194 |
+
</div>
|
| 195 |
+
""", unsafe_allow_html = True)
|
| 196 |
+
st.markdown(f"""
|
| 197 |
+
<div style="text-align: center;">
|
| 198 |
+
<div style="font-size: 10px;">Error range</div>
|
| 199 |
+
<div style="font-size: 10px;">±{range_percent_impact_one_sided_calculated["energy"]} %</div>
|
| 200 |
+
</div>
|
| 201 |
+
""", unsafe_allow_html = True)
|
| 202 |
+
|
| 203 |
+
with col_ghg:
|
| 204 |
+
st.markdown("""
|
| 205 |
+
<div style="text-align: center;">
|
| 206 |
+
<div style="font-size: 30px;">🌍️</div>
|
| 207 |
+
<div style="font-size: 18px;">GHG Emissions</div>
|
| 208 |
+
</div>
|
| 209 |
+
""", unsafe_allow_html = True)
|
| 210 |
+
impacts_ghg_units = impacts.gwp.units
|
| 211 |
+
company_impact = impacts.gwp.magnitude * company_multiplier
|
| 212 |
+
if company_impact >= 1000 and impacts_ghg_units == "gCO2eq":
|
| 213 |
+
company_impact /= 1000
|
| 214 |
+
impacts_ghg_units = "kgCO2eq"
|
| 215 |
+
if company_impact >= 1000 and impacts_ghg_units == "kgCO2eq":
|
| 216 |
+
company_impact /= 1000
|
| 217 |
+
impacts_ghg_units = "tCO2eq"
|
| 218 |
+
st.latex(f'\Large {company_impact:.3g} \ \large {impacts_ghg_units}')
|
| 219 |
+
st.markdown("""
|
| 220 |
+
<div style="text-align: center;"><i>Evaluates the effect on climate change<i>
|
| 221 |
+
</div>
|
| 222 |
+
""", unsafe_allow_html = True)
|
| 223 |
+
st.markdown(f"""
|
| 224 |
+
<div style="text-align: center;">
|
| 225 |
+
<div style="font-size: 10px;">Error range</div>
|
| 226 |
+
<div style="font-size: 10px;">±{range_percent_impact_one_sided_calculated["gwp"]} %</div>
|
| 227 |
+
</div>
|
| 228 |
+
""", unsafe_allow_html = True)
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
with col_adpe:
|
| 232 |
+
st.markdown("""
|
| 233 |
+
<div style="text-align: center;">
|
| 234 |
+
<div style="font-size: 30px;">🪨</div>
|
| 235 |
+
<div style="font-size: 16px;">Abiotic Resources</div>
|
| 236 |
+
</div>
|
| 237 |
+
""", unsafe_allow_html = True)
|
| 238 |
+
company_impact = impacts.adpe.magnitude * company_multiplier
|
| 239 |
+
impacts_adpe_units = impacts.adpe.units
|
| 240 |
+
if company_impact <= 1 and impacts_adpe_units == "kgSbeq":
|
| 241 |
+
company_impact *= 1000
|
| 242 |
+
impacts_adpe_units = "gSbeq"
|
| 243 |
+
if company_impact <= 1 and impacts_adpe_units == "gSbeq":
|
| 244 |
+
company_impact *= 1000
|
| 245 |
+
impacts_adpe_units = "mgSbeq"
|
| 246 |
+
|
| 247 |
+
##############
|
| 248 |
+
if company_impact <= 1 and impacts_adpe_units == "mgSbeq":
|
| 249 |
+
company_impact *= 1000
|
| 250 |
+
impacts_adpe_units = "μSbeq"
|
| 251 |
+
if company_impact >= 1000 and impacts_adpe_units == "kgSbeq":
|
| 252 |
+
company_impact /= 1000
|
| 253 |
+
impacts_adpe_units = "tSbeq"
|
| 254 |
+
st.latex(f'\Large {company_impact:.3g} \ \large {impacts_adpe_units}')
|
| 255 |
+
st.markdown("""
|
| 256 |
+
<div style="text-align: center;"><i>Evaluates the use of metals and minerals<i>
|
| 257 |
+
</div>
|
| 258 |
+
""", unsafe_allow_html = True)
|
| 259 |
+
st.markdown(f"""
|
| 260 |
+
<div style="text-align: center;">
|
| 261 |
+
<div style="font-size: 10px;">Error range</div>
|
| 262 |
+
<div style="font-size: 10px;">±{range_percent_impact_one_sided_calculated["adpe"]} %</div>
|
| 263 |
+
</div>
|
| 264 |
+
""", unsafe_allow_html = True)
|
| 265 |
+
|
| 266 |
+
with col_pe:
|
| 267 |
+
st.markdown("""
|
| 268 |
+
<div style="text-align: center;">
|
| 269 |
+
<div style="font-size: 30px;">⛽️</div>
|
| 270 |
+
<div style="font-size: 18px;">Primary Energy</div>
|
| 271 |
+
</div>
|
| 272 |
+
""", unsafe_allow_html = True)
|
| 273 |
+
company_impact = impacts.pe.magnitude * company_multiplier
|
| 274 |
+
impacts_pe_units = impacts.pe.units
|
| 275 |
+
if company_impact >= 1000 and impacts_pe_units == "kJ":
|
| 276 |
+
company_impact /= 1000
|
| 277 |
+
impacts_pe_units = "MJ"
|
| 278 |
+
if company_impact >= 1000 and impacts_pe_units == "MJ":
|
| 279 |
+
company_impact /= 1000
|
| 280 |
+
impacts_pe_units = "GJ"
|
| 281 |
+
if company_impact >= 1000 and impacts_pe_units == "GJ":
|
| 282 |
+
company_impact /= 1000
|
| 283 |
+
impacts_pe_units = "TJ"
|
| 284 |
+
if company_impact >= 1000 and impacts_pe_units == "TJ":
|
| 285 |
+
company_impact /= 1000
|
| 286 |
+
impacts_pe_units = "PJ"
|
| 287 |
+
st.latex(f'\Large {company_impact:.3g} \ \large {impacts_pe_units}')
|
| 288 |
+
st.markdown("""
|
| 289 |
+
<div style="height: 10px;"></div>
|
| 290 |
+
<div style="text-align: center;"><i>Evaluates the use of energy resources<i>
|
| 291 |
+
</div>
|
| 292 |
+
""", unsafe_allow_html = True)
|
| 293 |
+
st.markdown(f"""
|
| 294 |
+
<div style="text-align: center;">
|
| 295 |
+
<div style="font-size: 10px;">Error range</div>
|
| 296 |
+
<div style="font-size: 10px;">±{range_percent_impact_one_sided_calculated["pe"]} %</div>
|
| 297 |
+
</div>
|
| 298 |
+
""", unsafe_allow_html = True)
|
| 299 |
+
|
| 300 |
+
with col_water:
|
| 301 |
+
st.markdown("""
|
| 302 |
+
<div style="text-align: center;">
|
| 303 |
+
<div style="font-size: 30px;">🚰</div>
|
| 304 |
+
<div style="font-size: 25px;">Water</div>
|
| 305 |
+
</div>
|
| 306 |
+
""", unsafe_allow_html = True)
|
| 307 |
+
company_impact = impacts.water.magnitude * company_multiplier
|
| 308 |
+
impacts_water_units = impacts.water.units
|
| 309 |
+
if company_impact >= 1000 and impacts_water_units == "mL":
|
| 310 |
+
company_impact /= 1000
|
| 311 |
+
impacts_water_units = "L"
|
| 312 |
+
if company_impact >= 1000 and impacts_water_units == "L":
|
| 313 |
+
company_impact /= 1000
|
| 314 |
+
impacts_water_units = "kL"
|
| 315 |
+
if company_impact >= 1000 and impacts_water_units == "kL":
|
| 316 |
+
company_impact /= 1000
|
| 317 |
+
impacts_water_units = "ML"
|
| 318 |
+
if company_impact >= 1000 and impacts_water_units == "ML":
|
| 319 |
+
company_impact /= 1000
|
| 320 |
+
impacts_water_units = "GL"
|
| 321 |
+
if company_impact >= 1000 and impacts_water_units == "GL":
|
| 322 |
+
company_impact /= 1000
|
| 323 |
+
impacts_water_units = "TL"
|
| 324 |
+
st.latex(f'\Large {company_impact:.3g} \ \large {impacts_water_units}')
|
| 325 |
+
st.markdown("""
|
| 326 |
+
<div style="text-align: center;"><i>Evaluates the use of water<i>
|
| 327 |
+
</div>
|
| 328 |
+
""", unsafe_allow_html = True)
|
| 329 |
+
st.markdown(f"""
|
| 330 |
+
<div style="text-align: center;">
|
| 331 |
+
<div style="font-size: 10px;">Error range</div>
|
| 332 |
+
<div style="font-size: 10px;">±{range_percent_impact_one_sided_calculated["water"]} %</div>
|
| 333 |
+
</div>
|
| 334 |
+
""", unsafe_allow_html = True)
|
| 335 |
+
|
| 336 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
|
| 338 |
############################################################################################################
|
| 339 |
|
| 340 |
+
def display_equivalent(impacts, provider, location):
|
| 341 |
|
| 342 |
st.divider()
|
| 343 |
|
|
|
|
| 345 |
|
| 346 |
streaming_eq = format_gwp_eq_streaming(impacts.gwp)
|
| 347 |
|
| 348 |
+
col1, col2, col3, col4 = st.columns(4)
|
| 349 |
|
| 350 |
with col1:
|
| 351 |
physical_activity, distance = format_energy_eq_physical_activity(impacts.energy)
|
| 352 |
if physical_activity == PhysicalActivity.WALKING:
|
| 353 |
+
physical_activity_emoji = "🚶 "
|
| 354 |
+
physical_activity = physical_activity.capitalize()
|
| 355 |
if physical_activity == PhysicalActivity.RUNNING:
|
| 356 |
+
physical_activity_emoji = "🏃 "
|
| 357 |
+
physical_activity = physical_activity.capitalize()
|
| 358 |
|
| 359 |
+
st.markdown(f"""
|
| 360 |
+
<div style="text-align: center;">
|
| 361 |
+
<div style="font-size: 30px;">{physical_activity_emoji}</div>
|
| 362 |
+
<div style="font-size: 25px;">{physical_activity}</div>
|
| 363 |
+
</div>
|
| 364 |
+
""", unsafe_allow_html = True)
|
| 365 |
st.latex(f'\Large {distance.magnitude:.3g} \ \large {distance.units}')
|
| 366 |
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 367 |
|
| 368 |
with col2:
|
| 369 |
ev_eq = format_energy_eq_electric_vehicle(impacts.energy)
|
| 370 |
+
st.markdown(f"""
|
| 371 |
+
<div style="text-align: center;">
|
| 372 |
+
<div style="font-size: 30px;">🔋</div>
|
| 373 |
+
<div style="font-size: 22px;">Electric Vehicle</div>
|
| 374 |
+
</div>
|
| 375 |
+
""", unsafe_allow_html = True)
|
| 376 |
st.latex(f'\Large {ev_eq.magnitude:.3g} \ \large {ev_eq.units}')
|
| 377 |
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 378 |
|
| 379 |
with col3:
|
| 380 |
streaming_eq = format_gwp_eq_streaming(impacts.gwp)
|
| 381 |
+
st.markdown(f"""
|
| 382 |
+
<div style="text-align: center;">
|
| 383 |
+
<div style="font-size: 30px;">⏯️</div>
|
| 384 |
+
<div style="font-size: 25px;">Streaming</div>
|
| 385 |
+
</div>
|
| 386 |
+
""", unsafe_allow_html = True)
|
| 387 |
st.latex(f'\Large {streaming_eq.magnitude:.3g} \ \large {streaming_eq.units}')
|
| 388 |
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|
| 389 |
|
| 390 |
+
with col4:
|
| 391 |
+
#water = water_impact(impacts, provider, location)
|
| 392 |
+
water_eq = format_water_eq_bottled_waters(impacts.water)
|
| 393 |
+
st.markdown(f"""
|
| 394 |
+
<div style="text-align: center;">
|
| 395 |
+
<div style="font-size: 30px;">🚰</div>
|
| 396 |
+
<div style="font-size: 25px;">Bottled Waters</div>
|
| 397 |
+
</div>
|
| 398 |
+
""", unsafe_allow_html = True)
|
| 399 |
+
st.latex(f'\Large {water_eq.magnitude:.3g} \ \large {"bottles"}')
|
| 400 |
+
st.markdown(f'<p align="center"><i>Based on water consumption, measured in 0.75 L bottles.<i></p>', unsafe_allow_html = True)
|
| 401 |
+
|
| 402 |
+
|
| 403 |
st.divider()
|
| 404 |
|
| 405 |
st.markdown('<h3 align="center">What if 1% of the planet does this request everyday for 1 year ?</h3>', unsafe_allow_html = True)
|
| 406 |
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)
|
| 407 |
|
| 408 |
+
col5, col6, col7, col8 = st.columns(4)
|
| 409 |
|
| 410 |
+
with col5:
|
| 411 |
|
| 412 |
electricity_production, count = format_energy_eq_electricity_production(impacts.energy)
|
| 413 |
if electricity_production == EnergyProduction.NUCLEAR:
|
|
|
|
| 416 |
if electricity_production == EnergyProduction.WIND:
|
| 417 |
emoji = "💨️ "
|
| 418 |
name = "Wind turbines"
|
| 419 |
+
st.markdown(f"""
|
| 420 |
+
<div style="text-align: center;">
|
| 421 |
+
<div style="font-size: 30px;">
|
| 422 |
+
{emoji}
|
| 423 |
+
</div>
|
| 424 |
+
<div style="font-size: 30px;">
|
| 425 |
+
{count.magnitude:.3g}
|
| 426 |
+
</div>
|
| 427 |
+
<div style="font-size: 25px;">
|
| 428 |
+
{name}
|
| 429 |
+
</div>
|
| 430 |
+
<div style="font-size: 12px;">
|
| 431 |
+
(yearly ⚡️ production)
|
| 432 |
+
</div>
|
| 433 |
+
</div>
|
| 434 |
+
""", unsafe_allow_html=True)
|
| 435 |
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 436 |
|
| 437 |
+
with col6:
|
| 438 |
ireland_count = format_energy_eq_electricity_consumption_ireland(impacts.energy)
|
| 439 |
+
st.markdown(f"""
|
| 440 |
+
<div style="text-align: center;">
|
| 441 |
+
<div style="font-size: 30px;">
|
| 442 |
+
☘️🇮🇪
|
| 443 |
+
</div>
|
| 444 |
+
<div style="font-size: 30px;">
|
| 445 |
+
{ireland_count.magnitude:.3g}
|
| 446 |
+
</div>
|
| 447 |
+
<div style="font-size: 25px;">
|
| 448 |
+
Irelands
|
| 449 |
+
</div>
|
| 450 |
+
<div style="font-size: 12px;">
|
| 451 |
+
(yearly ⚡️ consumption)
|
| 452 |
+
</div>
|
| 453 |
+
</div>
|
| 454 |
+
""", unsafe_allow_html=True)
|
| 455 |
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 456 |
|
| 457 |
+
with col7:
|
| 458 |
paris_nyc_airplane = format_gwp_eq_airplane_paris_nyc(impacts.gwp)
|
| 459 |
+
st.markdown(f"""
|
| 460 |
+
<div style="text-align: center;">
|
| 461 |
+
<div style="font-size: 30px;">
|
| 462 |
+
✈️
|
| 463 |
+
</div>
|
| 464 |
+
<div style="font-size: 30px;">
|
| 465 |
+
{paris_nyc_airplane.magnitude:.3g}
|
| 466 |
+
</div>
|
| 467 |
+
<div style="font-size: 25px;">
|
| 468 |
+
Paris ↔ NYC
|
| 469 |
+
</div>
|
| 470 |
+
</div>
|
| 471 |
+
""", unsafe_allow_html=True)
|
| 472 |
+
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|
| 473 |
+
|
| 474 |
+
with col8:
|
| 475 |
+
olympic_swimming_pool = format_water_eq_olympic_sized_swimming_pool(impacts.water)
|
| 476 |
+
st.markdown(f"""
|
| 477 |
+
<div style="text-align: center;">
|
| 478 |
+
<div style="font-size: 30px;">
|
| 479 |
+
🏊🏼
|
| 480 |
+
</div>
|
| 481 |
+
<div style="font-size: 30px;">
|
| 482 |
+
{olympic_swimming_pool.magnitude:.3g}
|
| 483 |
+
</div>
|
| 484 |
+
<div style="font-size: 22px;">
|
| 485 |
+
Olympic-sized swimming pools
|
| 486 |
+
</div>
|
| 487 |
+
</div>
|
| 488 |
+
""", unsafe_allow_html=True)
|
| 489 |
+
st.markdown(f'<p align="center"><i>Based on water consumption<i></p>', unsafe_allow_html = True)
|
| 490 |
+
|
| 491 |
+
#####################################################################################
|
| 492 |
+
|
| 493 |
+
def display_equivalent_company(impacts, provider, company_multiplier, location):
|
| 494 |
+
|
| 495 |
+
st.divider()
|
| 496 |
+
|
| 497 |
+
ev_eq = format_energy_eq_electric_vehicle(impacts.energy)
|
| 498 |
+
|
| 499 |
+
streaming_eq = format_gwp_eq_streaming(impacts.gwp)
|
| 500 |
+
|
| 501 |
+
col1, col2, col3, col4 = st.columns(4)
|
| 502 |
+
|
| 503 |
+
with col1:
|
| 504 |
+
physical_activity, distance = format_energy_eq_physical_activity_company(impacts.energy, company_multiplier)
|
| 505 |
+
if physical_activity == PhysicalActivity.WALKING:
|
| 506 |
+
physical_activity_emoji = "🚶 "
|
| 507 |
+
physical_activity = physical_activity.capitalize()
|
| 508 |
+
if physical_activity == PhysicalActivity.RUNNING:
|
| 509 |
+
physical_activity_emoji = "🏃 "
|
| 510 |
+
physical_activity = physical_activity.capitalize()
|
| 511 |
+
|
| 512 |
+
st.markdown(f"""
|
| 513 |
+
<div style="text-align: center;">
|
| 514 |
+
<div style="font-size: 30px;">{physical_activity_emoji}</div>
|
| 515 |
+
<div style="font-size: 25px;">{physical_activity}</div>
|
| 516 |
+
</div>
|
| 517 |
+
""", unsafe_allow_html = True)
|
| 518 |
+
value = round(distance.magnitude, 3)
|
| 519 |
+
st.latex(rf'\Large {value:.0g} \ \large {distance.units}')
|
| 520 |
+
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 521 |
+
|
| 522 |
+
with col2:
|
| 523 |
+
ev_eq = format_energy_eq_electric_vehicle_company(impacts.energy, company_multiplier)
|
| 524 |
+
st.markdown(f"""
|
| 525 |
+
<div style="text-align: center;">
|
| 526 |
+
<div style="font-size: 30px;">🔋</div>
|
| 527 |
+
<div style="font-size: 22px;">Electric Vehicle</div>
|
| 528 |
+
</div>
|
| 529 |
+
""", unsafe_allow_html = True)
|
| 530 |
+
value = round(ev_eq.magnitude, 3)
|
| 531 |
+
st.latex(rf'\Large {value:.0f} \ \large {ev_eq.units}')
|
| 532 |
+
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 533 |
+
|
| 534 |
+
with col3:
|
| 535 |
+
streaming_eq = format_gwp_eq_streaming_company(impacts.gwp, company_multiplier)
|
| 536 |
+
st.markdown(f"""
|
| 537 |
+
<div style="text-align: center;">
|
| 538 |
+
<div style="font-size: 30px;">⏯️</div>
|
| 539 |
+
<div style="font-size: 25px;">Streaming</div>
|
| 540 |
+
</div>
|
| 541 |
+
""", unsafe_allow_html = True)
|
| 542 |
+
value = round(streaming_eq.magnitude, 3)
|
| 543 |
+
st.latex(rf'\Large {value:.0f} \ \large {streaming_eq.units}')
|
| 544 |
+
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|
| 545 |
+
|
| 546 |
+
with col4:
|
| 547 |
+
#water = water_impact(impacts, provider, location)
|
| 548 |
+
water_eq = format_water_eq_bottled_waters_company(impacts.water, company_multiplier)
|
| 549 |
+
st.markdown(f"""
|
| 550 |
+
<div style="text-align: center;">
|
| 551 |
+
<div style="font-size: 30px;">🚰</div>
|
| 552 |
+
<div style="font-size: 25px;">Bottled Waters</div>
|
| 553 |
+
</div>
|
| 554 |
+
""", unsafe_allow_html = True)
|
| 555 |
+
value = round(water_eq.magnitude, 3)
|
| 556 |
+
st.latex(rf'\Large {value:.0f} \ \large {"bottles"}')
|
| 557 |
+
st.markdown(f'<p align="center"><i>Based on water consumption, measured in 0.75 L bottles.<i></p>', unsafe_allow_html = True)
|
| 558 |
+
|
| 559 |
+
st.divider()
|
| 560 |
+
|
| 561 |
+
st.markdown('<h3 align="center">What if the company does this request everyday for 251 days (number of work days per year in France in 2025) ?</h3>', unsafe_allow_html = True)
|
| 562 |
+
|
| 563 |
+
col5, col6, col7, col8 = st.columns(4)
|
| 564 |
+
|
| 565 |
+
with col5:
|
| 566 |
+
|
| 567 |
+
electricity_production, count = format_energy_eq_electricity_production_company(impacts.energy, company_multiplier)
|
| 568 |
+
if electricity_production == EnergyProduction.NUCLEAR:
|
| 569 |
+
emoji = "☢️"
|
| 570 |
+
name = "Nuclear power plants"
|
| 571 |
+
if electricity_production == EnergyProduction.WIND:
|
| 572 |
+
emoji = "💨️ "
|
| 573 |
+
name = "Wind turbines"
|
| 574 |
+
st.markdown(f"""
|
| 575 |
+
<div style="text-align: center;">
|
| 576 |
+
<div style="font-size: 30px;">
|
| 577 |
+
{emoji}
|
| 578 |
+
</div>
|
| 579 |
+
<div style="font-size: 30px;">
|
| 580 |
+
{count.magnitude:.3g}
|
| 581 |
+
</div>
|
| 582 |
+
<div style="font-size: 25px;">
|
| 583 |
+
{name}
|
| 584 |
+
</div>
|
| 585 |
+
<div style="font-size: 12px;">
|
| 586 |
+
(yearly ⚡️ production)
|
| 587 |
+
</div>
|
| 588 |
+
</div>
|
| 589 |
+
""", unsafe_allow_html=True)
|
| 590 |
+
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 591 |
+
|
| 592 |
+
with col6:
|
| 593 |
+
ireland_count = format_energy_eq_electricity_consumption_ireland_company(impacts.energy, company_multiplier)
|
| 594 |
+
st.markdown(f"""
|
| 595 |
+
<div style="text-align: center;">
|
| 596 |
+
<div style="font-size: 30px;">
|
| 597 |
+
☘️🇮🇪
|
| 598 |
+
</div>
|
| 599 |
+
<div style="font-size: 30px;">
|
| 600 |
+
{ireland_count.magnitude:.3g}
|
| 601 |
+
</div>
|
| 602 |
+
<div style="font-size: 25px;">
|
| 603 |
+
Irelands
|
| 604 |
+
</div>
|
| 605 |
+
<div style="font-size: 12px;">
|
| 606 |
+
(yearly ⚡️ consumption)
|
| 607 |
+
</div>
|
| 608 |
+
</div>
|
| 609 |
+
""", unsafe_allow_html=True)
|
| 610 |
+
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 611 |
+
|
| 612 |
+
with col7:
|
| 613 |
+
paris_nyc_airplane = format_gwp_eq_airplane_paris_nyc_company(impacts.gwp, company_multiplier)
|
| 614 |
+
st.markdown(f"""
|
| 615 |
+
<div style="text-align: center;">
|
| 616 |
+
<div style="font-size: 30px;">
|
| 617 |
+
✈️
|
| 618 |
+
</div>
|
| 619 |
+
<div style="font-size: 30px;">
|
| 620 |
+
{paris_nyc_airplane.magnitude:.3g}
|
| 621 |
+
</div>
|
| 622 |
+
<div style="font-size: 25px;">
|
| 623 |
+
Paris ↔ NYC
|
| 624 |
+
</div>
|
| 625 |
+
</div>
|
| 626 |
+
""", unsafe_allow_html=True)
|
| 627 |
+
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|
| 628 |
+
|
| 629 |
+
with col8:
|
| 630 |
+
olympic_swimming_pool = format_water_eq_olympic_sized_swimming_pool_company(impacts.water, company_multiplier)
|
| 631 |
+
st.markdown(f"""
|
| 632 |
+
<div style="text-align: center;">
|
| 633 |
+
<div style="font-size: 30px;">
|
| 634 |
+
🏊🏼
|
| 635 |
+
</div>
|
| 636 |
+
<div style="font-size: 30px;">
|
| 637 |
+
{olympic_swimming_pool.magnitude:.3g}
|
| 638 |
+
</div>
|
| 639 |
+
<div style="font-size: 22px;">
|
| 640 |
+
Olympic-sized swimming pools
|
| 641 |
+
</div>
|
| 642 |
+
</div>
|
| 643 |
+
""", unsafe_allow_html=True)
|
| 644 |
+
st.markdown(f'<p align="center"><i>Based on water consumption<i></p>', unsafe_allow_html = True)
|
src/models.py
CHANGED
|
@@ -15,9 +15,13 @@ def clean_models_data(df, with_filter = True):
|
|
| 15 |
'cohere': 'Cohere',
|
| 16 |
'microsoft': 'Microsoft',
|
| 17 |
'mistral-community': 'Mistral Community',
|
| 18 |
-
'databricks': 'Databricks'
|
|
|
|
|
|
|
| 19 |
}
|
| 20 |
|
|
|
|
|
|
|
| 21 |
models_to_keep = MAIN_MODELS
|
| 22 |
|
| 23 |
df.drop('type', axis=1, inplace=True)
|
|
|
|
| 15 |
'cohere': 'Cohere',
|
| 16 |
'microsoft': 'Microsoft',
|
| 17 |
'mistral-community': 'Mistral Community',
|
| 18 |
+
'databricks': 'Databricks',
|
| 19 |
+
"azureopenai" : "Microsoft", #présent dans ecologits mais pas ici. traité comme Openai
|
| 20 |
+
"huggingfacehub" : "AWS" #présent dans ecologits mais pas ici. traité comme Openai
|
| 21 |
}
|
| 22 |
|
| 23 |
+
|
| 24 |
+
|
| 25 |
models_to_keep = MAIN_MODELS
|
| 26 |
|
| 27 |
df.drop('type', axis=1, inplace=True)
|
src/utils.py
CHANGED
|
@@ -2,7 +2,7 @@ from dataclasses import dataclass
|
|
| 2 |
from enum import Enum
|
| 3 |
|
| 4 |
from ecologits.model_repository import models
|
| 5 |
-
from ecologits.impacts.modeling import Impacts, Energy, GWP, ADPe, PE
|
| 6 |
#from ecologits.tracers.utils import llm_impacts
|
| 7 |
from pint import UnitRegistry, Quantity
|
| 8 |
|
|
@@ -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,10 +73,14 @@ 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 |
|
| 75 |
-
DAYS_IN_YEAR = 365
|
|
|
|
|
|
|
| 76 |
|
| 77 |
# For a 900 MW nuclear plant -> 500 000 MWh / month
|
| 78 |
# From 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
|
|
@@ -90,6 +98,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 +174,35 @@ 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:
|
|
@@ -122,18 +210,21 @@ def format_impacts(impacts: Impacts) -> QImpacts:
|
|
| 122 |
impacts.gwp.value = (impacts.gwp.value.max + impacts.gwp.value.min)/2
|
| 123 |
impacts.adpe.value = (impacts.adpe.value.max + impacts.adpe.value.min)/2
|
| 124 |
impacts.pe.value = (impacts.pe.value.max + impacts.pe.value.min)/2
|
|
|
|
| 125 |
return 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(
|
| 133 |
energy=format_energy(impacts.energy),
|
| 134 |
gwp=format_gwp(impacts.gwp),
|
| 135 |
adpe=format_adpe(impacts.adpe),
|
| 136 |
-
pe=format_pe(impacts.pe)
|
|
|
|
| 137 |
), impacts.usage, impacts.embodied
|
| 138 |
|
| 139 |
def split_impacts_u_e(impacts: Impacts) -> QImpacts:
|
|
@@ -153,7 +244,8 @@ def format_impacts_expert(impacts: Impacts, display_range: bool) -> QImpacts:
|
|
| 153 |
energy=format_energy(impacts.energy),
|
| 154 |
gwp=format_gwp(impacts.gwp),
|
| 155 |
adpe=format_adpe(impacts.adpe),
|
| 156 |
-
pe=format_pe(impacts.pe)
|
|
|
|
| 157 |
), impacts.usage, impacts.embodied
|
| 158 |
|
| 159 |
else:
|
|
@@ -165,8 +257,13 @@ def format_impacts_expert(impacts: Impacts, display_range: bool) -> QImpacts:
|
|
| 165 |
energy=format_energy(energy),
|
| 166 |
gwp=format_gwp(gwp),
|
| 167 |
adpe=format_adpe(adpe),
|
| 168 |
-
pe=format_pe(pe)
|
|
|
|
| 169 |
), impacts.usage, impacts.embodied
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
#####################################################################################
|
| 172 |
### EQUIVALENT FORMATING
|
|
@@ -199,6 +296,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")
|
|
@@ -213,7 +315,75 @@ def format_energy_eq_electricity_consumption_ireland(energy: Quantity) -> Quanti
|
|
| 213 |
electricity_eq = electricity_eq.to("TWh")
|
| 214 |
return electricity_eq / YEARLY_IRELAND_ELECTRICITY_CONSUMPTION
|
| 215 |
|
|
|
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
from enum import Enum
|
| 3 |
|
| 4 |
from ecologits.model_repository import models
|
| 5 |
+
from ecologits.impacts.modeling import Impacts, Energy, GWP, ADPe, PE, Water
|
| 6 |
#from ecologits.tracers.utils import llm_impacts
|
| 7 |
from pint import UnitRegistry, Quantity
|
| 8 |
|
|
|
|
| 27 |
u.define('s = second')
|
| 28 |
u.define('min = minute')
|
| 29 |
u.define('h = hour')
|
| 30 |
+
u.define('L = liter')
|
| 31 |
+
u.define('mL = milliliter')
|
| 32 |
+
#u.define('bottled waters = 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 = q("0.75 L")
|
| 77 |
+
|
| 78 |
# From https://ourworldindata.org/population-growth
|
| 79 |
ONE_PERCENT_WORLD_POPULATION = 80_000_000
|
| 80 |
|
| 81 |
+
DAYS_IN_YEAR = 365.15
|
| 82 |
+
|
| 83 |
+
WORKDAYS_IN_YEAR_FRANCE = 251
|
| 84 |
|
| 85 |
# For a 900 MW nuclear plant -> 500 000 MWh / month
|
| 86 |
# From 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
|
|
|
|
| 98 |
# From https://impactco2.fr/outils/comparateur?value=1&comparisons=&equivalent=avion-pny
|
| 99 |
AIRPLANE_PARIS_NYC_GWP_EQ = q("177000 kgCO2eq")
|
| 100 |
|
| 101 |
+
# From https://www.patagoniaalliance.org/wp-content/uploads/2014/08/How-much-water-does-an-Olympic-sized-swimming-pool-hold.pdf
|
| 102 |
+
OLYMPIC_SWIMMING_POOL = q("2500000 L") #2.5 million
|
| 103 |
+
|
| 104 |
+
# From https://docs.google.com/spreadsheets/d/1uj8yA601uBtJ7GSf7k96Lv1NoQBfsCnVmTCII2HgZvo/edit?gid=0#gid=0
|
| 105 |
+
# Google : https://www.gstatic.com/gumdrop/sustainability/google-2025-environmental-report.pdf
|
| 106 |
+
# Meta: https://sustainability.atmeta.com/wp-content/uploads/2024/08/Meta-2024-Sustainability-Report.pdf
|
| 107 |
+
# Microsoft: https://azure.microsoft.com/en-us/blog/how-microsoft-measures-datacenter-water-and-energy-use-to-improve-azure-cloud-sustainability/
|
| 108 |
+
# OVHCloud: https://corporate.ovhcloud.com/en/sustainability/environment/
|
| 109 |
+
# Scaleway: https://www-uploads.scaleway.com/Impact_Report2024_A4_EN_e63efcae20.pdf
|
| 110 |
+
# AWS: https://sustainability.aboutamazon.com/2023-report
|
| 111 |
+
# Equinix: https://www.equinix.com/resources/infopapers/2023-corporate-sustainability-report
|
| 112 |
+
PROVIDER_WUE_ONSITE = { #Water use efficiency on-site, as opposed to off-site generated energy
|
| 113 |
+
"Google" : 0.916,
|
| 114 |
+
"Meta": 0.18, # L/kWh, 2023
|
| 115 |
+
"Microsoft": 0.49, #2022
|
| 116 |
+
"OVHCloud": 0.37, #2024
|
| 117 |
+
"Scaleway": 0.216, #2023
|
| 118 |
+
"AWS" : 0.18, #2023
|
| 119 |
+
"Equinix" : 1.07 #2023
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
# Google https://www.gstatic.com/gumdrop/sustainability/google-2025-environmental-report.pdf
|
| 124 |
+
# Meta https://sustainability.atmeta.com/data-centers/#:~:text=Meta's%20operational%20data%20centers%2C%20on,Effectiveness%20(WUE)%20of%200.20.
|
| 125 |
+
# Microsoft https://azure.microsoft.com/en-us/blog/how-microsoft-measures-datacenter-water-and-energy-use-to-improve-azure-cloud-sustainability/
|
| 126 |
+
# OVHCloud https://corporate.ovhcloud.com/en/sustainability/environment/
|
| 127 |
+
# Scaleway https://www-uploads.scaleway.com/Impact_Report2024_A4_EN_e63efcae20.pdf
|
| 128 |
+
# AWS https://sustainability.aboutamazon.com/products-services/aws-cloud
|
| 129 |
+
# Equinix https://www.equinix.com/content/dam/eqxcorp/en_us/documents/resources/infopapers/ip_2023_sustainability_en.pdf
|
| 130 |
+
PROVIDER_PUE = { #Power use efficiency
|
| 131 |
+
"Google" : 1.09,
|
| 132 |
+
"Meta" : 1.09,
|
| 133 |
+
"Microsoft" : 1.18,
|
| 134 |
+
"OVHCloud" : 1.26,
|
| 135 |
+
"Scaleway" : 1.37,
|
| 136 |
+
"AWS" : 1.15,
|
| 137 |
+
"Equinix" : 1.42
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
AI_COMPANY_TO_DATA_CENTER_PROVIDER = { #A list that draws the connection between AI companies and their data center providers
|
| 141 |
+
"anthropic" : "Google",
|
| 142 |
+
"mistralai" : "OVHCloud",
|
| 143 |
+
"cohere" : "AWS",
|
| 144 |
+
"databricks" : "Microsoft",
|
| 145 |
+
"meta" : "Meta",
|
| 146 |
+
"google" : "Google",
|
| 147 |
+
"microsoft" : "Microsoft",
|
| 148 |
+
"openai" : "Microsoft"
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
|
| 152 |
#####################################################################################
|
| 153 |
### IMPACTS FORMATING
|
| 154 |
#####################################################################################
|
|
|
|
| 174 |
val = val.to("kJ")
|
| 175 |
return val
|
| 176 |
|
| 177 |
+
def format_water(water: Water) -> Quantity:
|
| 178 |
+
val = q(water.value, water.unit)
|
| 179 |
+
if val < q("1 L"):
|
| 180 |
+
val = val.to("mL")
|
| 181 |
+
return val
|
| 182 |
+
|
| 183 |
+
def range_percent_impact_one_sided(impacts: Impacts) -> float:
|
| 184 |
+
impacts_energy_mean = (impacts.energy.value.max + impacts.energy.value.min)/2
|
| 185 |
+
range_percent_energy_one_sided = (impacts.energy.value.max - impacts.energy.value.min) / (2* impacts_energy_mean) * 100
|
| 186 |
+
impacts_gwp_mean = (impacts.gwp.value.max + impacts.gwp.value.min)/2
|
| 187 |
+
range_percent_gwp_one_sided = (impacts.gwp.value.max - impacts.gwp.value.min) / (2* impacts_gwp_mean) * 100
|
| 188 |
+
impacts_adpe_mean = (impacts.adpe.value.max + impacts.adpe.value.min)/2
|
| 189 |
+
range_percent_adpe_one_sided = (impacts.adpe.value.max - impacts.adpe.value.min) / (2* impacts_adpe_mean) * 100
|
| 190 |
+
impacts_pe_mean = (impacts.pe.value.max + impacts.pe.value.min)/2
|
| 191 |
+
range_percent_pe_one_sided = (impacts.pe.value.max - impacts.pe.value.min) / (2* impacts_pe_mean) * 100
|
| 192 |
+
impacts_water_mean = (impacts.water.value.max + impacts.water.value.min)/2
|
| 193 |
+
range_percent_water_one_sided = (impacts.water.value.max - impacts.water.value.min) / (2* impacts_water_mean) * 100
|
| 194 |
+
|
| 195 |
+
results = {
|
| 196 |
+
"energy" : range_percent_energy_one_sided,
|
| 197 |
+
"gwp": range_percent_gwp_one_sided,
|
| 198 |
+
"adpe": range_percent_adpe_one_sided,
|
| 199 |
+
"pe": range_percent_pe_one_sided,
|
| 200 |
+
"water" : range_percent_water_one_sided
|
| 201 |
+
}
|
| 202 |
+
return results
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
|
| 206 |
def format_impacts(impacts: Impacts) -> QImpacts:
|
| 207 |
|
| 208 |
try:
|
|
|
|
| 210 |
impacts.gwp.value = (impacts.gwp.value.max + impacts.gwp.value.min)/2
|
| 211 |
impacts.adpe.value = (impacts.adpe.value.max + impacts.adpe.value.min)/2
|
| 212 |
impacts.pe.value = (impacts.pe.value.max + impacts.pe.value.min)/2
|
| 213 |
+
impacts.water.value = (impacts.water.value.max + impacts.water.value.min)/2
|
| 214 |
return QImpacts(
|
| 215 |
energy=format_energy(impacts.energy),
|
| 216 |
gwp=format_gwp(impacts.gwp),
|
| 217 |
adpe=format_adpe(impacts.adpe),
|
| 218 |
+
pe=format_pe(impacts.pe),
|
| 219 |
+
water=format_water(impacts.water)
|
| 220 |
), impacts.usage, impacts.embodied
|
| 221 |
except: #when no range
|
| 222 |
return QImpacts(
|
| 223 |
energy=format_energy(impacts.energy),
|
| 224 |
gwp=format_gwp(impacts.gwp),
|
| 225 |
adpe=format_adpe(impacts.adpe),
|
| 226 |
+
pe=format_pe(impacts.pe),
|
| 227 |
+
water=format_water(impacts.water)
|
| 228 |
), impacts.usage, impacts.embodied
|
| 229 |
|
| 230 |
def split_impacts_u_e(impacts: Impacts) -> QImpacts:
|
|
|
|
| 244 |
energy=format_energy(impacts.energy),
|
| 245 |
gwp=format_gwp(impacts.gwp),
|
| 246 |
adpe=format_adpe(impacts.adpe),
|
| 247 |
+
pe=format_pe(impacts.pe),
|
| 248 |
+
water=format_water(impacts.water)
|
| 249 |
), impacts.usage, impacts.embodied
|
| 250 |
|
| 251 |
else:
|
|
|
|
| 257 |
energy=format_energy(energy),
|
| 258 |
gwp=format_gwp(gwp),
|
| 259 |
adpe=format_adpe(adpe),
|
| 260 |
+
pe=format_pe(pe),
|
| 261 |
+
water=format_water(impacts.water)
|
| 262 |
), impacts.usage, impacts.embodied
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
######################################################################3
|
| 267 |
|
| 268 |
#####################################################################################
|
| 269 |
### EQUIVALENT FORMATING
|
|
|
|
| 296 |
streaming_eq = streaming_eq.to("s")
|
| 297 |
return streaming_eq
|
| 298 |
|
| 299 |
+
def format_water_eq_bottled_waters(water: Quantity) -> Quantity:
|
| 300 |
+
water = water.to("L")
|
| 301 |
+
bottled_water_eq = water / BOTTLED_WATERS_EQ
|
| 302 |
+
return bottled_water_eq
|
| 303 |
+
|
| 304 |
def format_energy_eq_electricity_production(energy: Quantity) -> tuple[EnergyProduction, Quantity]:
|
| 305 |
electricity_eq = energy * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
|
| 306 |
electricity_eq = electricity_eq.to("TWh")
|
|
|
|
| 315 |
electricity_eq = electricity_eq.to("TWh")
|
| 316 |
return electricity_eq / YEARLY_IRELAND_ELECTRICITY_CONSUMPTION
|
| 317 |
|
| 318 |
+
|
| 319 |
def format_gwp_eq_airplane_paris_nyc(gwp: Quantity) -> Quantity:
|
| 320 |
gwp_eq = gwp * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
|
| 321 |
gwp_eq = gwp_eq.to("kgCO2eq")
|
| 322 |
+
return gwp_eq / AIRPLANE_PARIS_NYC_GWP_EQ
|
| 323 |
+
|
| 324 |
+
def format_water_eq_olympic_sized_swimming_pool(water: Quantity) -> Quantity:
|
| 325 |
+
water_eq = water * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
|
| 326 |
+
water_eq = water_eq.to("L")
|
| 327 |
+
return water_eq / OLYMPIC_SWIMMING_POOL
|
| 328 |
+
|
| 329 |
+
########################################################################
|
| 330 |
+
|
| 331 |
+
def format_energy_eq_physical_activity_company(energy: Quantity, company_multiplier) -> tuple[PhysicalActivity, Quantity]:
|
| 332 |
+
energy = energy.to("kJ")
|
| 333 |
+
running_eq = energy / RUNNING_ENERGY_EQ * company_multiplier
|
| 334 |
+
if running_eq > q("1 km"):
|
| 335 |
+
return PhysicalActivity.RUNNING, running_eq
|
| 336 |
+
|
| 337 |
+
walking_eq = energy / WALKING_ENERGY_EQ
|
| 338 |
+
if walking_eq < q("1 km"):
|
| 339 |
+
walking_eq = walking_eq.to("meter")
|
| 340 |
+
return PhysicalActivity.WALKING, walking_eq
|
| 341 |
+
|
| 342 |
+
def format_energy_eq_electric_vehicle_company(energy: Quantity, company_multiplier) -> Quantity:
|
| 343 |
+
energy = energy.to("kWh")
|
| 344 |
+
ev_eq = energy / EV_ENERGY_EQ * company_multiplier
|
| 345 |
+
if ev_eq < q("1 km"):
|
| 346 |
+
ev_eq = ev_eq.to("meter")
|
| 347 |
+
return ev_eq
|
| 348 |
+
|
| 349 |
+
def format_gwp_eq_streaming_company(gwp: Quantity, company_multiplier) -> Quantity:
|
| 350 |
+
gwp = gwp.to("kgCO2eq")
|
| 351 |
+
streaming_eq = gwp * STREAMING_GWP_EQ * company_multiplier
|
| 352 |
+
if streaming_eq < q("1 h"):
|
| 353 |
+
streaming_eq = streaming_eq.to("min")
|
| 354 |
+
if streaming_eq < q("1 min"):
|
| 355 |
+
streaming_eq = streaming_eq.to("s")
|
| 356 |
+
return streaming_eq
|
| 357 |
+
|
| 358 |
+
def format_water_eq_bottled_waters_company(water: Quantity, company_multiplier) -> Quantity:
|
| 359 |
+
water = water.to("L")
|
| 360 |
+
bottled_water_eq = water / BOTTLED_WATERS_EQ * company_multiplier
|
| 361 |
+
return bottled_water_eq
|
| 362 |
+
|
| 363 |
+
def format_energy_eq_electricity_production_company(energy: Quantity, company_multiplier) -> tuple[EnergyProduction, Quantity]:
|
| 364 |
+
electricity_eq = energy * company_multiplier * WORKDAYS_IN_YEAR_FRANCE
|
| 365 |
+
electricity_eq = electricity_eq.to("TWh")
|
| 366 |
+
if electricity_eq > YEARLY_NUCLEAR_ENERGY_EQ:
|
| 367 |
+
return EnergyProduction.NUCLEAR, electricity_eq / YEARLY_NUCLEAR_ENERGY_EQ
|
| 368 |
+
electricity_eq = electricity_eq.to("GWh")
|
| 369 |
+
return EnergyProduction.WIND, electricity_eq / YEARLY_WIND_ENERGY_EQ
|
| 370 |
+
|
| 371 |
+
|
| 372 |
+
def format_energy_eq_electricity_consumption_ireland_company(energy: Quantity, company_multiplier) -> Quantity:
|
| 373 |
+
electricity_eq = energy * company_multiplier * WORKDAYS_IN_YEAR_FRANCE
|
| 374 |
+
electricity_eq = electricity_eq.to("TWh")
|
| 375 |
+
return electricity_eq / YEARLY_IRELAND_ELECTRICITY_CONSUMPTION
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
def format_gwp_eq_airplane_paris_nyc_company(gwp: Quantity, company_multiplier) -> Quantity:
|
| 379 |
+
gwp_eq = gwp * company_multiplier * WORKDAYS_IN_YEAR_FRANCE
|
| 380 |
+
gwp_eq = gwp_eq.to("kgCO2eq")
|
| 381 |
+
return gwp_eq / AIRPLANE_PARIS_NYC_GWP_EQ
|
| 382 |
+
|
| 383 |
+
def format_water_eq_olympic_sized_swimming_pool_company(water: Quantity, company_multiplier) -> Quantity:
|
| 384 |
+
water_eq = water * company_multiplier * WORKDAYS_IN_YEAR_FRANCE
|
| 385 |
+
water_eq = water_eq.to("L")
|
| 386 |
+
return water_eq / OLYMPIC_SWIMMING_POOL
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
####################################################################################### MODELS PARAMETER####################################################################################
|