Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,25 +9,19 @@ import numpy as np
|
|
9 |
import pandas as pd
|
10 |
|
11 |
|
12 |
-
basic_component_values = [None] * 6
|
13 |
leader_component_values = [None]
|
|
|
14 |
|
15 |
def make_default_md(arena_df, elo_results):
|
16 |
-
total_votes = sum(arena_df["num_battles"]) // 2
|
17 |
-
total_models = len(arena_df)
|
18 |
-
|
19 |
leaderboard_md = f"""
|
20 |
# NeurIPS LLM Merging Competition Leaderboard
|
21 |
-
[Website](https://llm-merging.github.io/index) | [Starter Kit (Github)](https://github.com/llm-merging/LLM-Merging) | [Discord](https://discord.com/invite/dPBHEVnV)
|
22 |
|
23 |
"""
|
24 |
return leaderboard_md
|
25 |
|
26 |
-
|
27 |
def make_arena_leaderboard_md(arena_df):
|
28 |
-
total_votes = sum(arena_df["num_battles"]) // 2
|
29 |
total_models = len(arena_df)
|
30 |
-
space = " "
|
31 |
leaderboard_md = f"""
|
32 |
Three benchmarks are displayed: **Test Task 1**, **Test Task 2**, **Test Task 3**.
|
33 |
|
@@ -39,13 +33,10 @@ Total #models: **{total_models}**.{space} Last updated: June 1, 2024.
|
|
39 |
return leaderboard_md
|
40 |
|
41 |
def make_category_arena_leaderboard_md(arena_df, arena_subset_df, name="Overall"):
|
42 |
-
total_votes = sum(arena_df["num_battles"]) // 2
|
43 |
total_models = len(arena_df)
|
44 |
-
space = " "
|
45 |
-
total_subset_votes = sum(arena_subset_df["num_battles"]) // 2
|
46 |
total_subset_models = len(arena_subset_df)
|
47 |
leaderboard_md = f"""### {cat_name_to_explanation[name]}
|
48 |
-
#### [Coverage] {space} #models: **{total_subset_models} ({round(total_subset_models/total_models *100)}%)**
|
49 |
"""
|
50 |
return leaderboard_md
|
51 |
|
@@ -59,43 +50,6 @@ Last updated: {elo_results["last_updated_datetime"]}
|
|
59 |
return leaderboard_md
|
60 |
|
61 |
|
62 |
-
def update_elo_components(max_num_files, elo_results_file):
|
63 |
-
log_files = get_log_files(max_num_files)
|
64 |
-
|
65 |
-
# Leaderboard
|
66 |
-
if elo_results_file is None: # Do live update
|
67 |
-
battles = clean_battle_data(log_files)
|
68 |
-
elo_results = report_elo_analysis_results(battles)
|
69 |
-
leader_component_values[0] = make_leaderboard_md_live(elo_results)
|
70 |
-
|
71 |
-
# Basic stats
|
72 |
-
basic_stats = report_basic_stats(log_files)
|
73 |
-
md0 = f"Last updated: {basic_stats['last_updated_datetime']}"
|
74 |
-
|
75 |
-
md1 = "### Action Histogram\n"
|
76 |
-
md1 += basic_stats["action_hist_md"] + "\n"
|
77 |
-
|
78 |
-
md2 = "### Anony. Vote Histogram\n"
|
79 |
-
md2 += basic_stats["anony_vote_hist_md"] + "\n"
|
80 |
-
|
81 |
-
md3 = "### Model Call Histogram\n"
|
82 |
-
md3 += basic_stats["model_hist_md"] + "\n"
|
83 |
-
|
84 |
-
md4 = "### Model Call (Last 24 Hours)\n"
|
85 |
-
md4 += basic_stats["num_chats_last_24_hours"] + "\n"
|
86 |
-
|
87 |
-
basic_component_values[0] = md0
|
88 |
-
basic_component_values[1] = basic_stats["chat_dates_bar"]
|
89 |
-
basic_component_values[2] = md1
|
90 |
-
basic_component_values[3] = md2
|
91 |
-
basic_component_values[4] = md3
|
92 |
-
basic_component_values[5] = md4
|
93 |
-
|
94 |
-
|
95 |
-
def model_hyperlink(model_name, link):
|
96 |
-
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
|
97 |
-
|
98 |
-
|
99 |
def load_leaderboard_table_csv(filename, add_hyperlink=False):
|
100 |
lines = open(filename).readlines()
|
101 |
heads = [v.strip() for v in lines[0].split(",")]
|
@@ -127,31 +81,10 @@ def load_leaderboard_table_csv(filename, add_hyperlink=False):
|
|
127 |
v = np.nan
|
128 |
item[h] = v
|
129 |
if add_hyperlink:
|
130 |
-
item["Model"] =
|
131 |
rows.append(item)
|
132 |
-
|
133 |
return rows
|
134 |
|
135 |
-
|
136 |
-
def build_basic_stats_tab():
|
137 |
-
empty = "Loading ..."
|
138 |
-
basic_component_values[:] = [empty, None, empty, empty, empty, empty]
|
139 |
-
|
140 |
-
md0 = gr.Markdown(empty)
|
141 |
-
gr.Markdown("#### Figure 1: Number of model calls and votes")
|
142 |
-
plot_1 = gr.Plot(show_label=False)
|
143 |
-
with gr.Row():
|
144 |
-
with gr.Column():
|
145 |
-
md1 = gr.Markdown(empty)
|
146 |
-
with gr.Column():
|
147 |
-
md2 = gr.Markdown(empty)
|
148 |
-
with gr.Row():
|
149 |
-
with gr.Column():
|
150 |
-
md3 = gr.Markdown(empty)
|
151 |
-
with gr.Column():
|
152 |
-
md4 = gr.Markdown(empty)
|
153 |
-
return [md0, plot_1, md1, md2, md3, md4]
|
154 |
-
|
155 |
def get_full_table(arena_df, model_table_df):
|
156 |
values = []
|
157 |
for i in range(len(model_table_df)):
|
|
|
9 |
import pandas as pd
|
10 |
|
11 |
|
|
|
12 |
leader_component_values = [None]
|
13 |
+
space = " "
|
14 |
|
15 |
def make_default_md(arena_df, elo_results):
|
|
|
|
|
|
|
16 |
leaderboard_md = f"""
|
17 |
# NeurIPS LLM Merging Competition Leaderboard
|
18 |
+
[Website](https://llm-merging.github.io/index) | [Starter Kit (Github)](https://github.com/llm-merging/LLM-Merging) | [Discord](https://discord.com/invite/dPBHEVnV)
|
19 |
|
20 |
"""
|
21 |
return leaderboard_md
|
22 |
|
|
|
23 |
def make_arena_leaderboard_md(arena_df):
|
|
|
24 |
total_models = len(arena_df)
|
|
|
25 |
leaderboard_md = f"""
|
26 |
Three benchmarks are displayed: **Test Task 1**, **Test Task 2**, **Test Task 3**.
|
27 |
|
|
|
33 |
return leaderboard_md
|
34 |
|
35 |
def make_category_arena_leaderboard_md(arena_df, arena_subset_df, name="Overall"):
|
|
|
36 |
total_models = len(arena_df)
|
|
|
|
|
37 |
total_subset_models = len(arena_subset_df)
|
38 |
leaderboard_md = f"""### {cat_name_to_explanation[name]}
|
39 |
+
#### [Coverage] {space} #models: **{total_subset_models} ({round(total_subset_models/total_models *100)}%)**{space}
|
40 |
"""
|
41 |
return leaderboard_md
|
42 |
|
|
|
50 |
return leaderboard_md
|
51 |
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
def load_leaderboard_table_csv(filename, add_hyperlink=False):
|
54 |
lines = open(filename).readlines()
|
55 |
heads = [v.strip() for v in lines[0].split(",")]
|
|
|
81 |
v = np.nan
|
82 |
item[h] = v
|
83 |
if add_hyperlink:
|
84 |
+
item["Model"] = f'<a target="_blank" href="{item["Link"]}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{item["Model"]}</a>'
|
85 |
rows.append(item)
|
|
|
86 |
return rows
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
def get_full_table(arena_df, model_table_df):
|
89 |
values = []
|
90 |
for i in range(len(model_table_df)):
|