Spaces:
Running
on
Zero
Running
on
Zero
File size: 6,124 Bytes
3427608 ffc77cb 3427608 ffc77cb 3427608 512e129 3427608 ffc77cb 3427608 8e65357 ffc77cb 3427608 ffc77cb 3427608 512e129 3427608 ffc77cb 3427608 ffc77cb |
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 |
"""
Live monitor of the website statistics and leaderboard.
Dependency:
sudo apt install pkg-config libicu-dev
pip install pytz gradio gdown plotly polyglot pyicu pycld2 tabulate
"""
import argparse
import ast
import pickle
import os
import threading
import time
import gradio as gr
import numpy as np
import pandas as pd
import json
from datetime import datetime
# def make_leaderboard_md(elo_results):
# leaderboard_md = f"""
# # π Chatbot Arena Leaderboard
# | [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) |
# This leaderboard is based on the following three benchmarks.
# - [Chatbot Arena](https://lmsys.org/blog/2023-05-03-arena/) - a crowdsourced, randomized battle platform. We use 100K+ user votes to compute Elo ratings.
# - [MT-Bench](https://arxiv.org/abs/2306.05685) - a set of challenging multi-turn questions. We use GPT-4 to grade the model responses.
# - [MMLU](https://arxiv.org/abs/2009.03300) (5-shot) - a test to measure a model's multitask accuracy on 57 tasks.
# π» Code: The Arena Elo ratings are computed by this [notebook]({notebook_url}). 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). The MMLU scores are mostly computed by [InstructEval](https://github.com/declare-lab/instruct-eval). Higher values are better for all benchmarks. Empty cells mean not available. Last updated: November, 2023.
# """
# return leaderboard_md
def make_leaderboard_md():
leaderboard_md = f"""
# π K-Sort-Arena Leaderboard
"""
return leaderboard_md
def model_hyperlink(model_name, link):
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
def make_arena_leaderboard_md(total_models, total_votes):
last_updated = datetime.now()
last_updated = last_updated.strftime("%Y-%m-%d")
leaderboard_md = f"""
Total #models: **{total_models}**(anonymous). Total #votes: **{total_votes}** (Equivalent to **{total_votes*6}** votes for one-on-one games).
\n Last updated: {last_updated}.
"""
return leaderboard_md
'''
def build_leaderboard_tab(elo_results_file, leaderboard_table_file, show_plot=False):
if elo_results_file is None: # Do live update
md = "Loading ..."
p1 = p2 = p3 = p4 = None
else:
with open(elo_results_file, "rb") as fin:
elo_results = pickle.load(fin)
anony_elo_results = elo_results["anony"]
full_elo_results = elo_results["full"]
anony_arena_df = anony_elo_results["leaderboard_table_df"]
full_arena_df = full_elo_results["leaderboard_table_df"]
p1 = anony_elo_results["win_fraction_heatmap"]
p2 = anony_elo_results["battle_count_heatmap"]
p3 = anony_elo_results["bootstrap_elo_rating"]
p4 = anony_elo_results["average_win_rate_bar"]
md = make_leaderboard_md(anony_elo_results)
md_1 = gr.Markdown(md, elem_id="leaderboard_markdown")
if leaderboard_table_file:
model_table_df = load_leaderboard_table_csv(leaderboard_table_file)
with gr.Tabs() as tabs:
# arena table
arena_table_vals = get_arena_table(anony_arena_df, model_table_df)
with gr.Tab("Arena Score", id=0):
md = make_arena_leaderboard_md(anony_elo_results)
gr.Markdown(md, elem_id="leaderboard_markdown")
gr.Dataframe(
headers=[
"Rank",
"π€ Model",
"β Arena Elo",
"π 95% CI",
"π³οΈ Votes",
"Organization",
"License",
],
datatype=[
"str",
"markdown",
"number",
"str",
"number",
"str",
"str",
],
value=arena_table_vals,
elem_id="arena_leaderboard_dataframe",
height=700,
column_widths=[50, 200, 100, 100, 100, 150, 150],
wrap=True,
)
if not show_plot:
gr.Markdown(
""" ## The leaderboard is updated frequently and continues to incorporate new models.
""",
elem_id="leaderboard_markdown",
)
else:
pass
leader_component_values[:] = [md, p1, p2, p3, p4]
from .utils import acknowledgment_md
gr.Markdown(acknowledgment_md)
# return [md_1, plot_1, plot_2, plot_3, plot_4]
return [md_1]
'''
def make_arena_leaderboard_data(results):
import pandas as pd
df = pd.DataFrame(results)
return df
def build_leaderboard_tab(score_result_file = 'sorted_score_list.json'):
with open(score_result_file, "r") as json_file:
data = json.load(json_file)
score_results = data["sorted_score_list"]
total_models = data["total_models"]
total_votes = data["total_votes"]
md = make_leaderboard_md()
md_1 = gr.Markdown(md, elem_id="leaderboard_markdown")
with gr.Tab("Arena Score", id=0):
md = make_arena_leaderboard_md(total_models, total_votes)
gr.Markdown(md, elem_id="leaderboard_markdown")
md = make_arena_leaderboard_data(score_results)
gr.Dataframe(md)
gr.Markdown(
""" ## The leaderboard is updated frequently and continues to incorporate new models.
""",
elem_id="leaderboard_markdown",
)
from .utils import acknowledgment_md
gr.Markdown(acknowledgment_md) |