Spaces:
AIR-Bench
/
Running on CPU Upgrade

nan commited on
Commit
ee1f0b7
1 Parent(s): af8395f

feat: implement anonymous displaying for long-doc

Browse files
Files changed (2) hide show
  1. app.py +17 -7
  2. src/utils.py +8 -10
app.py CHANGED
@@ -41,13 +41,14 @@ print(f'QA data loaded: {original_df_qa.shape}')
41
  print(f'Long-Doc data loaded: {len(original_df_long_doc)}')
42
 
43
  leaderboard_df_qa = original_df_qa.copy()
44
- shown_columns_qa, types_qa = get_default_cols('qa', leaderboard_df_qa.columns, add_fix_cols=True)
 
45
  leaderboard_df_qa = leaderboard_df_qa[~leaderboard_df_qa[COL_NAME_IS_ANONYMOUS]][shown_columns_qa]
46
 
47
  leaderboard_df_long_doc = original_df_long_doc.copy()
48
- shown_columns_long_doc, types_long_doc = get_default_cols('long-doc', leaderboard_df_long_doc.columns,
49
- add_fix_cols=True)
50
- leaderboard_df_long_doc = leaderboard_df_long_doc[shown_columns_long_doc]
51
 
52
 
53
  def update_metric_qa(
@@ -67,8 +68,9 @@ def update_metric_long_doc(
67
  langs: list,
68
  reranking_model: list,
69
  query: str,
 
70
  ):
71
- return update_metric(raw_data, "long-doc", metric, domains, langs, reranking_model, query)
72
 
73
 
74
  demo = gr.Blocks(css=custom_css)
@@ -243,6 +245,12 @@ with demo:
243
  multiselect=True,
244
  interactive=True
245
  )
 
 
 
 
 
 
246
 
247
  leaderboard_table_long_doc = gr.components.Dataframe(
248
  value=leaderboard_df_long_doc,
@@ -254,7 +262,7 @@ with demo:
254
 
255
  # Dummy leaderboard for handling the case when the user uses backspace key
256
  hidden_leaderboard_table_for_search = gr.components.Dataframe(
257
- value=leaderboard_df_long_doc,
258
  datatype=types_long_doc,
259
  visible=False,
260
  )
@@ -274,7 +282,7 @@ with demo:
274
 
275
  # Set column-wise listener
276
  for selector in [
277
- selected_domains, selected_langs, selected_rerankings
278
  ]:
279
  selector.change(
280
  update_table_long_doc,
@@ -284,6 +292,7 @@ with demo:
284
  selected_langs,
285
  selected_rerankings,
286
  search_bar,
 
287
  ],
288
  leaderboard_table_long_doc,
289
  queue=True,
@@ -298,6 +307,7 @@ with demo:
298
  selected_langs,
299
  selected_rerankings,
300
  search_bar,
 
301
  ],
302
  leaderboard_table_long_doc,
303
  queue=True
 
41
  print(f'Long-Doc data loaded: {len(original_df_long_doc)}')
42
 
43
  leaderboard_df_qa = original_df_qa.copy()
44
+ shown_columns_qa, types_qa = get_default_cols(
45
+ 'qa', leaderboard_df_qa.columns, add_fix_cols=True)
46
  leaderboard_df_qa = leaderboard_df_qa[~leaderboard_df_qa[COL_NAME_IS_ANONYMOUS]][shown_columns_qa]
47
 
48
  leaderboard_df_long_doc = original_df_long_doc.copy()
49
+ shown_columns_long_doc, types_long_doc = get_default_cols(
50
+ 'long-doc', leaderboard_df_long_doc.columns, add_fix_cols=True)
51
+ leaderboard_df_long_doc = leaderboard_df_long_doc[~leaderboard_df_long_doc[COL_NAME_IS_ANONYMOUS]][shown_columns_long_doc]
52
 
53
 
54
  def update_metric_qa(
 
68
  langs: list,
69
  reranking_model: list,
70
  query: str,
71
+ show_anonymous: bool
72
  ):
73
+ return update_metric(raw_data, "long-doc", metric, domains, langs, reranking_model, query, show_anonymous)
74
 
75
 
76
  demo = gr.Blocks(css=custom_css)
 
245
  multiselect=True,
246
  interactive=True
247
  )
248
+ with gr.Row():
249
+ show_anonymous = gr.Checkbox(
250
+ label="Show anonymous submissions",
251
+ value=False,
252
+ info="The anonymous submissions might have invalid model information."
253
+ )
254
 
