|
import gradio as gr |
|
from gradio_leaderboard import Leaderboard, SelectColumns, ColumnFilter |
|
from pathlib import Path |
|
|
|
from utils import LLM_BENCHMARKS_ABOUT_TEXT, LLM_BENCHMARKS_SUBMIT_TEXT, custom_css, jsonl_to_dataframe, add_average_column_to_df, apply_markdown_format_for_columns, submit, PART_LOGO, sort_dataframe_by_column |
|
|
|
|
|
|
|
abs_path = Path(__file__).parent |
|
|
|
|
|
leaderboard_df = jsonl_to_dataframe(str(abs_path / "leaderboard_data.jsonl")) |
|
|
|
|
|
all_columns = ["Model", "Average Accuracy", "Precision", "#Params (B)", "Part Multiple Choice", "ARC Easy", "ARC Challenge", "MMLU Pro", "Multiple Choice Persian"] |
|
columns_to_average = ["Part Multiple Choice", "ARC Easy", "ARC Challenge", "MMLU Pro", "Multiple Choice Persian"] |
|
|
|
average_column_name = "Average Accuracy" |
|
|
|
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))] |
|
|
|
|
|
|
|
|
|
with gr.Blocks(css=custom_css) as demo: |
|
|
|
gr.Markdown(""" |
|
# Persian LLM Leaderboard |
|
""") |
|
|
|
with gr.Tab("ποΈ Persian 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 (B)"], |
|
) |
|
with gr.TabItem("π About"): |
|
gr.Markdown(LLM_BENCHMARKS_ABOUT_TEXT) |
|
|
|
with gr.Tab("βοΈ Submit"): |
|
gr.Markdown(LLM_BENCHMARKS_SUBMIT_TEXT) |
|
model_name = gr.Textbox(label="Model name") |
|
model_id = gr.Textbox(label="username/space e.g PartAI/Dorna-Llama3-8B-Instruct") |
|
contact_email = gr.Textbox(label="Contact E-Mail") |
|
license = gr.Dropdown(choices=["llama2", "llama3", "llama3.1", "llama3.2", "cc-by-nc-4.0", "mit", "apache-2.0", "gemma", "cc-by-nc-sa-4.0", "other"], label="License") |
|
submit_btn = gr.Button("Submit") |
|
|
|
submit_btn.click(submit, inputs=[model_name, model_id, contact_email, license], outputs=[]) |
|
|
|
gr.Markdown(""" |
|
Please find more information about Part DP AI on [partdp.ai](https://partdp.ai)""") |
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|