File size: 4,821 Bytes
4d97309
 
 
badc551
4d97309
 
badc551
 
 
4d97309
 
badc551
4d97309
badc551
 
4d97309
 
 
badc551
4d97309
 
badc551
4d97309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
badc551
4d97309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
badc551
4d97309
 
badc551
 
 
4d97309
 
 
 
 
badc551
 
 
 
 
 
 
 
 
4d97309
 
 
 
 
 
 
 
 
badc551
4d97309
badc551
 
 
 
 
 
 
 
4d97309
 
 
 
 
 
 
badc551
4d97309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
badc551
4d97309
badc551
4d97309
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import gradio as gr

from src.assets.text_content import TITLE, INTRODUCTION_TEXT
from src.utils import compare_plots, filter_search, get_csv_data, split_models

############################ For Leaderboards #############################
# Get CSV data
global latest_df, all_dfs, all_vnames
latest_df, all_dfs, all_vnames = get_csv_data()

global prev_df
prev_df = all_dfs[0]
def select_prev_df(name):
    ind = all_vnames.index(name)
    prev_df = all_dfs[ind]
    return prev_df

############################ For Plots ####################################
global plot_df, MODEL_COLS, OPEN_MODELS, COMM_MODELS
plot_df = latest_df[0]
MODEL_COLS = list(plot_df['Model'].unique())
OPEN_MODELS, COMM_MODELS = split_models(MODEL_COLS)

############# MAIN APPLICATION ######################
demo = gr.Blocks()
with demo:
    gr.HTML(TITLE)
    gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")

    with gr.Tabs(elem_classes="tab-buttons") as tabs:
        with gr.TabItem("πŸ₯‡ CLEM Leaderboard", elem_id="llm-benchmark-tab-table", id=0):
            with gr.Row():
                search_bar = gr.Textbox(
                    placeholder=" πŸ” Search for models - separate multiple queries with `;` and press ENTER...",
                    show_label=False,
                    elem_id="search-bar",
                )
                                    
            leaderboard_table = gr.components.Dataframe(
                value=latest_df[0],
                elem_id="leaderboard-table",
                interactive=False,
                visible=True,
            )

            # Add a dummy leaderboard to handle search queries from the latest_df and not update latest_df
            dummy_leaderboard_table = gr.components.Dataframe(
                value=latest_df[0],
                elem_id="leaderboard-table",
                interactive=False,
                visible=False,
            )
                
            search_bar.submit(
                filter_search,
                [dummy_leaderboard_table, search_bar],
                leaderboard_table,
                queue=True
            )

        with gr.TabItem("πŸ“ˆ Plot", id=3):
            with gr.Row():
                open_model_cols = gr.CheckboxGroup(
                    OPEN_MODELS, 
                    label="Select Models - Open Weight 🌐", 
                    value=[],
                    elem_id="column-select",
                    interactive=True,
                )

            with gr.Row():
                comm_model_cols = gr.CheckboxGroup(
                    COMM_MODELS, 
                    label="Select Models - Closed Weight πŸ’Ό", 
                    value=[],
                    elem_id="column-select-2",
                    interactive=True,
                )

            with gr.Row():
                plot_grdf = gr.DataFrame(
                    value=plot_df,
                    visible=False
                )
            with gr.Row():
                # Output block for the plot
                plot_output = gr.Plot()

            open_model_cols.change(
                compare_plots,
                [plot_grdf, open_model_cols, comm_model_cols],
                plot_output,
                queue=True
            )

            comm_model_cols.change(
                compare_plots,
                [plot_grdf, open_model_cols, comm_model_cols],
                plot_output,
                queue=True
            )

        with gr.TabItem("πŸ”„ Versions and Details", elem_id="details", id=2):
            with gr.Row():
                ver_selection = gr.Dropdown(
                    all_vnames, label="Select Version πŸ•ΉοΈ", value=all_vnames[0]
                )
            with gr.Row():
                search_bar_prev = gr.Textbox(
                    placeholder=" πŸ” Search for models - separate multiple queries with `;` and press ENTER...",
                    show_label=False,
                    elem_id="search-bar-2",
                )

            prev_table = gr.components.Dataframe(
                value=prev_df,
                elem_id="leaderboard-table",
                interactive=False,
                visible=True,
            )

            dummy_prev_table = gr.components.Dataframe(
                value=prev_df,
                elem_id="leaderboard-table",
                interactive=False,
                visible=False,
            )

            search_bar_prev.submit(
                filter_search,
                [dummy_prev_table, search_bar_prev],
                prev_table,
                queue=True
            )

            ver_selection.change(
                select_prev_df,
                [ver_selection],
                prev_table,
                queue=True
            )
    demo.load()

demo.queue()

demo.launch()