Spaces:
Runtime error
Runtime error
Commit
·
0d4db15
1
Parent(s):
569183a
Updates
Browse files
app.py
CHANGED
|
@@ -23,55 +23,160 @@ def get_blocks_party_spaces():
|
|
| 23 |
def make_clickable_model(model_name):
|
| 24 |
# remove user from model name
|
| 25 |
model_name_show = ' '.join(model_name.split('/')[1:])
|
| 26 |
-
|
| 27 |
link = "https://huggingface.co/" + model_name
|
| 28 |
-
return f'<a target="_blank" href="{link}">{model_name_show}</a>'
|
|
|
|
| 29 |
|
| 30 |
-
def get_mteb_data(task="Clustering", metric="v_measure"):
|
| 31 |
api = HfApi()
|
| 32 |
models = api.list_models(filter="mteb")
|
| 33 |
df_list = []
|
| 34 |
for model in models:
|
| 35 |
readme_path = hf_hub_download(model.modelId, filename="README.md")
|
| 36 |
meta = metadata_load(readme_path)
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
)
|
| 42 |
-
)
|
| 43 |
out = {k: v for d in out for k, v in d.items()}
|
| 44 |
-
|
| 45 |
-
# Turning it into HTML will make the formatting ugly
|
| 46 |
-
# make_clickable_model(model.modelId)
|
| 47 |
-
out["Model"] = model.modelId
|
| 48 |
df_list.append(out)
|
| 49 |
df = pd.DataFrame(df_list)
|
| 50 |
-
# Put Model
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
block = gr.Blocks()
|
| 55 |
|
| 56 |
with block:
|
| 57 |
gr.Markdown("""Leaderboard for XX most popular Blocks Event Spaces. To learn more and join, see <a href="https://huggingface.co/Gradio-Blocks" target="_blank" style="text-decoration: underline">Blocks Party Event</a>""")
|
| 58 |
with gr.Tabs():
|
| 59 |
-
with gr.TabItem("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
with gr.Row():
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
with gr.Row():
|
| 63 |
data_run = gr.Button("Refresh")
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
| 66 |
with gr.Row():
|
| 67 |
-
gr.Markdown("""Leaderboard for
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
with gr.Row():
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
with gr.Row():
|
| 71 |
data_run = gr.Button("Refresh")
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
data_run.click(get_mteb_data, inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
with gr.TabItem("Blocks Party Leaderboard2"):
|
| 76 |
with gr.Row():
|
| 77 |
data = gr.components.Dataframe(type="pandas")
|
|
@@ -79,7 +184,14 @@ with block:
|
|
| 79 |
data_run = gr.Button("Refresh")
|
| 80 |
data_run.click(get_blocks_party_spaces, inputs=None, outputs=data)
|
| 81 |
# running the function on page load in addition to when the button is clicked
|
| 82 |
-
block.load(get_mteb_data, inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
block.load(get_blocks_party_spaces, inputs=None, outputs=data)
|
| 84 |
|
| 85 |
block.launch()
|
|
|
|
| 23 |
def make_clickable_model(model_name):
|
| 24 |
# remove user from model name
|
| 25 |
model_name_show = ' '.join(model_name.split('/')[1:])
|
|
|
|
| 26 |
link = "https://huggingface.co/" + model_name
|
| 27 |
+
return f'<a target="_blank" style="text-decoration: underline" href="{link}">{model_name_show}</a>'
|
| 28 |
+
|
| 29 |
|
| 30 |
+
def get_mteb_data(task="Clustering", metric="v_measure", lang=None):
|
| 31 |
api = HfApi()
|
| 32 |
models = api.list_models(filter="mteb")
|
| 33 |
df_list = []
|
| 34 |
for model in models:
|
| 35 |
readme_path = hf_hub_download(model.modelId, filename="README.md")
|
| 36 |
meta = metadata_load(readme_path)
|
| 37 |
+
# Use "get" instead of dict indexing to ignore incompat metadata instead of erroring out
|
| 38 |
+
if lang is None:
|
| 39 |
+
out = list(
|
| 40 |
+
map(
|
| 41 |
+
lambda x: {x["dataset"]["name"].replace("MTEB ", ""): round(list(filter(lambda x: x["type"] == metric, x["metrics"]))[0]["value"], 2)},
|
| 42 |
+
filter(lambda x: x.get("task", {}).get("type", "") == task, meta["model-index"][0]["results"])
|
| 43 |
+
)
|
| 44 |
+
)
|
| 45 |
+
else:
|
| 46 |
+
# Multilingual
|
| 47 |
+
out = list(
|
| 48 |
+
map(
|
| 49 |
+
lambda x: {x["dataset"]["name"].replace("MTEB ", ""): round(list(filter(lambda x: x["type"] == metric, x["metrics"]))[0]["value"], 2)},
|
| 50 |
+
filter(lambda x: (x.get("task", {}).get("type", "") == task) and (x.get("dataset", {}).get("config", "") in ("default", *lang)), meta["model-index"][0]["results"])
|
| 51 |
+
)
|
| 52 |
)
|
|
|
|
| 53 |
out = {k: v for d in out for k, v in d.items()}
|
| 54 |
+
out["Model"] = make_clickable_model(model.modelId)
|
|
|
|
|
|
|
|
|
|
| 55 |
df_list.append(out)
|
| 56 |
df = pd.DataFrame(df_list)
|
| 57 |
+
# Put 'Model' column first
|
| 58 |
+
cols = sorted(list(df.columns))
|
| 59 |
+
cols.insert(0, cols.pop(cols.index("Model")))
|
| 60 |
+
df = df[cols]
|
| 61 |
+
|
| 62 |
+
df.fillna('', inplace=True)
|
| 63 |
+
return df.astype(str) # Cast to str as Gradio does not accept floats
|
| 64 |
|
| 65 |
block = gr.Blocks()
|
| 66 |
|
| 67 |
with block:
|
| 68 |
gr.Markdown("""Leaderboard for XX most popular Blocks Event Spaces. To learn more and join, see <a href="https://huggingface.co/Gradio-Blocks" target="_blank" style="text-decoration: underline">Blocks Party Event</a>""")
|
| 69 |
with gr.Tabs():
|
| 70 |
+
with gr.TabItem("Classification"):
|
| 71 |
+
with gr.TabItem("English"):
|
| 72 |
+
with gr.Row():
|
| 73 |
+
gr.Markdown("""Leaderboard for Classification""")
|
| 74 |
+
with gr.Row():
|
| 75 |
+
data_classification_en = gr.components.Dataframe(
|
| 76 |
+
datatype=["markdown"] * 500,
|
| 77 |
+
type="pandas",
|
| 78 |
+
col_count=(13, "fixed"),
|
| 79 |
+
)
|
| 80 |
+
with gr.Row():
|
| 81 |
+
data_run = gr.Button("Refresh")
|
| 82 |
+
task_classification_en = gr.Variable(value="Classification")
|
| 83 |
+
metric_classification_en = gr.Variable(value="accuracy")
|
| 84 |
+
lang_classification_en = gr.Variable(value=["en"])
|
| 85 |
+
data_run.click(get_mteb_data, inputs=[task_classification_en, metric_classification_en, lang_classification_en], outputs=data_classification_en)
|
| 86 |
+
with gr.TabItem("Multilingual"):
|
| 87 |
+
with gr.Row():
|
| 88 |
+
gr.Markdown("""Multilingual Classification""")
|
| 89 |
+
with gr.Row():
|
| 90 |
+
data_classification = gr.components.Dataframe(
|
| 91 |
+
datatype=["markdown"] * 500,
|
| 92 |
+
type="pandas",
|
| 93 |
+
)
|
| 94 |
+
with gr.Row():
|
| 95 |
+
data_run = gr.Button("Refresh")
|
| 96 |
+
task_classification = gr.Variable(value="Classification")
|
| 97 |
+
metric_classification = gr.Variable(value="accuracy")
|
| 98 |
+
data_run.click(get_mteb_data, inputs=[task_classification, metric_classification], outputs=data_classification)
|
| 99 |
+
with gr.TabItem("Clustering"):
|
| 100 |
with gr.Row():
|
| 101 |
+
gr.Markdown("""Leaderboard for Clustering""")
|
| 102 |
+
with gr.Row():
|
| 103 |
+
data_clustering = gr.components.Dataframe(
|
| 104 |
+
datatype=["markdown"] * 500,
|
| 105 |
+
type="pandas",
|
| 106 |
+
)
|
| 107 |
with gr.Row():
|
| 108 |
data_run = gr.Button("Refresh")
|
| 109 |
+
task_clustering = gr.Variable(value="Clustering")
|
| 110 |
+
metric_clustering = gr.Variable(value="v_measure")
|
| 111 |
+
data_run.click(get_mteb_data, inputs=[task_clustering, metric_clustering], outputs=data_clustering)
|
| 112 |
+
with gr.TabItem("Retrieval"):
|
| 113 |
with gr.Row():
|
| 114 |
+
gr.Markdown("""Leaderboard for Retrieval""")
|
| 115 |
+
with gr.Row():
|
| 116 |
+
data_retrieval = gr.components.Dataframe(
|
| 117 |
+
datatype=["markdown"] * 500,
|
| 118 |
+
type="pandas",
|
| 119 |
+
)
|
| 120 |
+
with gr.Row():
|
| 121 |
+
data_run = gr.Button("Refresh")
|
| 122 |
+
task_retrieval = gr.Variable(value="Retrieval")
|
| 123 |
+
metric_retrieval = gr.Variable(value="ndcg_at_10")
|
| 124 |
+
data_run.click(get_mteb_data, inputs=[task_retrieval, metric_retrieval], outputs=data_retrieval)
|
| 125 |
+
with gr.TabItem("Reranking"):
|
| 126 |
+
with gr.Row():
|
| 127 |
+
gr.Markdown("""Leaderboard for Reranking""")
|
| 128 |
with gr.Row():
|
| 129 |
+
data_reranking = gr.components.Dataframe(
|
| 130 |
+
datatype=["markdown"] * 500,
|
| 131 |
+
type="pandas",
|
| 132 |
+
#col_count=(12, "fixed"),
|
| 133 |
+
)
|
| 134 |
with gr.Row():
|
| 135 |
data_run = gr.Button("Refresh")
|
| 136 |
+
task_reranking = gr.Variable(value="Reranking")
|
| 137 |
+
metric_reranking = gr.Variable(value="map")
|
| 138 |
+
data_run.click(get_mteb_data, inputs=[task_reranking, metric_reranking], outputs=data_reranking)
|
| 139 |
+
with gr.TabItem("STS"):
|
| 140 |
+
with gr.TabItem("English"):
|
| 141 |
+
with gr.Row():
|
| 142 |
+
gr.Markdown("""Leaderboard for STS""")
|
| 143 |
+
with gr.Row():
|
| 144 |
+
data_sts_en = gr.components.Dataframe(
|
| 145 |
+
datatype=["markdown"] * 500,
|
| 146 |
+
type="pandas",
|
| 147 |
+
)
|
| 148 |
+
with gr.Row():
|
| 149 |
+
data_run_en = gr.Button("Refresh")
|
| 150 |
+
task_sts_en = gr.Variable(value="STS")
|
| 151 |
+
metric_sts_en = gr.Variable(value="cos_sim_spearman")
|
| 152 |
+
lang_sts_en = gr.Variable(value=["en", "en-en"])
|
| 153 |
+
data_run.click(get_mteb_data, inputs=[task_sts_en, metric_sts_en, lang_sts_en], outputs=data_sts_en)
|
| 154 |
+
with gr.TabItem("Multilingual"):
|
| 155 |
+
with gr.Row():
|
| 156 |
+
gr.Markdown("""Leaderboard for STS""")
|
| 157 |
+
with gr.Row():
|
| 158 |
+
data_sts = gr.components.Dataframe(
|
| 159 |
+
datatype=["markdown"] * 500,
|
| 160 |
+
type="pandas",
|
| 161 |
+
)
|
| 162 |
+
with gr.Row():
|
| 163 |
+
data_run = gr.Button("Refresh")
|
| 164 |
+
task_sts = gr.Variable(value="STS")
|
| 165 |
+
metric_sts = gr.Variable(value="cos_sim_spearman")
|
| 166 |
+
data_run.click(get_mteb_data, inputs=[task_sts, metric_sts], outputs=data_sts)
|
| 167 |
+
with gr.TabItem("Summarization"):
|
| 168 |
+
with gr.Row():
|
| 169 |
+
gr.Markdown("""Leaderboard for Summarization""")
|
| 170 |
+
with gr.Row():
|
| 171 |
+
data_summarization = gr.components.Dataframe(
|
| 172 |
+
datatype=["markdown"] * 500,
|
| 173 |
+
type="pandas",
|
| 174 |
+
)
|
| 175 |
+
with gr.Row():
|
| 176 |
+
data_run = gr.Button("Refresh")
|
| 177 |
+
task_summarization = gr.Variable(value="Summarization")
|
| 178 |
+
metric_summarization = gr.Variable(value="cos_sim_spearman")
|
| 179 |
+
data_run.click(get_mteb_data, inputs=[task_summarization, metric_summarization], outputs=data_summarization)
|
| 180 |
with gr.TabItem("Blocks Party Leaderboard2"):
|
| 181 |
with gr.Row():
|
| 182 |
data = gr.components.Dataframe(type="pandas")
|
|
|
|
| 184 |
data_run = gr.Button("Refresh")
|
| 185 |
data_run.click(get_blocks_party_spaces, inputs=None, outputs=data)
|
| 186 |
# running the function on page load in addition to when the button is clicked
|
| 187 |
+
block.load(get_mteb_data, inputs=[task_classification_en, metric_classification_en], outputs=data_classification_en)
|
| 188 |
+
block.load(get_mteb_data, inputs=[task_classification, metric_classification], outputs=data_classification)
|
| 189 |
+
block.load(get_mteb_data, inputs=[task_clustering, metric_clustering], outputs=data_clustering)
|
| 190 |
+
block.load(get_mteb_data, inputs=[task_retrieval, metric_retrieval], outputs=data_retrieval)
|
| 191 |
+
block.load(get_mteb_data, inputs=[task_reranking, metric_reranking], outputs=data_reranking)
|
| 192 |
+
block.load(get_mteb_data, inputs=[task_sts, metric_sts], outputs=data_sts)
|
| 193 |
+
block.load(get_mteb_data, inputs=[task_summarization, metric_summarization], outputs=data_summarization)
|
| 194 |
+
|
| 195 |
block.load(get_blocks_party_spaces, inputs=None, outputs=data)
|
| 196 |
|
| 197 |
block.launch()
|