Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Pratik Bhavsar
commited on
Commit
·
7d1a2ad
1
Parent(s):
91da2cc
improved colors
Browse files- tabs/leaderboard.py +8 -0
- utils.py +28 -6
- visualization.py +65 -44
tabs/leaderboard.py
CHANGED
@@ -39,6 +39,10 @@ def filter_leaderboard(df, model_type, category, sort_by):
|
|
39 |
--hover-bg: #2d2e32;
|
40 |
--note-bg: #2d2e32;
|
41 |
--note-text: #a1a1aa;
|
|
|
|
|
|
|
|
|
42 |
}}
|
43 |
}}
|
44 |
|
@@ -50,6 +54,10 @@ def filter_leaderboard(df, model_type, category, sort_by):
|
|
50 |
--hover-bg: #f3f4f6;
|
51 |
--note-bg: #f3f4f6;
|
52 |
--note-text: #4b5563;
|
|
|
|
|
|
|
|
|
53 |
}}
|
54 |
}}
|
55 |
|
|
|
39 |
--hover-bg: #2d2e32;
|
40 |
--note-bg: #2d2e32;
|
41 |
--note-text: #a1a1aa;
|
42 |
+
--accent-blue: #60A5FA;
|
43 |
+
--accent-purple: #A78BFA;
|
44 |
+
--accent-pink: #F472B6;
|
45 |
+
--score-bg: rgba(255, 255, 255, 0.1);
|
46 |
}}
|
47 |
}}
|
48 |
|
|
|
54 |
--hover-bg: #f3f4f6;
|
55 |
--note-bg: #f3f4f6;
|
56 |
--note-text: #4b5563;
|
57 |
+
--accent-blue: #3B82F6;
|
58 |
+
--accent-purple: #8B5CF6;
|
59 |
+
--accent-pink: #EC4899;
|
60 |
+
--score-bg: rgba(0, 0, 0, 0.1);
|
61 |
}}
|
62 |
}}
|
63 |
|
utils.py
CHANGED
@@ -1,3 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
def get_rank_badge(rank):
|
2 |
"""Generate HTML for rank badge with appropriate styling"""
|
3 |
badge_styles = {
|
@@ -41,7 +61,8 @@ def get_rank_badge(rank):
|
|
41 |
|
42 |
def get_type_badge(model_type):
|
43 |
"""Generate HTML for model type badge"""
|
44 |
-
colors =
|
|
|
45 |
bg_color = colors.get(model_type, "#4F46E5")
|
46 |
return f"""
|
47 |
<div style="
|
@@ -60,23 +81,24 @@ def get_type_badge(model_type):
|
|
60 |
|
61 |
|
62 |
def get_score_bar(score):
|
63 |
-
"""Generate HTML for score bar"""
|
64 |
width = score * 100
|
65 |
return f"""
|
66 |
<div style="display: flex; align-items: center; gap: 12px; width: 100%;">
|
67 |
<div style="
|
68 |
flex-grow: 1;
|
69 |
-
height:
|
70 |
background: var(--score-bg, rgba(255, 255, 255, 0.1));
|
71 |
-
border-radius:
|
72 |
overflow: hidden;
|
73 |
max-width: 200px;
|
74 |
">
|
75 |
<div style="
|
76 |
width: {width}%;
|
77 |
height: 100%;
|
78 |
-
background: var(--accent-
|
79 |
-
border-radius:
|
|
|
80 |
"></div>
|
81 |
</div>
|
82 |
<span style="
|
|
|
1 |
+
def get_chart_colors():
|
2 |
+
# if is_dark_theme():
|
3 |
+
# return {
|
4 |
+
# "Private": "#60A5FA", # accent-blue
|
5 |
+
# "Open source": "#A78BFA", # accent-purple
|
6 |
+
# "performance_bands": ["#DCFCE7", "#FEF9C3", "#FEE2E2"],
|
7 |
+
# "text": "#FFFFFF",
|
8 |
+
# "background": "#1a1b1e",
|
9 |
+
# "grid": (1, 1, 1, 0.1), # RGBA tuple for grid
|
10 |
+
# }
|
11 |
+
return {
|
12 |
+
"Private": "#3F78FA", # accent-blue light
|
13 |
+
"Open source": "#A13AE2", # accent-purple light
|
14 |
+
"performance_bands": ["#DCFCE7", "#FEF9C3", "#FEE2E2"],
|
15 |
+
"text": "#111827",
|
16 |
+
"background": "#FFFFFF",
|
17 |
+
"grid": (0, 0, 0, 0.1), # RGBA tuple for grid
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
def get_rank_badge(rank):
|
22 |
"""Generate HTML for rank badge with appropriate styling"""
|
23 |
badge_styles = {
|
|
|
61 |
|
62 |
def get_type_badge(model_type):
|
63 |
"""Generate HTML for model type badge"""
|
64 |
+
colors = get_chart_colors()
|
65 |
+
colors = {"Private": colors["Private"], "Open source": colors["Open source"]}
|
66 |
bg_color = colors.get(model_type, "#4F46E5")
|
67 |
return f"""
|
68 |
<div style="
|
|
|
81 |
|
82 |
|
83 |
def get_score_bar(score):
|
84 |
+
"""Generate HTML for score bar with gradient styling"""
|
85 |
width = score * 100
|
86 |
return f"""
|
87 |
<div style="display: flex; align-items: center; gap: 12px; width: 100%;">
|
88 |
<div style="
|
89 |
flex-grow: 1;
|
90 |
+
height: 8px;
|
91 |
background: var(--score-bg, rgba(255, 255, 255, 0.1));
|
92 |
+
border-radius: 4px;
|
93 |
overflow: hidden;
|
94 |
max-width: 200px;
|
95 |
">
|
96 |
<div style="
|
97 |
width: {width}%;
|
98 |
height: 100%;
|
99 |
+
background: linear-gradient(90deg, var(--accent-blue, #60A5FA), var(--accent-purple, #A78BFA));
|
100 |
+
border-radius: 4px;
|
101 |
+
transition: width 0.3s ease;
|
102 |
"></div>
|
103 |
</div>
|
104 |
<span style="
|
visualization.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import matplotlib
|
2 |
import matplotlib.pyplot as plt
|
3 |
import numpy as np
|
@@ -5,54 +6,68 @@ import plotly.graph_objects as go
|
|
5 |
|
6 |
|
7 |
def setup_matplotlib():
|
8 |
-
"""Set up matplotlib configuration."""
|
9 |
matplotlib.use("Agg")
|
10 |
plt.close("all")
|
11 |
|
12 |
|
13 |
def get_performance_chart(df, category_name="Overall"):
|
14 |
plt.close("all")
|
|
|
15 |
score_column = "Category Score"
|
16 |
df_sorted = df.sort_values(score_column, ascending=True)
|
17 |
-
colors = {"Private": "#4F46E5", "Open source": "#16A34A"}
|
18 |
|
19 |
height = max(8, len(df_sorted) * 0.8)
|
20 |
fig, ax = plt.subplots(figsize=(16, height))
|
21 |
plt.rcParams.update({"font.size": 12})
|
22 |
|
|
|
|
|
|
|
23 |
try:
|
24 |
bars = ax.barh(
|
25 |
np.arange(len(df_sorted)),
|
26 |
df_sorted[score_column],
|
27 |
-
height=0.
|
|
|
28 |
color=[colors[t] for t in df_sorted["Model Type"]],
|
29 |
)
|
30 |
|
31 |
ax.set_title(
|
32 |
-
f"Model Performance
|
33 |
pad=20,
|
34 |
fontsize=20,
|
35 |
fontweight="bold",
|
|
|
36 |
)
|
37 |
-
ax.set_xlabel("Average Score", fontsize=14, labelpad=10)
|
38 |
ax.set_xlim(0.0, 1.0)
|
39 |
|
40 |
ax.set_yticks(np.arange(len(df_sorted)))
|
41 |
-
ax.set_yticklabels(df_sorted["Model"], fontsize=12)
|
42 |
|
43 |
plt.subplots_adjust(left=0.35)
|
44 |
|
45 |
for i, v in enumerate(df_sorted[score_column]):
|
46 |
ax.text(
|
47 |
-
v + 0.01,
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
)
|
49 |
|
50 |
-
ax.grid(True, axis="x", linestyle="--", alpha=0.2)
|
51 |
ax.spines[["top", "right"]].set_visible(False)
|
|
|
|
|
52 |
|
53 |
legend_elements = [
|
54 |
plt.Rectangle((0, 0), 1, 1, facecolor=color, label=label)
|
55 |
-
for label, color in
|
|
|
|
|
56 |
]
|
57 |
ax.legend(
|
58 |
handles=legend_elements,
|
@@ -60,6 +75,8 @@ def get_performance_chart(df, category_name="Overall"):
|
|
60 |
loc="lower right",
|
61 |
fontsize=12,
|
62 |
title_fontsize=14,
|
|
|
|
|
63 |
)
|
64 |
|
65 |
plt.tight_layout()
|
@@ -67,7 +84,6 @@ def get_performance_chart(df, category_name="Overall"):
|
|
67 |
finally:
|
68 |
plt.close(fig)
|
69 |
|
70 |
-
|
71 |
def create_radar_plot(df, model_names):
|
72 |
datasets = [col for col in df.columns[7:] if col != "IO Cost"]
|
73 |
fig = go.Figure()
|
@@ -132,26 +148,24 @@ def create_radar_plot(df, model_names):
|
|
132 |
|
133 |
|
134 |
def get_performance_cost_chart(df, category_name="Overall"):
|
135 |
-
|
136 |
fig, ax = plt.subplots(figsize=(12, 8), dpi=300)
|
137 |
|
138 |
-
|
139 |
-
ax.
|
140 |
-
ax.
|
141 |
-
fig.patch.set_facecolor("white")
|
142 |
-
|
143 |
-
colors = {"Private": "#4F46E5", "Open source": "#16A34A"}
|
144 |
-
performance_colors = ["#DCFCE7", "#FEF9C3", "#FEE2E2"]
|
145 |
|
146 |
score_column = "Category Score"
|
147 |
|
148 |
-
# Plot data points
|
149 |
for _, row in df.iterrows():
|
150 |
color = colors[row["Model Type"]]
|
151 |
size = 100 if row[score_column] > 0.85 else 80
|
152 |
-
edge_color =
|
|
|
|
|
|
|
|
|
153 |
|
154 |
-
# Plot scatter points
|
155 |
ax.scatter(
|
156 |
row["IO Cost"],
|
157 |
row[score_column] * 100,
|
@@ -160,11 +174,12 @@ def get_performance_cost_chart(df, category_name="Overall"):
|
|
160 |
alpha=0.9,
|
161 |
edgecolor=edge_color,
|
162 |
linewidth=1,
|
163 |
-
zorder=5,
|
164 |
)
|
165 |
|
166 |
-
|
167 |
-
|
|
|
168 |
|
169 |
ax.annotate(
|
170 |
f"{row['Model']}\n(${row['IO Cost']:.2f})",
|
@@ -172,50 +187,56 @@ def get_performance_cost_chart(df, category_name="Overall"):
|
|
172 |
xytext=(5, 5),
|
173 |
textcoords="offset points",
|
174 |
fontsize=8,
|
|
|
175 |
bbox=bbox_props,
|
176 |
zorder=6,
|
177 |
)
|
178 |
|
179 |
-
# Configure axes
|
180 |
ax.set_xscale("log")
|
181 |
-
ax.set_xlim(0.08, 40)
|
182 |
ax.set_ylim(60, 95)
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
-
# Add legend
|
189 |
legend_elements = [
|
190 |
-
plt.scatter([], [], c=
|
191 |
-
for label,
|
192 |
]
|
193 |
ax.legend(
|
194 |
handles=legend_elements,
|
195 |
loc="upper right",
|
196 |
frameon=True,
|
197 |
-
facecolor="
|
198 |
edgecolor="none",
|
199 |
fontsize=9,
|
|
|
200 |
)
|
201 |
|
202 |
-
# Set title
|
203 |
ax.set_title(
|
204 |
-
f"
|
|
|
|
|
|
|
|
|
205 |
)
|
206 |
|
207 |
-
|
208 |
-
for y1, y2, color in zip([85, 75, 60], [95, 85, 75], performance_colors):
|
209 |
ax.axhspan(y1, y2, alpha=0.2, color=color, zorder=1)
|
210 |
|
211 |
-
|
212 |
-
ax.tick_params(axis="both", which="
|
213 |
-
ax.tick_params(axis="both", which="minor", labelsize=8)
|
214 |
-
|
215 |
-
# Add minor ticks for log scale
|
216 |
ax.xaxis.set_minor_locator(plt.LogLocator(base=10.0, subs=np.arange(2, 10) * 0.1))
|
217 |
|
218 |
-
|
219 |
-
|
220 |
|
|
|
221 |
return fig
|
|
|
1 |
+
from utils import get_chart_colors
|
2 |
import matplotlib
|
3 |
import matplotlib.pyplot as plt
|
4 |
import numpy as np
|
|
|
6 |
|
7 |
|
8 |
def setup_matplotlib():
|
|
|
9 |
matplotlib.use("Agg")
|
10 |
plt.close("all")
|
11 |
|
12 |
|
13 |
def get_performance_chart(df, category_name="Overall"):
|
14 |
plt.close("all")
|
15 |
+
colors = get_chart_colors()
|
16 |
score_column = "Category Score"
|
17 |
df_sorted = df.sort_values(score_column, ascending=True)
|
|
|
18 |
|
19 |
height = max(8, len(df_sorted) * 0.8)
|
20 |
fig, ax = plt.subplots(figsize=(16, height))
|
21 |
plt.rcParams.update({"font.size": 12})
|
22 |
|
23 |
+
fig.patch.set_facecolor(colors["background"])
|
24 |
+
ax.set_facecolor(colors["background"])
|
25 |
+
|
26 |
try:
|
27 |
bars = ax.barh(
|
28 |
np.arange(len(df_sorted)),
|
29 |
df_sorted[score_column],
|
30 |
+
height=0.4,
|
31 |
+
capstyle="round",
|
32 |
color=[colors[t] for t in df_sorted["Model Type"]],
|
33 |
)
|
34 |
|
35 |
ax.set_title(
|
36 |
+
f"Model Performance - {category_name}",
|
37 |
pad=20,
|
38 |
fontsize=20,
|
39 |
fontweight="bold",
|
40 |
+
color=colors["text"],
|
41 |
)
|
42 |
+
ax.set_xlabel("Average Score", fontsize=14, labelpad=10, color=colors["text"])
|
43 |
ax.set_xlim(0.0, 1.0)
|
44 |
|
45 |
ax.set_yticks(np.arange(len(df_sorted)))
|
46 |
+
ax.set_yticklabels(df_sorted["Model"], fontsize=12, color=colors["text"])
|
47 |
|
48 |
plt.subplots_adjust(left=0.35)
|
49 |
|
50 |
for i, v in enumerate(df_sorted[score_column]):
|
51 |
ax.text(
|
52 |
+
v + 0.01,
|
53 |
+
i,
|
54 |
+
f"{v:.3f}",
|
55 |
+
va="center",
|
56 |
+
fontsize=12,
|
57 |
+
fontweight="bold",
|
58 |
+
color=colors["text"],
|
59 |
)
|
60 |
|
61 |
+
ax.grid(True, axis="x", linestyle="--", alpha=0.2, color=colors["grid"])
|
62 |
ax.spines[["top", "right"]].set_visible(False)
|
63 |
+
ax.spines[["bottom", "left"]].set_color(colors["grid"])
|
64 |
+
ax.tick_params(colors=colors["text"])
|
65 |
|
66 |
legend_elements = [
|
67 |
plt.Rectangle((0, 0), 1, 1, facecolor=color, label=label)
|
68 |
+
for label, color in {
|
69 |
+
k: colors[k] for k in ["Private", "Open source"]
|
70 |
+
}.items()
|
71 |
]
|
72 |
ax.legend(
|
73 |
handles=legend_elements,
|
|
|
75 |
loc="lower right",
|
76 |
fontsize=12,
|
77 |
title_fontsize=14,
|
78 |
+
facecolor=colors["background"],
|
79 |
+
labelcolor=colors["text"],
|
80 |
)
|
81 |
|
82 |
plt.tight_layout()
|
|
|
84 |
finally:
|
85 |
plt.close(fig)
|
86 |
|
|
|
87 |
def create_radar_plot(df, model_names):
|
88 |
datasets = [col for col in df.columns[7:] if col != "IO Cost"]
|
89 |
fig = go.Figure()
|
|
|
148 |
|
149 |
|
150 |
def get_performance_cost_chart(df, category_name="Overall"):
|
151 |
+
colors = get_chart_colors()
|
152 |
fig, ax = plt.subplots(figsize=(12, 8), dpi=300)
|
153 |
|
154 |
+
fig.patch.set_facecolor(colors["background"])
|
155 |
+
ax.set_facecolor(colors["background"])
|
156 |
+
ax.grid(True, linestyle="--", alpha=0.15, which="both", color=colors["grid"])
|
|
|
|
|
|
|
|
|
157 |
|
158 |
score_column = "Category Score"
|
159 |
|
|
|
160 |
for _, row in df.iterrows():
|
161 |
color = colors[row["Model Type"]]
|
162 |
size = 100 if row[score_column] > 0.85 else 80
|
163 |
+
edge_color = (
|
164 |
+
colors["Private"]
|
165 |
+
if row["Model Type"] == "Private"
|
166 |
+
else colors["Open source"]
|
167 |
+
)
|
168 |
|
|
|
169 |
ax.scatter(
|
170 |
row["IO Cost"],
|
171 |
row[score_column] * 100,
|
|
|
174 |
alpha=0.9,
|
175 |
edgecolor=edge_color,
|
176 |
linewidth=1,
|
177 |
+
zorder=5,
|
178 |
)
|
179 |
|
180 |
+
bbox_props = dict(
|
181 |
+
boxstyle="round,pad=0.3", fc=colors["background"], ec="none", alpha=0.8
|
182 |
+
)
|
183 |
|
184 |
ax.annotate(
|
185 |
f"{row['Model']}\n(${row['IO Cost']:.2f})",
|
|
|
187 |
xytext=(5, 5),
|
188 |
textcoords="offset points",
|
189 |
fontsize=8,
|
190 |
+
color=colors["text"],
|
191 |
bbox=bbox_props,
|
192 |
zorder=6,
|
193 |
)
|
194 |
|
|
|
195 |
ax.set_xscale("log")
|
196 |
+
ax.set_xlim(0.08, 40)
|
197 |
ax.set_ylim(60, 95)
|
198 |
|
199 |
+
ax.set_xlabel(
|
200 |
+
"I/O Cost per Million Tokens ($)",
|
201 |
+
fontsize=10,
|
202 |
+
labelpad=10,
|
203 |
+
color=colors["text"],
|
204 |
+
)
|
205 |
+
ax.set_ylabel(
|
206 |
+
"Model Performance Score", fontsize=10, labelpad=10, color=colors["text"]
|
207 |
+
)
|
208 |
|
|
|
209 |
legend_elements = [
|
210 |
+
plt.scatter([], [], c=colors[label], label=label, s=80)
|
211 |
+
for label in ["Private", "Open source"]
|
212 |
]
|
213 |
ax.legend(
|
214 |
handles=legend_elements,
|
215 |
loc="upper right",
|
216 |
frameon=True,
|
217 |
+
facecolor=colors["background"],
|
218 |
edgecolor="none",
|
219 |
fontsize=9,
|
220 |
+
labelcolor=colors["text"],
|
221 |
)
|
222 |
|
|
|
223 |
ax.set_title(
|
224 |
+
f"Performance vs. Cost - {category_name}",
|
225 |
+
fontsize=12,
|
226 |
+
pad=15,
|
227 |
+
fontweight="bold",
|
228 |
+
color=colors["text"],
|
229 |
)
|
230 |
|
231 |
+
for y1, y2, color in zip([85, 75, 60], [95, 85, 75], colors["performance_bands"]):
|
|
|
232 |
ax.axhspan(y1, y2, alpha=0.2, color=color, zorder=1)
|
233 |
|
234 |
+
ax.tick_params(axis="both", which="major", labelsize=9, colors=colors["text"])
|
235 |
+
ax.tick_params(axis="both", which="minor", labelsize=8, colors=colors["text"])
|
|
|
|
|
|
|
236 |
ax.xaxis.set_minor_locator(plt.LogLocator(base=10.0, subs=np.arange(2, 10) * 0.1))
|
237 |
|
238 |
+
for spine in ax.spines.values():
|
239 |
+
spine.set_color(colors["grid"])
|
240 |
|
241 |
+
plt.tight_layout()
|
242 |
return fig
|