WayToGoHe commited on
Commit
8df7b73
·
1 Parent(s): 44f8bc6

integrated code with ecologits

Browse files
src/__pycache__/calculator.cpython-311.pyc CHANGED
Binary files a/src/__pycache__/calculator.cpython-311.pyc and b/src/__pycache__/calculator.cpython-311.pyc differ
 
src/__pycache__/content.cpython-311.pyc CHANGED
Binary files a/src/__pycache__/content.cpython-311.pyc and b/src/__pycache__/content.cpython-311.pyc differ
 
src/__pycache__/expert.cpython-311.pyc CHANGED
Binary files a/src/__pycache__/expert.cpython-311.pyc and b/src/__pycache__/expert.cpython-311.pyc differ
 
src/__pycache__/impacts.cpython-311.pyc CHANGED
Binary files a/src/__pycache__/impacts.cpython-311.pyc and b/src/__pycache__/impacts.cpython-311.pyc differ
 
src/__pycache__/models.cpython-311.pyc CHANGED
Binary files a/src/__pycache__/models.cpython-311.pyc and b/src/__pycache__/models.cpython-311.pyc differ
 
src/__pycache__/utils.cpython-311.pyc CHANGED
Binary files a/src/__pycache__/utils.cpython-311.pyc and b/src/__pycache__/utils.cpython-311.pyc differ
 
src/calculator.py CHANGED
@@ -45,28 +45,28 @@ 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
- 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
- impacts, _, _ = format_impacts(impacts)
58
-
59
- with st.container(border=True):
60
 
61
- st.markdown('<h3 align = "center">Environmental impacts</h3>', unsafe_allow_html=True)
62
- st.markdown('<p align = "center">To understand how the environmental impacts are computed go to the 📖 Methodology tab.</p>', unsafe_allow_html=True)
63
- display_impacts(impacts, provider, location="🌎 World")
 
 
64
 
65
- with st.container(border=True):
66
-
67
- st.markdown('<h3 align = "center">That\'s equivalent to ...</h3>', unsafe_allow_html=True)
68
- st.markdown('<p align = "center">Making this request to the LLM is equivalent to the following actions :</p>', unsafe_allow_html=True)
69
- display_equivalent(impacts, provider, location="🌎 World")
70
 
71
- except Exception as e:
72
- st.error('Could not find the model in the repository. Please try another model.')
 
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
+ impacts, _, _ = format_impacts(impacts)
58
+
59
+ with st.container(border=True):
60
 
61
+ st.markdown('<h3 align = "center">Environmental impacts</h3>', unsafe_allow_html=True)
62
+ st.markdown('<p align = "center">To understand how the environmental impacts are computed go to the 📖 Methodology tab.</p>', unsafe_allow_html=True)
63
+ display_impacts(impacts, provider, location="🌎 World")
64
+
65
+ with st.container(border=True):
66
 
67
+ st.markdown('<h3 align = "center">That\'s equivalent to ...</h3>', unsafe_allow_html=True)
68
+ st.markdown('<p align = "center">Making this request to the LLM is equivalent to the following actions :</p>', unsafe_allow_html=True)
69
+ display_equivalent(impacts, provider, location="🌎 World")
 
 
70
 
71
+ # except Exception as e:
72
+ # st.error('Could not find the model in the repository. Please try another model.')
src/content.py CHANGED
@@ -171,27 +171,15 @@ Where
171
 
172
  Additionally, the environmental impacts are expressed in **four dimensions
173
  (multi-criteria impacts)**:
174
- * 🌍 **Global Warming Potential** (GWP): Potential impact on global warming in kilograms of CO2 equivalent,
175
  or kgCO2eq, also commonly known as green house gases (GHG) or carbon emissions.
176
  * 🪨 **Abiotic Depletion Potential for Elements** (ADPe): Mesures the impact on the depletion of non-organic resources such as
