File size: 1,303 Bytes
6dc0c9c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Convert a leaderboard csv file to html table used in the blog.

Usage:
python3 leaderboard_csv_to_html.py --in leaderboard_table_20230619.csv
"""
import argparse

import numpy as np

from fastchat.serve.monitor.monitor import load_leaderboard_table_csv


def model_hyperlink(model_name, link):
    return f'<a target="_blank" href="{link}"> {model_name} </a>'


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--input", type=str, required=True)
    args = parser.parse_args()

    data = load_leaderboard_table_csv(args.input, add_hyperlink=False)
    headers = [
        "Model",
        "MT-bench (score)",
        "Arena Elo rating",
        "MMLU",
        "License",
    ]
    values = []
    for item in data:
        row = []
        for key in headers:
            value = item[key]
            row.append(value)
        row[0] = model_hyperlink(item["Model"], item["Link"])
        values.append(row)
    values.sort(key=lambda x: -x[1] if not np.isnan(x[1]) else 1e9)

    for value in values:
        row = "<tr>"
        for x in value:
            try:
                if np.isnan(x):
                    x = "-"
            except TypeError:
                pass
            row += f" <td>{x}</td> "
        row += "</tr>"
        print(row)