Spaces:
AIR-Bench
/
Running on CPU Upgrade

File size: 23,701 Bytes
a3fa5e4
 
f766ce9
 
34e2886
f766ce9
ec8e2d4
 
a3d4c8d
f29af77
ec8e2d4
93fda91
 
ec8e2d4
 
 
 
93fda91
ec8e2d4
 
93fda91
f29af77
34e2886
 
ec8e2d4
 
 
34e2886
ec8e2d4
 
 
 
 
34e2886
 
f29af77
ec8e2d4
f765492
f766ce9
 
 
 
df659d0
34e2886
a3fa5e4
 
 
ec8e2d4
 
 
 
 
 
a3fa5e4
ec8e2d4
 
34e2886
f766ce9
5e11615
 
7845083
5e11615
2508d96
34e2886
5e11615
ec8e2d4
 
 
 
 
 
 
f30cbcc
5e11615
ec8e2d4
d62c98e
6f9f649
d62c98e
 
 
 
 
 
a3d4c8d
ec8e2d4
7845083
 
5e11615
ec8e2d4
 
 
 
 
 
 
bf586e3
5e11615
ec8e2d4
 
6f9f649
ec8e2d4
 
 
 
 
 
 
 
7845083
 
5e11615
7845083
5e11615
 
 
 
 
 
 
 
 
 
 
f70b03c
5e11615
 
 
 
 
 
 
 
f70b03c
649e0fb
f766ce9
b80bda9
83bdd4e
 
f766ce9
 
 
 
 
0785fe4
f766ce9
5e11615
b80bda9
0785fe4
 
 
 
 
fe361b7
0785fe4
 
fe361b7
0785fe4
 
fe361b7
0785fe4
 
 
fe361b7
0785fe4
 
 
 
 
 
 
 
fe361b7
7845083
0401aeb
0785fe4
a3d4c8d
 
 
b80bda9
5e11615
 
fe361b7
0401aeb
7845083
e050b39
0785fe4
6f9f649
0401aeb
 
0785fe4
5e11615
fe361b7
 
 
b80bda9
fe361b7
0785fe4
a0387d8
0785fe4
fe361b7
5e11615
fe361b7
0401aeb
ec8e2d4
0785fe4
2508d96
0785fe4
 
 
0401aeb
0785fe4
0401aeb
e050b39
0401aeb
 
 
23b3543
0785fe4
a3d4c8d
 
 
0401aeb
a3d4c8d
 
 
e050b39
5e11615
 
0401aeb
a3d4c8d
 
 
 
 
 
 
e050b39
b80bda9
0785fe4
6f9f649
0401aeb
 
 
5e11615
fe361b7
 
0401aeb
b80bda9
fe361b7
0785fe4
5808d8f
fe361b7
5e11615
0785fe4
fe361b7
 
 
0401aeb
 
0785fe4
fe361b7
0785fe4
0401aeb
ec8e2d4
0785fe4
0401aeb
0785fe4
a3d4c8d
0401aeb
a3d4c8d
0785fe4
 
0401aeb
0785fe4
0401aeb
 
23b3543
0401aeb
26e4c47
a3d4c8d
0401aeb
 
 
23b3543
 
5e11615
 
0401aeb
 
0785fe4
 
 
6f9f649
0401aeb
 
 
5e11615
fe361b7
 
0401aeb
64a83a1
fe361b7
f30cbcc
0401aeb
fe361b7
5e11615
0785fe4
fe361b7
 
 
0401aeb
 
0785fe4
fe361b7
0785fe4
0401aeb
ec8e2d4
0785fe4
 
 
 
 
 
fe361b7
0785fe4
 
fe361b7
0785fe4
 
 
fe361b7
0785fe4
 
 
fe361b7
1a22df4
0785fe4
 
 
 
 
fe361b7
b80bda9
a3d4c8d
b80bda9
0785fe4
0401aeb
26e4c47
bf586e3
 
5e11615
 
0401aeb
 
0785fe4
b80bda9
0785fe4
6f9f649
0401aeb
 
0785fe4
5e11615
fe361b7
 
 
b80bda9
fe361b7
0785fe4
b80bda9
0785fe4
fe361b7
5e11615
0785fe4
fe361b7
 
 
 
