albertvillanova HF staff commited on
Commit
729af67
β€’
1 Parent(s): e7f29e1

Set result_paths_per_model as State

Browse files
Files changed (2) hide show
  1. app.py +15 -8
  2. src/results.py +4 -0
app.py CHANGED
@@ -1,5 +1,3 @@
1
- from functools import partial
2
-
3
  import gradio as gr
4
 
5
  import src.constants as constants
@@ -19,18 +17,15 @@ from src.results import (
19
  display_loading_message_for_results,
20
  display_results,
21
  download_results,
22
- fetch_result_paths,
23
  load_results,
24
  plot_results,
25
- sort_result_paths_per_model,
26
  update_load_results_component,
27
  update_tasks_component,
28
  )
29
 
30
 
31
  # if __name__ == "__main__":
32
- result_paths_per_model = sort_result_paths_per_model(fetch_result_paths())
33
- load_results = partial(load_results, result_paths_per_model=result_paths_per_model)
34
 
35
  with gr.Blocks(fill_height=True, fill_width=True) as demo:
36
  gr.HTML("<h1 style='text-align: center;'>Compare Results of the πŸ€— Open LLM Leaderboard</h1>")
@@ -43,7 +38,8 @@ with gr.Blocks(fill_height=True, fill_width=True) as demo:
43
  "Check out the [documentation](https://huggingface.co/docs/leaderboards/open_llm_leaderboard/about) πŸ“„ to find explanations on the evaluations used, their configuration parameters and details on the input/outputs for the models."
44
  )
45
  with gr.Row():
46
- model_ids = gr.Dropdown(choices=list(result_paths_per_model.keys()), label="Models", multiselect=True)
 
47
 
48
  with gr.Row():
49
  with gr.Tab("Results"):
@@ -113,6 +109,17 @@ with gr.Blocks(fill_height=True, fill_width=True) as demo:
113
  details = gr.HTML()
114
  details_dataframe = gr.State()
115
 
 
 
 
 
 
 
 
 
 
 
 
116
  gr.on(
117
  triggers=[model_ids.input],
118
  fn=update_load_results_component,
@@ -124,7 +131,7 @@ with gr.Blocks(fill_height=True, fill_width=True) as demo:
124
  outputs=[results, configs],
125
  ).then(
126
  fn=load_results,
127
- inputs=model_ids,
128
  outputs=results_dataframe,
129
  ).then(
130
  fn=update_tasks_component,
 
 
 
1
  import gradio as gr
2
 
3
  import src.constants as constants
 
17
  display_loading_message_for_results,
18
  display_results,
19
  download_results,
20
+ load_result_paths_per_model,
21
  load_results,
22
  plot_results,
 
23
  update_load_results_component,
24
  update_tasks_component,
25
  )
26
 
27
 
28
  # if __name__ == "__main__":
 
 
29
 
30
  with gr.Blocks(fill_height=True, fill_width=True) as demo:
31
  gr.HTML("<h1 style='text-align: center;'>Compare Results of the πŸ€— Open LLM Leaderboard</h1>")
 
38
  "Check out the [documentation](https://huggingface.co/docs/leaderboards/open_llm_leaderboard/about) πŸ“„ to find explanations on the evaluations used, their configuration parameters and details on the input/outputs for the models."
39
  )
40
  with gr.Row():
41
+ model_ids = gr.Dropdown(label="Models", multiselect=True)
42
+ result_paths_per_model = gr.State()
43
 
44
  with gr.Row():
45
  with gr.Tab("Results"):
 
109
  details = gr.HTML()
110
  details_dataframe = gr.State()
111
 
112
+ # DEMO:
113
+ demo.load(
114
+ fn=load_result_paths_per_model,
115
+ outputs=result_paths_per_model,
116
+ ).then(
117
+ fn=lambda x: gr.Dropdown(choices=list(x.keys())),
118
+ inputs=result_paths_per_model,
119
+ outputs=model_ids,
120
+ )
121
+
122
+ # RESULTS:
123
  gr.on(
124
  triggers=[model_ids.input],
125
  fn=update_load_results_component,
 
131
  outputs=[results, configs],
132
  ).then(
133
  fn=load_results,
134
+ inputs=[model_ids, result_paths_per_model],
135
  outputs=results_dataframe,
136
  ).then(
137
  fn=update_tasks_component,
src/results.py CHANGED
@@ -10,6 +10,10 @@ import src.constants as constants
10
  from src.hub import glob, load_json_file
11
 
12
 
 
 
 
 
13
  def fetch_result_paths():
14
  path = f"{constants.RESULTS_DATASET_ID}/**/**/*.json"
15
  return glob(path)
 
10
  from src.hub import glob, load_json_file
11
 
12
 
13
+ def load_result_paths_per_model():
14
+ return sort_result_paths_per_model(fetch_result_paths())
15
+
16
+
17
  def fetch_result_paths():
18
  path = f"{constants.RESULTS_DATASET_ID}/**/**/*.json"
19
  return glob(path)