File size: 2,200 Bytes
5b15f5e |
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 |
#source: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard/blob/main/src/utils_display.py
from dataclasses import dataclass
# These classes are for user facing column names, to avoid having to change them
# all around the code when a modif is needed
@dataclass
class ColumnContent:
name: str
type: str
displayed_by_default: bool
hidden: bool = False
def fields(raw_class):
return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
@dataclass(frozen=True)
class AutoEvalColumn: # Auto evals column
model_type_symbol = ColumnContent("T", "str", True)
model = ColumnContent("Models", "markdown", True)
win_rate = ColumnContent("Win Rate", "number", True)
throughput = ColumnContent("Throughput (tokens/s)", "number", True)
languages = ColumnContent("#Languages", "number", True)
humaneval_python = ColumnContent("humaneval-python", "number", True)
java = ColumnContent("java", "number", True)
javascript = ColumnContent("javascript", "number", True)
cpp = ColumnContent("cpp", "number", True)
php = ColumnContent("php", "number", True)
rust = ColumnContent("rust", "number", True)
swift = ColumnContent("swift", "number", True)
r = ColumnContent("r", "number", True)
lua = ColumnContent("lua", "number", False)
d = ColumnContent("d", "number", False)
racket = ColumnContent("racket", "number", False)
julia = ColumnContent("julia", "number", False)
throughput_bs50 = ColumnContent("Throughput (tokens/s) bs=50", "number", False)
peak_memory = ColumnContent("Peak Memory (MB)", "number", False)
seq_length = ColumnContent("Seq_length", "number", False)
average = ColumnContent("Average Score", "number", False)
link = ColumnContent("Links", "str", False)
dummy = ColumnContent("Models", "str", False)
def model_hyperlink(link, model_name):
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
def make_clickable_names(df):
df['Models'] = df.apply(lambda row: model_hyperlink(row['Links'], row['Models']), axis=1)
return df |