0785fe4
 
fe361b7
0785fe4
0401aeb
ec8e2d4
0785fe4
 
 
 
0401aeb
0785fe4
0401aeb
 
 
26e4c47
a3d4c8d
0401aeb
a3d4c8d
f70b03c
0401aeb
26e4c47
a3d4c8d
0401aeb
 
 
f70b03c
 
5e11615
 
0401aeb
 
0785fe4
f30cbcc
0785fe4
6f9f649
0401aeb
 
 
5e11615
fe361b7
 
0401aeb
b80bda9
fe361b7
0785fe4
 
fe361b7
5e11615
0785fe4
fe361b7
 
 
0401aeb
 
0785fe4
fe361b7
0785fe4
0401aeb
ec8e2d4
0785fe4
 
0401aeb
26e4c47
a3d4c8d
0401aeb
 
 
ec8e2d4
0785fe4
 
a3d4c8d
0785fe4
0401aeb
 
 
26e4c47
a3d4c8d
0401aeb
 
 
0785fe4
64a83a1
5e11615
 
0401aeb
 
f765492
 
0785fe4
6f9f649
0401aeb
 
 
5e11615
fe361b7
 
0401aeb
64a83a1
fe361b7
0785fe4
0401aeb
fe361b7
5e11615
0785fe4
fe361b7
 
 
0401aeb
 
0785fe4
fe361b7
0785fe4
0401aeb
ec8e2d4
0785fe4
8ec7973
36c5a0c
 
 
 
 
 
a30a228
 
f000c74
a30a228
f000c74
240d9ce
4cf5eb9
240d9ce
ec8e2d4
240d9ce
4cf5eb9
ec8e2d4
240d9ce
69a9e46
 
93fda91
 
69a9e46
ec8e2d4
 
4a6f9cd
d00fb74
2c777fc
36c5a0c
d00fb74
9400714
d00fb74
 
ec8e2d4
 
2c777fc
4a6f9cd
 
 
9f44d20
 
 
 
 
ec8e2d4
 
4a6f9cd
 
 
 
 
d00fb74
240d9ce
 
d00fb74
ec8e2d4
4a6f9cd
 
ec8e2d4
4a6f9cd
36c5a0c
8a1daf9
 
f766ce9
dd592d8
 
 
 
e58b5e9
 
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
import os

import gradio as gr
from apscheduler.schedulers.background import BackgroundScheduler
from huggingface_hub import snapshot_download

from src.about import BENCHMARKS_TEXT, EVALUATION_QUEUE_TEXT, INTRODUCTION_TEXT, TITLE
from src.benchmarks import LongDocBenchmarks, QABenchmarks
from src.columns import COL_NAME_RERANKING_MODEL, COL_NAME_RETRIEVAL_MODEL
from src.components import (
    get_anonymous_checkbox,
    get_domain_dropdown,
    get_language_dropdown,
    get_leaderboard_table,
    get_metric_dropdown,
    get_noreranking_dropdown,
    get_reranking_dropdown,
    get_revision_and_ts_checkbox,
    get_search_bar,
    get_version_dropdown,
)
from src.css_html_js import custom_css
from src.envs import (
    API,
    BENCHMARK_VERSION_LIST,
    DEFAULT_METRIC_LONG_DOC,
    DEFAULT_METRIC_QA,
    EVAL_RESULTS_PATH,
    LATEST_BENCHMARK_VERSION,
    METRIC_LIST,
    REPO_ID,
    RESULTS_REPO,
    TOKEN,
)
from src.loaders import load_eval_results
from src.models import TaskType, model_hyperlink
from src.utils import remove_html, reset_rank, set_listeners, submit_results, update_metric, upload_file


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


try:
    if not os.environ.get("LOCAL_MODE", False):
        print("Running in local mode")
        snapshot_download(
            repo_id=RESULTS_REPO,
            local_dir=EVAL_RESULTS_PATH,
            repo_type="dataset",
            tqdm_class=None,
            etag_timeout=30,
            token=TOKEN,
        )
except Exception:
    print("failed to download")
    restart_space()

