Spaces:
Running
Running
File size: 3,058 Bytes
e0fa3ac c44d464 e0fa3ac c44d464 e0fa3ac c44d464 e0fa3ac c44d464 e0fa3ac |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
import gradio as gr
from gradio_leaderboard import Leaderboard, SelectColumns, ColumnFilter
from pathlib import Path
from utils import ABOUT_TEXT, SUBMIT_TEXT, custom_css, jsonl_to_dataframe, add_average_column_to_df, apply_markdown_format_for_columns, submit, PART_LOGO, sort_dataframe_by_column, tasks_and_metrics_table_markdown
abs_path = Path(__file__).parent
# Any pandas-compatible data
leaderboard_df = jsonl_to_dataframe(str(abs_path / "leaderboard_data.jsonl"))
average_column_name = "Average Score"
columns_to_average = ["FarsTail-Pair-Classification",
"MIRACL-Reranking",
"Wikipedia-Multilingual-Reranking",
"NeuCLIR2023-Retrieval",
"MIRACL-Retrieval",
"Wikipedia-Multilingual-Retrieval",
"Massive-Intent-Classification",
"Massive-Scenario-Classification",
"Multilingual-Sentiment-Classification",
"Persian-Food-Sentiment-Classification",
]
all_columns = ["Model", average_column_name, "Precision", "#Params (M)", "Embedding Dimension", "Context Size"] + columns_to_average
leaderboard_df = add_average_column_to_df(leaderboard_df, columns_to_average, index=3, average_column_name=average_column_name)
leaderboard_df = apply_markdown_format_for_columns(df=leaderboard_df, model_column_name="Model")
leaderboard_df = sort_dataframe_by_column(leaderboard_df, column_name=average_column_name)
columns_data_type = ["markdown" for i in range(len(leaderboard_df.columns))]
NUM_MODELS=len(leaderboard_df)
with gr.Blocks(css=custom_css) as demo:
gr.Markdown("""
# Persian Text Embedding Benchmark
""")
gr.Markdown(f"""
- **Total Models**: {NUM_MODELS}
""")
with gr.Tab("ποΈ Leaderboard"):
Leaderboard(
value=leaderboard_df,
datatype=columns_data_type,
select_columns=SelectColumns(
default_selection=all_columns,
cant_deselect=["Model"],
label="Select Columns to Show",
),
search_columns=["model_name_for_query"],
hide_columns=["model_name_for_query",],
filter_columns=["Precision", "#Params (M)"],
)
gr.Markdown("The tasks and their corresponding metrics are available in the About tab.")
with gr.TabItem("π About"):
gr.Markdown(ABOUT_TEXT)
gr.Markdown(tasks_and_metrics_table_markdown)
with gr.Tab("βοΈ Submit"):
gr.Markdown(SUBMIT_TEXT)
model_name = gr.Textbox(label="Model name")
model_id = gr.Textbox(label="username/space e.g PartAI/Tooka-SBERT")
contact_email = gr.Textbox(label="Contact E-Mail")
submit_btn = gr.Button("Submit")
submit_btn.click(submit, inputs=[model_name, model_id, contact_email], outputs=[])
gr.Markdown("""
Please find more information about Part DP AI on [partdp.ai](https://partdp.ai)""")
if __name__ == "__main__":
demo.launch()
|