MohamedRashad commited on
Commit
492c93e
·
1 Parent(s): 995d9de

Refactor submit_gradio_module to improve layout and enhance model submission functionality

Browse files
Files changed (2) hide show
  1. app.py +7 -3
  2. utils.py +76 -79
app.py CHANGED
@@ -72,7 +72,7 @@ def search_leaderboard(model_name, columns_to_show):
72
  def main():
73
  global df, original_columns_order
74
  df = load_retrieval_results()
75
- df[["Model"]] = df[["Model"]].applymap(lambda x: f'<a href="https://huggingface.co/{x}" target="_blank">{x}</a>')
76
  df.drop(columns=["Revision", "Precision", "Task"], inplace=True)
77
  df.sort_values("Web Search Dataset (Overall Score)", ascending=False, inplace=True)
78
 
@@ -117,7 +117,8 @@ def main():
117
  outputs=retrieval_leaderboard
118
  )
119
 
120
- submit_gradio_module("Retriever")
 
121
 
122
  with gr.Tab("Reranking"):
123
  with gr.Tabs():
@@ -141,7 +142,10 @@ def main():
141
  inputs=search_box_reranker,
142
  outputs=reranker_leaderboard
143
  )
144
- submit_gradio_module("Reranker")
 
 
 
145
 
146
  # with gr.Tab("LLM Context Answering"):
147
  # with gr.Tabs():
 
72
  def main():
73
  global df, original_columns_order
74
  df = load_retrieval_results()
75
+ df[["Model"]] = df[["Model"]].map(lambda x: f'<a href="https://huggingface.co/{x}" target="_blank">{x}</a>')
76
  df.drop(columns=["Revision", "Precision", "Task"], inplace=True)
77
  df.sort_values("Web Search Dataset (Overall Score)", ascending=False, inplace=True)
78
 
 
117
  outputs=retrieval_leaderboard
118
  )
119
 
120
+ with gr.Tab("Submit Retriever"):
121
+ submit_gradio_module("Retriever")
122
 
123
  with gr.Tab("Reranking"):
124
  with gr.Tabs():
 
142
  inputs=search_box_reranker,
143
  outputs=reranker_leaderboard
144
  )
145
+
146
+ with gr.Tab("Submit Reranker"):
147
+ submit_gradio_module("Reranker")
148
+
149
 
150
  # with gr.Tab("LLM Context Answering"):
151
  # with gr.Tabs():
utils.py CHANGED
@@ -185,87 +185,84 @@ def load_requests(status_folder):
185
 
186
  def submit_gradio_module(task_type):
187
  var = gr.State(value=task_type)
188
- with gr.Tab(f"Submit {task_type}") as submitter_tab:
189
- with gr.Row(equal_height=True):
190
- model_name_input = gr.Textbox(
191
- label="Model",
192
- placeholder="Enter the full model name from HuggingFace Hub (e.g., intfloat/multilingual-e5-large-instruct)",
193
- scale=4,
194
- )
195
- fetch_data_button = gr.Button(value="Auto Fetch Model Info", variant="secondary")
196
-
197
- with gr.Row():
198
- precision_input = gr.Dropdown(
199
- choices=["F16", "F32", "BF16", "I8", "U8", "I16"],
200
- label="Precision",
201
- value="F16"
202
- )
203
- license_input = gr.Textbox(
204
- label="License",
205
- placeholder="Enter the license type (Generic one is 'Open' in case no License is provided)",
206
- value="Open"
207
- )
208
- revision_input = gr.Textbox(
209
- label="Revision",
210
- placeholder="main",
211
- value="main"
212
- )
213
-
214
- with gr.Row():
215
- params_input = gr.Textbox(
216
- label="Params (in Millions)",
217
- interactive=False,
218
- )
219
- num_downloads_input = gr.Textbox(
220
- label="Number of Downloads",
221
- interactive=False,
222
- )
223
- num_likes_input = gr.Textbox(
224
- label="Number of Likes",
225
- interactive=False,
226
- )
227
-
228
- submit_button = gr.Button("Submit Model", variant="primary")
229
- submission_result = gr.Markdown()
230
- fetch_outputs = [precision_input, license_input, params_input, num_downloads_input, num_likes_input]
231
-
232
- fetch_data_button.click(
233
- fetch_model_information,
234
- inputs=[model_name_input],
235
- outputs=fetch_outputs
236
  )
237
- model_name_input.submit(
238
- fetch_model_information,
239
- inputs=[model_name_input],
240
- outputs=fetch_outputs
241
  )
