bingran-you's picture
Deploy PostTrain Arena leaderboard
da95979 verified
Raw
History Blame Contribute Delete
1.78 kB
"""Live PostTrain Arena leaderboard backed by a Hub dataset."""
import json
import gradio as gr
from huggingface_hub import hf_hub_download
LEADERBOARD_REPO = 'benchflow/posttrainarena-leaderboard'
def load_rows():
path = hf_hub_download(
LEADERBOARD_REPO,
"leaderboard.json",
repo_type="dataset",
force_download=True,
)
records = json.loads(open(path, encoding="utf-8").read())
rows = []
rank = 0
for record in records:
if record.get("status") == "succeeded":
rank += 1
shown_rank = rank
else:
shown_rank = None
rows.append(
[
shown_rank,
record.get("submission_id"),
record.get("status"),
record.get("baseline_score"),
record.get("score_after_posttrain"),
record.get("delta_score"),
record.get("run_id"),
record.get("artifact_url"),
]
)
return rows
with gr.Blocks(title="PostTrain Arena Leaderboard") as demo:
gr.Markdown("# PostTrain Arena Leaderboard")
gr.Markdown(
"Continuously updated results from pinned Hugging Face Jobs. "
"Scores link to immutable run artifacts."
)
table = gr.Dataframe(
headers=[
"Rank",
"Submission",
"Status",
"Baseline",
"Final",
"Delta",
"Run",
"Artifacts",
],
value=load_rows,
interactive=False,
)
refresh = gr.Button("Refresh")
refresh.click(load_rows, outputs=table)
timer = gr.Timer(60)
timer.tick(load_rows, outputs=table)
if __name__ == "__main__":
demo.launch()