Spaces:
AIR-Bench
/
Running on CPU Upgrade

nan commited on
Commit
254881e
1 Parent(s): d62c98e

refactor: rename the variables

Browse files
Files changed (3) hide show
  1. app.py +16 -16
  2. src/loaders.py +8 -8
  3. src/models.py +2 -2
app.py CHANGED
@@ -114,7 +114,7 @@ def update_datastore(version):
114
  selected_domains = get_domain_dropdown(QABenchmarks[datastore.slug])
115
  selected_langs = get_language_dropdown(QABenchmarks[datastore.slug])
116
  selected_rerankings = get_reranking_dropdown(datastore.reranking_models)
117
- leaderboard_table = get_leaderboard_table(datastore.leaderboard_df_qa, datastore.types_qa)
118
  hidden_leaderboard_table = \
119
  get_leaderboard_table(datastore.raw_df_qa, datastore.types_qa, visible=False)
120
  return selected_domains, selected_langs, selected_rerankings, leaderboard_table, hidden_leaderboard_table
@@ -127,7 +127,7 @@ def update_datastore_long_doc(version):
127
  selected_domains = get_domain_dropdown(LongDocBenchmarks[datastore.slug])
128
  selected_langs = get_language_dropdown(LongDocBenchmarks[datastore.slug])
129
  selected_rerankings = get_reranking_dropdown(datastore.reranking_models)
130
- leaderboard_table = get_leaderboard_table(datastore.leaderboard_df_long_doc, datastore.types_long_doc)
131
  hidden_leaderboard_table = \
132
  get_leaderboard_table(datastore.raw_df_long_doc, datastore.types_long_doc, visible=False)
133
  return selected_domains, selected_langs, selected_rerankings, leaderboard_table, hidden_leaderboard_table
@@ -170,7 +170,7 @@ with demo:
170
  with gr.Column():
171
  selected_rerankings = get_reranking_dropdown(datastore.reranking_models)
172
  # shown_table
173
- lb_table = get_leaderboard_table(datastore.leaderboard_df_qa, datastore.types_qa)
174
  # Dummy leaderboard for handling the case when the user uses backspace key
175
  hidden_lb_table = get_leaderboard_table(datastore.raw_df_qa, datastore.types_qa, visible=False)
176
 
@@ -218,9 +218,9 @@ with demo:
218
  with gr.Column(scale=1):
219
  selected_noreranker = get_noreranking_dropdown()
220
 
221
- lb_df_retriever = datastore.leaderboard_df_qa[
222
- datastore.leaderboard_df_qa[COL_NAME_RERANKING_MODEL] == "NoReranker"
223
- ]
224
  lb_df_retriever = reset_rank(lb_df_retriever)
225
  lb_table_retriever = get_leaderboard_table(lb_df_retriever, datastore.types_qa)
226
 
@@ -276,9 +276,9 @@ with demo:
276
  queue=True,
277
  )
278
  with gr.TabItem("Reranking Only", id=12):
279
- lb_df_reranker = datastore.leaderboard_df_qa[
280
- datastore.leaderboard_df_qa[COL_NAME_RETRIEVAL_MODEL] == BM25_LINK
281
- ]
282
  lb_df_reranker = reset_rank(lb_df_reranker)