global ds_dict
ds_dict = load_eval_results(EVAL_RESULTS_PATH)
global datastore
datastore = ds_dict[LATEST_BENCHMARK_VERSION]


def update_qa_metric(
    metric: str,
    domains: list,
    langs: list,
    reranking_model: list,
    query: str,
    show_anonymous: bool,
    show_revision_and_timestamp: bool,
):
    global datastore
    return update_metric(
        datastore,
        TaskType.qa,
        metric,
        domains,
        langs,
        reranking_model,
        query,
        show_anonymous,
        show_revision_and_timestamp,
    )


def update_doc_metric(
    metric: str,
    domains: list,
    langs: list,
    reranking_model: list,
    query: str,
    show_anonymous: bool,
    show_revision_and_timestamp,
):
    global datastore
    return update_metric(
        datastore,
        TaskType.long_doc,
        metric,
        domains,
        langs,
        reranking_model,
        query,
        show_anonymous,
        show_revision_and_timestamp,
    )


def update_qa_version(version):
    global datastore
    global ds_dict
    datastore = ds_dict[version]
    domain_elem = get_domain_dropdown(QABenchmarks[datastore.slug])
    lang_elem = get_language_dropdown(QABenchmarks[datastore.slug])
    model_elem = get_reranking_dropdown(datastore.reranking_models)
    df_elem = get_leaderboard_table(datastore.qa_fmt_df, datastore.qa_types)
    hidden_df_elem = get_leaderboard_table(datastore.qa_raw_df, datastore.qa_types, visible=False)
    return domain_elem, lang_elem, model_elem, df_elem, hidden_df_elem


def update_doc_version(version):
    global datastore
    global ds_dict
    datastore = ds_dict[version]
    domain_elem = get_domain_dropdown(LongDocBenchmarks[datastore.slug])
    lang_elem = get_language_dropdown(LongDocBenchmarks[datastore.slug])
    model_elem = get_reranking_dropdown(datastore.reranking_models)
    df_elem = get_leaderboard_table(datastore.doc_fmt_df, datastore.doc_types)
    hidden_df_elem = get_leaderboard_table(datastore.doc_raw_df, datastore.doc_types, visible=False)
    return domain_elem, lang_elem, model_elem, df_elem, hidden_df_elem


demo = gr.Blocks(css=custom_css)

