EcoQueryQuest / game_data.py
vighnesh-shetty-vs
Add updated files
12130fe
Raw
History Blame Contribute Delete
2.18 kB
# Model Baselines (per 1000 tokens) based on scaling laws
MODELS = {
"Mistral Large 3": {"energy_wh": 1.98, "water_ml": 3.56, "co2_g": 0.95},
"Mistral Medium 3": {"energy_wh": 6.76, "water_ml": 12.17, "co2_g": 3.24},
"Claude Sonnet 4.6": {"energy_wh": 19.32, "water_ml": 34.78, "co2_g": 9.27},
"Gemini 3 Pro": {"energy_wh": 72.45, "water_ml": 130.41, "co2_g": 34.78},
"Gemini 3.1 Pro": {"energy_wh": 77.28, "water_ml": 139.10, "co2_g": 37.09},
"Claude Opus 4.6": {"energy_wh": 96.60, "water_ml": 173.88, "co2_g": 46.37},
"GPT-5.2": {"energy_wh": 144.90, "water_ml": 260.82, "co2_g": 69.55},
"GPT-5.4": {"energy_wh": 169.05, "water_ml": 304.29, "co2_g": 81.14}
}
# Category Token Multipliers
CATEGORY_MULTIPLIERS = {
"simple factual question": 0.05,
"mathematical calculation": 0.10,
"creative content generation": 0.80,
"complex research query": 1.50
}
def calculate_impact(category, confidence_score, query_text, model_name):
# Get base costs for the specific model
model_cost = MODELS.get(model_name, MODELS["Mistral Large 3"])
cat_mult = CATEGORY_MULTIPLIERS.get(category, 0.05)
# 1. Confidence Multiplier
if confidence_score > 0.8:
conf_mult = 1.0
elif 0.5 <= confidence_score <= 0.8:
conf_mult = 1.2
else:
conf_mult = 1.5
# 2. Dynamic Word Count Logic (Continuous Scaling)
word_count = len(query_text.split())
# Baseline is 15 words (1.0x). Each word adjusts the impact by 1.5% (0.015)
# Minimum factor is floored at 0.5x to ensure small queries still cost resources
len_factor = max(0.5, 1.0 + ((word_count - 15) * 0.015))
# 3. Final Calculation Formula
water_ml = model_cost["water_ml"] * cat_mult * conf_mult * len_factor
energy_wh = model_cost["energy_wh"] * cat_mult * conf_mult * len_factor
co2_g = model_cost["co2_g"] * cat_mult * conf_mult * len_factor
return {
"water_l": water_ml / 1000.0,
"energy_kwh": energy_wh / 1000.0,
"water_ml": round(water_ml, 1),
"energy_wh": round(energy_wh, 2),
"co2_g": round(co2_g, 2)
}