177
  minerals or metals in kilograms of antimony equivalent. This is to say the impact equating to that amount of antimony extracted.
178
  * ⛽️ **Primary Energy** (PE): Total energy consumed from primary sources in megajoules.
179
- * 💧 **Water Use** : Water consumption from this request. The formula for quantifying this is:
180
- $$
181
- WCF_{request} = E_{\text{server}} \times \left( \text{WUE}_{\text{on-site}} + \text{PUE} \times \text{WUE}_{\text{off-site}} \right) + \color{orange}{\frac{\Delta T \times {WCF}_{embodied}}{\Delta L \times N_{requests}} }
182
- $$
183
- Where
184
- * $WCF_{request}$ : Water consumption footprint for the request
185
- * $E_{\text{server}}$ : Energy cost at the server for the request
186
- * $WUE_{on-site}$ : Water usage efficiency at the data center
187
- * $PUE$: Power usage efficiency at the data center
188
- * $WUE_{off-site}$ : Water usage efficiency of the local electricity mix
189
- * $\color{orange}{\Delta T}$ : Generation latency, or the time it takes for the server to process the request, in seconds
190
- * $\color{orange}{\Delta L}$ : Server lifespan in seconds
191
- * $\color{orange}{N_{requests}}$ : Number of simultanous reqeusts handled by the server
192
- * $\color{orange}{WCF_{embodied}}$ : Embodied water consumption footprint for manufacturing the server
193
 
194
- The variables in $\color{orange}{orange}$ represent the embodied water consumption and are not presently integrated into the calculations due to the lack of data. According to many sources, once integrated, they could double or more our water consumption estimation.
195
  ### Principles, Data and Hypotheses
196
  We use a **bottom-up methodology** to model impacts, meaning that we estimate the impacts of low-level physical
197
  components to then estimate the impacts at software level (in our case an LLM inference). We also rely on **Life
@@ -277,7 +265,7 @@ CITATION_TEXT = r"""@misc{ecologits-calculator,
277
  howpublished= {\url{https://huggingface.co/spaces/genai-impact/ecologits-calculator}},
278
  }
279
  @software{ecologits,
280
- author = {Samuel Rincé, Adrien Banse, Vinh Nguyen and Luc Berton},
281
  publisher = {GenAI Impact},
282
  title = {EcoLogits: track the energy consumption and environmental footprint of using generative AI models through APIs.},
283
  }"""
 
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
 
