Spaces:
Running
Running
Update leaderboard.py
Browse files- leaderboard.py +42 -3
leaderboard.py
CHANGED
@@ -31,11 +31,50 @@ def save_leaderboard(leaderboard_data: Dict[str, Any]) -> bool:
|
|
31 |
return False
|
32 |
|
33 |
def get_model_size(model_name):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
for model, human_readable in config.get_approved_models():
|
35 |
if model == model_name:
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
def calculate_expected_score(rating_a, rating_b):
|
41 |
return 1 / (1 + math.pow(10, (rating_b - rating_a) / 400))
|
|
|
31 |
return False
|
32 |
|
33 |
def get_model_size(model_name):
|
34 |
+
"""Extract model size in billions from model name.
|
35 |
+
Handles various formats like:
|
36 |
+
- "Model 14B (4-bit)"
|
37 |
+
- "Model (14B)"
|
38 |
+
- "Model 14.5B"
|
39 |
+
- "Model 1,000M"
|
40 |
+
"""
|
41 |
for model, human_readable in config.get_approved_models():
|
42 |
if model == model_name:
|
43 |
+
try:
|
44 |
+
# Remove any commas
|
45 |
+
clean_name = human_readable.replace(',', '')
|
46 |
+
|
47 |
+
# Try to find size in parentheses first
|
48 |
+
if '(' in clean_name:
|
49 |
+
parts = clean_name.split('(')
|
50 |
+
for part in parts:
|
51 |
+
if 'B' in part:
|
52 |
+
size_str = part.split('B')[0].strip()
|
53 |
+
try:
|
54 |
+
return float(size_str)
|
55 |
+
except ValueError:
|
56 |
+
continue
|
57 |
+
|
58 |
+
# If not in parentheses, look for B or M in the whole string
|
59 |
+
words = clean_name.split()
|
60 |
+
for word in words:
|
61 |
+
if 'B' in word:
|
62 |
+
size_str = word.replace('B', '').strip()
|
63 |
+
try:
|
64 |
+
return float(size_str)
|
65 |
+
except ValueError:
|
66 |
+
continue
|
67 |
+
elif 'M' in word:
|
68 |
+
size_str = word.replace('M', '').strip()
|
69 |
+
try:
|
70 |
+
return float(size_str) / 1000 # Convert millions to billions
|
71 |
+
except ValueError:
|
72 |
+
continue
|
73 |
+
|
74 |
+
except Exception as e:
|
75 |
+
print(f"Error parsing size for {model_name}: {e}")
|
76 |
+
|
77 |
+
return 1.0 # Default size if not found or parsing failed
|
78 |
|
79 |
def calculate_expected_score(rating_a, rating_b):
|
80 |
return 1 / (1 + math.pow(10, (rating_b - rating_a) / 400))
|