Spaces:
Running
Running
File size: 2,037 Bytes
ab5f5f1 a8a6326 ab5f5f1 a8a6326 ab5f5f1 a8a6326 ab5f5f1 a8a6326 ab5f5f1 a8a6326 ab5f5f1 a8a6326 |
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 gradio as gr
from src.utils import model_hyperlink, process_score
LEADERBOARD_COLUMN_TO_DATATYPE = {
# open llm
"Model π€": "markdown",
"Experiment π§ͺ": "str",
# primary measurements
"Prefill Latency (s)": "number",
"Decode Throughput (tokens/s)": "number",
"Allocated Memory (MB)": "number",
"Energy (tokens/kWh)": "number",
# deployment settings
"DType π₯": "str",
"Backend π": "str",
"Optimization π οΈ": "str",
"Quantization ποΈ": "str",
# additional measurements
"Arch ποΈ": "markdown",
"Params (B)": "number",
"Open LLM Score (%)": "number",
"E2E Latency (s)": "number",
"E2E Throughput (tokens/s)": "number",
"Reserved Memory (MB)": "number",
"Used Memory (MB)": "number",
}
def process_model(model_name):
link = f"https://huggingface.co/{model_name}"
return model_hyperlink(link, model_name)
def get_leaderboard_df(llm_perf_df):
df = llm_perf_df.copy()
# transform for leaderboard
df["Model π€"] = df["Model π€"].apply(process_model)
# process quantization for leaderboard
df["Open LLM Score (%)"] = df.apply(
lambda x: process_score(x["Open LLM Score (%)"], x["Quantization ποΈ"]),
axis=1,
)
return df
def create_leaderboard_table(llm_perf_df):
# get dataframe
leaderboard_df = get_leaderboard_df(llm_perf_df)
# create checkboxes
columns_checkboxes = gr.CheckboxGroup(
label="Columns π",
choices=list(LEADERBOARD_COLUMN_TO_DATATYPE.keys()),
value=list(LEADERBOARD_COLUMN_TO_DATATYPE.keys()),
info="βοΈ Select the columns to display",
elem_id="columns-checkboxes",
)
# create table
leaderboard_table = gr.components.Dataframe(
value=leaderboard_df,
datatype=list(LEADERBOARD_COLUMN_TO_DATATYPE.values()),
headers=list(LEADERBOARD_COLUMN_TO_DATATYPE.keys()),
elem_id="leaderboard-table",
)
return leaderboard_table, columns_checkboxes
|