265
  howpublished= {\url{https://huggingface.co/spaces/genai-impact/ecologits-calculator}},
266
  }
267
  @software{ecologits,
268
+ author = {Samuel Rincé, Adrien Banse, Vinh Nguyen, Luc Berton, and Chieh Hsu},
269
  publisher = {GenAI Impact},
270
  title = {EcoLogits: track the energy consumption and environmental footprint of using generative AI models through APIs.},
271
  }"""
src/expert.py CHANGED
@@ -32,6 +32,8 @@ def expert_mode():
32
  key = 1
33
  )
34
 
 
 
35
  with col2:
36
  model_exp = st.selectbox(
37
  label = 'Model',
@@ -79,7 +81,7 @@ def expert_mode():
79
 
80
  location = st.selectbox('Location', [x[0] for x in COUNTRY_CODES])
81
 
82
- col4, col5, col6 = st.columns(3)
83
 
84
  with col4:
85
  try:
@@ -97,6 +99,8 @@ def expert_mode():
97
  mix_adpe = st.number_input('Electricity mix - Abiotic resources [kgSbeq / kWh]', float(find_electricity_mix(["WOR"][0])[0]), format="%0.13f")
98
  st.warning(f"Lacking data on {location}, showing global average data.")
99
 
 
 
100
  with col6:
101
  try:
102
  mix_pe = st.number_input('Electricity mix - Primary energy [MJ / kWh]', float(find_electricity_mix([x[1] for x in COUNTRY_CODES if x[0] ==location][0])[1]), format="%0.3f")
@@ -104,6 +108,13 @@ def expert_mode():
104
  mix_pe = st.number_input('Electricity mix - Primary energy [MJ / kWh]', float(find_electricity_mix(["WOR"][0])[1]), format="%0.3f")
105
  st.warning(f"Lacking data on {location}, showing global average data.")
106
 
 
 
 
 
 
 
 
107
 
108
  impacts = compute_llm_impacts(model_active_parameter_count=active_params,
109
  model_total_parameter_count=total_params,
@@ -111,7 +122,9 @@ def expert_mode():
111
  request_latency=100000,
112
  if_electricity_mix_gwp=mix_gwp,
113
  if_electricity_mix_adpe=mix_adpe,
114
- if_electricity_mix_pe=mix_pe
 
 
115
  )
116
 
117
  impacts, usage, embodied = format_impacts(impacts)
 
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:
 
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")
 
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
  impacts, usage, embodied = format_impacts(impacts)
src/impacts.py CHANGED
@@ -34,58 +34,72 @@ def display_impacts(impacts, provider, location):
34
  col_energy, col_ghg, col_adpe, col_pe, col_water = st.columns(5)
35
 
36
  with col_energy:
37
- st.markdown('<h4 align="center">⚡️ Energy</h4>', unsafe_allow_html = True)
 
 
 
 
 
38
  st.latex(f'\Large {impacts.energy.magnitude:.3g} \ \large {impacts.energy.units}')
39
- st.markdown(f'<p align="center"><i>Evaluates the electricity consumption<i></p>', unsafe_allow_html = True)
 
 
 
 
40
 
41
  with col_ghg:
42
- st.markdown('<h4 align="center">🌍️ GHG Emissions</h4>', unsafe_allow_html = True)
 
 
 
 
 
43
  st.latex(f'\Large {impacts.gwp.magnitude:.3g} \ \large {impacts.gwp.units}')
44
- st.markdown(f'<p align="center"><i>Evaluates the effect on global warming<i></p>', unsafe_allow_html = True)
 
 
 
45
 
46
  with col_adpe:
47
- st.markdown('<h4 align="center">🪨 Abiotic Resources</h4>', unsafe_allow_html = True)
 
 
 
 
 
48
  st.latex(f'\Large {impacts.adpe.magnitude:.3g} \ \large {impacts.adpe.units}')
49
- st.markdown(f'<p align="center"><i>Evaluates the use of metals and minerals<i></p>', unsafe_allow_html = True)
 
 
 
50
 
51
  with col_pe:
52
- st.markdown('<h4 align="center">⛽️ Primary Energy</h4>', unsafe_allow_html = True)
 
 
 
 
 
53
  st.latex(f'\Large {impacts.pe.magnitude:.3g} \ \large {impacts.pe.units}')
54
- st.markdown(f'<p align="center"><i>Evaluates the use of energy resources<i></p>', unsafe_allow_html = True)
55
-
56
-
57
- with col_water: #je sais pas où se trouve magnitude ou impact, donc j'ai commencé par une approche locale
58
- st.markdown('<h4 align="center">🚰 Water</h4>', unsafe_allow_html = True)
59
- water = water_impact(impacts, provider, location)
60
- if water >= 1 :
61
- st.latex(f'\Large {water:.3g} \ \large {"Liters"}')
62
- else :
63
- st.latex(f'\Large {water * 1000 :.3g} \ \large {"mLiters"}')
64
- st.markdown(f'<p align="center"><i>Evaluates the use of water<i></p>', unsafe_allow_html = True)
65
-
66
-
67
- # WCF = E_server * [WUE_on-site + PUE * WUE_off-site] + embodied (embodied not yet implemented, embodied = T * WCF_embodied / lifetime)
68
- # WCF : Water Consumption Footprint for the request
69
- # E_server : energy cost at the server for the request
70
- # WUE_on-site : Water usage efficiency at the data center
71
- # PUE: Power usage efficiency at the data center
72
- # WUE_off-site: Water usage efficiency of the local electricity mix
73
- def water_impact(impacts, provider, location):
74
- energy = impacts.energy.magnitude
75
- PUE = PROVIDER_PUE[AI_COMPANY_TO_DATA_CENTER_PROVIDER[provider.lower()]]
76
- WUE_onsite = PROVIDER_WUE_ONSITE[AI_COMPANY_TO_DATA_CENTER_PROVIDER[provider.lower()]]
77
- #WUE_on-site =
78
- #pas de variation régionale pour le simulateur simple mais oui pour le simulateur expert mode
79
- try:
80
- WUE_offsite = float(find_electricity_mix([x[1] for x in COUNTRY_CODES if x[0] ==location][0])[4])
81
- except :
82
- WUE_offsite = float(find_electricity_mix(["WOR"][0])[4])
83
- st.warning(f"Lacking data on {location}, showing global average data.")
84
-
85
- water_consumption = energy * (WUE_onsite + PUE * WUE_offsite) /1000 #5.04 est la valeur WUF moyenne du globe
86
-
87
- #/1000 parce que les WUE et PUE sont en kWh
88
- return water_consumption
89
 
90
  ############################################################################################################
91
 
@@ -102,31 +116,53 @@ def display_equivalent(impacts, provider, location):
102
  with col1:
103
  physical_activity, distance = format_energy_eq_physical_activity(impacts.energy)
104
  if physical_activity == PhysicalActivity.WALKING:
105
- physical_activity = "🚶 " + physical_activity.capitalize()
 
106
  if physical_activity == PhysicalActivity.RUNNING:
107
- physical_activity = "🏃 " + physical_activity.capitalize()
108
-
109
- st.markdown(f'<h4 align="center">{physical_activity}</h4>', unsafe_allow_html = True)
 
 
 
 
 
 
110
  st.latex(f'\Large {distance.magnitude:.3g} \ \large {distance.units}')
111
  st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
112
 
113
  with col2:
114
  ev_eq = format_energy_eq_electric_vehicle(impacts.energy)
115
- st.markdown(f'<h4 align="center">🔋 Electric Vehicle</h4>', unsafe_allow_html = True)
 
 
 
 
 
116
  st.latex(f'\Large {ev_eq.magnitude:.3g} \ \large {ev_eq.units}')
117
  st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
118
 
119
  with col3:
120
  streaming_eq = format_gwp_eq_streaming(impacts.gwp)
121
- st.markdown(f'<h4 align="center">⏯️ Streaming</h4>', unsafe_allow_html = True)
 
 
 
 
 
122
  st.latex(f'\Large {streaming_eq.magnitude:.3g} \ \large {streaming_eq.units}')
123
  st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
124
 
125
  with col4:
126
- water = water_impact(impacts, provider, location)
127
- water_eq = format_water_eq_bottled_waters(water)
128
- st.markdown(f'<h4 align="center">🚰 Bottled waters</h4>', unsafe_allow_html = True)
129
- st.latex(f'\Large {water_eq:.3g} \ \large {"bottles"}')
 
 
 
 
 
130
  st.markdown(f'<p align="center"><i>Based on water consumption, measured in 0.75 L bottles.<i></p>', unsafe_allow_html = True)
131
 
132
 
@@ -160,8 +196,7 @@ def display_equivalent(impacts, provider, location):
160
  st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
161
 
162
  with col8:
163
- water = water_impact(impacts, provider, location)
164
- water_eq = format_water_eq_olympic_sized_swimming_pool(water)
165
- st.markdown(f'<h4 align="center">🏊🏼 {round(water_eq):,} Olympic-sized swimming pools</h4>', unsafe_allow_html = True)
166
  st.markdown(f'<p align="center"><i>Based on water consumption<i></p>', unsafe_allow_html = True)
167
 
 
34
  col_energy, col_ghg, col_adpe, col_pe, col_water = st.columns(5)
35
 
36
  with col_energy:
37
+ st.markdown("""
38
+ <div style="text-align: center;">
39
+ <div style="font-size: 30px;">⚡️</div>
40
+ <div style="font-size: 25px;">Energy</div>
41
+ </div>
42
+ """, unsafe_allow_html = True)
43
  st.latex(f'\Large {impacts.energy.magnitude:.3g} \ \large {impacts.energy.units}')
44
+ st.markdown("""
45
+ <div style="height: 10px;"></div>
46
+ <div style="text-align: center;"><i>Evaluates the electricity consumption<i>
47
+ </div>
48
+ """, unsafe_allow_html = True)
49
 
50
  with col_ghg:
51
+ st.markdown("""
52
+ <div style="text-align: center;">
53
+ <div style="font-size: 30px;">🌍️</div>
54
+ <div style="font-size: 18px;">GHG Emissions</div>
55
+ </div>
56
+ """, unsafe_allow_html = True)
57
  st.latex(f'\Large {impacts.gwp.magnitude:.3g} \ \large {impacts.gwp.units}')
58
+ st.markdown("""
59
+ <div style="text-align: center;"><i>Evaluates the effect on climate change<i>
60
+ </div>
61
+ """, unsafe_allow_html = True)
62
 
63
  with col_adpe:
64
+ st.markdown("""
65
+ <div style="text-align: center;">
66
+ <div style="font-size: 30px;">🪨</div>
67
+ <div style="font-size: 16px;">Abiotic Resources</div>
68
+ </div>
69
+ """, unsafe_allow_html = True)
70
  st.latex(f'\Large {impacts.adpe.magnitude:.3g} \ \large {impacts.adpe.units}')
71
+ st.markdown("""
72
+ <div style="text-align: center;"><i>Evaluates the use of metals and minerals<i>
73
+ </div>
74
+ """, unsafe_allow_html = True)
75
 
76
  with col_pe:
77
+ st.markdown("""
78
+ <div style="text-align: center;">
79
+ <div style="font-size: 30px;">⛽️</div>
80
+ <div style="font-size: 18px;">Primary Energy</div>
81
+ </div>
82
+ """, unsafe_allow_html = True)
83
  st.latex(f'\Large {impacts.pe.magnitude:.3g} \ \large {impacts.pe.units}')
84
+ st.markdown("""
85
+ <div style="height: 10px;"></div>
86
+ <div style="text-align: center;"><i>Evaluates the use of energy resources<i>
87
+ </div>
88
+ """, unsafe_allow_html = True)
89
+
90
+ with col_water:
91
+ st.markdown("""
92
+ <div style="text-align: center;">
93
+ <div style="font-size: 30px;">🚰</div>
94
+ <div style="font-size: 25px;">Water</div>
95
+ </div>
96
+ """, unsafe_allow_html = True)
97
+ st.latex(f'\Large {impacts.water.magnitude:.3g} \ \large {impacts.water.units}')
98
+ st.markdown("""
99
+ <div style="text-align: center;"><i>Evaluates the use of water<i>
100
+ </div>
101
+ """, unsafe_allow_html = True)
102
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
  ############################################################################################################
105
 
 
116
  with col1:
117
  physical_activity, distance = format_energy_eq_physical_activity(impacts.energy)
118
  if physical_activity == PhysicalActivity.WALKING:
119
+ physical_activity_emoji = "🚶 "
120
+ physical_activity = physical_activity.capitalize()
121
  if physical_activity == PhysicalActivity.RUNNING:
122
+ physical_activity_emoji = "🏃 "
123
+ physical_activity = physical_activity.capitalize()
124
+
125
+ st.markdown(f"""
126
+ <div style="text-align: center;">
127
+ <div style="font-size: 30px;">{physical_activity_emoji}</div>
128
+ <div style="font-size: 25px;">{physical_activity}</div>
129
+ </div>
130
+ """, unsafe_allow_html = True)
131
  st.latex(f'\Large {distance.magnitude:.3g} \ \large {distance.units}')
132
  st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
133
 
134
  with col2:
135
  ev_eq = format_energy_eq_electric_vehicle(impacts.energy)
136
+ st.markdown(f"""
137
+ <div style="text-align: center;">
138
+ <div style="font-size: 30px;">🔋</div>
139
+ <div style="font-size: 22px;">Electric Vehicle</div>
140
+ </div>
141
+ """, unsafe_allow_html = True)
142
  st.latex(f'\Large {ev_eq.magnitude:.3g} \ \large {ev_eq.units}')
143
  st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
144
 
145
  with col3:
146
  streaming_eq = format_gwp_eq_streaming(impacts.gwp)
147
+ st.markdown(f"""
148
+ <div style="text-align: center;">
149
+ <div style="font-size: 30px;">⏯️</div>
150
+ <div style="font-size: 25px;">Streaming</div>
151
+ </div>
152
+ """, unsafe_allow_html = True)
153
  st.latex(f'\Large {streaming_eq.magnitude:.3g} \ \large {streaming_eq.units}')
154
  st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
155
 
156
  with col4:
157
+ #water = water_impact(impacts, provider, location)
158
+ water_eq = format_water_eq_bottled_waters(impacts.water)
159
+ st.markdown(f"""
160
+ <div style="text-align: center;">
161
+ <div style="font-size: 30px;">🚰</div>
162
+ <div style="font-size: 25px;">Bottled Waters</div>
163
+ </div>
164
+ """, unsafe_allow_html = True)
165
+ st.latex(f'\Large {water_eq.magnitude:.3g} \ \large {"bottles"}')
166
  st.markdown(f'<p align="center"><i>Based on water consumption, measured in 0.75 L bottles.<i></p>', unsafe_allow_html = True)
167
 
168
 
 
196
  st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
197
 
198
  with col8:
199
+ olympic_swimming_pool = format_water_eq_olympic_sized_swimming_pool(impacts.water)
200
+ st.markdown(f'<div style="text-align: center; font-size: 20px; font-weight: bold;">🏊🏼 {round(olympic_swimming_pool.magnitude):,} Olympic-sized swimming pools</h4>', unsafe_allow_html = True)
 
201
  st.markdown(f'<p align="center"><i>Based on water consumption<i></p>', unsafe_allow_html = True)
202
 
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,9 +27,9 @@ u.define('km = kilometer')
27
  u.define('s = second')
28
  u.define('min = minute')
29
  u.define('h = hour')
30
- # u.define('L = liters')
31
- # u.define('mL = milliliters')
32
- # u.define('bottled waters')
33
  q = u.Quantity
34
 
35
  @dataclass
@@ -38,7 +38,7 @@ class QImpacts:
38
  gwp: Quantity
39
  adpe: Quantity
40
  pe: Quantity
41
- # water: Quantity
42
 
43
 
44
  class PhysicalActivity(str, Enum):
@@ -73,7 +73,7 @@ EV_ENERGY_EQ = q("0.17 kWh / km")
73
  # From https://impactco2.fr/outils/comparateur?value=1&comparisons=streamingvideo
74
  STREAMING_GWP_EQ = q("15.6 h / kgCO2eq")
75
 
76
- BOTTLED_WATERS_EQ = 0.75
77
 
78
  # From https://ourworldindata.org/population-growth
79
  ONE_PERCENT_WORLD_POPULATION = 80_000_000
@@ -97,7 +97,7 @@ IRELAND_POPULATION_MILLION = 5
97
  AIRPLANE_PARIS_NYC_GWP_EQ = q("177000 kgCO2eq")
98
 
99
  # From https://www.patagoniaalliance.org/wp-content/uploads/2014/08/How-much-water-does-an-Olympic-sized-swimming-pool-hold.pdf
100
- OLYMPIC_SWIMMING_POOL = 2500000 #2.5 million
101
 
102
  # From https://docs.google.com/spreadsheets/d/1uj8yA601uBtJ7GSf7k96Lv1NoQBfsCnVmTCII2HgZvo/edit?gid=0#gid=0
103
  # Google : https://www.gstatic.com/gumdrop/sustainability/google-2025-environmental-report.pdf
@@ -172,9 +172,11 @@ def format_pe(pe: PE) -> Quantity:
172
  val = val.to("kJ")
173
  return val
174
 
175
- # def format_water(water: PE) -> Quantity:
176
- # val = q(water.value, water.unit)
177
- # return val
 
 
178
 
179
  def format_impacts(impacts: Impacts) -> QImpacts:
180
 
@@ -183,18 +185,21 @@ def format_impacts(impacts: Impacts) -> QImpacts:
183
  impacts.gwp.value = (impacts.gwp.value.max + impacts.gwp.value.min)/2
184
  impacts.adpe.value = (impacts.adpe.value.max + impacts.adpe.value.min)/2
185
  impacts.pe.value = (impacts.pe.value.max + impacts.pe.value.min)/2
 
186
  return QImpacts(
187
  energy=format_energy(impacts.energy),
188
  gwp=format_gwp(impacts.gwp),
189
  adpe=format_adpe(impacts.adpe),
190
  pe=format_pe(impacts.pe),
 
191
  ), impacts.usage, impacts.embodied
192
  except: #when no range
193
  return QImpacts(
194
  energy=format_energy(impacts.energy),
195
  gwp=format_gwp(impacts.gwp),
196
  adpe=format_adpe(impacts.adpe),
197
- pe=format_pe(impacts.pe)
 
198
  ), impacts.usage, impacts.embodied
199
 
200
  def split_impacts_u_e(impacts: Impacts) -> QImpacts:
@@ -214,7 +219,8 @@ def format_impacts_expert(impacts: Impacts, display_range: bool) -> QImpacts:
214
  energy=format_energy(impacts.energy),
215
  gwp=format_gwp(impacts.gwp),
216
  adpe=format_adpe(impacts.adpe),
217
- pe=format_pe(impacts.pe)
 
218
  ), impacts.usage, impacts.embodied
219
 
220
  else:
@@ -226,7 +232,8 @@ def format_impacts_expert(impacts: Impacts, display_range: bool) -> QImpacts:
226
  energy=format_energy(energy),
227
  gwp=format_gwp(gwp),
228
  adpe=format_adpe(adpe),
229
- pe=format_pe(pe)
 
230
  ), impacts.usage, impacts.embodied
231
 
232
  #####################################################################################
@@ -260,8 +267,8 @@ def format_gwp_eq_streaming(gwp: Quantity) -> Quantity:
260
  streaming_eq = streaming_eq.to("s")
261
  return streaming_eq
262
 
263
- def format_water_eq_bottled_waters(water):
264
- #water = water.to("bottled waters")
265
  bottled_water_eq = water / BOTTLED_WATERS_EQ
266
  return bottled_water_eq
267
 
@@ -284,8 +291,13 @@ def format_gwp_eq_airplane_paris_nyc(gwp: Quantity) -> Quantity:
284
  gwp_eq = gwp_eq.to("kgCO2eq")
285
  return gwp_eq / AIRPLANE_PARIS_NYC_GWP_EQ
286
 
287
- def format_water_eq_olympic_sized_swimming_pool(water):
288
  water_eq = water * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
 
289
  return water_eq / OLYMPIC_SWIMMING_POOL
290
 
 
 
 
 
291
  ####################################################################################### MODELS PARAMETER####################################################################################
 
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
 
97
  AIRPLANE_PARIS_NYC_GWP_EQ = q("177000 kgCO2eq")
98
 
99
  # From https://www.patagoniaalliance.org/wp-content/uploads/2014/08/How-much-water-does-an-Olympic-sized-swimming-pool-hold.pdf
100
+ OLYMPIC_SWIMMING_POOL = q("2500000 L") #2.5 million
101
 
102
  # From https://docs.google.com/spreadsheets/d/1uj8yA601uBtJ7GSf7k96Lv1NoQBfsCnVmTCII2HgZvo/edit?gid=0#gid=0
103
  # Google : https://www.gstatic.com/gumdrop/sustainability/google-2025-environmental-report.pdf
 
172
  val = val.to("kJ")
173
  return val
174
 
175
+ def format_water(water: Water) -> Quantity:
176
+ val = q(water.value, water.unit)
177
+ if val < q("1 L"):
178
+ val = val.to("mL")
179
+ return val
180
 
181
  def format_impacts(impacts: Impacts) -> QImpacts:
182
 
 
185
  impacts.gwp.value = (impacts.gwp.value.max + impacts.gwp.value.min)/2
186
  impacts.adpe.value = (impacts.adpe.value.max + impacts.adpe.value.min)/2
187
  impacts.pe.value = (impacts.pe.value.max + impacts.pe.value.min)/2
188
+ impacts.water.value = (impacts.water.value.max + impacts.water.value.min)/2
189
  return QImpacts(
190
  energy=format_energy(impacts.energy),
191
  gwp=format_gwp(impacts.gwp),
192
  adpe=format_adpe(impacts.adpe),
193
  pe=format_pe(impacts.pe),
194
+ water=format_water(impacts.water)
195
  ), impacts.usage, impacts.embodied
196
  except: #when no range
197
  return QImpacts(
198
  energy=format_energy(impacts.energy),
199
  gwp=format_gwp(impacts.gwp),
200
  adpe=format_adpe(impacts.adpe),
201
+ pe=format_pe(impacts.pe),
202
+ water=format_water(impacts.water)
203
  ), impacts.usage, impacts.embodied
204
 
205
  def split_impacts_u_e(impacts: Impacts) -> QImpacts:
 
219
  energy=format_energy(impacts.energy),
220
  gwp=format_gwp(impacts.gwp),
221
  adpe=format_adpe(impacts.adpe),
222
+ pe=format_pe(impacts.pe),
223
+ water=format_water(impacts.water)
224
  ), impacts.usage, impacts.embodied
225
 
226
  else:
 
232
  energy=format_energy(energy),
233
  gwp=format_gwp(gwp),
234
  adpe=format_adpe(adpe),
235
+ pe=format_pe(pe),
236
+ water=format_water(impacts.water)
237
  ), impacts.usage, impacts.embodied
238
 
239
  #####################################################################################
 
267
  streaming_eq = streaming_eq.to("s")
268
  return streaming_eq
269
 
270
+ def format_water_eq_bottled_waters(water: Quantity) -> Quantity:
271
+ water = water.to("L")
272
  bottled_water_eq = water / BOTTLED_WATERS_EQ
273
  return bottled_water_eq
274
 
 
291
  gwp_eq = gwp_eq.to("kgCO2eq")
292
  return gwp_eq / AIRPLANE_PARIS_NYC_GWP_EQ
293
 
294
+ def format_water_eq_olympic_sized_swimming_pool(water: Quantity) -> Quantity:
295
  water_eq = water * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
296
+ water_eq = water_eq.to("L")
297
  return water_eq / OLYMPIC_SWIMMING_POOL
298
 
299
+ # def format_water_eq_olympic_sized_swimming_pool(water):
300
+ # water_eq = water * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
301
+ # return water_eq / OLYMPIC_SWIMMING_POOL
302
+
303
  ####################################################################################### MODELS PARAMETER####################################################################################