sherzod-hakimov commited on
Commit
69c36b6
1 Parent(s): b345ff4

update page loading

Browse files
Files changed (3) hide show
  1. app.py +32 -12
  2. src/assets/text_content.py +5 -1
  3. src/plot_utils.py +24 -3
app.py CHANGED
@@ -1,10 +1,11 @@
1
  import gradio as gr
2
 
3
- from src.assets.text_content import TITLE, INTRODUCTION_TEXT
4
  from src.leaderboard_utils import filter_search, get_github_data
5
  from src.plot_utils import split_models, compare_plots
6
 
7
  # For Leaderboards
 
8
  # Get CSV data
9
  global primary_leaderboard_df, version_dfs, version_names
10
  primary_leaderboard_df, version_dfs, version_names = get_github_data()
@@ -38,19 +39,22 @@ with main_app:
38
  elem_id="search-bar",
39
  )
40
 
41
- leaderboard_table = gr.components.Dataframe(
42
  value=primary_leaderboard_df[0],
43
  elem_id="leaderboard-table",
44
  interactive=False,
45
  visible=True,
 
46
  )
47
 
 
 
48
  # Add a dummy leaderboard to handle search queries from the primary_leaderboard_df and not update primary_leaderboard_df
49
- dummy_leaderboard_table = gr.components.Dataframe(
50
  value=primary_leaderboard_df[0],
51
  elem_id="leaderboard-table",
52
  interactive=False,
53
- visible=False,
54
  )
55
 
56
  search_bar.submit(
@@ -106,6 +110,14 @@ with main_app:
106
  elem_id="value-select-5",
107
  interactive=True,
108
  )
 
 
 
 
 
 
 
 
109
 
110
  with gr.Row():
111
  dummy_plot_df = gr.DataFrame(
@@ -120,35 +132,42 @@ with main_app:
120
 
121
  open_models_selection.change(
122
  compare_plots,
123
- [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend],
124
  plot_output,
125
  queue=True
126
  )
127
 
128
  closed_models_selection.change(
129
  compare_plots,
130
- [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend],
131
  plot_output,
132
  queue=True
133
  )
134
 
135
  show_all.change(
136
  compare_plots,
137
- [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend],
138
  plot_output,
139
  queue=True
140
  )
141
 
142
  show_names.change(
143
  compare_plots,
144
- [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend],
145
  plot_output,
146
  queue=True
147
  )
148
 
149
  show_legend.change(
150
  compare_plots,
151
- [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend],
 
 
 
 
 
 
 
152
  plot_output,
153
  queue=True
154
  )
@@ -165,18 +184,19 @@ with main_app:
165
  elem_id="search-bar-2",
166
  )
167
 
168
- prev_table = gr.components.Dataframe(
169
  value=prev_df,
170
  elem_id="leaderboard-table",
171
  interactive=False,
172
  visible=True,
 
173
  )
174
 
175
- dummy_prev_table = gr.components.Dataframe(
176
  value=prev_df,
177
  elem_id="leaderboard-table",
178
  interactive=False,
179
- visible=False,
180
  )
181
 
182
  search_bar_prev.submit(
 
1
  import gradio as gr
2
 
3
+ from src.assets.text_content import TITLE, INTRODUCTION_TEXT, CLEMSCORE_TEXT
4
  from src.leaderboard_utils import filter_search, get_github_data
5
  from src.plot_utils import split_models, compare_plots
6
 
7
  # For Leaderboards
8
+ dataframe_height = 800 # Height of the table in pixels
9
  # Get CSV data
10
  global primary_leaderboard_df, version_dfs, version_names
11
  primary_leaderboard_df, version_dfs, version_names = get_github_data()
 
39
  elem_id="search-bar",
40
  )
41
 
42
+ leaderboard_table = gr.Dataframe(
43
  value=primary_leaderboard_df[0],
44
  elem_id="leaderboard-table",
45
  interactive=False,
46
  visible=True,
47
+ height=dataframe_height
48
  )
49
 
50
+ gr.HTML(CLEMSCORE_TEXT)
51
+
52
  # Add a dummy leaderboard to handle search queries from the primary_leaderboard_df and not update primary_leaderboard_df
53
+ dummy_leaderboard_table = gr.Dataframe(
54
  value=primary_leaderboard_df[0],
55
  elem_id="leaderboard-table",
56
  interactive=False,
57
+ visible=False
58
  )
59
 
