File size: 10,823 Bytes
d83a64f
903cbb7
d83a64f
 
 
 
0865d34
f236920
e74285c
 
d83a64f
 
 
 
 
8a48b81
fdde5a7
2bfa906
d83a64f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5f67fb5
d83a64f
 
e74285c
 
 
 
 
 
 
 
 
 
d83a64f
 
 
 
e74285c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d83a64f
 
 
 
 
 
 
 
 
 
 
61cf28b
 
d83a64f
e74285c
a49fb33
e74285c
 
a49fb33
e74285c
 
 
 
 
 
 
 
 
 
d83a64f
 
 
 
 
 
 
 
8a48b81
 
 
d83a64f
903cbb7
d83a64f
 
 
903cbb7
e74285c
903cbb7
 
e74285c
903cbb7
 
d83a64f
 
 
 
 
 
 
 
 
f6237c7
 
e74285c
1f16be9
d83a64f
1f16be9
d83a64f
 
f6237c7
fdde5a7
 
 
 
 
 
 
b80544e
efc63fc
d83a64f
a9c4433
903cbb7
5f67fb5
d83a64f
903cbb7
d83a64f
 
 
 
5f67fb5
 
 
 
 
 
903cbb7
 
 
d83a64f
 
 
fdde5a7
 
 
 
903cbb7
fdde5a7
 
 
903cbb7
e74285c
903cbb7
 
e74285c
903cbb7
 
fdde5a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f16be9
fdde5a7
 
 
 
 
 
 
 
 
 
b80544e
903cbb7
fdde5a7
 
0e30c3b
903cbb7
5f67fb5
fdde5a7
903cbb7
1e1de2d
 
 
 
 
 
 
 
 
 
5f67fb5
 
903cbb7
 
 
fdde5a7
5f67fb5
fdde5a7
 
8a48b81
2bfa906
d83a64f
 
 
 
 
 
 
 
 
 
 
e74285c
d83a64f
 
 
e74285c
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
import gradio as gr

from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
import pandas as pd
from apscheduler.schedulers.background import BackgroundScheduler
from huggingface_hub import snapshot_download
from src.data_utils import get_dataframe_category, get_dataframe_language
import src.config as configs
from utils import get_profile, get_organizations, get_profile_and_organizations, download_with_restart


from src.about import (
    CITATION_BUTTON_LABEL,
    CITATION_BUTTON_TEXT,
    EVALUATION_QUEUE_TEXT,
    EVALUATION_QUEUE_TEXT_OPTION1,
    EVALUATION_QUEUE_TEXT_OPTION2,
    EVALUATION_QUEUE_TEXT_OPTION3,
    INTRODUCTION_TEXT,
    LLM_BENCHMARKS_TEXT,
    TITLE,
)
from src.display.css_html_js import custom_css
from src.display.utils import (
    BENCHMARK_COLS,
    COLS,
    EVAL_COLS,
    EVAL_TYPES,
    AutoEvalColumn,
    fields,
    WeightType,
    Precision
)
from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REPO_ID, RESULTS_REPO, TOKEN
from src.populate import get_evaluation_queue_df, get_leaderboard_df
from src.submission.submit import add_new_eval_option1, add_new_eval_option2


from handlers import (
    search_leaderboard,
    update_modelselector_group,
    update_columnselector_group,
    update_leaderboard,
    get_models_by_group,
)
from ui import create_leaderboard_tab
from constants import TAB_KEYS, TAB_NAMES, VLLM_VERSIONS

def restart_space():
    API.restart_space(repo_id=REPO_ID)

### Space initialisation
download_with_restart(
    snapshot_download,
    repo_id=QUEUE_REPO,
    local_dir=EVAL_REQUESTS_PATH,
    repo_type="dataset",
    token=TOKEN,
    restart_func=restart_space
)
download_with_restart(
    snapshot_download,
    repo_id=RESULTS_REPO,
    local_dir=EVAL_RESULTS_PATH,
    repo_type="dataset",
    token=TOKEN,
    restart_func=restart_space
)

