Spaces:
Running
Running
1Suro1
commited on
Commit
•
69b4d58
1
Parent(s):
1105563
edit
Browse files- app.py +27 -8
- data/leaderboard.json +42 -0
- m_data/generate_leaderboard.py +29 -0
- src/radial/radial.py +67 -0
app.py
CHANGED
@@ -5,6 +5,8 @@ os.environ['TMP_DIR'] = "tmp"
|
|
5 |
import subprocess
|
6 |
import shutil
|
7 |
import gradio as gr
|
|
|
|
|
8 |
from apscheduler.schedulers.background import BackgroundScheduler
|
9 |
from gradio_leaderboard import Leaderboard, SelectColumns
|
10 |
from gradio_space_ci import enable_space_ci
|
@@ -17,7 +19,6 @@ def handle_file_upload(file):
|
|
17 |
with open(file.name, "r") as f:
|
18 |
v = json.load(f)
|
19 |
return v, file_path
|
20 |
-
|
21 |
def submit_file(v, file_path, mn, profile: gr.OAuthProfile | None):
|
22 |
if profile is None:
|
23 |
return "Hub Login Required"
|
@@ -67,16 +68,19 @@ logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(
|
|
67 |
# Start ephemeral Spaces on PRs (see config in README.md)
|
68 |
enable_space_ci()
|
69 |
|
70 |
-
download_openbench()
|
71 |
|
72 |
def restart_space():
|
73 |
API.restart_space(repo_id=REPO_ID)
|
74 |
download_openbench()
|
75 |
|
|
|
|
|
76 |
|
77 |
def build_demo():
|
78 |
demo = gr.Blocks(title="Small Shlepa", css=custom_css)
|
79 |
leaderboard_df = build_leadearboard_df()
|
|
|
80 |
with demo:
|
81 |
gr.HTML(TITLE)
|
82 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
@@ -167,11 +171,26 @@ def build_demo():
|
|
167 |
[out]
|
168 |
)
|
169 |
|
170 |
-
with gr.TabItem("Analytics", elem_id="llm-benchmark-tab-table", id=4):
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
return demo
|
176 |
|
177 |
|
@@ -227,7 +246,7 @@ if __name__ == "__main__":
|
|
227 |
|
228 |
scheduler = BackgroundScheduler()
|
229 |
# update_board()
|
230 |
-
scheduler.add_job(update_board, "interval", minutes=600)
|
231 |
scheduler.start()
|
232 |
|
233 |
demo_app = build_demo()
|
|
|
5 |
import subprocess
|
6 |
import shutil
|
7 |
import gradio as gr
|
8 |
+
import numpy as np
|
9 |
+
from src.radial.radial import create_plot
|
10 |
from apscheduler.schedulers.background import BackgroundScheduler
|
11 |
from gradio_leaderboard import Leaderboard, SelectColumns
|
12 |
from gradio_space_ci import enable_space_ci
|
|
|
19 |
with open(file.name, "r") as f:
|
20 |
v = json.load(f)
|
21 |
return v, file_path
|
|
|
22 |
def submit_file(v, file_path, mn, profile: gr.OAuthProfile | None):
|
23 |
if profile is None:
|
24 |
return "Hub Login Required"
|
|
|
68 |
# Start ephemeral Spaces on PRs (see config in README.md)
|
69 |
enable_space_ci()
|
70 |
|
71 |
+
# download_openbench()
|
72 |
|
73 |
def restart_space():
|
74 |
API.restart_space(repo_id=REPO_ID)
|
75 |
download_openbench()
|
76 |
|
77 |
+
def update_plot(selected_models):
|
78 |
+
return create_plot(selected_models)
|
79 |
|
80 |
def build_demo():
|
81 |
demo = gr.Blocks(title="Small Shlepa", css=custom_css)
|
82 |
leaderboard_df = build_leadearboard_df()
|
83 |
+
default_model = leaderboard_df["model"].iloc[0]
|
84 |
with demo:
|
85 |
gr.HTML(TITLE)
|
86 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
|
|
171 |
[out]
|
172 |
)
|
173 |
|
174 |
+
with gr.TabItem("📊 Analytics", elem_id="llm-benchmark-tab-table", id=4):
|
175 |
+
with gr.Column():
|
176 |
+
model_dropdown = gr.Dropdown(
|
177 |
+
choices=leaderboard_df["model"].tolist(),
|
178 |
+
label="Models",
|
179 |
+
value=default_model,
|
180 |
+
multiselect=True,
|
181 |
+
info="Select models"
|
182 |
+
)
|
183 |
+
with gr.Column():
|
184 |
+
plot = gr.Plot(value=
|
185 |
+
update_plot(
|
186 |
+
default_model,
|
187 |
+
)
|
188 |
+
)
|
189 |
+
model_dropdown.change(
|
190 |
+
fn=update_plot,
|
191 |
+
inputs=[model_dropdown],
|
192 |
+
outputs=[plot]
|
193 |
+
)
|
194 |
return demo
|
195 |
|
196 |
|
|
|
246 |
|
247 |
scheduler = BackgroundScheduler()
|
248 |
# update_board()
|
249 |
+
# scheduler.add_job(update_board, "interval", minutes=600)
|
250 |
scheduler.start()
|
251 |
|
252 |
demo_app = build_demo()
|
data/leaderboard.json
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
{
|
3 |
+
"musicmc": 0.09361702127659574,
|
4 |
+
"mmluproru": 0.10207253886010363,
|
5 |
+
"lawmc": 0.11431513903192585,
|
6 |
+
"model": "NousResearch/Llama-2-7b-hf",
|
7 |
+
"moviesmc": 0.07175925925925926,
|
8 |
+
"booksmc": 0.1078838174273859,
|
9 |
+
"model_dtype": "torch.float16",
|
10 |
+
"ppl": 0
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"musicmc": 0.2553191489361702,
|
14 |
+
"mmluproru": 0.2621761658031088,
|
15 |
+
"lawmc": 0.5818743563336766,
|
16 |
+
"model": "google/gemma-2-9b",
|
17 |
+
"moviesmc": 0.5046296296296297,
|
18 |
+
"booksmc": 0.3360995850622407,
|
19 |
+
"model_dtype": "torch.float16",
|
20 |
+
"ppl": 0
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"musicmc": 0.2680851063829787,
|
24 |
+
"mmluproru": 0.20103626943005182,
|
25 |
+
"lawmc": 0.5386199794026777,
|
26 |
+
"model": "Vikhrmodels/it-5.2-fp16-cp",
|
27 |
+
"moviesmc": 0.4537037037037037,
|
28 |
+
"booksmc": 0.3070539419087137,
|
29 |
+
"model_dtype": "torch.float16",
|
30 |
+
"ppl": 0
|
31 |
+
},
|
32 |
+
{
|
33 |
+
"musicmc": 0.25957446808510637,
|
34 |
+
"mmluproru": 0.19378238341968912,
|
35 |
+
"lawmc": 0.518022657054583,
|
36 |
+
"model": "lightblue/suzume-llama-3-8B-multilingual",
|
37 |
+
"moviesmc": 0.3287037037037037,
|
38 |
+
"booksmc": 0.2966804979253112,
|
39 |
+
"model_dtype": "torch.float16",
|
40 |
+
"ppl": 0
|
41 |
+
}
|
42 |
+
]
|
m_data/generate_leaderboard.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import json
|
3 |
+
|
4 |
+
def merge_json_files(folder_path, output_file):
|
5 |
+
merged_data = []
|
6 |
+
if not os.path.exists(folder_path):
|
7 |
+
print(f"Папка '{folder_path}' не существует.")
|
8 |
+
return
|
9 |
+
|
10 |
+
for filename in os.listdir(folder_path):
|
11 |
+
if filename.endswith('.json'):
|
12 |
+
file_path = os.path.join(folder_path, filename)
|
13 |
+
try:
|
14 |
+
with open(file_path, 'r', encoding='utf-8') as f:
|
15 |
+
data = json.load(f)
|
16 |
+
merged_data.append(data)
|
17 |
+
except Exception as e:
|
18 |
+
print(f"Ошибка при чтении файла '{file_path}': {e}")
|
19 |
+
|
20 |
+
with open(output_file, 'w', encoding='utf-8') as f:
|
21 |
+
json.dump(merged_data, f, ensure_ascii=False, indent=4)
|
22 |
+
|
23 |
+
print(f"Данные успешно объединены и сохранены в файл '{output_file}'.")
|
24 |
+
|
25 |
+
if __name__ == "__main__":
|
26 |
+
folder_path = './model_data/external'
|
27 |
+
output_file = 'leaderboard.json'
|
28 |
+
|
29 |
+
merge_json_files(folder_path, output_file)
|
src/radial/radial.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import plotly.graph_objects as go
|
2 |
+
import random
|
3 |
+
from src.leaderboard.build_leaderboard import build_leadearboard_df
|
4 |
+
import numpy as np
|
5 |
+
import itertools as it
|
6 |
+
|
7 |
+
|
8 |
+
def create_plot(selected_models):
|
9 |
+
models = build_leadearboard_df()
|
10 |
+
metrics = ["musicmc", "lawmc", "moviesmc", "booksmc", "mmluproru"]
|
11 |
+
MIN_COLOUR_DISTANCE_BETWEEN_MODELS = 100
|
12 |
+
seed = 42
|
13 |
+
|
14 |
+
def generate_colours(min_distance, seed):
|
15 |
+
colour_mapping = {}
|
16 |
+
all_models = selected_models
|
17 |
+
|
18 |
+
for i in it.count():
|
19 |
+
min_colour_distance = min_distance - i
|
20 |
+
retries_left = 10 * len(all_models)
|
21 |
+
|
22 |
+
for model_id in all_models:
|
23 |
+
random.seed(hash(model_id) + i + seed)
|
24 |
+
r, g, b = 0, 0, 0
|
25 |
+
too_bright, similar_to_other_model = True, True
|
26 |
+
|
27 |
+
while (too_bright or similar_to_other_model) and retries_left > 0:
|
28 |
+
r, g, b = tuple(random.randint(0, 255) for _ in range(3))
|
29 |
+
too_bright = np.min([r, g, b]) > 200
|
30 |
+
similar_to_other_model = any(
|
31 |
+
np.abs(np.array(colour) - np.array([r, g, b])).sum() < min_colour_distance
|
32 |
+
for colour in colour_mapping.values()
|
33 |
+
)
|
34 |
+
retries_left -= 1
|
35 |
+
|
36 |
+
colour_mapping[model_id] = (r, g, b)
|
37 |
+
if len(colour_mapping) == len(all_models):
|
38 |
+
break
|
39 |
+
|
40 |
+
return colour_mapping
|
41 |
+
|
42 |
+
colour_mapping = generate_colours(MIN_COLOUR_DISTANCE_BETWEEN_MODELS, seed)
|
43 |
+
fig = go.Figure()
|
44 |
+
for _, model_data in models.iterrows():
|
45 |
+
model_name = model_data["model"]
|
46 |
+
if not model_name in selected_models:
|
47 |
+
continue
|
48 |
+
values = [model_data[metric] for metric in metrics]
|
49 |
+
color = f'rgb{colour_mapping[model_name]}'
|
50 |
+
|
51 |
+
fig.add_trace(go.Scatterpolar(
|
52 |
+
r=values,
|
53 |
+
theta=metrics,
|
54 |
+
name=model_name,
|
55 |
+
fill='toself',
|
56 |
+
fillcolor=f'rgba{colour_mapping[model_name] + (0.6,)}',
|
57 |
+
line=dict(color=color)
|
58 |
+
))
|
59 |
+
fig.update_layout(
|
60 |
+
polar=dict(radialaxis=dict(visible=True)),
|
61 |
+
showlegend=True,
|
62 |
+
title='Models metrics',
|
63 |
+
template="plotly_dark",
|
64 |
+
)
|
65 |
+
return fig
|
66 |
+
|
67 |
+
|