60
  search_bar.submit(
 
110
  elem_id="value-select-5",
111
  interactive=True,
112
  )
113
+ with gr.Column():
114
+ mobile_view = gr.CheckboxGroup(
115
+ ["Mobile View"],
116
+ label ="View plot on smaller screens 📱",
117
+ value=[],
118
+ elem_id="value-select-6",
119
+ interactive=True,
120
+ )
121
 
122
  with gr.Row():
123
  dummy_plot_df = gr.DataFrame(
 
132
 
133
  open_models_selection.change(
134
  compare_plots,
135
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend, mobile_view],
136
  plot_output,
137
  queue=True
138
  )
139
 
140
  closed_models_selection.change(
141
  compare_plots,
142
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend, mobile_view],
143
  plot_output,
144
  queue=True
145
  )
146
 
147
  show_all.change(
148
  compare_plots,
149
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend, mobile_view],
150
  plot_output,
151
  queue=True
152
  )
153
 
154
  show_names.change(
155
  compare_plots,
156
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend, mobile_view],
157
  plot_output,
158
  queue=True
159
  )
160
 
161
  show_legend.change(
162
  compare_plots,
163
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend, mobile_view],
164
+ plot_output,
165
+ queue=True
166
+ )
167
+
168
+ mobile_view.change(
169
+ compare_plots,
170
+ [dummy_plot_df, open_models_selection, closed_models_selection, show_all, show_names, show_legend, mobile_view],
171
  plot_output,
172
  queue=True
173
  )
 
184
  elem_id="search-bar-2",
185
  )
186
 
187
+ prev_table = gr.Dataframe(
188
  value=prev_df,
189
  elem_id="leaderboard-table",
190
  interactive=False,
191
  visible=True,
192
+ height=dataframe_height
193
  )
194
 
195
+ dummy_prev_table = gr.Dataframe(
196
  value=prev_df,
197
  elem_id="leaderboard-table",
198
  interactive=False,
199
+ visible=False
200
  )
201
 
