|
import os |
|
import json |
|
import gradio as gr |
|
import pandas as pd |
|
import numpy as np |
|
|
|
from pathlib import Path |
|
from apscheduler.schedulers.background import BackgroundScheduler |
|
from huggingface_hub import snapshot_download |
|
|
|
from src.about import ( |
|
CITATION_BUTTON_LABEL, |
|
CITATION_BUTTON_TEXT, |
|
EVALUATION_QUEUE_TEXT, |
|
INTRODUCTION_TEXT, |
|
LLM_BENCHMARKS_TEXT, |
|
TITLE, |
|
ABOUT_TEXT, |
|
SUBMISSION_TEXT |
|
) |
|
from src.display.css_html_js import custom_css |
|
from src.display.formatting import has_no_nan_values, make_clickable_model, model_hyperlink |
|
|
|
|
|
COLUMN_GROUPS = { |
|
"ALL": ["Model", "Perception", "Reasoning", "IF", "Safety", "AMU Score", |
|
"Modality Selection", "Instruction Following", "Modality Synergy", |
|
"AMG Score", "Overall", "Verified"], |
|
"AMU": ["Model", "Perception", "Reasoning", "IF", "Safety", "AMU Score", "Verified"], |
|
"AMG": ["Model", "Modality Selection", "Instruction Following", "Modality Synergy", "AMG Score", "Verified"] |
|
} |
|
|
|
def format_table(df): |
|
"""Format the dataframe for display""" |
|
|
|
float_cols = df.select_dtypes(include=['float64']).columns |
|
for col in float_cols: |
|
df[col] = df[col].apply(lambda x: f"{x:.2f}") |
|
|
|
bold_columns = ['AMU Score', 'AMG Score', 'Overall'] |
|
for col in bold_columns: |
|
if col in df.columns: |
|
df[col] = df[col].apply(lambda x: f'**{x}**') |
|
|
|
|
|
model_links = dict(zip(df['Model'], df['Model Link'])) |
|
|
|
df['Model'] = df['Model'].apply(lambda x: f'[{x}]({model_links[x]})') |
|
|
|
return df |
|
|
|
def regex_table(dataframe, regex, filter_button, column_group="ALL"): |
|
"""Takes a model name as a regex, then returns only the rows that has that in it.""" |
|
|
|
df = dataframe.copy() |
|
|
|
|
|
columns_to_show = COLUMN_GROUPS.get(column_group, COLUMN_GROUPS["ALL"]) |
|
df = df[columns_to_show] |
|
|
|
|
|
if regex: |
|
regex_list = [x.strip() for x in regex.split(",")] |
|
|
|
combined_regex = '|'.join(regex_list) |
|
|
|
df = df[df["Model"].str.contains(combined_regex, case=False, na=False)] |
|
|
|
df = df.sort_values(by='Overall' if 'Overall' in columns_to_show else columns_to_show[-1], ascending=False) |
|
df.reset_index(drop=True, inplace=True) |
|
|
|
|
|
df.insert(0, '', range(1, 1 + len(df))) |
|
|
|
return df |
|
|
|
|
|
df = pd.read_csv("data/eval_board.csv").sort_values(by='Overall', ascending=False) |
|
total_models = len(df) |
|
|
|
|
|
df = format_table(df) |
|
|
|
with gr.Blocks(css=custom_css) as app: |
|
gr.HTML(TITLE) |
|
with gr.Row(): |
|
with gr.Column(scale=6): |
|
gr.Markdown(INTRODUCTION_TEXT.format(str(total_models))) |
|
|
|
with gr.Tabs(elem_classes="tab-buttons") as tabs: |
|
with gr.TabItem("🏆 Model Performance Leaderboard"): |
|
with gr.Row(): |
|
search_overall = gr.Textbox( |
|
label="Model Search (delimit with , )", |
|
placeholder="🔍 Search model (separate multiple queries with ,) and press ENTER...", |
|
show_label=False |
|
) |
|
column_group = gr.Radio( |
|
choices=list(COLUMN_GROUPS.keys()), |
|
value="ALL", |
|
label="Select columns to show" |
|
) |
|
|
|
with gr.Row(): |
|
performance_table_hidden = gr.Dataframe( |
|
df, |
|
headers=df.columns.tolist(), |
|
elem_id="performance_table_hidden", |
|
wrap=True, |
|
visible=False, |
|
datatype='markdown', |
|
) |
|
performance_table = gr.Dataframe( |
|
regex_table(df.copy(), "", []), |
|
headers=df.columns.tolist(), |
|
elem_id="performance_table", |
|
wrap=True, |
|
show_label=False, |
|
datatype='markdown', |
|
) |
|
|
|
with gr.TabItem("About"): |
|
gr.Markdown(ABOUT_TEXT) |
|
|
|
with gr.TabItem("Submit results 🚀", id=3): |
|
gr.Markdown(SUBMISSION_TEXT) |
|
|
|
with gr.Accordion("📚 Citation", open=False): |
|
citation_button = gr.Textbox( |
|
value=CITATION_BUTTON_TEXT, |
|
lines=7, |
|
label="Copy the following to cite these results.", |
|
elem_id="citation-button", |
|
show_copy_button=True, |
|
) |
|
|
|
|
|
def update_table(search_text, selected_group): |
|
return regex_table(df, search_text, [], selected_group) |
|
|
|
search_overall.change( |
|
update_table, |
|
inputs=[search_overall, column_group], |
|
outputs=performance_table |
|
) |
|
|
|
column_group.change( |
|
update_table, |
|
inputs=[search_overall, column_group], |
|
outputs=performance_table |
|
) |
|
|
|
|
|
scheduler = BackgroundScheduler() |
|
scheduler.add_job(lambda: None, "interval", seconds=18000) |
|
scheduler.start() |
|
|
|
|
|
app.launch(share=True) |