283
  reranking_models_reranker = (
284
  lb_df_reranker[COL_NAME_RERANKING_MODEL].apply(remove_html).unique().tolist()
@@ -365,7 +365,7 @@ with demo:
365
  selected_rerankings = get_reranking_dropdown(datastore.reranking_models)
366
 
367
  lb_table_long_doc = get_leaderboard_table(
368
- datastore.leaderboard_df_long_doc, datastore.types_long_doc
369
  )
370
 
371
  # Dummy leaderboard for handling the case when the user uses backspace key
@@ -421,9 +421,9 @@ with demo:
421
  search_bar_retriever = get_search_bar()
422
  with gr.Column(scale=1):
423
  selected_noreranker = get_noreranking_dropdown()
424
- lb_df_retriever_long_doc = datastore.leaderboard_df_long_doc[
425
- datastore.leaderboard_df_long_doc[COL_NAME_RERANKING_MODEL] == "NoReranker"
426
- ]
427
  lb_df_retriever_long_doc = reset_rank(lb_df_retriever_long_doc)
428
  lb_table_retriever_long_doc = get_leaderboard_table(
429
  lb_df_retriever_long_doc, datastore.types_long_doc
@@ -479,9 +479,9 @@ with demo:
479
  queue=True,
480
  )
481
  with gr.TabItem("Reranking Only", id=22):
482
- lb_df_reranker_ldoc = datastore.leaderboard_df_long_doc[
483
- datastore.leaderboard_df_long_doc[COL_NAME_RETRIEVAL_MODEL] == BM25_LINK
484
- ]
485
  lb_df_reranker_ldoc = reset_rank(lb_df_reranker_ldoc)
486
  reranking_models_reranker_ldoc = (
487
  lb_df_reranker_ldoc[COL_NAME_RERANKING_MODEL].apply(remove_html).unique().tolist()
 
114
  selected_domains = get_domain_dropdown(QABenchmarks[datastore.slug])
115
  selected_langs = get_language_dropdown(QABenchmarks[datastore.slug])
116
  selected_rerankings = get_reranking_dropdown(datastore.reranking_models)
117
+ leaderboard_table = get_leaderboard_table(datastore.formatted_df_qa, datastore.types_qa)
118
  hidden_leaderboard_table = \
119
  get_leaderboard_table(datastore.raw_df_qa, datastore.types_qa, visible=False)
120
  return selected_domains, selected_langs, selected_rerankings, leaderboard_table, hidden_leaderboard_table
 
127
  selected_domains = get_domain_dropdown(LongDocBenchmarks[datastore.slug])
128
  selected_langs = get_language_dropdown(LongDocBenchmarks[datastore.slug])
129
  selected_rerankings = get_reranking_dropdown(datastore.reranking_models)
130
+ leaderboard_table = get_leaderboard_table(datastore.formatted_df_ldoc, datastore.types_long_doc)
131
  hidden_leaderboard_table = \
132
  get_leaderboard_table(datastore.raw_df_long_doc, datastore.types_long_doc, visible=False)
133
  return selected_domains, selected_langs, selected_rerankings, leaderboard_table, hidden_leaderboard_table
 
170
  with gr.Column():
171
  selected_rerankings = get_reranking_dropdown(datastore.reranking_models)
172
  # shown_table
173
+ lb_table = get_leaderboard_table(datastore.formatted_df_qa, datastore.types_qa)
174
  # Dummy leaderboard for handling the case when the user uses backspace key
175
  hidden_lb_table = get_leaderboard_table(datastore.raw_df_qa, datastore.types_qa, visible=False)
176
 
 
218
  with gr.Column(scale=1):
219
  selected_noreranker = get_noreranking_dropdown()
220
 
221
+ lb_df_retriever = datastore.formatted_df_qa[
222
+ datastore.formatted_df_qa[COL_NAME_RERANKING_MODEL] == "NoReranker"
223
+ ]
224
  lb_df_retriever = reset_rank(lb_df_retriever)
225
  lb_table_retriever = get_leaderboard_table(lb_df_retriever, datastore.types_qa)
226
 
 
276
  queue=True,
277
  )
278
  with gr.TabItem("Reranking Only", id=12):
279
+ lb_df_reranker = datastore.formatted_df_qa[
280
+ datastore.formatted_df_qa[COL_NAME_RETRIEVAL_MODEL] == BM25_LINK
281
+ ]
282
  lb_df_reranker = reset_rank(lb_df_reranker)
283
  reranking_models_reranker = (
284
  lb_df_reranker[COL_NAME_RERANKING_MODEL].apply(remove_html).unique().tolist()
 
365
  selected_rerankings = get_reranking_dropdown(datastore.reranking_models)
366
 
367
  lb_table_long_doc = get_leaderboard_table(
368
+ datastore.formatted_df_ldoc, datastore.types_long_doc
369
  )
370
 
371
  # Dummy leaderboard for handling the case when the user uses backspace key
 
421
  search_bar_retriever = get_search_bar()
422
  with gr.Column(scale=1):
423
  selected_noreranker = get_noreranking_dropdown()
424
+ lb_df_retriever_long_doc = datastore.formatted_df_ldoc[
425
+ datastore.formatted_df_ldoc[COL_NAME_RERANKING_MODEL] == "NoReranker"
426
+ ]
427
  lb_df_retriever_long_doc = reset_rank(lb_df_retriever_long_doc)
428
  lb_table_retriever_long_doc = get_leaderboard_table(
429
  lb_df_retriever_long_doc, datastore.types_long_doc
 
479
  queue=True,
480
  )
481
  with gr.TabItem("Reranking Only", id=22):
482
+ lb_df_reranker_ldoc = datastore.formatted_df_ldoc[
483
+ datastore.formatted_df_ldoc[COL_NAME_RETRIEVAL_MODEL] == BM25_LINK
484
+ ]
485
  lb_df_reranker_ldoc = reset_rank(lb_df_reranker_ldoc)
486
  reranking_models_reranker_ldoc = (
487
  lb_df_reranker_ldoc[COL_NAME_RERANKING_MODEL].apply(remove_html).unique().tolist()
src/loaders.py CHANGED
@@ -70,23 +70,23 @@ def load_leaderboard_datastore(file_path, version) -> LeaderboardDataStore:
70
 
71
  lb_data_store.raw_df_qa = get_leaderboard_df(lb_data_store, task="qa", metric=DEFAULT_METRIC_QA)
72
  print(f"QA data loaded: {lb_data_store.raw_df_qa.shape}")
73
- lb_data_store.leaderboard_df_qa = lb_data_store.raw_df_qa.copy()
74
  shown_columns_qa, types_qa = get_default_cols("qa", lb_data_store.slug, add_fix_cols=True)
75
  lb_data_store.types_qa = types_qa
76
- lb_data_store.leaderboard_df_qa = lb_data_store.leaderboard_df_qa[
77
- ~lb_data_store.leaderboard_df_qa[COL_NAME_IS_ANONYMOUS]
78
  ][shown_columns_qa]
79
- lb_data_store.leaderboard_df_qa.drop([COL_NAME_REVISION, COL_NAME_TIMESTAMP], axis=1, inplace=True)
80
 
81
  lb_data_store.raw_df_long_doc = get_leaderboard_df(lb_data_store, task="long-doc", metric=DEFAULT_METRIC_LONG_DOC)
82
  print(f"Long-Doc data loaded: {len(lb_data_store.raw_df_long_doc)}")
83
- lb_data_store.leaderboard_df_long_doc = lb_data_store.raw_df_long_doc.copy()
84
  shown_columns_long_doc, types_long_doc = get_default_cols("long-doc", lb_data_store.slug, add_fix_cols=True)
85
  lb_data_store.types_long_doc = types_long_doc
86
- lb_data_store.leaderboard_df_long_doc = lb_data_store.leaderboard_df_long_doc[
87
- ~lb_data_store.leaderboard_df_long_doc[COL_NAME_IS_ANONYMOUS]
88
  ][shown_columns_long_doc]
89
- lb_data_store.leaderboard_df_long_doc.drop([COL_NAME_REVISION, COL_NAME_TIMESTAMP], axis=1, inplace=True)
90
 
91
  lb_data_store.reranking_models = sorted(
92
  list(frozenset([eval_result.reranking_model for eval_result in lb_data_store.raw_data]))
 
70
 
71
  lb_data_store.raw_df_qa = get_leaderboard_df(lb_data_store, task="qa", metric=DEFAULT_METRIC_QA)
72
  print(f"QA data loaded: {lb_data_store.raw_df_qa.shape}")
73
+ lb_data_store.formatted_df_qa = lb_data_store.raw_df_qa.copy()
74
  shown_columns_qa, types_qa = get_default_cols("qa", lb_data_store.slug, add_fix_cols=True)
75
  lb_data_store.types_qa = types_qa
76
+ lb_data_store.formatted_df_qa = lb_data_store.formatted_df_qa[
77
+ ~lb_data_store.formatted_df_qa[COL_NAME_IS_ANONYMOUS]
78
  ][shown_columns_qa]
79
+ lb_data_store.formatted_df_qa.drop([COL_NAME_REVISION, COL_NAME_TIMESTAMP], axis=1, inplace=True)
80
 
81
  lb_data_store.raw_df_long_doc = get_leaderboard_df(lb_data_store, task="long-doc", metric=DEFAULT_METRIC_LONG_DOC)
82
  print(f"Long-Doc data loaded: {len(lb_data_store.raw_df_long_doc)}")
83
+ lb_data_store.formatted_df_ldoc = lb_data_store.raw_df_long_doc.copy()
84
  shown_columns_long_doc, types_long_doc = get_default_cols("long-doc", lb_data_store.slug, add_fix_cols=True)
85
  lb_data_store.types_long_doc = types_long_doc
86
+ lb_data_store.formatted_df_ldoc = lb_data_store.formatted_df_ldoc[
87
+ ~lb_data_store.formatted_df_ldoc[COL_NAME_IS_ANONYMOUS]
88
  ][shown_columns_long_doc]
89
+ lb_data_store.formatted_df_ldoc.drop([COL_NAME_REVISION, COL_NAME_TIMESTAMP], axis=1, inplace=True)
90
 
91
  lb_data_store.reranking_models = sorted(
92
  list(frozenset([eval_result.reranking_model for eval_result in lb_data_store.raw_data]))
src/models.py CHANGED
@@ -143,8 +143,8 @@ class LeaderboardDataStore:
143
  raw_data: Optional[list]
144
  raw_df_qa: Optional[pd.DataFrame]
145
  raw_df_long_doc: Optional[pd.DataFrame]
146
- leaderboard_df_qa: Optional[pd.DataFrame]
147
- leaderboard_df_long_doc: Optional[pd.DataFrame]
148
  reranking_models: Optional[list]
149
  types_qa: Optional[list]
150
  types_long_doc: Optional[list]
 
143
  raw_data: Optional[list]
144
  raw_df_qa: Optional[pd.DataFrame]
145
  raw_df_long_doc: Optional[pd.DataFrame]
146
+ formatted_df_qa: Optional[pd.DataFrame]
147
+ formatted_df_ldoc: Optional[pd.DataFrame]
148
  reranking_models: Optional[list]
149
  types_qa: Optional[list]
150
  types_long_doc: Optional[list]