from typing import Callable import gradio as gr from gradio_leaderboard import Leaderboard, SearchColumns, SelectColumns, ColumnFilter from src.leaderboard.read_evals import FILTERED_ONLY_FIELD from src.envs import EVAL_RESULTS_PATH from src.populate import get_leaderboard_df from src.display.utils import ( AutoEvalColumn, fields, ) def show_result_page(root_path: str, title: str, index: int, extra: Callable[[None], None] = None): raw_data, original_df = get_leaderboard_df(EVAL_RESULTS_PATH + f"/{root_path}") leaderboard_df = original_df.copy() with gr.TabItem(title, elem_id="llm-benchmark-tab-table", id=index): Leaderboard( value=leaderboard_df, datatype=[c.type for c in fields(AutoEvalColumn)], select_columns=SelectColumns( default_selection=[c for c in list(original_df.keys())], cant_deselect=[c.name for c in fields(AutoEvalColumn)], label="Select Columns to show:", ), hide_columns=FILTERED_ONLY_FIELD, search_columns=SearchColumns( primary_column=AutoEvalColumn.model.name, secondary_columns=[], placeholder="🔍 Search for your model (separate multiple queries with `;`) and press ENTER...", label="Search", ), filter_columns=[ ColumnFilter( "params", type="slider", min=0.01, max=150, label="Select the number of parameters (B)", ), ], bool_checkboxgroup_label="Hide models", interactive=False, ) if extra is not None: with gr.Column(): extra()