BM25_LINK = model_hyperlink("https://github.com/castorini/pyserini", "BM25")

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("Results", elem_id="results-tab-table"):
            with gr.Row():
                version = get_version_dropdown()

            with gr.TabItem("QA", elem_id="qa-benchmark-tab-table", id=0):
                with gr.Row():
                    with gr.Column(min_width=320):
                        # select domain
                        with gr.Row():
                            domains = get_domain_dropdown(QABenchmarks[datastore.slug])
                        # select language
                        with gr.Row():
                            langs = get_language_dropdown(QABenchmarks[datastore.slug])
                    with gr.Column():
                        # select the metric
                        metric = get_metric_dropdown(METRIC_LIST, DEFAULT_METRIC_QA)
                        with gr.Row():
                            show_anonymous = get_anonymous_checkbox()
                        with gr.Row():
                            show_rev_ts = get_revision_and_ts_checkbox()
                with gr.Tabs(elem_classes="tab-buttons") as sub_tabs:
                    with gr.TabItem("Retrieval + Reranking", id=10):
                        with gr.Row():
                            # search retrieval models
                            with gr.Column():
                                search_bar = get_search_bar()
                            # select reranking models
                            with gr.Column():
                                models = get_reranking_dropdown(datastore.reranking_models)
                        #  shown_table
                        qa_df_elem_ret_rerank = get_leaderboard_table(datastore.qa_fmt_df, datastore.qa_types)
                        # Dummy leaderboard for handling the case when the user uses backspace key
                        qa_df_elem_ret_rerank_hidden = get_leaderboard_table(
                            datastore.qa_raw_df, datastore.qa_types, visible=False
                        )

                        version.change(
                            update_qa_version,
                            version,
                            [domains, langs, models, qa_df_elem_ret_rerank, qa_df_elem_ret_rerank_hidden],
                        )

                        set_listeners(
                            TaskType.qa,
                            qa_df_elem_ret_rerank,
                            qa_df_elem_ret_rerank_hidden,
                            search_bar,
                            version,
                            domains,
                            langs,
                            models,
                            show_anonymous,
                            show_rev_ts,
                        )

                        # set metric listener
                        metric.change(
                            update_qa_metric,
                            [metric, domains, langs, models, search_bar, show_anonymous, show_rev_ts],
                            qa_df_elem_ret_rerank,
                            queue=True,
                        )

                    with gr.TabItem("Retrieval Only", id=11):
                        with gr.Row():
                            with gr.Column(scale=1):
                                search_bar_ret = get_search_bar()
                            with gr.Column(scale=1):
                                models_ret = get_noreranking_dropdown()

                        _qa_df_ret = datastore.qa_fmt_df[datastore.qa_fmt_df[COL_NAME_RERANKING_MODEL] == "NoReranker"]
                        _qa_df_ret = reset_rank(_qa_df_ret)
                        qa_df_elem_ret = get_leaderboard_table(_qa_df_ret, datastore.qa_types)

                        # Dummy leaderboard for handling the case when the user uses backspace key
                        _qa_df_ret_hidden = datastore.qa_raw_df[
                            datastore.qa_raw_df[COL_NAME_RERANKING_MODEL] == "NoReranker"
                        ]
                        _qa_df_ret_hidden = reset_rank(_qa_df_ret_hidden)
                        qa_df_elem_ret_hidden = get_leaderboard_table(
                            _qa_df_ret_hidden, datastore.qa_types, visible=False
                        )

                        version.change(
                            update_qa_version,
                            version,
                            [
                                domains,
                                langs,
                                models_ret,
                                qa_df_elem_ret,
                                qa_df_elem_ret_hidden,
                            ],
                        )

                        set_listeners(
                            TaskType.qa,
                            qa_df_elem_ret,
                            qa_df_elem_ret_hidden,
                            search_bar_ret,
                            version,
                            domains,
                            langs,
                            models_ret,
                            show_anonymous,
                            show_rev_ts,
                        )

                        metric.change(
                            update_qa_metric,
                            [
                                metric,
                                domains,
                                langs,
                                models_ret,
                                search_bar_ret,
                                show_anonymous,
                                show_rev_ts,
                            ],
                            qa_df_elem_ret,
                            queue=True,
                        )

                    with gr.TabItem("Reranking Only", id=12):
                        _qa_df_rerank = datastore.qa_fmt_df[datastore.qa_fmt_df[COL_NAME_RETRIEVAL_MODEL] == BM25_LINK]
                        _qa_df_rerank = reset_rank(_qa_df_rerank)
                        qa_rerank_models = _qa_df_rerank[COL_NAME_RERANKING_MODEL].apply(remove_html).unique().tolist()
                        with gr.Row():
                            with gr.Column(scale=1):
                                qa_models_rerank = get_reranking_dropdown(qa_rerank_models)
                            with gr.Column(scale=1):
                                qa_search_bar_rerank = gr.Textbox(show_label=False, visible=False)
                        qa_df_elem_rerank = get_leaderboard_table(_qa_df_rerank, datastore.qa_types)

                        _qa_df_rerank_hidden = datastore.qa_raw_df[
                            datastore.qa_raw_df[COL_NAME_RETRIEVAL_MODEL] == BM25_LINK
                        ]
                        _qa_df_rerank_hidden = reset_rank(_qa_df_rerank_hidden)
                        qa_df_elem_rerank_hidden = get_leaderboard_table(
                            _qa_df_rerank_hidden, datastore.qa_types, visible=False
                        )

                        version.change(
                            update_qa_version,
                            version,
                            [domains, langs, qa_models_rerank, qa_df_elem_rerank, qa_df_elem_rerank_hidden],
                        )

                        set_listeners(
                            TaskType.qa,
                            qa_df_elem_rerank,
                            qa_df_elem_rerank_hidden,
                            qa_search_bar_rerank,
                            version,
                            domains,
                            langs,
                            qa_models_rerank,
                            show_anonymous,
                            show_rev_ts,
                        )

                        metric.change(
                            update_qa_metric,
                            [
                                metric,
                                domains,
                                langs,
                                qa_models_rerank,
                                qa_search_bar_rerank,
                                show_anonymous,
                                show_rev_ts,
                            ],
                            qa_df_elem_rerank,
                            queue=True,
                        )
            with gr.TabItem("Long Doc", elem_id="long-doc-benchmark-tab-table", id=1):
                with gr.Row():
                    with gr.Column(min_width=320):
                        # select domain
                        with gr.Row():
                            domains = get_domain_dropdown(LongDocBenchmarks[datastore.slug])
                        # select language
                        with gr.Row():
                            langs = get_language_dropdown(LongDocBenchmarks[datastore.slug])
                    with gr.Column():
                        # select the metric
                        with gr.Row():
                            metric = get_metric_dropdown(METRIC_LIST, DEFAULT_METRIC_LONG_DOC)
                        with gr.Row():
                            show_anonymous = get_anonymous_checkbox()
                        with gr.Row():
                            show_rev_ts = get_revision_and_ts_checkbox()
                with gr.Tabs(elem_classes="tab-buttons"):
                    with gr.TabItem("Retrieval + Reranking", id=20):
                        with gr.Row():
                            with gr.Column():
                                search_bar = get_search_bar()
                            with gr.Column():
                                models = get_reranking_dropdown(datastore.reranking_models)

                        doc_df_elem_ret_rerank = get_leaderboard_table(datastore.doc_fmt_df, datastore.doc_types)

                        # Dummy leaderboard for handling the case when the user uses backspace key
                        doc_df_elem_ret_rerank_hidden = get_leaderboard_table(
                            datastore.doc_raw_df, datastore.doc_types, visible=False
                        )

                        version.change(
                            update_doc_version,
                            version,
                            [domains, langs, models, doc_df_elem_ret_rerank, doc_df_elem_ret_rerank_hidden],
                        )

                        set_listeners(
                            TaskType.long_doc,
                            doc_df_elem_ret_rerank,
                            doc_df_elem_ret_rerank_hidden,
                            search_bar,
                            version,
                            domains,
                            langs,
                            models,
                            show_anonymous,
                            show_rev_ts,
                        )

                        # set metric listener
                        metric.change(
                            update_doc_metric,
                            [
                                metric,
                                domains,
                                langs,
                                models,
                                search_bar,
                                show_anonymous,
                                show_rev_ts,
                            ],
                            doc_df_elem_ret_rerank,
                            queue=True,
                        )
                    with gr.TabItem("Retrieval Only", id=21):
                        with gr.Row():
                            with gr.Column(scale=1):
                                search_bar_ret = get_search_bar()
                            with gr.Column(scale=1):
                                models_ret = get_noreranking_dropdown()

                        _doc_df_ret = datastore.doc_fmt_df[
                            datastore.doc_fmt_df[COL_NAME_RERANKING_MODEL] == "NoReranker"
                        ]
                        _doc_df_ret = reset_rank(_doc_df_ret)
                        doc_df_elem_ret = get_leaderboard_table(_doc_df_ret, datastore.doc_types)

                        _doc_df_ret_hidden = datastore.doc_raw_df[
                            datastore.doc_raw_df[COL_NAME_RERANKING_MODEL] == "NoReranker"
                        ]
                        _doc_df_ret_hidden = reset_rank(_doc_df_ret_hidden)
                        doc_df_elem_ret_hidden = get_leaderboard_table(
                            _doc_df_ret_hidden, datastore.doc_types, visible=False
                        )

                        version.change(
                            update_doc_version,
                            version,
                            [domains, langs, models_ret, doc_df_elem_ret, doc_df_elem_ret_hidden],
                        )

                        set_listeners(
                            TaskType.long_doc,
                            doc_df_elem_ret,
                            doc_df_elem_ret_hidden,
                            search_bar_ret,
                            version,
                            domains,
                            langs,
                            models_ret,
                            show_anonymous,
                            show_rev_ts,
                        )

                        metric.change(
                            update_doc_metric,
                            [
                                metric,
                                domains,
                                langs,
                                models_ret,
                                search_bar_ret,
                                show_anonymous,
                                show_rev_ts,
                            ],
                            doc_df_elem_ret,
                            queue=True,
                        )
                    with gr.TabItem("Reranking Only", id=22):
                        _doc_df_rerank = datastore.doc_fmt_df[
                            datastore.doc_fmt_df[COL_NAME_RETRIEVAL_MODEL] == BM25_LINK
                        ]
                        _doc_df_rerank = reset_rank(_doc_df_rerank)
                        doc_rerank_models = (
                            _doc_df_rerank[COL_NAME_RERANKING_MODEL].apply(remove_html).unique().tolist()
                        )
                        with gr.Row():
                            with gr.Column(scale=1):
                                doc_models_rerank = get_reranking_dropdown(doc_rerank_models)
                            with gr.Column(scale=1):
                                doc_search_bar_rerank = gr.Textbox(show_label=False, visible=False)
                        doc_df_elem_rerank = get_leaderboard_table(_doc_df_rerank, datastore.doc_types)
                        _doc_df_rerank_hidden = datastore.doc_raw_df[
                            datastore.doc_raw_df[COL_NAME_RETRIEVAL_MODEL] == BM25_LINK
                        ]
                        _doc_df_rerank_hidden = reset_rank(_doc_df_rerank_hidden)
                        doc_df_elem_rerank_hidden = get_leaderboard_table(
                            _doc_df_rerank_hidden, datastore.doc_types, visible=False
                        )

                        version.change(
                            update_doc_version,
                            version,
                            [domains, langs, doc_models_rerank, doc_df_elem_rerank, doc_df_elem_rerank_hidden],
                        )

                        set_listeners(
                            TaskType.long_doc,
                            doc_df_elem_rerank,
                            doc_df_elem_rerank_hidden,
                            doc_search_bar_rerank,
                            version,
                            domains,
                            langs,
                            doc_models_rerank,
                            show_anonymous,
                            show_rev_ts,
                        )

                        metric.change(
                            update_doc_metric,
                            [
                                metric,
                                domains,
                                langs,
                                doc_models_rerank,
                                doc_search_bar_rerank,
                                show_anonymous,
                                show_rev_ts,
                            ],
                            doc_df_elem_rerank,
                            queue=True,
                        )

        with gr.TabItem("🚀Submit here!", elem_id="submit-tab-table", id=2):
            with gr.Column():
                with gr.Row():
                    gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
                with gr.Row():
                    gr.Markdown("## ✉️Submit your model here!", elem_classes="markdown-text")
                with gr.Row():
                    with gr.Column():
                        model_name = gr.Textbox(label="Retrieval Method name")
                    with gr.Column():
                        model_url = gr.Textbox(label="Retrieval Method URL")
                with gr.Row():
                    with gr.Column():
                        reranking_model_name = gr.Textbox(
                            label="Reranking Model name", info="Optional", value="NoReranker"
                        )
                    with gr.Column():
                        reranking_model_url = gr.Textbox(label="Reranking Model URL", info="Optional", value="")
                with gr.Row():
                    with gr.Column():
                        benchmark_version = gr.Dropdown(
                            BENCHMARK_VERSION_LIST,
                            value=LATEST_BENCHMARK_VERSION,
                            interactive=True,
                            label="AIR-Bench Version",
                        )
                with gr.Row():
                    upload_button = gr.UploadButton("Click to upload search results", file_count="single")
                with gr.Row():
                    file_output = gr.File()
                with gr.Row():
                    is_anonymous = gr.Checkbox(
                        label="Nope. I want to submit anonymously 🥷",
                        value=False,
                        info="Do you want to shown on the leaderboard by default?",
                    )
                with gr.Row():
                    submit_button = gr.Button("Submit")
                with gr.Row():
                    submission_result = gr.Markdown()
                upload_button.upload(
                    upload_file,
                    [
                        upload_button,
                    ],
                    file_output,
                )
                submit_button.click(
                    submit_results,
                    [
                        file_output,
                        model_name,
                        model_url,
                        reranking_model_name,
                        reranking_model_url,
                        benchmark_version,
                        is_anonymous,
                    ],
                    submission_result,
                    show_progress="hidden",
                )

        with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=3):
            gr.Markdown(BENCHMARKS_TEXT, elem_classes="markdown-text")

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