Spaces:
Runtime error
Runtime error
Commit
·
09af587
1
Parent(s):
3d56068
add metadat scoring explanation tab
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import asyncio
|
2 |
import copy
|
|
|
3 |
import os
|
4 |
from dataclasses import asdict, dataclass
|
5 |
from datetime import datetime, timedelta
|
@@ -12,14 +13,13 @@ import httpx
|
|
12 |
import orjson
|
13 |
from cachetools import TTLCache, cached
|
14 |
from cashews import NOT_NONE, cache
|
|
|
15 |
from httpx import AsyncClient, Client
|
16 |
from huggingface_hub import hf_hub_url, logging
|
17 |
from huggingface_hub.utils import disable_progress_bars
|
18 |
from rich import print
|
19 |
from tqdm.auto import tqdm
|
20 |
|
21 |
-
from dotenv import load_dotenv
|
22 |
-
|
23 |
load_dotenv() # take environment variables from .env.
|
24 |
|
25 |
CACHE_EXPIRY_TIME = timedelta(hours=3)
|
@@ -233,6 +233,10 @@ ALL_PIPELINES = {
|
|
233 |
"zero-shot-image-classification",
|
234 |
}
|
235 |
|
|
|
|
|
|
|
|
|
236 |
|
237 |
@lru_cache()
|
238 |
def generate_task_scores_dict():
|
@@ -575,20 +579,42 @@ with gr.Blocks() as demo:
|
|
575 |
[query, min_metadata_score, mim_model_card_length],
|
576 |
[filter_results, results_markdown],
|
577 |
)
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
594 |
demo.launch()
|
|
|
1 |
import asyncio
|
2 |
import copy
|
3 |
+
import json
|
4 |
import os
|
5 |
from dataclasses import asdict, dataclass
|
6 |
from datetime import datetime, timedelta
|
|
|
13 |
import orjson
|
14 |
from cachetools import TTLCache, cached
|
15 |
from cashews import NOT_NONE, cache
|
16 |
+
from dotenv import load_dotenv
|
17 |
from httpx import AsyncClient, Client
|
18 |
from huggingface_hub import hf_hub_url, logging
|
19 |
from huggingface_hub.utils import disable_progress_bars
|
20 |
from rich import print
|
21 |
from tqdm.auto import tqdm
|
22 |
|
|
|
|
|
23 |
load_dotenv() # take environment variables from .env.
|
24 |
|
25 |
CACHE_EXPIRY_TIME = timedelta(hours=3)
|
|
|
233 |
"zero-shot-image-classification",
|
234 |
}
|
235 |
|
236 |
+
formatted_scores = "\n"
|
237 |
+
for k, v in COMMON_SCORES.items():
|
238 |
+
formatted_scores += f"{k}:{v}" + "\n"
|
239 |
+
|
240 |
|
241 |
@lru_cache()
|
242 |
def generate_task_scores_dict():
|
|
|
579 |
[query, min_metadata_score, mim_model_card_length],
|
580 |
[filter_results, results_markdown],
|
581 |
)
|
582 |
+
with gr.Tab("Scoring metadata quality (details)"):
|
583 |
+
with gr.Row():
|
584 |
+
gr.Markdown(
|
585 |
+
"""# How metadata quality is scored?
|
586 |
+
The current approach to metadata scoring is based on checking if a particular piece of metadata is present or not i.e. is a dataset specified in the mode's metadata or not?
|
587 |
+
For each metadata field a score between 1 and 3 is given if that feature is present or not. These scores are based on the relative importance of the metadata field.
|
588 |
+
We do this on a task specific basis for models where a `pipeline_tag` exists.
|
589 |
+
For each task the scores achieved are compared to the maximum possible score for that field."""
|
590 |
+
)
|
591 |
+
with gr.Row():
|
592 |
+
gr.Markdown(
|
593 |
+
"""
|
594 |
+
### Common Scores
|
595 |
+
We start with some 'common scores'. These common scores are for fields which should be present for any model i.e. they are not specific to a particular task."""
|
596 |
+
)
|
597 |
+
with gr.Accordion(label="Common scores dictionary"):
|
598 |
+
gr.JSON(json.dumps(COMMON_SCORES))
|
599 |
+
with gr.Row():
|
600 |
+
gr.Markdown(
|
601 |
+
"""# Task specific scoring.
|
602 |
+
We also define task specific scores for the following model task types. This allows are scoring to reflect the fact that different tasks have different metadata requirements. For example, the following set includes all tasks for which a language should be specified."""
|
603 |
+
)
|
604 |
+
with gr.Row():
|
605 |
+
markdown_formatted_languages = "".join(
|
606 |
+
"-" + " " + task + "\n" for task in TASK_TYPES_WITH_LANGUAGES
|
607 |
+
)
|
608 |
+
gr.Markdown(markdown_formatted_languages)
|
609 |
+
with gr.Row():
|
610 |
+
gr.Markdown(
|
611 |
+
"""#### Text classification example
|
612 |
+
Below you can see the example scoring dictionary for text-classification models."""
|
613 |
+
)
|
614 |
+
with gr.Accordion(label="Text classification dictionary"):
|
615 |
+
text_class_scores_example = SCORES["text-classification"]
|
616 |
+
gr.Json(json.dumps(text_class_scores_example))
|
617 |
+
with gr.Accordion(label="Full overview of all scores", open=False):
|
618 |
+
gr.Json(json.dumps(SCORES))
|
619 |
+
|
620 |
demo.launch()
|