kiliangoto's picture
Initial commit of Sahabat-AI Leaderboard
ef54478
import gradio as gr
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
# Import function to load leaderboard tables
from src.populate import load_tables
# Import configurations and informational texts
from src.config import (
file_path,
model_types,
hidden_tabs,
INTRODUCTION_TEXT,
TITLE,
INFO_BENCHMARK_TASK,
INFO_SCORE_CALCULATION,
INFO_GOTO_SAHABAT_AI,
CITATIONS
)
# Create a Gradio application with block-based UI
# 'Blocks()' is used to group multiple components in a single interface
demo = gr.Blocks()
with demo:
gr.HTML(TITLE) # Display the main title of the application
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text") # Display introductory text
# Create tabs to display different leaderboard tables
with gr.Tabs(elem_classes="tab-buttons") as tabs:
tables = load_tables(file_path) # Load leaderboard data from file
for model_type in model_types:
with gr.TabItem(model_type, elem_id="llm-benchmark-tab-table", id=model_type):
for i, t in enumerate(tables): # Loop through the tables to create tabs
if (model_type, t["name"]) in hidden_tabs:
continue
with gr.TabItem(t["name"], elem_id="llm-benchmark-tab-table", id=i):
table_df = t["table"][t["table"]["Type"] == model_type]
table_df = table_df.dropna(axis=1, how='all')
leaderboard = Leaderboard(
value=table_df, # Leaderboard data
search_columns=["Model"], # Columns that can be searched
filter_columns=[
ColumnFilter(table_df["Size"].name, type="checkboxgroup", label="Model sizes"),
], # Filters based on model type and size
hide_columns=t["hidden_col"], # Columns to be hidden imported from config.py
interactive=False,
)
# Add additional informational sections using Accordion
with gr.Row():
with gr.Accordion("๐Ÿ“š Benchmark Tasks", open=False):
gr.Markdown(INFO_BENCHMARK_TASK, elem_classes="markdown-text")
with gr.Row():
with gr.Accordion("๐Ÿงฎ Score Calculation", open=False):
gr.Markdown(INFO_SCORE_CALCULATION, elem_classes="markdown-text")
with gr.Row():
with gr.Accordion("๐Ÿค About Sahabat-AI", open=False):
gr.Markdown(INFO_GOTO_SAHABAT_AI, elem_classes="markdown-text")
with gr.Row():
with gr.Accordion("๐Ÿ“ Citations", open=False):
gr.Markdown(CITATIONS, elem_classes="markdown-text")
# Run the application
demo.launch()