202
  search_bar_prev.submit(
src/assets/text_content.py CHANGED
@@ -4,13 +4,17 @@ INTRODUCTION_TEXT = """
4
  <h6 align="center">
5
  The CLEM Leaderboard aims to track, rank and evaluate current cLLMs (chat-optimized Large Language Models) with the suggested pronounciation “clems”.
6
 
7
- The benchmarking approach is described in [Clembench: Using Game Play to Evaluate Chat-Optimized Language Models as Conversational Agents](https://arxiv.org/abs/2305.13455).
8
 
9
  Source code for benchmarking "clems" is available here: [Clembench](https://github.com/clembench/clembench)
10
 
11
  All generated files and results from the benchmark runs are available here: [clembench-runs](https://github.com/clembench/clembench-runs) </h6>
12
  """
13
 
 
 
 
 
14
  SHORT_NAMES = {
15
  "t0.0": "",
16
  "claude-v1.3": "cl-1.3",
 
4
  <h6 align="center">
5
  The CLEM Leaderboard aims to track, rank and evaluate current cLLMs (chat-optimized Large Language Models) with the suggested pronounciation “clems”.
6
 
7
+ The benchmarking approach is described in [Clembench: Using Game Play to Evaluate Chat-Optimized Language Models as Conversational Agents](https://aclanthology.org/2023.emnlp-main.689.pdf).
8
 
9
  Source code for benchmarking "clems" is available here: [Clembench](https://github.com/clembench/clembench)
10
 
11
  All generated files and results from the benchmark runs are available here: [clembench-runs](https://github.com/clembench/clembench-runs) </h6>
12
  """
13
 
14
+ CLEMSCORE_TEXT = """
15
+ The <i>clemscore</i> combines a score representing the overall ability to just follow the game instructions (separately scored in field <i>Played</i>) and the quality of the play in attempt where instructions were followed (field <i>Quality Scores</i>). For details about the games / interaction settings, and for results on older versions of the benchmark, see the tab <i>Versions and Details</i>.
16
+ """
17
+
18
  SHORT_NAMES = {
19
  "t0.0": "",
20
  "claude-v1.3": "cl-1.3",
src/plot_utils.py CHANGED
@@ -3,7 +3,7 @@ import plotly.express as px
3
 
4
  from src.assets.text_content import SHORT_NAMES
5
 
6
- def plotly_plot(df:pd.DataFrame, LIST:list, ALL:list, NAMES:list, LEGEND:list):
7
  '''
8
  Takes in a list of models for a plotly plot
9
  Args:
@@ -12,6 +12,7 @@ def plotly_plot(df:pd.DataFrame, LIST:list, ALL:list, NAMES:list, LEGEND:list):
12
  ALL: Either [] or ["Show All Models"] - toggle view to plot all models
13
  NAMES: Either [] or ["Show Names"] - toggle view to show model names on plot
14
  LEGEND: Either [] or ["Show Legend"] - toggle view to show legend on plot
 
15
  Returns:
16
  Fig: plotly figure
17
  '''
@@ -52,11 +53,30 @@ def plotly_plot(df:pd.DataFrame, LIST:list, ALL:list, NAMES:list, LEGEND:list):
52
  fig.update_xaxes(range=[-5, 105])
53
  fig.update_yaxes(range=[-5, 105])
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  return fig
56
 
57
 
58
  # ['Model', 'Clemscore', 'All(Played)', 'All(Quality Score)']
59
- def compare_plots(df: pd.DataFrame, LIST1: list, LIST2: list, ALL:list, NAMES:list, LEGEND: list):
60
  '''
61
  Quality Score v/s % Played plot by selecting models
62
  Args:
@@ -66,13 +86,14 @@ def compare_plots(df: pd.DataFrame, LIST1: list, LIST2: list, ALL:list, NAMES:li
66
  ALL: Either [] or ["Show All Models"] - toggle view to plot all models
67
  NAMES: Either [] or ["Show Names"] - toggle view to show model names on plot
68
  LEGEND: Either [] or ["Show Legend"] - toggle view to show legend on plot
 
69
  Returns:
70
  fig: The plot
71
  '''
72
 
73
  # Combine lists for Open source and commercial models
74
  LIST = LIST1 + LIST2
75
- fig = plotly_plot(df, LIST, ALL, NAMES, LEGEND)
76
 
77
  return fig
78
 
 
3
 
4
  from src.assets.text_content import SHORT_NAMES
5
 
6
+ def plotly_plot(df:pd.DataFrame, LIST:list, ALL:list, NAMES:list, LEGEND:list, MOBILE:list ):
7
  '''
8
  Takes in a list of models for a plotly plot
9
  Args:
 
12
  ALL: Either [] or ["Show All Models"] - toggle view to plot all models
13
  NAMES: Either [] or ["Show Names"] - toggle view to show model names on plot
14
  LEGEND: Either [] or ["Show Legend"] - toggle view to show legend on plot
15
+ MOBILE: Either [] or ["Mobile View"] - toggle view to for smaller screens
16
  Returns:
17
  Fig: plotly figure
18
  '''
 
53
  fig.update_xaxes(range=[-5, 105])
54
  fig.update_yaxes(range=[-5, 105])
55
 
56
+ if MOBILE:
57
+ fig.update_layout(height=300)
58
+
59
+
60
+ if MOBILE and LEGEND:
61
+ fig.update_layout(height=450)
62
+ fig.update_layout(legend=dict(
63
+ yanchor="bottom",
64
+ y=-5.52,
65
+ xanchor="left",
66
+ x=0.01
67
+ ))
68
+
69
+ fig.update_layout(
70
+ xaxis_title="",
71
+ yaxis_title="",
72
+ title="% Played v/s Quality Score"
73
+ )
74
+
75
  return fig
76
 
77
 
78
  # ['Model', 'Clemscore', 'All(Played)', 'All(Quality Score)']
79
+ def compare_plots(df: pd.DataFrame, LIST1: list, LIST2: list, ALL:list, NAMES:list, LEGEND: list, MOBILE: list):
80
  '''
81
  Quality Score v/s % Played plot by selecting models
82
  Args:
 
86
  ALL: Either [] or ["Show All Models"] - toggle view to plot all models
87
  NAMES: Either [] or ["Show Names"] - toggle view to show model names on plot
88
  LEGEND: Either [] or ["Show Legend"] - toggle view to show legend on plot
89
+ MOBILE: Either [] or ["Mobile View"] - toggle view to for smaller screens
90
  Returns:
91
  fig: The plot
92
  '''
93
 
94
  # Combine lists for Open source and commercial models
95
  LIST = LIST1 + LIST2
96
+ fig = plotly_plot(df, LIST, ALL, NAMES, LEGEND, MOBILE)
97
 
98
  return fig
99