hysts HF staff commited on
Commit
7c83c02
1 Parent(s): 3a41fad

Separate leaderboard section

Browse files
Files changed (1) hide show
  1. app.py +179 -175
app.py CHANGED
@@ -211,187 +211,191 @@ def filter_models(
211
 
212
  leaderboard_df = filter_models(leaderboard_df, [t.to_str(" : ") for t in ModelType], list(NUMERIC_INTERVALS.keys()), [i.value.name for i in Precision], [i.value.name for i in AddSpecialTokens], [i.value.name for i in NumFewShots], False, False, False)
213
 
214
- with gr.Blocks(css=custom_css) as demo:
215
- gr.HTML(TITLE)
216
- gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
217
-
218
- with gr.Tabs(elem_classes="tab-buttons") as tabs:
219
- with gr.TabItem("🏅 LLM Benchmark", elem_id="llm-benchmark-tab-table", id=0):
220
  with gr.Row():
221
- with gr.Column():
222
- with gr.Row():
223
- search_bar = gr.Textbox(
224
- placeholder=" 🔍 Search for your model (separate multiple queries with `;`) and press ENTER...",
225
- show_label=False,
226
- elem_id="search-bar",
227
- )
228
- with gr.Row():
229
- shown_columns = gr.CheckboxGroup(
230
- choices=[
231
- c.name
232
- for c in fields(AutoEvalColumn)
233
- if not c.hidden and not c.never_hidden# and not c.dummy
234
- ],
235
- value=[
236
- c.name
237
- for c in fields(AutoEvalColumn)
238
- if c.displayed_by_default and not c.hidden and not c.never_hidden
239
- ],
240
- label="Select columns to show",
241
- elem_id="column-select",
242
- interactive=True,
243
- )
244
- with gr.Row():
245
- deleted_models_visibility = gr.Checkbox(
246
- value=False, label="Show private/deleted models", interactive=True
247
- )
248
- merged_models_visibility = gr.Checkbox(
249
- value=False, label="Show merges", interactive=True
250
- )
251
- flagged_models_visibility = gr.Checkbox(
252
- value=False, label="Show flagged models", interactive=True
253
- )
254
- with gr.Column(min_width=320):
255
- #with gr.Box(elem_id="box-filter"):
256
- filter_columns_type = gr.CheckboxGroup(
257
- label="Model types",
258
- choices=[t.to_str() for t in ModelType],
259
- value=[t.to_str() for t in ModelType],
260
- interactive=True,
261
- elem_id="filter-columns-type",
262
- )
263
- filter_columns_precision = gr.CheckboxGroup(
264
- label="Precision",
265
- choices=[i.value.name for i in Precision],
266
- value=[i.value.name for i in Precision],
267
- interactive=True,
268
- elem_id="filter-columns-precision",
269
- )
270
- filter_columns_size = gr.CheckboxGroup(
271
- label="Model sizes (in billions of parameters)",
272
- choices=list(NUMERIC_INTERVALS.keys()),
273
- value=list(NUMERIC_INTERVALS.keys()),
274
- interactive=True,
275
- elem_id="filter-columns-size",
276
- )
277
- filter_columns_add_special_tokens = gr.CheckboxGroup(
278
- label="Add Special Tokens",
279
- choices=[i.value.name for i in AddSpecialTokens],
280
- value=[i.value.name for i in AddSpecialTokens],
281
- interactive=True,
282
- elem_id="filter-columns-add-special-tokens",
283
- )
284
- filter_columns_num_few_shots = gr.CheckboxGroup(
285
- label="Num Few Shots",
286
- choices=[i.value.name for i in NumFewShots],
287
- value=[i.value.name for i in NumFewShots],
288
- interactive=True,
289
- elem_id="filter-columns-num-few-shots",
290
- )
291
-
292
- leaderboard_df_filtered = filter_models(leaderboard_df, [t.to_str(" : ") for t in ModelType], list(NUMERIC_INTERVALS.keys()), [i.value.name for i in Precision], [i.value.name for i in AddSpecialTokens], [i.value.name for i in NumFewShots], False, False, False)
293
- # initial_columns = [c.name for c in fields(AutoEvalColumn) if c.never_hidden or c.displayed_by_default]
294
- # leaderboard_df_filtered = select_columns(leaderboard_df_filtered, initial_columns)
295
-
296
- # leaderboard_table = gr.components.Dataframe(
297
- # value=leaderboard_df_filtered,
298
- # headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
299
- # datatype=TYPES,
300
- # elem_id="leaderboard-table",
301
- # interactive=False,
302
- # visible=True,
303
- # )
304
-
305
- # DataFrameの初期化部分のみを修正
306
- initial_columns = ['T'] + [c.name for c in fields(AutoEvalColumn) if (c.never_hidden or c.displayed_by_default) and c.name != 'T']
307
- leaderboard_df_filtered = select_columns(leaderboard_df, initial_columns)
308
-
309
- # Model列のリンク形式を修正
310
- leaderboard_df_filtered['Model'] = leaderboard_df_filtered['Model'].apply(
311
- lambda x: f'[{x.split(">")[-2].split("<")[0]}]({x.split("href=")[1].split(chr(34))[1]})' if isinstance(x, str) and 'href=' in x else x
312
  )
313
-
314
- # 数値データを文字列に変換
315
- for col in leaderboard_df_filtered.columns:
316
- if col not in ['T', 'Model']:
317
- leaderboard_df_filtered[col] = leaderboard_df_filtered[col].astype(str)
318
-
319
- # DataFrameコンポーネントの初期化
320
- leaderboard_table = gr.components.Dataframe(
321
- value=leaderboard_df_filtered,
322
- headers=initial_columns,
323
- datatype=TYPES,
324
- elem_id="leaderboard-table",
325
- interactive=False,
326
- visible=True
327
  )
328
-
329
- # Dummy leaderboard for handling the case when the user uses backspace key
330
- hidden_leaderboard_table_for_search = gr.components.Dataframe(
331
- value=original_df[COLS],
332
- headers=COLS,
333
- datatype=TYPES,
334
- visible=False,
335
  )
336
- search_bar.submit(
337
- update_table,
338
- [
339
- hidden_leaderboard_table_for_search,
340
- shown_columns,
341
- filter_columns_type,
342
- filter_columns_precision,
343
- filter_columns_size,
344
- filter_columns_add_special_tokens,
345
- filter_columns_num_few_shots,
346
- deleted_models_visibility,
347
- merged_models_visibility,
348
- flagged_models_visibility,
349
- search_bar,
350
- ],
351
- leaderboard_table,
352
  )
353
-
354
- # Define a hidden component that will trigger a reload only if a query parameter has be set
355
- hidden_search_bar = gr.Textbox(value="", visible=False)
356
- hidden_search_bar.change(
357
- update_table,
358
- [
359
- hidden_leaderboard_table_for_search,
360
- shown_columns,
361
- filter_columns_type,
362
- filter_columns_precision,
363
- filter_columns_size,
364
- filter_columns_add_special_tokens,
365
- filter_columns_num_few_shots,
366
- deleted_models_visibility,
367
- merged_models_visibility,
368
- flagged_models_visibility,
369
- search_bar,
370
- ],
371
- leaderboard_table,
372
  )
373
- # Check query parameter once at startup and update search bar + hidden component
374
- demo.load(load_query, inputs=[], outputs=[search_bar, hidden_search_bar])
375
-
376
- for selector in [shown_columns, filter_columns_type, filter_columns_precision, filter_columns_size, filter_columns_add_special_tokens, filter_columns_num_few_shots, deleted_models_visibility, merged_models_visibility, flagged_models_visibility]:
377
- selector.change(
378
- update_table,
379
- [
380
- hidden_leaderboard_table_for_search,
381
- shown_columns,
382
- filter_columns_type,
383
- filter_columns_precision,
384
- filter_columns_size,
385
- filter_columns_add_special_tokens,
386
- filter_columns_num_few_shots,
387
- deleted_models_visibility,
388
- merged_models_visibility,
389
- flagged_models_visibility,
390
- search_bar,
391
- ],
392
- leaderboard_table,
393
- queue=True,
394
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
395
 
396
  with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=2):
397
  gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
 
211
 
212
  leaderboard_df = filter_models(leaderboard_df, [t.to_str(" : ") for t in ModelType], list(NUMERIC_INTERVALS.keys()), [i.value.name for i in Precision], [i.value.name for i in AddSpecialTokens], [i.value.name for i in NumFewShots], False, False, False)
213
 
214
+ with gr.Blocks() as demo_leaderboard:
215
+ with gr.Row():
216
+ with gr.Column():
 
 
 
217
  with gr.Row():
218
+ search_bar = gr.Textbox(
219
+ placeholder=" 🔍 Search for your model (separate multiple queries with `;`) and press ENTER...",
220
+ show_label=False,
221
+ elem_id="search-bar",
222
+ )
223
+ with gr.Row():
224
+ shown_columns = gr.CheckboxGroup(
225
+ choices=[
226
+ c.name
227
+ for c in fields(AutoEvalColumn)
228
+ if not c.hidden and not c.never_hidden# and not c.dummy
229
+ ],
230
+ value=[
231
+ c.name
232
+ for c in fields(AutoEvalColumn)
233
+ if c.displayed_by_default and not c.hidden and not c.never_hidden
234
+ ],
235
+ label="Select columns to show",
236
+ elem_id="column-select",
237
+ interactive=True,
238
+ )
239
+ with gr.Row():
240
+ deleted_models_visibility = gr.Checkbox(
241
+ value=False, label="Show private/deleted models", interactive=True
242
+ )
243
+ merged_models_visibility = gr.Checkbox(
244
+ value=False, label="Show merges", interactive=True
245
+ )
246
+ flagged_models_visibility = gr.Checkbox(
247
+ value=False, label="Show flagged models", interactive=True
248
+ )
249
+ with gr.Column(min_width=320):
250
+ #with gr.Box(elem_id="box-filter"):
251
+ filter_columns_type = gr.CheckboxGroup(
252
+ label="Model types",
253
+ choices=[t.to_str() for t in ModelType],
254
+ value=[t.to_str() for t in ModelType],
255
+ interactive=True,
256
+ elem_id="filter-columns-type",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  )
258
+ filter_columns_precision = gr.CheckboxGroup(
259
+ label="Precision",
260
+ choices=[i.value.name for i in Precision],
261
+ value=[i.value.name for i in Precision],
262
+ interactive=True,
263
+ elem_id="filter-columns-precision",
 
 
 
 
 
 
 
 
264
  )
265
+ filter_columns_size = gr.CheckboxGroup(
266
+ label="Model sizes (in billions of parameters)",
267
+ choices=list(NUMERIC_INTERVALS.keys()),
268
+ value=list(NUMERIC_INTERVALS.keys()),
269
+ interactive=True,
270
+ elem_id="filter-columns-size",
 
271
  )
272
+ filter_columns_add_special_tokens = gr.CheckboxGroup(
273
+ label="Add Special Tokens",
274
+ choices=[i.value.name for i in AddSpecialTokens],
275
+ value=[i.value.name for i in AddSpecialTokens],
276
+ interactive=True,
277
+ elem_id="filter-columns-add-special-tokens",
 
 
 
 
 
 
 
 
 
 
278
  )
279
+ filter_columns_num_few_shots = gr.CheckboxGroup(
280
+ label="Num Few Shots",
281
+ choices=[i.value.name for i in NumFewShots],
282
+ value=[i.value.name for i in NumFewShots],
283
+ interactive=True,
284
+ elem_id="filter-columns-num-few-shots",
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  )
286
+
287
+ leaderboard_df_filtered = filter_models(leaderboard_df, [t.to_str(" : ") for t in ModelType], list(NUMERIC_INTERVALS.keys()), [i.value.name for i in Precision], [i.value.name for i in AddSpecialTokens], [i.value.name for i in NumFewShots], False, False, False)
288
+ # initial_columns = [c.name for c in fields(AutoEvalColumn) if c.never_hidden or c.displayed_by_default]
289
+ # leaderboard_df_filtered = select_columns(leaderboard_df_filtered, initial_columns)
290
+
291
+ # leaderboard_table = gr.components.Dataframe(
292
+ # value=leaderboard_df_filtered,
293
+ # headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
294
+ # datatype=TYPES,
295
+ # elem_id="leaderboard-table",
296
+ # interactive=False,
297
+ # visible=True,
298
+ # )
299
+
300
+ # DataFrameの初期化部分のみを修正
301
+ initial_columns = ['T'] + [c.name for c in fields(AutoEvalColumn) if (c.never_hidden or c.displayed_by_default) and c.name != 'T']
302
+ leaderboard_df_filtered = select_columns(leaderboard_df, initial_columns)
303
+
304
+ # Model列のリンク形式を修正
305
+ leaderboard_df_filtered['Model'] = leaderboard_df_filtered['Model'].apply(
306
+ lambda x: f'[{x.split(">")[-2].split("<")[0]}]({x.split("href=")[1].split(chr(34))[1]})' if isinstance(x, str) and 'href=' in x else x
307
+ )
308
+
309
+ # 数値データを文字列に変換
310
+ for col in leaderboard_df_filtered.columns:
311
+ if col not in ['T', 'Model']:
312
+ leaderboard_df_filtered[col] = leaderboard_df_filtered[col].astype(str)
313
+
314
+ # DataFrameコンポーネントの初期化
315
+ leaderboard_table = gr.components.Dataframe(
316
+ value=leaderboard_df_filtered,
317
+ headers=initial_columns,
318
+ datatype=TYPES,
319
+ elem_id="leaderboard-table",
320
+ interactive=False,
321
+ visible=True
322
+ )
323
+
324
+ # Dummy leaderboard for handling the case when the user uses backspace key
325
+ hidden_leaderboard_table_for_search = gr.components.Dataframe(
326
+ value=original_df[COLS],
327
+ headers=COLS,
328
+ datatype=TYPES,
329
+ visible=False,
330
+ )
331
+ search_bar.submit(
332
+ update_table,
333
+ [
334
+ hidden_leaderboard_table_for_search,
335
+ shown_columns,
336
+ filter_columns_type,
337
+ filter_columns_precision,
338
+ filter_columns_size,
339
+ filter_columns_add_special_tokens,
340
+ filter_columns_num_few_shots,
341
+ deleted_models_visibility,
342
+ merged_models_visibility,
343
+ flagged_models_visibility,
344
+ search_bar,
345
+ ],
346
+ leaderboard_table,
347
+ )
348
+
349
+ # Define a hidden component that will trigger a reload only if a query parameter has be set
350
+ hidden_search_bar = gr.Textbox(value="", visible=False)
351
+ hidden_search_bar.change(
352
+ update_table,
353
+ [
354
+ hidden_leaderboard_table_for_search,
355
+ shown_columns,
356
+ filter_columns_type,
357
+ filter_columns_precision,
358
+ filter_columns_size,
359
+ filter_columns_add_special_tokens,
360
+ filter_columns_num_few_shots,
361
+ deleted_models_visibility,
362
+ merged_models_visibility,
363
+ flagged_models_visibility,
364
+ search_bar,
365
+ ],
366
+ leaderboard_table,
367
+ )
368
+ # Check query parameter once at startup and update search bar + hidden component
369
+ demo_leaderboard.load(load_query, inputs=[], outputs=[search_bar, hidden_search_bar])
370
+
371
+ for selector in [shown_columns, filter_columns_type, filter_columns_precision, filter_columns_size, filter_columns_add_special_tokens, filter_columns_num_few_shots, deleted_models_visibility, merged_models_visibility, flagged_models_visibility]:
372
+ selector.change(
373
+ update_table,
374
+ [
375
+ hidden_leaderboard_table_for_search,
376
+ shown_columns,
377
+ filter_columns_type,
378
+ filter_columns_precision,
379
+ filter_columns_size,
380
+ filter_columns_add_special_tokens,
381
+ filter_columns_num_few_shots,
382
+ deleted_models_visibility,
383
+ merged_models_visibility,
384
+ flagged_models_visibility,
385
+ search_bar,
386
+ ],
387
+ leaderboard_table,
388
+ queue=True,
389
+ )
390
+
391
+
392
+ with gr.Blocks(css=custom_css) as demo:
393
+ gr.HTML(TITLE)
394
+ gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
395
+
396
+ with gr.Tabs(elem_classes="tab-buttons") as tabs:
397
+ with gr.TabItem("🏅 LLM Benchmark", elem_id="llm-benchmark-tab-table", id=0):
398
+ demo_leaderboard.render()
399
 
400
  with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=2):
401
  gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")