File size: 2,295 Bytes
54f0e5a
 
498bbe0
54f0e5a
 
 
 
2051b0b
 
54f0e5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cf19c7c
 
 
54f0e5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cf19c7c
 
 
54f0e5a
 
 
 
 
1a497e8
54f0e5a
498bbe0
54f0e5a
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
import pandas as pd
from pathlib import Path
from ..styles import highlight_color

abs_path = Path(__file__).parent.parent.parent

def replace_models_names(model_name):
    if "gpt" in model_name:
        return model_name
    replaces = {'meta-llama': 'meta_llama',
        'epfl-llm':'epfl_llm',
        '01-ai':'01_ai'}
    new_name = model_name.replace('model-', '')
    for k, v in replaces.items():
        if new_name.startswith(k):
            new_name = new_name.replace(k, v)
    new_name = new_name.replace('-','/',1)
    new_name = new_name.replace('_','-',1)
    new_name = f"[{new_name}](https://huggingface.co/{new_name})"
    return new_name

def load_json_data(file_path):
    ALL_ACCS = pd.read_json(file_path)

    for column in ALL_ACCS.columns:
        if ALL_ACCS[column].apply(type).eq(dict).any():
            ALL_ACCS[column] = ALL_ACCS[column].apply(str)

    for column in ALL_ACCS.select_dtypes(include='number').columns:
        ALL_ACCS[column] = ALL_ACCS[column].round(2)

    return ALL_ACCS

file_paths = [
    str(abs_path / "leaderboards/pes_accs.json"),
    str(abs_path / "leaderboards/ldek_accs.json"),
    str(abs_path / "leaderboards/lek_accs.json"),
]

model_data = {}

for file_path in file_paths:
    ALL_ACCS = load_json_data(file_path)

    for _, row in ALL_ACCS.iterrows():
        model_name = replace_models_names(row["model_name"])
        overall_accuracy = row["overall_accuracy"]

        if model_name not in model_data:
            model_data[model_name] = {"model_name": model_name}

        file_key = file_path.split("/")[-1].replace(".json", "")  # Use file name as key
        model_data[model_name][f"overall_acc_from_{file_key}"] = overall_accuracy

ALL_ACCS = pd.DataFrame(list(model_data.values()))
ALL_ACCS=ALL_ACCS.rename(columns={'overall_acc_from_pes_accs':'PES',
    'overall_acc_from_ldek_accs':'LDEK',
    'overall_acc_from_lek_accs':'LEK'})

ALL_ACCS['Average'] = ALL_ACCS[['PES', 'LDEK', 'LEK']].mean(axis=1).round(2)
columns = list(ALL_ACCS.columns)
columns.insert(1, columns.pop(columns.index('Average')))
ALL_ACCS = ALL_ACCS[columns]
ALL_ACCS = ALL_ACCS.sort_values(by="Average", ascending=False)
STYLED = ALL_ACCS.style.highlight_max(
    color = highlight_color,
    subset=ALL_ACCS.columns[-4:]).format(precision=2)