242
- submit_button.click(
243
- submit_model,
244
- inputs=[model_name_input, revision_input, precision_input, params_input, license_input, var],
245
- outputs=submission_result
246
  )
247
-
248
- # Load pending, finished, and failed requests
249
- df_pending = load_requests('pending')
250
- df_finished = load_requests('finished')
251
- df_failed = load_requests('failed')
252
 
253
- # Display the tables
254
- gr.Markdown("## Evaluation Status")
255
- with gr.Accordion(f"Pending Evaluations ({len(df_pending)})", open=False):
256
- if not df_pending.empty:
257
- gr.Dataframe(df_pending)
258
- else:
259
- gr.Markdown("No pending evaluations.")
260
- with gr.Accordion(f"Finished Evaluations ({len(df_finished)})", open=False):
261
- if not df_finished.empty:
262
- gr.Dataframe(df_finished)
263
- else:
264
- gr.Markdown("No finished evaluations.")
265
- with gr.Accordion(f"Failed Evaluations ({len(df_failed)})", open=False):
266
- if not df_failed.empty:
267
- gr.Dataframe(df_failed)
268
- else:
269
- gr.Markdown("No failed evaluations.")
 
 
 
270
 
271
- return submitter_tab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
 
186
  def submit_gradio_module(task_type):
187
  var = gr.State(value=task_type)
188
+ with gr.Row(equal_height=True):
189
+ model_name_input = gr.Textbox(
190
+ label="Model",
191
+ placeholder="Enter the full model name from HuggingFace Hub (e.g., intfloat/multilingual-e5-large-instruct)",
192
+ scale=4,
193
+ )
194
+ fetch_data_button = gr.Button(value="Auto Fetch Model Info", variant="secondary")
195
+
196
+ with gr.Row():
197
+ precision_input = gr.Dropdown(
198
+ choices=["F16", "F32", "BF16", "I8", "U8", "I16"],
199
+ label="Precision",
200
+ value="F16"
201
+ )
202
+ license_input = gr.Textbox(
203
+ label="License",
204
+ placeholder="Enter the license type (Generic one is 'Open' in case no License is provided)",
205
+ value="Open"
206
+ )
207
+ revision_input = gr.Textbox(
208
+ label="Revision",
209
+ placeholder="main",
210
+ value="main"
211
+ )
212
+
213
+ with gr.Row():
214
+ params_input = gr.Textbox(
215
+ label="Params (in Millions)",
216
+ interactive=False,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  )
218
+ num_downloads_input = gr.Textbox(
219
+ label="Number of Downloads",
220
+ interactive=False,
 
221
  )
222
+ num_likes_input = gr.Textbox(
223
+ label="Number of Likes",
224
+ interactive=False,
 
225
  )
226
+
227
+ submit_button = gr.Button("Submit Model", variant="primary")
228
+ submission_result = gr.Markdown()
229
+ fetch_outputs = [precision_input, license_input, params_input, num_downloads_input, num_likes_input]
 
230
 
231
+ fetch_data_button.click(
232
+ fetch_model_information,
233
+ inputs=[model_name_input],
234
+ outputs=fetch_outputs
235
+ )
236
+ model_name_input.submit(
237
+ fetch_model_information,
238
+ inputs=[model_name_input],
239
+ outputs=fetch_outputs
240
+ )
241
+ submit_button.click(
242
+ submit_model,
243
+ inputs=[model_name_input, revision_input, precision_input, params_input, license_input, var],
244
+ outputs=submission_result
245
+ )
246
+
247
+ # Load pending, finished, and failed requests
248
+ df_pending = load_requests('pending')
249
+ df_finished = load_requests('finished')
250
+ df_failed = load_requests('failed')
251
 
252
+ # Display the tables
253
+ gr.Markdown("## Evaluation Status")
254
+ with gr.Accordion(f"Pending Evaluations ({len(df_pending)})", open=False):
255
+ if not df_pending.empty:
256
+ gr.Dataframe(df_pending)
257
+ else:
258
+ gr.Markdown("No pending evaluations.")
259
+ with gr.Accordion(f"Finished Evaluations ({len(df_finished)})", open=False):
260
+ if not df_finished.empty:
261
+ gr.Dataframe(df_finished)
262
+ else:
263
+ gr.Markdown("No finished evaluations.")
264
+ with gr.Accordion(f"Failed Evaluations ({len(df_failed)})", open=False):
265
+ if not df_failed.empty:
266
+ gr.Dataframe(df_failed)
267
+ else:
268
+ gr.Markdown("No failed evaluations.")