(
    finished_eval_queue_df,
    running_eval_queue_df,
    pending_eval_queue_df,
) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)

demo = gr.Blocks(css=custom_css)
with demo:
    gr.HTML(TITLE)
    gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
    user_state = gr.State()
    organization_state = gr.State()
    with gr.Tabs(elem_classes="tab-buttons") as tabs:
        for _, key in enumerate(TAB_KEYS):
            if key == "Category":
                df = get_dataframe_category()
                column_selector_value = configs.ON_LOAD_COLUMNS_CATEGORY[3:]
            else:
                df = get_dataframe_language()
                column_selector_value = configs.ON_LOAD_COLUMNS_LANG[3:]
            create_leaderboard_tab(
                df,
                key,
                search_leaderboard,
                update_modelselector_group,
                update_leaderboard,
                column_selector_value
            )
        with gr.TabItem("๐Ÿ“ About", elem_id="llm-benchmark-tab-table", id=2):
            gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")

        with gr.TabItem("๐Ÿš€ Submit here! ", elem_id="llm-benchmark-tab-table", id=3):
            with gr.Column():
                with gr.Row():
                    gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")

                with gr.Row():
                    gr.Markdown(EVALUATION_QUEUE_TEXT_OPTION1, elem_classes="markdown-text")

            with gr.Row():
                gr.Markdown("## โœ‰๏ธโœจ Submit your model here! (if vLLM inference is available)", elem_classes="markdown-text")

            with gr.Row():
                with gr.Column():
                    benchmark_type = gr.Dropdown(
                        choices=["TRUEBench v0.1"],
                        label="The name of the benchmark to be evaluated",
                        multiselect=False,
                        value="TRUEBench v0.1",
                        interactive=True,
                    )
                    model_name_textbox = gr.Textbox(label="Model name")
                    revision_name_textbox = gr.Textbox(label="Revision commit", placeholder="main")
                    precision = gr.Dropdown(
                        choices=[i.value.name for i in Precision if i != Precision.Unknown],
                        label="Precision",
                        multiselect=False,
                        value="float16",
                        interactive=True,
                    )
                    base_model_name_textbox = gr.Textbox(label="Base model (for delta or adapter weights)")
                    vllm_version_type = gr.Dropdown(
                        choices=VLLM_VERSIONS,
                        label="vLLM version",
                        multiselect=False,
                        value="v0.9.2",
                        interactive=True,
                    )
                with gr.Column():
                    temperature_textbox = gr.Textbox(label="Sampling Temperature (default: 1.0)", placeholder="1.0")
                    top_p_textbox = gr.Textbox(label="Top-p (default: 1.0)", placeholder="1.0")
                    top_k_textbox = gr.Textbox(label="Top-k (default: -1)", placeholder="-1")
                    presence_penalty_textbox = gr.Textbox(label="Presence penalty (default: 0.0)", placeholder="0.0")
                    frequency_penalty_textbox = gr.Textbox(label="Frequency penalty (default: 0.0)", placeholder="0.0")
                    repetition_penalty_textbox = gr.Textbox(label="Repetition penalty (default: 1.0)", placeholder="1.0")
            
            login_button = gr.LoginButton()
            submit_button = gr.Button("Submit Eval")
            submission_result = gr.Markdown()
            event = submit_button.click(get_profile_and_organizations, inputs=[], outputs=[user_state, organization_state])
            event.then(
                add_new_eval_option1,
                [
                    benchmark_type,
                    model_name_textbox,
                    base_model_name_textbox,
                    revision_name_textbox,
                    precision,
                    temperature_textbox,
                    top_p_textbox,
                    top_k_textbox,
                    presence_penalty_textbox,
                    frequency_penalty_textbox,
                    repetition_penalty_textbox,
                    vllm_version_type,
                    user_state,
                    organization_state
                ],
                submission_result,
            )
            with gr.Row():
                    gr.Markdown(EVALUATION_QUEUE_TEXT_OPTION2, elem_classes="markdown-text")

            with gr.Row():
                gr.Markdown("## โœ‰๏ธโœจ Submit your model here! (if vLLM inference is unavailable)", elem_classes="markdown-text")

            with gr.Row():
                with gr.Column():
                    benchmark_type2 = gr.Dropdown(
                        choices=["TRUEBench v0.1"],
                        label="The name of the benchmark to be evaluated",
                        multiselect=False,
                        value="TRUEBench v0.1",
                        interactive=True,
                    )
                    model_name_textbox2 = gr.Textbox(label="Model name")
                    revision_name_textbox2 = gr.Textbox(label="Revision commit", placeholder="main")
                    precision2 = gr.Dropdown(
                        choices=[i.value.name for i in Precision if i != Precision.Unknown],
                        label="Precision",
                        multiselect=False,
                        value="float16",
                        interactive=True,
                    )
                    base_model_name_textbox2 = gr.Textbox(label="Base model (for delta or adapter weights)")
                    
                with gr.Column():
                    temperature_textbox2 = gr.Textbox(label="Sampling Temperature (default: 1.0)", placeholder="1.0")
                    top_p_textbox2 = gr.Textbox(label="Top-p (default: 1.0)", placeholder="1.0")
                    top_k_textbox2 = gr.Textbox(label="Top-k (default: -1)", placeholder="-1")
                    presence_penalty_textbox2 = gr.Textbox(label="Presence penalty (default: 0.0)", placeholder="0.0")
                    frequency_penalty_textbox2 = gr.Textbox(label="Frequency penalty (default: 0.0)", placeholder="0.0")
                    repetition_penalty_textbox2 = gr.Textbox(label="Repetition penalty (default: 1.0)", placeholder="1.0")

            with gr.Row():
                with gr.Column():
                    model_load_code_snippet_textbox = gr.Textbox(label="Code for model loading", lines=15, placeholder="model = AutoModel.from_pretrained('your model name', revision=revision)")
                with gr.Column():
                    inference_code_snippet_textbox = gr.Textbox(label="Code for inference", lines=15, placeholder="output = model(...)")
                with gr.Column():
                    terminate_code_snippet_textbox = gr.Textbox(label="Code for termination", lines=15)
            
            login_button2 = gr.LoginButton()
            
            submit_button2 = gr.Button("Submit Eval")
            submission_result2 = gr.Markdown()
            event2 = submit_button2.click(get_profile_and_organizations, inputs=[], outputs=[user_state, organization_state])
            event2.then(
                add_new_eval_option2,
                [
                    benchmark_type2,
                    model_name_textbox2,
                    base_model_name_textbox2,
                    revision_name_textbox2,
                    precision2,
                    temperature_textbox2,
                    top_p_textbox2,
                    top_k_textbox2,
                    presence_penalty_textbox2,
                    frequency_penalty_textbox2,
                    repetition_penalty_textbox2,
                    model_load_code_snippet_textbox,
                    inference_code_snippet_textbox,
                    terminate_code_snippet_textbox,
                    user_state,
                    organization_state
                ],
                submission_result2,
            )

            with gr.Row():
                    gr.Markdown(EVALUATION_QUEUE_TEXT_OPTION3, elem_classes="markdown-text")

    with gr.Row():
        with gr.Accordion("๐Ÿ“™ Citation", open=False):
            citation_button = gr.Textbox(
                value=CITATION_BUTTON_TEXT,
                label=CITATION_BUTTON_LABEL,
                lines=20,
                elem_id="citation-button",
                show_copy_button=True,
            )


scheduler = BackgroundScheduler()
scheduler.add_job(restart_space, "interval", seconds=1800)
scheduler.start()
demo.queue(default_concurrency_limit=40).launch()