255
  leaderboard_table_long_doc = gr.components.Dataframe(
256
  value=leaderboard_df_long_doc,
 
262
 
263
  # Dummy leaderboard for handling the case when the user uses backspace key
264
  hidden_leaderboard_table_for_search = gr.components.Dataframe(
265
+ value=original_df_long_doc,
266
  datatype=types_long_doc,
267
  visible=False,
268
  )
 
282
 
283
  # Set column-wise listener
284
  for selector in [
285
+ selected_domains, selected_langs, selected_rerankings, show_anonymous
286
  ]:
287
  selector.change(
288
  update_table_long_doc,
 
292
  selected_langs,
293
  selected_rerankings,
294
  search_bar,
295
+ show_anonymous,
296
  ],
297
  leaderboard_table_long_doc,
298
  queue=True,
 
307
  selected_langs,
308
  selected_rerankings,
309
  search_bar,
310
+ show_anonymous,
311
  ],
312
  leaderboard_table_long_doc,
313
  queue=True
src/utils.py CHANGED
@@ -107,15 +107,12 @@ def update_table(
107
  query: str,
108
  show_anonymous: bool
109
  ):
110
- print(f"shown_anonymous: {show_anonymous}")
111
  filtered_df = hidden_df
112
  if not show_anonymous:
113
- print(filtered_df[COL_NAME_IS_ANONYMOUS])
114
  filtered_df = filtered_df[~filtered_df[COL_NAME_IS_ANONYMOUS]]
115
- print(f"filtered_df: {len(filtered_df)}")
116
  filtered_df = filter_models(filtered_df, reranking_query)
117
  filtered_df = filter_queries(query, filtered_df)
118
- df = select_columns(filtered_df, domains, langs)
119
  return df
120
 
121
 
@@ -125,13 +122,14 @@ def update_table_long_doc(
125
  langs: list,
126
  reranking_query: list,
127
  query: str,
128
- # show_anonymous: bool
129
  ):
130
- filtered_df = filter_models(hidden_df, reranking_query)
 
 
 
131
  filtered_df = filter_queries(query, filtered_df)
132
  df = select_columns(filtered_df, domains, langs, task='long_doc')
133
- # if not show_anonymous:
134
- # df = df[~df[COL_NAME_IS_ANONYMOUS]]
135
  return df
136
 
137
 
@@ -143,7 +141,7 @@ def update_metric(
143
  langs: list,
144
  reranking_model: list,
145
  query: str,
146
- show_anonymous: bool
147
  ) -> pd.DataFrame:
148
  if task == 'qa':
149
  leaderboard_df = get_leaderboard_df(raw_data, task=task, metric=metric)
@@ -163,7 +161,7 @@ def update_metric(
163
  langs,
164
  reranking_model,
165
  query,
166
- # show_anonymous
167
  )
168
 
169
 
 
107
  query: str,
108
  show_anonymous: bool
109
  ):
 
110
  filtered_df = hidden_df
111
  if not show_anonymous:
 
112
  filtered_df = filtered_df[~filtered_df[COL_NAME_IS_ANONYMOUS]]
 
113
  filtered_df = filter_models(filtered_df, reranking_query)
114
  filtered_df = filter_queries(query, filtered_df)
115
+ df = select_columns(filtered_df, domains, langs, task='qa')
116
  return df
117
 
118
 
 
122
  langs: list,
123
  reranking_query: list,
124
  query: str,
125
+ show_anonymous: bool
126
  ):
127
+ filtered_df = hidden_df
128
+ if not show_anonymous:
129
+ filtered_df = filtered_df[~filtered_df[COL_NAME_IS_ANONYMOUS]]
130
+ filtered_df = filter_models(filtered_df, reranking_query)
131
  filtered_df = filter_queries(query, filtered_df)
132
  df = select_columns(filtered_df, domains, langs, task='long_doc')
 
 
133
  return df
134
 
135
 
 
141
  langs: list,
142
  reranking_model: list,
143
  query: str,
144
+ show_anonymous: bool = False
145
  ) -> pd.DataFrame:
146
  if task == 'qa':
147
  leaderboard_df = get_leaderboard_df(raw_data, task=task, metric=metric)
 
161
  langs,
162
  reranking_model,
163
  query,
164
+ show_anonymous
165
  )
166
 
167