File size: 2,820 Bytes
ef54478
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()