Spaces:
Runtime error
Runtime error
Archive project
Browse files
app.py
CHANGED
@@ -131,6 +131,9 @@ SUPPORTED_METRICS = [
|
|
131 |
# APP #
|
132 |
#######
|
133 |
st.title("Evaluation on the Hub")
|
|
|
|
|
|
|
134 |
st.markdown(
|
135 |
"""
|
136 |
Welcome to Hugging Face's automatic model evaluator π!
|
@@ -146,548 +149,548 @@ st.markdown(
|
|
146 |
"""
|
147 |
)
|
148 |
|
149 |
-
all_datasets = [d.id for d in list_datasets()]
|
150 |
-
query_params = st.experimental_get_query_params()
|
151 |
-
if "first_query_params" not in st.session_state:
|
152 |
-
|
153 |
-
first_query_params = st.session_state.first_query_params
|
154 |
-
default_dataset = all_datasets[0]
|
155 |
-
if "dataset" in first_query_params:
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
selected_dataset = st.selectbox(
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
)
|
166 |
-
st.experimental_set_query_params(**{"dataset": [selected_dataset]})
|
167 |
-
|
168 |
-
# Check if selected dataset can be streamed
|
169 |
-
is_valid_dataset = http_get(
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
).json()
|
174 |
-
if is_valid_dataset["viewer"] is False and is_valid_dataset["preview"] is False:
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
metadata = get_metadata(selected_dataset, token=HF_TOKEN)
|
181 |
-
print(f"INFO -- Dataset metadata: {metadata}")
|
182 |
-
if metadata is None:
|
183 |
-
|
184 |
-
|
185 |
-
with st.expander("Advanced configuration"):
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
with st.form(key="form"):
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
|
|
131 |
# APP #
|
132 |
#######
|
133 |
st.title("Evaluation on the Hub")
|
134 |
+
st.warning(
|
135 |
+
"**β οΈ This project has been archived. If you want to evaluate LLMs, checkout [this collection](https://huggingface.co/collections/clefourrier/llm-leaderboards-and-benchmarks-β¨-64f99d2e11e92ca5568a7cce) of leaderboards.**"
|
136 |
+
)
|
137 |
st.markdown(
|
138 |
"""
|
139 |
Welcome to Hugging Face's automatic model evaluator π!
|
|
|
149 |
"""
|
150 |
)
|
151 |
|
152 |
+
# all_datasets = [d.id for d in list_datasets()]
|
153 |
+
# query_params = st.experimental_get_query_params()
|
154 |
+
# if "first_query_params" not in st.session_state:
|
155 |
+
# st.session_state.first_query_params = query_params
|
156 |
+
# first_query_params = st.session_state.first_query_params
|
157 |
+
# default_dataset = all_datasets[0]
|
158 |
+
# if "dataset" in first_query_params:
|
159 |
+
# if len(first_query_params["dataset"]) > 0 and first_query_params["dataset"][0] in all_datasets:
|
160 |
+
# default_dataset = first_query_params["dataset"][0]
|
161 |
+
|
162 |
+
# selected_dataset = st.selectbox(
|
163 |
+
# "Select a dataset",
|
164 |
+
# all_datasets,
|
165 |
+
# index=all_datasets.index(default_dataset),
|
166 |
+
# help="""Datasets with metadata can be evaluated with 1-click. Configure an evaluation job to add \
|
167 |
+
# new metadata to a dataset card.""",
|
168 |
+
# )
|
169 |
+
# st.experimental_set_query_params(**{"dataset": [selected_dataset]})
|
170 |
+
|
171 |
+
# # Check if selected dataset can be streamed
|
172 |
+
# is_valid_dataset = http_get(
|
173 |
+
# path="/is-valid",
|
174 |
+
# domain=DATASETS_PREVIEW_API,
|
175 |
+
# params={"dataset": selected_dataset},
|
176 |
+
# ).json()
|
177 |
+
# if is_valid_dataset["viewer"] is False and is_valid_dataset["preview"] is False:
|
178 |
+
# st.error(
|
179 |
+
# """The dataset you selected is not currently supported. Open a \
|
180 |
+
# [discussion](https://huggingface.co/spaces/autoevaluate/model-evaluator/discussions) for support."""
|
181 |
+
# )
|
182 |
+
|
183 |
+
# metadata = get_metadata(selected_dataset, token=HF_TOKEN)
|
184 |
+
# print(f"INFO -- Dataset metadata: {metadata}")
|
185 |
+
# if metadata is None:
|
186 |
+
# st.warning("No evaluation metadata found. Please configure the evaluation job below.")
|
187 |
+
|
188 |
+
# with st.expander("Advanced configuration"):
|
189 |
+
# # Select task
|
190 |
+
# selected_task = st.selectbox(
|
191 |
+
# "Select a task",
|
192 |
+
# SUPPORTED_TASKS,
|
193 |
+
# index=SUPPORTED_TASKS.index(metadata[0]["task_id"]) if metadata is not None else 0,
|
194 |
+
# help="""Don't see your favourite task here? Open a \
|
195 |
+
# [discussion](https://huggingface.co/spaces/autoevaluate/model-evaluator/discussions) to request it!""",
|
196 |
+
# )
|
197 |
+
# # Select config
|
198 |
+
# configs = get_dataset_config_names(selected_dataset)
|
199 |
+
# selected_config = st.selectbox(
|
200 |
+
# "Select a config",
|
201 |
+
# configs,
|
202 |
+
# help="""Some datasets contain several sub-datasets, known as _configurations_. \
|
203 |
+
# Select one to evaluate your models on. \
|
204 |
+
# See the [docs](https://huggingface.co/docs/datasets/master/en/load_hub#configurations) for more details.
|
205 |
+
# """,
|
206 |
+
# )
|
207 |
+
# # Some datasets have multiple metadata (one per config), so we grab the one associated with the selected config
|
208 |
+
# config_metadata = get_config_metadata(selected_config, metadata)
|
209 |
+
# print(f"INFO -- Config metadata: {config_metadata}")
|
210 |
+
|
211 |
+
# # Select splits
|
212 |
+
# splits_resp = http_get(
|
213 |
+
# path="/splits",
|
214 |
+
# domain=DATASETS_PREVIEW_API,
|
215 |
+
# params={"dataset": selected_dataset},
|
216 |
+
# )
|
217 |
+
# if splits_resp.status_code == 200:
|
218 |
+
# split_names = []
|
219 |
+
# all_splits = splits_resp.json()
|
220 |
+
# for split in all_splits["splits"]:
|
221 |
+
# if split["config"] == selected_config:
|
222 |
+
# split_names.append(split["split"])
|
223 |
+
|
224 |
+
# if config_metadata is not None:
|
225 |
+
# eval_split = config_metadata["splits"].get("eval_split", None)
|
226 |
+
# else:
|
227 |
+
# eval_split = None
|
228 |
+
# selected_split = st.selectbox(
|
229 |
+
# "Select a split",
|
230 |
+
# split_names,
|
231 |
+
# index=split_names.index(eval_split) if eval_split is not None else 0,
|
232 |
+
# help="Be wary when evaluating models on the `train` split.",
|
233 |
+
# )
|
234 |
+
|
235 |
+
# # Select columns
|
236 |
+
# rows_resp = http_get(
|
237 |
+
# path="/first-rows",
|
238 |
+
# domain=DATASETS_PREVIEW_API,
|
239 |
+
# params={
|
240 |
+
# "dataset": selected_dataset,
|
241 |
+
# "config": selected_config,
|
242 |
+
# "split": selected_split,
|
243 |
+
# },
|
244 |
+
# ).json()
|
245 |
+
# col_names = list(pd.json_normalize(rows_resp["rows"][0]["row"]).columns)
|
246 |
+
|
247 |
+
# st.markdown("**Map your dataset columns**")
|
248 |
+
# st.markdown(
|
249 |
+
# """The model evaluator uses a standardised set of column names for the input examples and labels. \
|
250 |
+
# Please define the mapping between your dataset columns (right) and the standardised column names (left)."""
|
251 |
+
# )
|
252 |
+
# col1, col2 = st.columns(2)
|
253 |
+
|
254 |
+
# # TODO: find a better way to layout these items
|
255 |
+
# # TODO: need graceful way of handling dataset <--> task mismatch for datasets with metadata
|
256 |
+
# col_mapping = {}
|
257 |
+
# if selected_task in ["binary_classification", "multi_class_classification"]:
|
258 |
+
# with col1:
|
259 |
+
# st.markdown("`text` column")
|
260 |
+
# st.text("")
|
261 |
+
# st.text("")
|
262 |
+
# st.text("")
|
263 |
+
# st.text("")
|
264 |
+
# st.markdown("`target` column")
|
265 |
+
# with col2:
|
266 |
+
# text_col = st.selectbox(
|
267 |
+
# "This column should contain the text to be classified",
|
268 |
+
# col_names,
|
269 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "text"))
|
270 |
+
# if config_metadata is not None
|
271 |
+
# else 0,
|
272 |
+
# )
|
273 |
+
# target_col = st.selectbox(
|
274 |
+
# "This column should contain the labels associated with the text",
|
275 |
+
# col_names,
|
276 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "target"))
|
277 |
+
# if config_metadata is not None
|
278 |
+
# else 0,
|
279 |
+
# )
|
280 |
+
# col_mapping[text_col] = "text"
|
281 |
+
# col_mapping[target_col] = "target"
|
282 |
+
|
283 |
+
# elif selected_task == "text_zero_shot_classification":
|
284 |
+
# with col1:
|
285 |
+
# st.markdown("`text` column")
|
286 |
+
# st.text("")
|
287 |
+
# st.text("")
|
288 |
+
# st.text("")
|
289 |
+
# st.text("")
|
290 |
+
# st.markdown("`classes` column")
|
291 |
+
# st.text("")
|
292 |
+
# st.text("")
|
293 |
+
# st.text("")
|
294 |
+
# st.text("")
|
295 |
+
# st.markdown("`target` column")
|
296 |
+
# with col2:
|
297 |
+
# text_col = st.selectbox(
|
298 |
+
# "This column should contain the text to be classified",
|
299 |
+
# col_names,
|
300 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "text"))
|
301 |
+
# if config_metadata is not None
|
302 |
+
# else 0,
|
303 |
+
# )
|
304 |
+
# classes_col = st.selectbox(
|
305 |
+
# "This column should contain the classes associated with the text",
|
306 |
+
# col_names,
|
307 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "classes"))
|
308 |
+
# if config_metadata is not None
|
309 |
+
# else 0,
|
310 |
+
# )
|
311 |
+
# target_col = st.selectbox(
|
312 |
+
# "This column should contain the index of the correct class",
|
313 |
+
# col_names,
|
314 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "target"))
|
315 |
+
# if config_metadata is not None
|
316 |
+
# else 0,
|
317 |
+
# )
|
318 |
+
# col_mapping[text_col] = "text"
|
319 |
+
# col_mapping[classes_col] = "classes"
|
320 |
+
# col_mapping[target_col] = "target"
|
321 |
+
|
322 |
+
# if selected_task in ["natural_language_inference"]:
|
323 |
+
# config_metadata = get_config_metadata(selected_config, metadata)
|
324 |
+
# with col1:
|
325 |
+
# st.markdown("`text1` column")
|
326 |
+
# st.text("")
|
327 |
+
# st.text("")
|
328 |
+
# st.text("")
|
329 |
+
# st.text("")
|
330 |
+
# st.text("")
|
331 |
+
# st.markdown("`text2` column")
|
332 |
+
# st.text("")
|
333 |
+
# st.text("")
|
334 |
+
# st.text("")
|
335 |
+
# st.text("")
|
336 |
+
# st.text("")
|
337 |
+
# st.markdown("`target` column")
|
338 |
+
# with col2:
|
339 |
+
# text1_col = st.selectbox(
|
340 |
+
# "This column should contain the first text passage to be classified",
|
341 |
+
# col_names,
|
342 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "text1"))
|
343 |
+
# if config_metadata is not None
|
344 |
+
# else 0,
|
345 |
+
# )
|
346 |
+
# text2_col = st.selectbox(
|
347 |
+
# "This column should contain the second text passage to be classified",
|
348 |
+
# col_names,
|
349 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "text2"))
|
350 |
+
# if config_metadata is not None
|
351 |
+
# else 0,
|
352 |
+
# )
|
353 |
+
# target_col = st.selectbox(
|
354 |
+
# "This column should contain the labels associated with the text",
|
355 |
+
# col_names,
|
356 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "target"))
|
357 |
+
# if config_metadata is not None
|
358 |
+
# else 0,
|
359 |
+
# )
|
360 |
+
# col_mapping[text1_col] = "text1"
|
361 |
+
# col_mapping[text2_col] = "text2"
|
362 |
+
# col_mapping[target_col] = "target"
|
363 |
+
|
364 |
+
# elif selected_task == "entity_extraction":
|
365 |
+
# with col1:
|
366 |
+
# st.markdown("`tokens` column")
|
367 |
+
# st.text("")
|
368 |
+
# st.text("")
|
369 |
+
# st.text("")
|
370 |
+
# st.text("")
|
371 |
+
# st.markdown("`tags` column")
|
372 |
+
# with col2:
|
373 |
+
# tokens_col = st.selectbox(
|
374 |
+
# "This column should contain the array of tokens to be classified",
|
375 |
+
# col_names,
|
376 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "tokens"))
|
377 |
+
# if config_metadata is not None
|
378 |
+
# else 0,
|
379 |
+
# )
|
380 |
+
# tags_col = st.selectbox(
|
381 |
+
# "This column should contain the labels associated with each part of the text",
|
382 |
+
# col_names,
|
383 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "tags"))
|
384 |
+
# if config_metadata is not None
|
385 |
+
# else 0,
|
386 |
+
# )
|
387 |
+
# col_mapping[tokens_col] = "tokens"
|
388 |
+
# col_mapping[tags_col] = "tags"
|
389 |
+
|
390 |
+
# elif selected_task == "translation":
|
391 |
+
# with col1:
|
392 |
+
# st.markdown("`source` column")
|
393 |
+
# st.text("")
|
394 |
+
# st.text("")
|
395 |
+
# st.text("")
|
396 |
+
# st.text("")
|
397 |
+
# st.markdown("`target` column")
|
398 |
+
# with col2:
|
399 |
+
# text_col = st.selectbox(
|
400 |
+
# "This column should contain the text to be translated",
|
401 |
+
# col_names,
|
402 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "source"))
|
403 |
+
# if config_metadata is not None
|
404 |
+
# else 0,
|
405 |
+
# )
|
406 |
+
# target_col = st.selectbox(
|
407 |
+
# "This column should contain the target translation",
|
408 |
+
# col_names,
|
409 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "target"))
|
410 |
+
# if config_metadata is not None
|
411 |
+
# else 0,
|
412 |
+
# )
|
413 |
+
# col_mapping[text_col] = "source"
|
414 |
+
# col_mapping[target_col] = "target"
|
415 |
+
|
416 |
+
# elif selected_task == "summarization":
|
417 |
+
# with col1:
|
418 |
+
# st.markdown("`text` column")
|
419 |
+
# st.text("")
|
420 |
+
# st.text("")
|
421 |
+
# st.text("")
|
422 |
+
# st.text("")
|
423 |
+
# st.markdown("`target` column")
|
424 |
+
# with col2:
|
425 |
+
# text_col = st.selectbox(
|
426 |
+
# "This column should contain the text to be summarized",
|
427 |
+
# col_names,
|
428 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "text"))
|
429 |
+
# if config_metadata is not None
|
430 |
+
# else 0,
|
431 |
+
# )
|
432 |
+
# target_col = st.selectbox(
|
433 |
+
# "This column should contain the target summary",
|
434 |
+
# col_names,
|
435 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "target"))
|
436 |
+
# if config_metadata is not None
|
437 |
+
# else 0,
|
438 |
+
# )
|
439 |
+
# col_mapping[text_col] = "text"
|
440 |
+
# col_mapping[target_col] = "target"
|
441 |
+
|
442 |
+
# elif selected_task == "extractive_question_answering":
|
443 |
+
# if config_metadata is not None:
|
444 |
+
# col_mapping = config_metadata["col_mapping"]
|
445 |
+
# # Hub YAML parser converts periods to hyphens, so we remap them here
|
446 |
+
# col_mapping = format_col_mapping(col_mapping)
|
447 |
+
# with col1:
|
448 |
+
# st.markdown("`context` column")
|
449 |
+
# st.text("")
|
450 |
+
# st.text("")
|
451 |
+
# st.text("")
|
452 |
+
# st.text("")
|
453 |
+
# st.markdown("`question` column")
|
454 |
+
# st.text("")
|
455 |
+
# st.text("")
|
456 |
+
# st.text("")
|
457 |
+
# st.text("")
|
458 |
+
# st.markdown("`answers.text` column")
|
459 |
+
# st.text("")
|
460 |
+
# st.text("")
|
461 |
+
# st.text("")
|
462 |
+
# st.text("")
|
463 |
+
# st.markdown("`answers.answer_start` column")
|
464 |
+
# with col2:
|
465 |
+
# context_col = st.selectbox(
|
466 |
+
# "This column should contain the question's context",
|
467 |
+
# col_names,
|
468 |
+
# index=col_names.index(get_key(col_mapping, "context")) if config_metadata is not None else 0,
|
469 |
+
# )
|
470 |
+
# question_col = st.selectbox(
|
471 |
+
# "This column should contain the question to be answered, given the context",
|
472 |
+
# col_names,
|
473 |
+
# index=col_names.index(get_key(col_mapping, "question")) if config_metadata is not None else 0,
|
474 |
+
# )
|
475 |
+
# answers_text_col = st.selectbox(
|
476 |
+
# "This column should contain example answers to the question, extracted from the context",
|
477 |
+
# col_names,
|
478 |
+
# index=col_names.index(get_key(col_mapping, "answers.text")) if config_metadata is not None else 0,
|
479 |
+
# )
|
480 |
+
# answers_start_col = st.selectbox(
|
481 |
+
# "This column should contain the indices in the context of the first character of each `answers.text`",
|
482 |
+
# col_names,
|
483 |
+
# index=col_names.index(get_key(col_mapping, "answers.answer_start"))
|
484 |
+
# if config_metadata is not None
|
485 |
+
# else 0,
|
486 |
+
# )
|
487 |
+
# col_mapping[context_col] = "context"
|
488 |
+
# col_mapping[question_col] = "question"
|
489 |
+
# col_mapping[answers_text_col] = "answers.text"
|
490 |
+
# col_mapping[answers_start_col] = "answers.answer_start"
|
491 |
+
# elif selected_task in ["image_binary_classification", "image_multi_class_classification"]:
|
492 |
+
# with col1:
|
493 |
+
# st.markdown("`image` column")
|
494 |
+
# st.text("")
|
495 |
+
# st.text("")
|
496 |
+
# st.text("")
|
497 |
+
# st.text("")
|
498 |
+
# st.markdown("`target` column")
|
499 |
+
# with col2:
|
500 |
+
# image_col = st.selectbox(
|
501 |
+
# "This column should contain the images to be classified",
|
502 |
+
# col_names,
|
503 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "image"))
|
504 |
+
# if config_metadata is not None
|
505 |
+
# else 0,
|
506 |
+
# )
|
507 |
+
# target_col = st.selectbox(
|
508 |
+
# "This column should contain the labels associated with the images",
|
509 |
+
# col_names,
|
510 |
+
# index=col_names.index(get_key(config_metadata["col_mapping"], "target"))
|
511 |
+
# if config_metadata is not None
|
512 |
+
# else 0,
|
513 |
+
# )
|
514 |
+
# col_mapping[image_col] = "image"
|
515 |
+
# col_mapping[target_col] = "target"
|
516 |
+
|
517 |
+
# # Select metrics
|
518 |
+
# st.markdown("**Select metrics**")
|
519 |
+
# st.markdown("The following metrics will be computed")
|
520 |
+
# html_string = " ".join(
|
521 |
+
# [
|
522 |
+
# '<div style="padding-right:5px;padding-left:5px;padding-top:5px;padding-bottom:5px;float:left">'
|
523 |
+
# + '<div style="background-color:#D3D3D3;border-radius:5px;display:inline-block;padding-right:5px;'
|
524 |
+
# + 'padding-left:5px;color:white">'
|
525 |
+
# + metric
|
526 |
+
# + "</div></div>"
|
527 |
+
# for metric in TASK_TO_DEFAULT_METRICS[selected_task]
|
528 |
+
# ]
|
529 |
+
# )
|
530 |
+
# st.markdown(html_string, unsafe_allow_html=True)
|
531 |
+
# selected_metrics = st.multiselect(
|
532 |
+
# "(Optional) Select additional metrics",
|
533 |
+
# sorted(list(set(SUPPORTED_METRICS) - set(TASK_TO_DEFAULT_METRICS[selected_task]))),
|
534 |
+
# help="""User-selected metrics will be computed with their default arguments. \
|
535 |
+
# For example, `f1` will report results for binary labels. \
|
536 |
+
# Check out the [available metrics](https://huggingface.co/metrics) for more details.""",
|
537 |
+
# )
|
538 |
+
|
539 |
+
# with st.form(key="form"):
|
540 |
+
# compatible_models = get_compatible_models(selected_task, [selected_dataset])
|
541 |
+
# selected_models = st.multiselect(
|
542 |
+
# "Select the models you wish to evaluate",
|
543 |
+
# compatible_models,
|
544 |
+
# help="""Don't see your favourite model in this list? Add the dataset and task it was trained on to the \
|
545 |
+
# [model card metadata.](https://huggingface.co/docs/hub/models-cards#model-card-metadata)""",
|
546 |
+
# )
|
547 |
+
# print("INFO -- Selected models before filter:", selected_models)
|
548 |
+
|
549 |
+
# hf_username = st.text_input("Enter your π€ Hub username to be notified when the evaluation is finished")
|
550 |
+
|
551 |
+
# submit_button = st.form_submit_button("Evaluate models π")
|
552 |
+
|
553 |
+
# if submit_button:
|
554 |
+
# if len(hf_username) == 0:
|
555 |
+
# st.warning("No π€ Hub username provided! Please enter your username and try again.")
|
556 |
+
# elif len(selected_models) == 0:
|
557 |
+
# st.warning("β οΈ No models were selected for evaluation! Please select at least one model and try again.")
|
558 |
+
# elif len(selected_models) > 10:
|
559 |
+
# st.warning("Only 10 models can be evaluated at once. Please select fewer models and try again.")
|
560 |
+
# else:
|
561 |
+
# # Filter out previously evaluated models
|
562 |
+
# selected_models = filter_evaluated_models(
|
563 |
+
# selected_models,
|
564 |
+
# selected_task,
|
565 |
+
# selected_dataset,
|
566 |
+
# selected_config,
|
567 |
+
# selected_split,
|
568 |
+
# selected_metrics,
|
569 |
+
# )
|
570 |
+
# print("INFO -- Selected models after filter:", selected_models)
|
571 |
+
# if len(selected_models) > 0:
|
572 |
+
# project_payload = {
|
573 |
+
# "username": AUTOTRAIN_USERNAME,
|
574 |
+
# "proj_name": create_autotrain_project_name(selected_dataset, selected_config),
|
575 |
+
# "task": TASK_TO_ID[selected_task],
|
576 |
+
# "config": {
|
577 |
+
# "language": AUTOTRAIN_TASK_TO_LANG[selected_task]
|
578 |
+
# if selected_task in AUTOTRAIN_TASK_TO_LANG
|
579 |
+
# else "en",
|
580 |
+
# "max_models": 5,
|
581 |
+
# "instance": {
|
582 |
+
# "provider": "sagemaker" if selected_task in AUTOTRAIN_MACHINE.keys() else "ovh",
|
583 |
+
# "instance_type": AUTOTRAIN_MACHINE[selected_task]
|
584 |
+
# if selected_task in AUTOTRAIN_MACHINE.keys()
|
585 |
+
# else "p3",
|
586 |
+
# "max_runtime_seconds": 172800,
|
587 |
+
# "num_instances": 1,
|
588 |
+
# "disk_size_gb": 200,
|
589 |
+
# },
|
590 |
+
# "evaluation": {
|
591 |
+
# "metrics": selected_metrics,
|
592 |
+
# "models": selected_models,
|
593 |
+
# "hf_username": hf_username,
|
594 |
+
# },
|
595 |
+
# },
|
596 |
+
# }
|
597 |
+
# print(f"INFO -- Payload: {project_payload}")
|
598 |
+
# project_json_resp = http_post(
|
599 |
+
# path="/projects/create",
|
600 |
+
# payload=project_payload,
|
601 |
+
# token=HF_TOKEN,
|
602 |
+
# domain=AUTOTRAIN_BACKEND_API,
|
603 |
+
# ).json()
|
604 |
+
# print(f"INFO -- Project creation response: {project_json_resp}")
|
605 |
+
|
606 |
+
# if project_json_resp["created"]:
|
607 |
+
# data_payload = {
|
608 |
+
# "split": 4, # use "auto" split choice in AutoTrain
|
609 |
+
# "col_mapping": col_mapping,
|
610 |
+
# "load_config": {"max_size_bytes": 0, "shuffle": False},
|
611 |
+
# "dataset_id": selected_dataset,
|
612 |
+
# "dataset_config": selected_config,
|
613 |
+
# "dataset_split": selected_split,
|
614 |
+
# }
|
615 |
+
# data_json_resp = http_post(
|
616 |
+
# path=f"/projects/{project_json_resp['id']}/data/dataset",
|
617 |
+
# payload=data_payload,
|
618 |
+
# token=HF_TOKEN,
|
619 |
+
# domain=AUTOTRAIN_BACKEND_API,
|
620 |
+
# ).json()
|
621 |
+
# print(f"INFO -- Dataset creation response: {data_json_resp}")
|
622 |
+
# if data_json_resp["download_status"] == 1:
|
623 |
+
# train_json_resp = http_post(
|
624 |
+
# path=f"/projects/{project_json_resp['id']}/data/start_processing",
|
625 |
+
# token=HF_TOKEN,
|
626 |
+
# domain=AUTOTRAIN_BACKEND_API,
|
627 |
+
# ).json()
|
628 |
+
# # For local development we process and approve projects on-the-fly
|
629 |
+
# if "localhost" in AUTOTRAIN_BACKEND_API:
|
630 |
+
# with st.spinner("β³ Waiting for data processing to complete ..."):
|
631 |
+
# is_data_processing_success = False
|
632 |
+
# while is_data_processing_success is not True:
|
633 |
+
# project_status = http_get(
|
634 |
+
# path=f"/projects/{project_json_resp['id']}",
|
635 |
+
# token=HF_TOKEN,
|
636 |
+
# domain=AUTOTRAIN_BACKEND_API,
|
637 |
+
# ).json()
|
638 |
+
# if project_status["status"] == 3:
|
639 |
+
# is_data_processing_success = True
|
640 |
+
# time.sleep(10)
|
641 |
+
|
642 |
+
# # Approve training job
|
643 |
+
# train_job_resp = http_post(
|
644 |
+
# path=f"/projects/{project_json_resp['id']}/start_training",
|
645 |
+
# token=HF_TOKEN,
|
646 |
+
# domain=AUTOTRAIN_BACKEND_API,
|
647 |
+
# ).json()
|
648 |
+
# st.success("β
Data processing and project approval complete - go forth and evaluate!")
|
649 |
+
# else:
|
650 |
+
# # Prod/staging submissions are evaluated in a cron job via run_evaluation_jobs.py
|
651 |
+
# print(f"INFO -- AutoTrain job response: {train_json_resp}")
|
652 |
+
# if train_json_resp["success"]:
|
653 |
+
# train_eval_index = {
|
654 |
+
# "train-eval-index": [
|
655 |
+
# {
|
656 |
+
# "config": selected_config,
|
657 |
+
# "task": AUTOTRAIN_TASK_TO_HUB_TASK[selected_task],
|
658 |
+
# "task_id": selected_task,
|
659 |
+
# "splits": {"eval_split": selected_split},
|
660 |
+
# "col_mapping": col_mapping,
|
661 |
+
# }
|
662 |
+
# ]
|
663 |
+
# }
|
664 |
+
# selected_metadata = yaml.dump(train_eval_index, sort_keys=False)
|
665 |
+
# dataset_card_url = get_dataset_card_url(selected_dataset)
|
666 |
+
# st.success("β
Successfully submitted evaluation job!")
|
667 |
+
# st.markdown(
|
668 |
+
# f"""
|
669 |
+
# Evaluation can take up to 1 hour to complete, so grab a βοΈ or π΅ while you wait:
|
670 |
+
|
671 |
+
# * π A [Hub pull request](https://huggingface.co/docs/hub/repositories-pull-requests-discussions) with the evaluation results will be opened for each model you selected. Check your email for notifications.
|
672 |
+
# * π Click [here](https://hf.co/spaces/autoevaluate/leaderboards?dataset={selected_dataset}) to view the results from your submission once the Hub pull request is merged.
|
673 |
+
# * π₯± Tired of configuring evaluations? Add the following metadata to the [dataset card]({dataset_card_url}) to enable 1-click evaluations:
|
674 |
+
# """ # noqa
|
675 |
+
# )
|
676 |
+
# st.markdown(
|
677 |
+
# f"""
|
678 |
+
# ```yaml
|
679 |
+
# {selected_metadata}
|
680 |
+
# """
|
681 |
+
# )
|
682 |
+
# print("INFO -- Pushing evaluation job logs to the Hub")
|
683 |
+
# evaluation_log = {}
|
684 |
+
# evaluation_log["project_id"] = project_json_resp["id"]
|
685 |
+
# evaluation_log["autotrain_env"] = (
|
686 |
+
# "staging" if "staging" in AUTOTRAIN_BACKEND_API else "prod"
|
687 |
+
# )
|
688 |
+
# evaluation_log["payload"] = project_payload
|
689 |
+
# evaluation_log["project_creation_response"] = project_json_resp
|
690 |
+
# evaluation_log["dataset_creation_response"] = data_json_resp
|
691 |
+
# evaluation_log["autotrain_job_response"] = train_json_resp
|
692 |
+
# commit_evaluation_log(evaluation_log, hf_access_token=HF_TOKEN)
|
693 |
+
# else:
|
694 |
+
# st.error("π Oh no, there was an error submitting your evaluation job!")
|
695 |
+
# else:
|
696 |
+
# st.warning("β οΈ No models left to evaluate! Please select other models and try again.")
|