-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Leaderboard 2.0: added performance x n_parameters plot + more benchma…
…rk info (#1437) * Added elementary speed/performance plot * Refactored table formatting code * Bumped Gradio version * Added more general info to benchmark description markdown block * Adjusted margin an range on plot * Made hover information easier to read on plot * Made range scaling dynamic in plot * Moved citation next to benchmark description * Made titles in benchmark info bold
- Loading branch information
1 parent
19aefa3
commit 76c2112
Showing
4 changed files
with
124 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import numpy as np | ||
import pandas as pd | ||
import plotly.express as px | ||
import plotly.graph_objects as go | ||
|
||
|
||
def parse_n_params(text: str) -> int: | ||
if text.endswith("M"): | ||
return float(text[:-1]) * 1e6 | ||
if text.endswith("B"): | ||
return float(text[:-1]) * 1e9 | ||
|
||
|
||
def parse_model_name(name: str) -> str: | ||
name, _ = name.split("]") | ||
return name[1:] | ||
|
||
|
||
models_to_annotate = [ | ||
"all-MiniLM-L6-v2", | ||
"GritLM-7B", | ||
"LaBSE", | ||
"multilingual-e5-large-instruct", | ||
] | ||
|
||
|
||
def performance_size_plot(df: pd.DataFrame) -> go.Figure: | ||
df = df.copy() | ||
df["Number of Parameters"] = df["Number of Parameters"].map(parse_n_params) | ||
df["Model"] = df["Model"].map(parse_model_name) | ||
df["model_text"] = df["Model"].where(df["Model"].isin(models_to_annotate), "") | ||
df["Embedding Dimensions"] = df["Embedding Dimensions"].map(int) | ||
df["Max Tokens"] = df["Max Tokens"].map(int) | ||
df["Log(Tokens)"] = np.log10(df["Max Tokens"]) | ||
min_score, max_score = df["Mean (Task)"].min(), df["Mean (Task)"].max() | ||
fig = px.scatter( | ||
df, | ||
x="Number of Parameters", | ||
y="Mean (Task)", | ||
log_x=True, | ||
template="plotly_white", | ||
text="model_text", | ||
size="Embedding Dimensions", | ||
color="Log(Tokens)", | ||
range_color=[2, 5], | ||
range_x=[8 * 1e6, 11 * 1e9], | ||
range_y=[min(0, min_score * 1.25), max_score * 1.25], | ||
hover_data={ | ||
"Max Tokens": True, | ||
"Embedding Dimensions": True, | ||
"Number of Parameters": True, | ||
"Mean (Task)": True, | ||
"Rank (Borda)": True, | ||
"Log(Tokens)": False, | ||
"model_text": False, | ||
}, | ||
hover_name="Model", | ||
) | ||
fig.update_layout( | ||
coloraxis_colorbar=dict( | ||
title="Max Tokens", | ||
tickvals=[2, 3, 4, 5], | ||
ticktext=[ | ||
"100", | ||
"1K", | ||
"10K", | ||
"100K", | ||
], | ||
), | ||
hoverlabel=dict( | ||
bgcolor="white", | ||
font_size=16, | ||
), | ||
) | ||
fig.update_traces( | ||
textposition="top center", | ||
) | ||
fig.update_layout( | ||
font=dict(size=16, color="black"), | ||
margin=dict(b=20, t=10, l=20, r=10), | ||
) | ||
return fig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters