Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add edit leaderboard #3661

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 80 additions & 27 deletions fastchat/serve/monitor/copilot_arena.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,44 +37,91 @@ def process_copilot_arena_leaderboard(leaderboard):
by=["Rank* (UB)", "score"], ascending=[True, False]
)

leaderboard = leaderboard.rename(
columns={
"name": "Model",
"confidence_interval": "Confidence Interval",
"score": "Arena Score",
"organization": "Organization",
"votes": "Votes",
}
)

column_order = [
"Rank* (UB)",
"Model",
"Arena Score",
"Confidence Interval",
"Votes",
"Organization",
]
leaderboard = leaderboard[column_order]

return leaderboard


def make_copilot_arena_leaderboard_md(leaderboard, interaction_mode):
num_models = len(leaderboard)
total_battles = int(leaderboard["Votes"].sum()) // 2
space = "   "
leaderboard_md = f"""### {interaction_mode}
#### {space} #models: **{num_models}** {space} #votes: **{"{:,}".format(total_battles)}** {space}
"""
return leaderboard_md


def build_copilot_arena_tab():
if copilot_arena_leaderboard_url is None:
print("Copilot Arena Leaderboard URL is not set. Skipping this leaderboard.")
return
response = requests.get(copilot_arena_leaderboard_url)
if response.status_code == 200:
leaderboard = pd.DataFrame(response.json()["elo_data"])
leaderboard = process_copilot_arena_leaderboard(leaderboard)
leaderboard = leaderboard.rename(
columns={
"name": "Model",
"confidence_interval": "Confidence Interval",
"score": "Arena Score",
"organization": "Organization",
"votes": "Votes",
}
response_json = response.json()

def update_copilot_arena_leaderboard(interaction_mode):
if interaction_mode == "Code Completion":
leaderboard = pd.DataFrame(response_json["elo_data"])
else:
leaderboard = pd.DataFrame(response_json["edit_elo_data"])
leaderboard = process_copilot_arena_leaderboard(leaderboard)
leaderboard_df = gr.DataFrame(
leaderboard,
datatype=["str" for _ in leaderboard.columns],
elem_id="arena_hard_leaderboard",
height=600,
wrap=True,
interactive=False,
column_widths=[70, 130, 60, 80, 50, 80],
)

md = make_copilot_arena_leaderboard_md(leaderboard, interaction_mode)
leaderboard_md = gr.Markdown(md, elem_id="leaderboard_markdown")

return leaderboard_df, leaderboard_md

gr.Markdown(
"[Copilot Arena](https://blog.lmarena.ai/blog/2024/copilot-arena/) is a free AI coding assistant that provides paired responses from different state-of-the-art LLMs.",
elem_id="copilot_arena_introduction",
)

column_order = [
"Rank* (UB)",
"Model",
"Arena Score",
"Confidence Interval",
"Votes",
"Organization",
]
leaderboard = leaderboard[column_order]
num_models = len(leaderboard)
total_battles = int(leaderboard["Votes"].sum()) // 2
md = f"""
[Copilot Arena](https://blog.lmarena.ai/blog/2024/copilot-arena/) is a free AI coding assistant that provides paired responses from different state-of-the-art LLMs. This leaderboard contains the relative performance and ranking of {num_models} models over {total_battles} battles.
"""

gr.Markdown(md, elem_id="leaderboard_markdown")
gr.DataFrame(
leaderboard = pd.DataFrame(response_json["elo_data"])
leaderboard = process_copilot_arena_leaderboard(leaderboard)
with gr.Row():
with gr.Column(scale=2):
interaction_mode_dropdown = gr.Radio(
choices=["Code Completion", "Code Edit"],
label="Interaction Mode",
value="Code Completion",
)
vote_data = make_copilot_arena_leaderboard_md(
leaderboard, "Code Completion"
)
with gr.Column(scale=3, variant="panel"):
interaction_mode_details = gr.Markdown(
vote_data, elem_id="interaction_mode_details"
)

leaderboard_df = gr.DataFrame(
leaderboard,
datatype=["str" for _ in leaderboard.columns],
elem_id="arena_hard_leaderboard",
Expand All @@ -92,5 +139,11 @@ def build_copilot_arena_tab():
""",
elem_id="leaderboard_markdown",
)

interaction_mode_dropdown.change(
update_copilot_arena_leaderboard,
inputs=[interaction_mode_dropdown],
outputs=[leaderboard_df, interaction_mode_details],
)
else:
gr.Markdown("Error with fetching Copilot Arena data. Check back in later.")
Loading