File size: 1,896 Bytes
c5afbf5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7318493
 
 
c5afbf5
 
 
 
 
 
 
 
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
import pandas as pd
from pathlib import Path

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

ORDER_LIST = ["Name", "Lang", "Score", "Parameters (B)", "Date"]
COLUMN_HEADERS = ["Name", "Language", "Score", "Parameters (B)", "Date"]
DATA_TYPES = ["markdown", "str", "number", "number", "str"]

def filter_data(selected_columns, search_query):
    df = LB_LLMZSZL[selected_columns]
    if search_query:
        df = df[df['Name'].str.contains(search_query, case=False, na=False)]
    return df

def filter_row(language):
    if language:
        return LB_LLMZSZL[LB_LLMZSZL["Lang"] == language]
    return LB_LLMZSZL

def filter_columns(column_choices):
    selected_columns = [col for col in ORDER_LIST if col in column_choices]
    return LB_LLMZSZL[selected_columns]

def load_json_data(file_path, order_list):
    LB_LLMZSZL = pd.read_json(file_path)

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

    LB_LLMZSZL["Name"] = LB_LLMZSZL["Name"].apply(
        lambda name: f"[{name}](https://huggingface.co/{name})"
    )

    lang_replacements = {
        'E': 'English',
        'P': 'Polish',
        'm': 'Multilingual'
    }

    LB_LLMZSZL["Lang"] = LB_LLMZSZL["Lang"].apply(
        lambda lang_code: lang_replacements.get(lang_code, lang_code)  # Replace using the dictionary, keep original if not found
    )

    if "Parameters (B)" in LB_LLMZSZL.columns:
        LB_LLMZSZL["Parameters (B)"] = LB_LLMZSZL["Parameters (B)"].astype(float).round(1)

    ordered_columns = [col for col in order_list if col in LB_LLMZSZL.columns]
    LB_LLMZSZL = LB_LLMZSZL[ordered_columns]
    LB_LLMZSZL = LB_LLMZSZL.sort_values(by="Score", ascending=False)
    return LB_LLMZSZL


file_path = str(abs_path / "leaderboards/llmzszl.json")
LB_LLMZSZL = load_json_data(file_path, ORDER_LIST)