weichiang commited on
Commit
ff7bf79
β€’
1 Parent(s): 94ee81e
Files changed (4) hide show
  1. README.md +0 -1
  2. app.py +0 -706
  3. index.html +12 -0
  4. style.css +39 -0
README.md CHANGED
@@ -5,7 +5,6 @@ colorFrom: indigo
5
  colorTo: green
6
  sdk: gradio
7
  sdk_version: 3.50.2
8
- app_file: app.py
9
  pinned: false
10
  license: apache-2.0
11
  tags:
 
5
  colorTo: green
6
  sdk: gradio
7
  sdk_version: 3.50.2
 
8
  pinned: false
9
  license: apache-2.0
10
  tags:
app.py DELETED
@@ -1,706 +0,0 @@
1
- """A gradio app that renders a static leaderboard. This is used for Hugging Face Space."""
2
- import ast
3
- import argparse
4
- import glob
5
- import pickle
6
-
7
- import gradio as gr
8
- import numpy as np
9
- import pandas as pd
10
-
11
-
12
- # notebook_url = "https://colab.research.google.com/drive/1RAWb22-PFNI-X1gPVzc927SGUdfr6nsR?usp=sharing"
13
- notebook_url = "https://colab.research.google.com/drive/1KdwokPjirkTmpO_P1WByFNFiqxWQquwH#scrollTo=o_CpbkGEbhrK"
14
-
15
- basic_component_values = [None] * 6
16
- leader_component_values = [None] * 5
17
-
18
-
19
- def make_default_md(arena_df, elo_results):
20
- total_votes = sum(arena_df["num_battles"]) // 2
21
- total_models = len(arena_df)
22
-
23
- leaderboard_md = f"""
24
- # πŸ† LMSYS Chatbot Arena Leaderboard
25
- | [Vote](https://chat.lmsys.org) | [Blog](https://lmsys.org/blog/2023-05-03-arena/) | [GitHub](https://github.com/lm-sys/FastChat) | [Paper](https://arxiv.org/abs/2306.05685) | [Dataset](https://github.com/lm-sys/FastChat/blob/main/docs/dataset_release.md) | [Twitter](https://twitter.com/lmsysorg) | [Discord](https://discord.gg/HSWAKCrnFx) |
26
-
27
- LMSYS [Chatbot Arena](https://lmsys.org/blog/2023-05-03-arena/) is a crowdsourced open platform for LLM evals.
28
- We've collected over **500,000** human preference votes to rank LLMs with the Elo ranking system.
29
- """
30
- return leaderboard_md
31
-
32
-
33
- def make_arena_leaderboard_md(arena_df):
34
- total_votes = sum(arena_df["num_battles"]) // 2
35
- total_models = len(arena_df)
36
- space = "   "
37
- leaderboard_md = f"""
38
- Total #models: **{total_models}**.{space} Total #votes: **{"{:,}".format(total_votes)}**.{space} Last updated: April 11, 2024.
39
-
40
- πŸ“£ **NEW!** View leaderboard for different categories (e.g., coding, long user query)!
41
-
42
- Code to recreate leaderboard tables and plots in this [notebook]({notebook_url}). Cast your vote πŸ—³οΈ at [chat.lmsys.org](https://chat.lmsys.org)!
43
- """
44
- return leaderboard_md
45
-
46
- def make_category_arena_leaderboard_md(arena_df, arena_subset_df, name="Overall"):
47
- total_votes = sum(arena_df["num_battles"]) // 2
48
- total_models = len(arena_df)
49
- space = "   "
50
- total_subset_votes = sum(arena_subset_df["num_battles"]) // 2
51
- total_subset_models = len(arena_subset_df)
52
- leaderboard_md = f"""### {cat_name_to_explanation[name]}
53
- #### [Coverage] {space} #models: **{total_subset_models} ({round(total_subset_models/total_models *100)}%)** {space} #votes: **{"{:,}".format(total_subset_votes)} ({round(total_subset_votes/total_votes * 100)}%)**{space}
54
- """
55
- return leaderboard_md
56
-
57
- def make_full_leaderboard_md(elo_results):
58
- leaderboard_md = f"""
59
- Three benchmarks are displayed: **Arena Elo**, **MT-Bench** and **MMLU**.
60
- - [Chatbot Arena](https://chat.lmsys.org/?arena) - a crowdsourced, randomized battle platform. We use 500K+ user votes to compute Elo ratings.
61
- - [MT-Bench](https://arxiv.org/abs/2306.05685): a set of challenging multi-turn questions. We use GPT-4 to grade the model responses.
62
- - [MMLU](https://arxiv.org/abs/2009.03300) (5-shot): a test to measure a model's multitask accuracy on 57 tasks.
63
-
64
- πŸ’» Code: The MT-bench scores (single-answer grading on a scale of 10) are computed by [fastchat.llm_judge](https://github.com/lm-sys/FastChat/tree/main/fastchat/llm_judge).
65
- The MMLU scores are mostly computed by [InstructEval](https://github.com/declare-lab/instruct-eval).
66
- Higher values are better for all benchmarks. Empty cells mean not available.
67
- """
68
- return leaderboard_md
69
-
70
-
71
- def make_leaderboard_md_live(elo_results):
72
- leaderboard_md = f"""
73
- # Leaderboard
74
- Last updated: {elo_results["last_updated_datetime"]}
75
- {elo_results["leaderboard_table"]}
76
- """
77
- return leaderboard_md
78
-
79
-
80
- def update_elo_components(max_num_files, elo_results_file):
81
- log_files = get_log_files(max_num_files)
82
-
83
- # Leaderboard
84
- if elo_results_file is None: # Do live update
85
- battles = clean_battle_data(log_files)
86
- elo_results = report_elo_analysis_results(battles)
87
-
88
- leader_component_values[0] = make_leaderboard_md_live(elo_results)
89
- leader_component_values[1] = elo_results["win_fraction_heatmap"]
90
- leader_component_values[2] = elo_results["battle_count_heatmap"]
91
- leader_component_values[3] = elo_results["bootstrap_elo_rating"]
92
- leader_component_values[4] = elo_results["average_win_rate_bar"]
93
-
94
- # Basic stats
95
- basic_stats = report_basic_stats(log_files)
96
- md0 = f"Last updated: {basic_stats['last_updated_datetime']}"
97
-
98
- md1 = "### Action Histogram\n"
99
- md1 += basic_stats["action_hist_md"] + "\n"
100
-
101
- md2 = "### Anony. Vote Histogram\n"
102
- md2 += basic_stats["anony_vote_hist_md"] + "\n"
103
-
104
- md3 = "### Model Call Histogram\n"
105
- md3 += basic_stats["model_hist_md"] + "\n"
106
-
107
- md4 = "### Model Call (Last 24 Hours)\n"
108
- md4 += basic_stats["num_chats_last_24_hours"] + "\n"
109
-
110
- basic_component_values[0] = md0
111
- basic_component_values[1] = basic_stats["chat_dates_bar"]
112
- basic_component_values[2] = md1
113
- basic_component_values[3] = md2
114
- basic_component_values[4] = md3
115
- basic_component_values[5] = md4
116
-
117
-
118
- def update_worker(max_num_files, interval, elo_results_file):
119
- while True:
120
- tic = time.time()
121
- update_elo_components(max_num_files, elo_results_file)
122
- durtaion = time.time() - tic
123
- print(f"update duration: {durtaion:.2f} s")
124
- time.sleep(max(interval - durtaion, 0))
125
-
126
-
127
- def load_demo(url_params, request: gr.Request):
128
- logger.info(f"load_demo. ip: {request.client.host}. params: {url_params}")
129
- return basic_component_values + leader_component_values
130
-
131
-
132
- def model_hyperlink(model_name, link):
133
- return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
134
-
135
-
136
- def load_leaderboard_table_csv(filename, add_hyperlink=True):
137
- lines = open(filename).readlines()
138
- heads = [v.strip() for v in lines[0].split(",")]
139
- rows = []
140
- for i in range(1, len(lines)):
141
- row = [v.strip() for v in lines[i].split(",")]
142
- for j in range(len(heads)):
143
- item = {}
144
- for h, v in zip(heads, row):
145
- if h == "Arena Elo rating":
146
- if v != "-":
147
- v = int(ast.literal_eval(v))
148
- else:
149
- v = np.nan
150
- elif h == "MMLU":
151
- if v != "-":
152
- v = round(ast.literal_eval(v) * 100, 1)
153
- else:
154
- v = np.nan
155
- elif h == "MT-bench (win rate %)":
156
- if v != "-":
157
- v = round(ast.literal_eval(v[:-1]), 1)
158
- else:
159
- v = np.nan
160
- elif h == "MT-bench (score)":
161
- if v != "-":
162
- v = round(ast.literal_eval(v), 2)
163
- else:
164
- v = np.nan
165
- item[h] = v
166
- if add_hyperlink:
167
- item["Model"] = model_hyperlink(item["Model"], item["Link"])
168
- rows.append(item)
169
-
170
- return rows
171
-
172
-
173
- def build_basic_stats_tab():
174
- empty = "Loading ..."
175
- basic_component_values[:] = [empty, None, empty, empty, empty, empty]
176
-
177
- md0 = gr.Markdown(empty)
178
- gr.Markdown("#### Figure 1: Number of model calls and votes")
179
- plot_1 = gr.Plot(show_label=False)
180
- with gr.Row():
181
- with gr.Column():
182
- md1 = gr.Markdown(empty)
183
- with gr.Column():
184
- md2 = gr.Markdown(empty)
185
- with gr.Row():
186
- with gr.Column():
187
- md3 = gr.Markdown(empty)
188
- with gr.Column():
189
- md4 = gr.Markdown(empty)
190
- return [md0, plot_1, md1, md2, md3, md4]
191
-
192
- def get_full_table(arena_df, model_table_df):
193
- values = []
194
- for i in range(len(model_table_df)):
195
- row = []
196
- model_key = model_table_df.iloc[i]["key"]
197
- model_name = model_table_df.iloc[i]["Model"]
198
- # model display name
199
- row.append(model_name)
200
- if model_key in arena_df.index:
201
- idx = arena_df.index.get_loc(model_key)
202
- row.append(round(arena_df.iloc[idx]["rating"]))
203
- else:
204
- row.append(np.nan)
205
- row.append(model_table_df.iloc[i]["MT-bench (score)"])
206
- row.append(model_table_df.iloc[i]["MMLU"])
207
- # Organization
208
- row.append(model_table_df.iloc[i]["Organization"])
209
- # license
210
- row.append(model_table_df.iloc[i]["License"])
211
-
212
- values.append(row)
213
- values.sort(key=lambda x: -x[1] if not np.isnan(x[1]) else 1e9)
214
- return values
215
-
216
- def create_ranking_str(ranking, ranking_difference):
217
- if ranking_difference > 0:
218
- # return f"{int(ranking)} (\u2191{int(ranking_difference)})"
219
- return f"{int(ranking)} \u2191"
220
- elif ranking_difference < 0:
221
- # return f"{int(ranking)} (\u2193{int(-ranking_difference)})"
222
- return f"{int(ranking)} \u2193"
223
- else:
224
- return f"{int(ranking)}"
225
-
226
- def recompute_final_ranking(arena_df):
227
- # compute ranking based on CI
228
- ranking = {}
229
- for i, model_a in enumerate(arena_df.index):
230
- ranking[model_a] = 1
231
- for j, model_b in enumerate(arena_df.index):
232
- if i == j:
233
- continue
234
- if arena_df.loc[model_b]["rating_q025"] > arena_df.loc[model_a]["rating_q975"]:
235
- ranking[model_a] += 1
236
- return list(ranking.values())
237
-
238
- def get_arena_table(arena_df, model_table_df, arena_subset_df=None):
239
- arena_df = arena_df.sort_values(by=["final_ranking", "rating"], ascending=[True, False])
240
- arena_df = arena_df[arena_df["num_battles"] > 2000]
241
- arena_df["final_ranking"] = recompute_final_ranking(arena_df)
242
- arena_df = arena_df.sort_values(by=["final_ranking"], ascending=True)
243
-
244
- # arena_df["final_ranking"] = range(1, len(arena_df) + 1)
245
- # sort by rating
246
- if arena_subset_df is not None:
247
- # filter out models not in the arena_df
248
- arena_subset_df = arena_subset_df[arena_subset_df.index.isin(arena_df.index)]
249
- arena_subset_df = arena_subset_df.sort_values(by=["rating"], ascending=False)
250
- # arena_subset_df = arena_subset_df.sort_values(by=["final_ranking"], ascending=True)
251
- # arena_subset_df = arena_subset_df[arena_subset_df["num_battles"] > 500]
252
- arena_subset_df["final_ranking"] = recompute_final_ranking(arena_subset_df)
253
- # keep only the models in the subset in arena_df and recompute final_ranking
254
- arena_df = arena_df[arena_df.index.isin(arena_subset_df.index)]
255
- # recompute final ranking
256
- arena_df["final_ranking"] = recompute_final_ranking(arena_df)
257
-
258
- # assign ranking by the order
259
- arena_subset_df["final_ranking_no_tie"] = range(1, len(arena_subset_df) + 1)
260
- arena_df["final_ranking_no_tie"] = range(1, len(arena_df) + 1)
261
- # join arena_df and arena_subset_df on index
262
- arena_df = arena_subset_df.join(arena_df["final_ranking"], rsuffix="_global", how="inner")
263
- arena_df["ranking_difference"] = arena_df["final_ranking_global"] - arena_df["final_ranking"]
264
-
265
- # no tie version
266
- # arena_df = arena_subset_df.join(arena_df["final_ranking_no_tie"], rsuffix="_global", how="inner")
267
- # arena_df["ranking_difference"] = arena_df["final_ranking_no_tie_global"] - arena_df["final_ranking_no_tie"]
268
-
269
- arena_df = arena_df.sort_values(by=["final_ranking", "rating"], ascending=[True, False])
270
- arena_df["final_ranking"] = arena_df.apply(lambda x: create_ranking_str(x["final_ranking"], x["ranking_difference"]), axis=1)
271
-
272
- values = []
273
- for i in range(len(arena_df)):
274
- row = []
275
- model_key = arena_df.index[i]
276
- try: # this is a janky fix for where the model key is not in the model table (model table and arena table dont contain all the same models)
277
- model_name = model_table_df[model_table_df["key"] == model_key]["Model"].values[
278
- 0
279
- ]
280
- # rank
281
- ranking = arena_df.iloc[i].get("final_ranking") or i+1
282
- row.append(ranking)
283
- if arena_subset_df is not None:
284
- row.append(arena_df.iloc[i].get("ranking_difference") or 0)
285
- # model display name
286
- row.append(model_name)
287
- # elo rating
288
- row.append(round(arena_df.iloc[i]["rating"]))
289
- upper_diff = round(
290
- arena_df.iloc[i]["rating_q975"] - arena_df.iloc[i]["rating"]
291
- )
292
- lower_diff = round(
293
- arena_df.iloc[i]["rating"] - arena_df.iloc[i]["rating_q025"]
294
- )
295
- row.append(f"+{upper_diff}/-{lower_diff}")
296
- # num battles
297
- row.append(round(arena_df.iloc[i]["num_battles"]))
298
- # Organization
299
- row.append(
300
- model_table_df[model_table_df["key"] == model_key]["Organization"].values[0]
301
- )
302
- # license
303
- row.append(
304
- model_table_df[model_table_df["key"] == model_key]["License"].values[0]
305
- )
306
- cutoff_date = model_table_df[model_table_df["key"] == model_key]["Knowledge cutoff date"].values[0]
307
- if cutoff_date == "-":
308
- row.append("Unknown")
309
- else:
310
- row.append(cutoff_date)
311
- values.append(row)
312
- except Exception as e:
313
- print(f"{model_key} - {e}")
314
- return values
315
-
316
- key_to_category_name = {
317
- "full": "Overall",
318
- "coding": "Coding",
319
- "long_user": "Longer Query",
320
- "english": "English",
321
- "chinese": "Chinese",
322
- "french": "French",
323
- "no_tie": "Exclude Ties",
324
- "no_short": "Exclude Short",
325
- "no_refusal": "Exclude Refusal",
326
- }
327
- cat_name_to_explanation = {
328
- "Overall": "Overall Questions",
329
- "Coding": "Coding: whether conversation contains code snippets",
330
- "Longer Query": "Longer Query (>= 500 tokens)",
331
- "English": "English Prompts",
332
- "Chinese": "Chinese Prompts",
333
- "French": "French Prompts",
334
- "Exclude Ties": "Exclude Ties and Bothbad",
335
- "Exclude Short": "User Query >= 5 tokens",
336
- "Exclude Refusal": 'Exclude model responses with refusal (e.g., "I cannot answer")',
337
- }
338
-
339
-
340
- def build_leaderboard_tab(elo_results_file, leaderboard_table_file, show_plot=False):
341
- arena_dfs = {}
342
- category_elo_results = {}
343
- if elo_results_file is None: # Do live update
344
- default_md = "Loading ..."
345
- p1 = p2 = p3 = p4 = None
346
- else:
347
- with open(elo_results_file, "rb") as fin:
348
- elo_results = pickle.load(fin)
349
- if "full" in elo_results:
350
- print("KEYS ", elo_results.keys())
351
- for k in key_to_category_name.keys():
352
- if k not in elo_results:
353
- continue
354
- arena_dfs[key_to_category_name[k]] = elo_results[k]["leaderboard_table_df"]
355
- category_elo_results[key_to_category_name[k]] = elo_results[k]
356
-
357
- p1 = category_elo_results["Overall"]["win_fraction_heatmap"]
358
- p2 = category_elo_results["Overall"]["battle_count_heatmap"]
359
- p3 = category_elo_results["Overall"]["bootstrap_elo_rating"]
360
- p4 = category_elo_results["Overall"]["average_win_rate_bar"]
361
- arena_df = arena_dfs["Overall"]
362
- default_md = make_default_md(arena_df, category_elo_results["Overall"])
363
-
364
- md_1 = gr.Markdown(default_md, elem_id="leaderboard_markdown")
365
- if leaderboard_table_file:
366
- data = load_leaderboard_table_csv(leaderboard_table_file)
367
- model_table_df = pd.DataFrame(data)
368
-
369
- with gr.Tabs() as tabs:
370
- # arena table
371
- arena_table_vals = get_arena_table(arena_df, model_table_df)
372
- with gr.Tab("Arena Elo", id=0):
373
- md = make_arena_leaderboard_md(arena_df)
374
- leaderboard_markdown = gr.Markdown(md, elem_id="leaderboard_markdown")
375
- with gr.Row():
376
- with gr.Column(scale=2):
377
- category_dropdown = gr.Dropdown(choices=list(arena_dfs.keys()), label="Category", value="Overall")
378
- default_category_details = make_category_arena_leaderboard_md(arena_df, arena_df, name="Overall")
379
- with gr.Column(scale=4, variant="panel"):
380
- category_deets = gr.Markdown(default_category_details, elem_id="category_deets")
381
-
382
- elo_display_df = gr.Dataframe(
383
- headers=[
384
- "Rank",
385
- "πŸ€– Model",
386
- "⭐ Arena Elo",
387
- "πŸ“Š 95% CI",
388
- "πŸ—³οΈ Votes",
389
- "Organization",
390
- "License",
391
- "Knowledge Cutoff",
392
- ],
393
- datatype=[
394
- "number",
395
- "markdown",
396
- "number",
397
- "str",
398
- "number",
399
- "str",
400
- "str",
401
- "str",
402
- ],
403
- value=arena_table_vals,
404
- elem_id="arena_leaderboard_dataframe",
405
- height=700,
406
- column_widths=[70, 190, 110, 100, 90, 160, 150, 140],
407
- wrap=True,
408
- )
409
-
410
- gr.Markdown(
411
- f"""Note: we take the 95% confidence interval into account when determining a model's ranking.
412
- A model is ranked higher only if its lower bound of model score is higher than the upper bound of the other model's score.
413
- See Figure 3 below for visualization of the confidence intervals. More details in [notebook]({notebook_url}).
414
- """,
415
- elem_id="leaderboard_markdown"
416
- )
417
-
418
- leader_component_values[:] = [default_md, p1, p2, p3, p4]
419
-
420
- if show_plot:
421
- more_stats_md = gr.Markdown(
422
- f"""## More Statistics for Chatbot Arena (Overall)""",
423
- elem_id="leaderboard_header_markdown"
424
- )
425
- with gr.Row():
426
- with gr.Column():
427
- gr.Markdown(
428
- "#### Figure 1: Fraction of Model A Wins for All Non-tied A vs. B Battles", elem_id="plot-title"
429
- )
430
- plot_1 = gr.Plot(p1, show_label=False, elem_id="plot-container")
431
- with gr.Column():
432
- gr.Markdown(
433
- "#### Figure 2: Battle Count for Each Combination of Models (without Ties)", elem_id="plot-title"
434
- )
435
- plot_2 = gr.Plot(p2, show_label=False)
436
- with gr.Row():
437
- with gr.Column():
438
- gr.Markdown(
439
- "#### Figure 3: Confidence Intervals on Model Strength (via Bootstrapping)", elem_id="plot-title"
440
- )
441
- plot_3 = gr.Plot(p3, show_label=False)
442
- with gr.Column():
443
- gr.Markdown(
444
- "#### Figure 4: Average Win Rate Against All Other Models (Assuming Uniform Sampling and No Ties)", elem_id="plot-title"
445
- )
446
- plot_4 = gr.Plot(p4, show_label=False)
447
-
448
- with gr.Tab("Full Leaderboard", id=1):
449
- md = make_full_leaderboard_md(elo_results)
450
- gr.Markdown(md, elem_id="leaderboard_markdown")
451
- full_table_vals = get_full_table(arena_df, model_table_df)
452
- gr.Dataframe(
453
- headers=[
454
- "πŸ€– Model",
455
- "⭐ Arena Elo",
456
- "πŸ“ˆ MT-bench",
457
- "πŸ“š MMLU",
458
- "Organization",
459
- "License",
460
- ],
461
- datatype=["markdown", "number", "number", "number", "str", "str"],
462
- value=full_table_vals,
463
- elem_id="full_leaderboard_dataframe",
464
- column_widths=[200, 100, 100, 100, 150, 150],
465
- height=700,
466
- wrap=True,
467
- )
468
- if not show_plot:
469
- gr.Markdown(
470
- """ ## Visit our [HF space](https://huggingface.co/spaces/lmsys/chatbot-arena-leaderboard) for more analysis!
471
- If you want to see more models, please help us [add them](https://github.com/lm-sys/FastChat/blob/main/docs/arena.md#how-to-add-a-new-model).
472
- """,
473
- elem_id="leaderboard_markdown",
474
- )
475
- else:
476
- pass
477
-
478
- def update_leaderboard_df(arena_table_vals):
479
- elo_datarame = pd.DataFrame(arena_table_vals, columns=[ "Rank", "Delta", "πŸ€– Model", "⭐ Arena Elo", "πŸ“Š 95% CI", "πŸ—³οΈ Votes", "Organization", "License", "Knowledge Cutoff"])
480
-
481
- # goal: color the rows based on the rank with styler
482
- def highlight_max(s):
483
- # all items in S which contain up arrow should be green, down arrow should be red, otherwise black
484
- return ["color: green; font-weight: bold" if "\u2191" in v else "color: red; font-weight: bold" if "\u2193" in v else "" for v in s]
485
-
486
- def highlight_rank_max(s):
487
- return ["color: green; font-weight: bold" if v > 0 else "color: red; font-weight: bold" if v < 0 else "" for v in s]
488
-
489
- return elo_datarame.style.apply(highlight_max, subset=["Rank"]).apply(highlight_rank_max, subset=["Delta"])
490
-
491
- def update_leaderboard_and_plots(category):
492
- arena_subset_df = arena_dfs[category]
493
- arena_subset_df = arena_subset_df[arena_subset_df["num_battles"] > 500]
494
- elo_subset_results = category_elo_results[category]
495
- arena_df = arena_dfs["Overall"]
496
- arena_values = get_arena_table(arena_df, model_table_df, arena_subset_df = arena_subset_df if category != "Overall" else None)
497
- if category != "Overall":
498
- arena_values = update_leaderboard_df(arena_values)
499
- arena_values = gr.Dataframe(
500
- headers=[
501
- "Rank",
502
- "Delta",
503
- "πŸ€– Model",
504
- "⭐ Arena Elo",
505
- "πŸ“Š 95% CI",
506
- "πŸ—³οΈ Votes",
507
- "Organization",
508
- "License",
509
- "Knowledge Cutoff",
510
- ],
511
- datatype=[
512
- "number",
513
- "number",
514
- "markdown",
515
- "number",
516
- "str",
517
- "number",
518
- "str",
519
- "str",
520
- "str",
521
- ],
522
- value=arena_values,
523
- elem_id="arena_leaderboard_dataframe",
524
- height=700,
525
- column_widths=[60, 70, 190, 110, 100, 90, 160, 150, 140],
526
- wrap=True,
527
- )
528
- else:
529
- arena_values = gr.Dataframe(
530
- headers=[
531
- "Rank",
532
- "πŸ€– Model",
533
- "⭐ Arena Elo",
534
- "πŸ“Š 95% CI",
535
- "πŸ—³οΈ Votes",
536
- "Organization",
537
- "License",
538
- "Knowledge Cutoff",
539
- ],
540
- datatype=[
541
- "number",
542
- "markdown",
543
- "number",
544
- "str",
545
- "number",
546
- "str",
547
- "str",
548
- "str",
549
- ],
550
- value=arena_values,
551
- elem_id="arena_leaderboard_dataframe",
552
- height=700,
553
- column_widths=[70, 190, 110, 100, 90, 160, 150, 140],
554
- wrap=True,
555
- )
556
-
557
- p1 = elo_subset_results["win_fraction_heatmap"]
558
- p2 = elo_subset_results["battle_count_heatmap"]
559
- p3 = elo_subset_results["bootstrap_elo_rating"]
560
- p4 = elo_subset_results["average_win_rate_bar"]
561
- more_stats_md = f"""## More Statistics for Chatbot Arena - {category}
562
- """
563
- leaderboard_md = make_category_arena_leaderboard_md(arena_df, arena_subset_df, name=category)
564
- return arena_values, p1, p2, p3, p4, more_stats_md, leaderboard_md
565
-
566
- category_dropdown.change(update_leaderboard_and_plots, inputs=[category_dropdown], outputs=[elo_display_df, plot_1, plot_2, plot_3, plot_4, more_stats_md, category_deets])
567
-
568
- with gr.Accordion(
569
- "πŸ“ Citation",
570
- open=True,
571
- ):
572
- citation_md = """
573
- ### Citation
574
- Please cite the following paper if you find our leaderboard or dataset helpful.
575
- ```
576
- @misc{chiang2024chatbot,
577
- title={Chatbot Arena: An Open Platform for Evaluating LLMs by Human Preference},
578
- author={Wei-Lin Chiang and Lianmin Zheng and Ying Sheng and Anastasios Nikolas Angelopoulos and Tianle Li and Dacheng Li and Hao Zhang and Banghua Zhu and Michael Jordan and Joseph E. Gonzalez and Ion Stoica},
579
- year={2024},
580
- eprint={2403.04132},
581
- archivePrefix={arXiv},
582
- primaryClass={cs.AI}
583
- }
584
- """
585
- gr.Markdown(citation_md, elem_id="leaderboard_markdown")
586
- gr.Markdown(acknowledgment_md)
587
-
588
- if show_plot:
589
- return [md_1, plot_1, plot_2, plot_3, plot_4]
590
- return [md_1]
591
-
592
-
593
- block_css = """
594
- #notice_markdown {
595
- font-size: 104%
596
- }
597
- #notice_markdown th {
598
- display: none;
599
- }
600
- #notice_markdown td {
601
- padding-top: 6px;
602
- padding-bottom: 6px;
603
- }
604
-
605
- #category_deets {
606
- text-align: center;
607
- padding: 0px;
608
- padding-left: 5px;
609
- }
610
-
611
- #leaderboard_markdown {
612
- font-size: 104%
613
- }
614
- #leaderboard_markdown td {
615
- padding-top: 6px;
616
- padding-bottom: 6px;
617
- }
618
-
619
- #leaderboard_header_markdown {
620
- font-size: 104%;
621
- text-align: center;
622
- display:block;
623
- }
624
-
625
- #leaderboard_dataframe td {
626
- line-height: 0.1em;
627
- }
628
-
629
- #plot-title {
630
- text-align: center;
631
- display:block;
632
- }
633
-
634
- #non-interactive-button {
635
- display: inline-block;
636
- padding: 10px 10px;
637
- background-color: #f7f7f7; /* Super light grey background */
638
- text-align: center;
639
- font-size: 26px; /* Larger text */
640
- border-radius: 0; /* Straight edges, no border radius */
641
- border: 0px solid #dcdcdc; /* A light grey border to match the background */
642
- user-select: none; /* The text inside the button is not selectable */
643
- pointer-events: none; /* The button is non-interactive */
644
- }
645
-
646
- footer {
647
- display:none !important
648
- }
649
- .sponsor-image-about img {
650
- margin: 0 20px;
651
- margin-top: 20px;
652
- height: 40px;
653
- max-height: 100%;
654
- width: auto;
655
- float: left;
656
- }
657
- """
658
-
659
- acknowledgment_md = """
660
- ### Acknowledgment
661
- We thank [Kaggle](https://www.kaggle.com/), [MBZUAI](https://mbzuai.ac.ae/), [a16z](https://www.a16z.com/), [Together AI](https://www.together.ai/), [Anyscale](https://www.anyscale.com/), [HuggingFace](https://huggingface.co/) for their generous [sponsorship](https://lmsys.org/donations/).
662
-
663
- <div class="sponsor-image-about">
664
- <img src="https://storage.googleapis.com/public-arena-asset/kaggle.png" alt="Kaggle">
665
- <img src="https://storage.googleapis.com/public-arena-asset/mbzuai.jpeg" alt="MBZUAI">
666
- <img src="https://storage.googleapis.com/public-arena-asset/a16z.jpeg" alt="a16z">
667
- <img src="https://storage.googleapis.com/public-arena-asset/together.png" alt="Together AI">
668
- <img src="https://storage.googleapis.com/public-arena-asset/anyscale.png" alt="AnyScale">
669
- <img src="https://storage.googleapis.com/public-arena-asset/huggingface.png" alt="HuggingFace">
670
- </div>
671
- """
672
-
673
- def build_demo(elo_results_file, leaderboard_table_file):
674
- text_size = gr.themes.sizes.text_lg
675
- theme = gr.themes.Base(text_size=text_size)
676
- theme.set(button_secondary_background_fill_hover="*primary_300",
677
- button_secondary_background_fill_hover_dark="*primary_700")
678
- with gr.Blocks(
679
- title="Chatbot Arena Leaderboard",
680
- theme=theme,
681
- # theme = gr.themes.Base.load("theme.json"), # uncomment to use new cool theme
682
- css=block_css,
683
- ) as demo:
684
- leader_components = build_leaderboard_tab(
685
- elo_results_file, leaderboard_table_file, show_plot=True
686
- )
687
- return demo
688
-
689
-
690
- if __name__ == "__main__":
691
- parser = argparse.ArgumentParser()
692
- parser.add_argument("--share", action="store_true")
693
- parser.add_argument("--host", default="0.0.0.0")
694
- parser.add_argument("--port", type=int, default=7860)
695
- args = parser.parse_args()
696
-
697
- elo_result_files = glob.glob("elo_results_*.pkl")
698
- elo_result_files.sort(key=lambda x: int(x[12:-4]))
699
- elo_result_file = elo_result_files[-1]
700
-
701
- leaderboard_table_files = glob.glob("leaderboard_table_*.csv")
702
- leaderboard_table_files.sort(key=lambda x: int(x[18:-4]))
703
- leaderboard_table_file = leaderboard_table_files[-1]
704
-
705
- demo = build_demo(elo_result_file, leaderboard_table_file)
706
- demo.launch(share=args.share, server_name=args.host, server_port=args.port)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
index.html ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width" />
6
+ <title>Chatbot Arena</title>
7
+ <link rel="stylesheet" href="style.css" />
8
+ </head>
9
+ <body>
10
+ <div>Please visit <a href="https://chat.lmsys.org" target="_blank">chat.lmsys.org</a>.</div>
11
+ </body>
12
+ </html>
style.css ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ padding: 2rem;
3
+ font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
4
+ display: flex;
5
+ justify-content: center;
6
+ align-items: center;
7
+ height: 100vh; /* Make the body take the full viewport height */
8
+ font-size: 30px; /* Increase the font size */
9
+ text-align: center; /* Center the text */
10
+ }
11
+
12
+ h1 {
13
+ font-size: 16px;
14
+ margin-top: 0;
15
+ }
16
+
17
+ p {
18
+ color: rgb(107, 114, 128);
19
+ font-size: 15px;
20
+ margin-bottom: 10px;
21
+ margin-top: 5px;
22
+ }
23
+
24
+ .card {
25
+ max-width: 620px;
26
+ margin: 0 auto;
27
+ padding: 16px;
28
+ border: 1px solid lightgray;
29
+ border-radius: 16px;
30
+ }
31
+
32
+ .card p:last-child {
33
+ margin-bottom: 0;
34
+ }
35
+
36
+ /* Additional style to ensure the link is also affected by the font size */
37
+ a {
38
+ font-size: inherit; /* Ensures that links inherit the body's font size */
39
+ }