Use latest result per model
Browse files
app.py
CHANGED
@@ -10,41 +10,59 @@ RESULTS_DATASET_ID = "datasets/open-llm-leaderboard/results"
|
|
10 |
fs = HfFileSystem()
|
11 |
|
12 |
|
13 |
-
def
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
|
19 |
def load_result(result_path) -> dict:
|
20 |
-
with fs.open(
|
21 |
data = json.load(f)
|
22 |
return data
|
23 |
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
10 |
fs = HfFileSystem()
|
11 |
|
12 |
|
13 |
+
def fetch_result_paths():
|
14 |
+
paths = fs.glob(f"{RESULTS_DATASET_ID}/**/**/*.json")
|
15 |
+
return paths
|
16 |
+
|
17 |
+
|
18 |
+
def filter_latest_result_path_per_model(paths):
|
19 |
+
from collections import defaultdict
|
20 |
+
|
21 |
+
d = defaultdict(list)
|
22 |
+
for path in paths:
|
23 |
+
model_id, _ = path[len(RESULTS_DATASET_ID) +1:].rsplit("/", 1)
|
24 |
+
d[model_id].append(path)
|
25 |
+
return {model_id: max(paths) for model_id, paths in d.items()}
|
26 |
+
|
27 |
+
|
28 |
+
def get_result_path_from_model(model_id, result_path_per_model):
|
29 |
+
return result_path_per_model[model_id]
|
30 |
|
31 |
|
32 |
def load_result(result_path) -> dict:
|
33 |
+
with fs.open(result_path, "r") as f:
|
34 |
data = json.load(f)
|
35 |
return data
|
36 |
|
37 |
|
38 |
+
def render_result(model_id):
|
39 |
+
result_path = get_result_path_from_model(model_id, latest_result_path_per_model)
|
40 |
+
return load_result(result_path)
|
41 |
+
|
42 |
+
|
43 |
+
# if __name__ == "__main__":
|
44 |
+
latest_result_path_per_model = filter_latest_result_path_per_model(fetch_result_paths())
|
45 |
+
|
46 |
+
with gr.Blocks() as demo:
|
47 |
+
gr.HTML("<h1 style='text-align: center;'>Compare Results of the 🤗 Open LLM Leaderboard</h1>")
|
48 |
+
gr.HTML("<h3 style='text-align: center;'>Select 2 results to load and compare</h3>")
|
49 |
+
with gr.Row():
|
50 |
+
with gr.Column():
|
51 |
+
model_id_1 = gr.Dropdown(choices=list(latest_result_path_per_model.keys()), label="Results")
|
52 |
+
load_btn_1 = gr.Button("Load")
|
53 |
+
result_1 = gr.JSON(label="Result")
|
54 |
+
load_btn_1.click(
|
55 |
+
fn=render_result,
|
56 |
+
inputs=model_id_1,
|
57 |
+
outputs=result_1,
|
58 |
+
)
|
59 |
+
with gr.Column():
|
60 |
+
model_id_2 = gr.Dropdown(choices=list(latest_result_path_per_model.keys()), label="Results")
|
61 |
+
load_btn_2 = gr.Button("Load")
|
62 |
+
result_2 = gr.JSON(label="Result")
|
63 |
+
load_btn_2.click(
|
64 |
+
fn=render_result,
|
65 |
+
inputs=model_id_2,
|
66 |
+
outputs=result_2,
|
67 |
+
)
|
68 |
+
demo.launch()
|