vighnesh-shetty-vs commited on
Commit
12130fe
·
1 Parent(s): b3ba296

Add updated files

Browse files
Files changed (1) hide show
  1. game_data.py +17 -4
game_data.py CHANGED
@@ -1,4 +1,4 @@
1
- # Model Baselines (per 1000 tokens) based on scaling laws [cite: 26, 27]
2
  MODELS = {
3
  "Mistral Large 3": {"energy_wh": 1.98, "water_ml": 3.56, "co2_g": 0.95},
4
  "Mistral Medium 3": {"energy_wh": 6.76, "water_ml": 12.17, "co2_g": 3.24},
@@ -10,6 +10,7 @@ MODELS = {
10
  "GPT-5.4": {"energy_wh": 169.05, "water_ml": 304.29, "co2_g": 81.14}
11
  }
12
 
 
13
  CATEGORY_MULTIPLIERS = {
14
  "simple factual question": 0.05,
15
  "mathematical calculation": 0.10,
@@ -18,14 +19,26 @@ CATEGORY_MULTIPLIERS = {
18
  }
19
 
20
  def calculate_impact(category, confidence_score, query_text, model_name):
 
21
  model_cost = MODELS.get(model_name, MODELS["Mistral Large 3"])
22
  cat_mult = CATEGORY_MULTIPLIERS.get(category, 0.05)
23
 
24
- # Logic for buffers and length factors [cite: 25, 29]
25
- conf_mult = 1.0 if confidence_score > 0.8 else (1.2 if confidence_score > 0.5 else 1.5)
 
 
 
 
 
 
 
26
  word_count = len(query_text.split())
27
- len_factor = 1.0 if word_count < 20 else (1.3 if word_count <= 50 else 1.5)
28
 
 
 
 
 
 
29
  water_ml = model_cost["water_ml"] * cat_mult * conf_mult * len_factor
30
  energy_wh = model_cost["energy_wh"] * cat_mult * conf_mult * len_factor
31
  co2_g = model_cost["co2_g"] * cat_mult * conf_mult * len_factor
 
1
+ # Model Baselines (per 1000 tokens) based on scaling laws
2
  MODELS = {
3
  "Mistral Large 3": {"energy_wh": 1.98, "water_ml": 3.56, "co2_g": 0.95},
4
  "Mistral Medium 3": {"energy_wh": 6.76, "water_ml": 12.17, "co2_g": 3.24},
 
10
  "GPT-5.4": {"energy_wh": 169.05, "water_ml": 304.29, "co2_g": 81.14}
11
  }
12
 
13
+ # Category Token Multipliers
14
  CATEGORY_MULTIPLIERS = {
15
  "simple factual question": 0.05,
16
  "mathematical calculation": 0.10,
 
19
  }
20
 
21
  def calculate_impact(category, confidence_score, query_text, model_name):
22
+ # Get base costs for the specific model
23
  model_cost = MODELS.get(model_name, MODELS["Mistral Large 3"])
24
  cat_mult = CATEGORY_MULTIPLIERS.get(category, 0.05)
25
 
26
+ # 1. Confidence Multiplier
27
+ if confidence_score > 0.8:
28
+ conf_mult = 1.0
29
+ elif 0.5 <= confidence_score <= 0.8:
30
+ conf_mult = 1.2
31
+ else:
32
+ conf_mult = 1.5
33
+
34
+ # 2. Dynamic Word Count Logic (Continuous Scaling)
35
  word_count = len(query_text.split())
 
36
 
37
+ # Baseline is 15 words (1.0x). Each word adjusts the impact by 1.5% (0.015)
38
+ # Minimum factor is floored at 0.5x to ensure small queries still cost resources
39
+ len_factor = max(0.5, 1.0 + ((word_count - 15) * 0.015))
40
+
41
+ # 3. Final Calculation Formula
42
  water_ml = model_cost["water_ml"] * cat_mult * conf_mult * len_factor
43
  energy_wh = model_cost["energy_wh"] * cat_mult * conf_mult * len_factor
44
  co2_g = model_cost["co2_g"] * cat_mult * conf_mult * len_factor