Spaces:
Running
Running
Kung-Hsiang Huang
commited on
Commit
•
a708f96
1
Parent(s):
481130d
update initial lb results
Browse files- app.py +317 -175
- crmarena_results/all_results.csv +19 -0
- src/about.py +28 -60
- src/display/css_html_js.py +2 -2
- src/display/utils.py +84 -83
- src/envs.py +6 -3
- src/leaderboard/read_evals.py +29 -30
- src/populate.py +9 -51
- src/submission/check_validity.py +0 -99
- src/submission/submit.py +0 -119
app.py
CHANGED
@@ -1,193 +1,335 @@
|
|
1 |
import gradio as gr
|
2 |
-
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
3 |
import pandas as pd
|
4 |
-
|
5 |
-
from
|
6 |
-
|
7 |
-
from src.about import (
|
8 |
-
CITATION_BUTTON_LABEL,
|
9 |
-
CITATION_BUTTON_TEXT,
|
10 |
-
EVALUATION_QUEUE_TEXT,
|
11 |
-
INTRODUCTION_TEXT,
|
12 |
-
LLM_BENCHMARKS_TEXT,
|
13 |
-
TITLE,
|
14 |
-
)
|
15 |
from src.display.css_html_js import custom_css
|
16 |
-
from src.display.utils import
|
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 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
)
|
90 |
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
demo = gr.Blocks(css=custom_css)
|
93 |
with demo:
|
94 |
gr.HTML(TITLE)
|
95 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
96 |
|
97 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
98 |
-
with gr.TabItem("🏅
|
99 |
-
|
100 |
-
|
101 |
-
with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=2):
|
102 |
-
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
103 |
-
|
104 |
-
with gr.TabItem("🚀 Submit here! ", elem_id="llm-benchmark-tab-table", id=3):
|
105 |
-
with gr.Column():
|
106 |
-
with gr.Row():
|
107 |
-
gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
|
108 |
-
|
109 |
-
with gr.Column():
|
110 |
-
with gr.Accordion(
|
111 |
-
f"✅ Finished Evaluations ({len(finished_eval_queue_df)})",
|
112 |
-
open=False,
|
113 |
-
):
|
114 |
-
with gr.Row():
|
115 |
-
finished_eval_table = gr.components.Dataframe(
|
116 |
-
value=finished_eval_queue_df,
|
117 |
-
headers=EVAL_COLS,
|
118 |
-
datatype=EVAL_TYPES,
|
119 |
-
row_count=5,
|
120 |
-
)
|
121 |
-
with gr.Accordion(
|
122 |
-
f"🔄 Running Evaluation Queue ({len(running_eval_queue_df)})",
|
123 |
-
open=False,
|
124 |
-
):
|
125 |
-
with gr.Row():
|
126 |
-
running_eval_table = gr.components.Dataframe(
|
127 |
-
value=running_eval_queue_df,
|
128 |
-
headers=EVAL_COLS,
|
129 |
-
datatype=EVAL_TYPES,
|
130 |
-
row_count=5,
|
131 |
-
)
|
132 |
-
|
133 |
-
with gr.Accordion(
|
134 |
-
f"⏳ Pending Evaluation Queue ({len(pending_eval_queue_df)})",
|
135 |
-
open=False,
|
136 |
-
):
|
137 |
-
with gr.Row():
|
138 |
-
pending_eval_table = gr.components.Dataframe(
|
139 |
-
value=pending_eval_queue_df,
|
140 |
-
headers=EVAL_COLS,
|
141 |
-
datatype=EVAL_TYPES,
|
142 |
-
row_count=5,
|
143 |
-
)
|
144 |
-
with gr.Row():
|
145 |
-
gr.Markdown("# ✉️✨ Submit your model here!", elem_classes="markdown-text")
|
146 |
-
|
147 |
with gr.Row():
|
148 |
with gr.Column():
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
multiselect=False,
|
155 |
-
value=None,
|
156 |
interactive=True,
|
157 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
add_new_eval,
|
180 |
-
[
|
181 |
-
model_name_textbox,
|
182 |
-
base_model_name_textbox,
|
183 |
-
revision_name_textbox,
|
184 |
-
precision,
|
185 |
-
weight_type,
|
186 |
-
model_type,
|
187 |
-
],
|
188 |
-
submission_result,
|
189 |
)
|
190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
with gr.Row():
|
192 |
with gr.Accordion("📙 Citation", open=False):
|
193 |
citation_button = gr.Textbox(
|
@@ -198,7 +340,7 @@ with demo:
|
|
198 |
show_copy_button=True,
|
199 |
)
|
200 |
|
201 |
-
scheduler = BackgroundScheduler()
|
202 |
-
scheduler.add_job(restart_space, "interval", seconds=1800)
|
203 |
-
scheduler.start()
|
204 |
-
demo.queue(default_concurrency_limit=40).launch()
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import pandas as pd
|
3 |
+
|
4 |
+
from src.about import CITATION_BUTTON_LABEL, CITATION_BUTTON_TEXT, INTRODUCTION_TEXT, LLM_BENCHMARKS_TEXT, SUBMIT_TEXT, TITLE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
from src.display.css_html_js import custom_css
|
6 |
+
from src.display.utils import COLS, TYPES, AutoEvalColumn, fields
|
7 |
+
from src.envs import CRM_RESULTS_PATH
|
8 |
+
from src.populate import get_leaderboard_df_crm
|
9 |
+
|
10 |
+
original_df = get_leaderboard_df_crm(CRM_RESULTS_PATH, COLS)
|
11 |
+
|
12 |
+
leaderboard_df = original_df.copy()
|
13 |
+
# leaderboard_df = leaderboard_df.style.format({"accuracy_metric_average": "{0:.2f}"})
|
14 |
+
|
15 |
+
|
16 |
+
# Searching and filtering
|
17 |
+
def update_table(
|
18 |
+
hidden_df: pd.DataFrame,
|
19 |
+
columns: list,
|
20 |
+
framework_query: list
|
21 |
+
# llm_query: list,
|
22 |
+
# llm_provider_query: list,
|
23 |
+
# accuracy_method_query: str,
|
24 |
+
# accuracy_threshold_query: str,
|
25 |
+
# use_case_area_query: list,
|
26 |
+
# use_case_query: list,
|
27 |
+
# use_case_type_query: list,
|
28 |
+
# metric_area_query: list,
|
29 |
+
):
|
30 |
+
filtered_df = filter_framework_func(hidden_df, framework_query)
|
31 |
+
# filtered_df = filter_llm_func(hidden_df, llm_query)
|
32 |
+
|
33 |
+
# filtered_df = filter_llm_provider_func(filtered_df, llm_provider_query)
|
34 |
+
# filtered_df = filter_accuracy_method_func(filtered_df, accuracy_method_query)
|
35 |
+
# filtered_df["Accuracy Threshold"] = filter_accuracy_threshold_func(filtered_df, accuracy_threshold_query)
|
36 |
+
# filtered_df = filtered_df[filtered_df["Accuracy Threshold"]]
|
37 |
+
# filtered_df["Use Case Area"] = filtered_df["Use Case Name"].apply(lambda x: x.split(": ")[0])
|
38 |
+
# filtered_df = filter_use_case_area_func(filtered_df, use_case_area_query)
|
39 |
+
# filtered_df = filter_use_case_func(filtered_df, use_case_query)
|
40 |
+
# filtered_df = filter_use_case_type_func(filtered_df, use_case_type_query)
|
41 |
+
# Filtering by metric area
|
42 |
+
# metric_area_maps = {
|
43 |
+
# "Cost": ["Cost Band"],
|
44 |
+
# "Accuracy": ["Accuracy", "Instruction Following", "Conciseness", "Completeness", "Factuality"],
|
45 |
+
# "Speed (Latency)": ["Response Time (Sec)", "Mean Output Tokens"],
|
46 |
+
# "Trust & Safety": ["Trust & Safety", "Safety", "Privacy", "Truthfulness", "CRM Fairness"],
|
47 |
+
# }
|
48 |
+
# all_metric_cols = []
|
49 |
+
# for area in metric_area_maps:
|
50 |
+
# all_metric_cols = all_metric_cols + metric_area_maps[area]
|
51 |
+
|
52 |
+
# columns_to_keep = list(set(columns).difference(set(all_metric_cols)))
|
53 |
+
# for area in metric_area_query:
|
54 |
+
# columns_to_keep = columns_to_keep + metric_area_maps[area]
|
55 |
+
# columns = list(set(columns).intersection(set(columns_to_keep)))
|
56 |
+
|
57 |
+
df = select_columns(filtered_df, columns)
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
+
return df.style.map(highlight_cost_band_low, props="background-color: #b3d5a4")
|
62 |
+
|
63 |
+
|
64 |
+
# def highlight_cols(x):
|
65 |
+
# df = x.copy()
|
66 |
+
# df.loc[:, :] = "color: black"
|
67 |
+
# df.loc[, ["Accuracy"]] = "background-color: #b3d5a4"
|
68 |
+
# return df
|
69 |
+
|
70 |
+
|
71 |
+
def highlight_cost_band_low(s, props=""):
|
72 |
+
|
73 |
+
return props if s == "Low" else None
|
74 |
+
|
75 |
+
|
76 |
+
def init_leaderboard_df(
|
77 |
+
leaderboard_df: pd.DataFrame,
|
78 |
+
columns: list,
|
79 |
+
llm_query: list,
|
80 |
+
# llm_provider_query: list,
|
81 |
+
# accuracy_method_query: str,
|
82 |
+
# accuracy_threshold_query: str,
|
83 |
+
# use_case_area_query: list,
|
84 |
+
# use_case_query: list,
|
85 |
+
# use_case_type_query: list,
|
86 |
+
# metric_area_query: list,
|
87 |
+
):
|
88 |
+
|
89 |
+
# Applying the style function
|
90 |
+
# return df.style.apply(highlight_cols, axis=None)
|
91 |
+
return update_table(
|
92 |
+
leaderboard_df,
|
93 |
+
columns,
|
94 |
+
llm_query,
|
95 |
+
# llm_provider_query,
|
96 |
+
# accuracy_method_query,
|
97 |
+
# accuracy_threshold_query,
|
98 |
+
# use_case_area_query,
|
99 |
+
# use_case_query,
|
100 |
+
# use_case_type_query,
|
101 |
+
# metric_area_query,
|
102 |
)
|
103 |
|
104 |
|
105 |
+
def filter_accuracy_method_func(df: pd.DataFrame, accuracy_method_query: str) -> pd.DataFrame:
|
106 |
+
return df[df["Accuracy Method"] == accuracy_method_query]
|
107 |
+
|
108 |
+
|
109 |
+
def filter_accuracy_threshold_func(df: pd.DataFrame, accuracy_threshold_query: str) -> pd.DataFrame:
|
110 |
+
accuracy_cols = ["Instruction Following", "Conciseness", "Completeness", "Accuracy"]
|
111 |
+
return (df.loc[:, accuracy_cols] >= float(accuracy_threshold_query)).all(axis=1)
|
112 |
+
|
113 |
+
|
114 |
+
def filter_use_case_area_func(df: pd.DataFrame, use_case_area_query: list) -> pd.DataFrame:
|
115 |
+
return df[
|
116 |
+
df["Use Case Area"].apply(
|
117 |
+
lambda x: len(set([_.strip() for _ in x.split("&")]).intersection(use_case_area_query))
|
118 |
+
)
|
119 |
+
> 0
|
120 |
+
]
|
121 |
+
|
122 |
+
|
123 |
+
def filter_use_case_func(df: pd.DataFrame, use_case_query: list) -> pd.DataFrame:
|
124 |
+
return df[df["Use Case Name"].isin(use_case_query)]
|
125 |
+
|
126 |
+
|
127 |
+
def filter_use_case_type_func(df: pd.DataFrame, use_case_type_query: list) -> pd.DataFrame:
|
128 |
+
return df[df["Use Case Type"].isin(use_case_type_query)]
|
129 |
+
|
130 |
+
|
131 |
+
def filter_llm_func(df: pd.DataFrame, llm_query: list) -> pd.DataFrame:
|
132 |
+
return df[df["Model"].isin(llm_query)]
|
133 |
+
|
134 |
+
def filter_framework_func(df: pd.DataFrame, framework_query: list) -> pd.DataFrame:
|
135 |
+
return df[df["Agentic Framework"].isin(framework_query)]
|
136 |
+
|
137 |
+
def filter_llm_provider_func(df: pd.DataFrame, llm_provider_query: list) -> pd.DataFrame:
|
138 |
+
return df[df["LLM Provider"].isin(llm_provider_query)]
|
139 |
+
|
140 |
+
|
141 |
+
def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
|
142 |
+
# always_here_cols = [
|
143 |
+
# AutoEvalColumn.model.name,
|
144 |
+
# ]
|
145 |
+
# model_provider_col = [AutoEvalColumn.model_provider.name] if AutoEvalColumn.model_provider.name in columns else []
|
146 |
+
# We use COLS to maintain sortingx
|
147 |
+
|
148 |
+
filtered_df = df[
|
149 |
+
(
|
150 |
+
[AutoEvalColumn.model.name]
|
151 |
+
# + model_provider_col
|
152 |
+
+ [AutoEvalColumn.agentic_framework.name]
|
153 |
+
+ [c for c in COLS if c in df.columns and c in columns ]
|
154 |
+
+ [AutoEvalColumn.overall.name]
|
155 |
+
)
|
156 |
+
]
|
157 |
+
|
158 |
+
return filtered_df
|
159 |
+
|
160 |
+
|
161 |
demo = gr.Blocks(css=custom_css)
|
162 |
with demo:
|
163 |
gr.HTML(TITLE)
|
164 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
165 |
|
166 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
167 |
+
with gr.TabItem("🏅 CRMArena Benchmark", elem_id="llm-benchmark-tab-table", id=0):
|
168 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
with gr.Row():
|
170 |
with gr.Column():
|
171 |
+
filter_agentic_framework = gr.CheckboxGroup(
|
172 |
+
choices=list(original_df["Agentic Framework"].unique()),
|
173 |
+
value=list(original_df["Agentic Framework"].unique()),
|
174 |
+
label="Agentic Framework",
|
175 |
+
info="",
|
|
|
|
|
176 |
interactive=True,
|
177 |
)
|
178 |
+
|
179 |
+
with gr.Row():
|
180 |
+
shown_columns = gr.CheckboxGroup(
|
181 |
+
choices=[c.name for c in fields(AutoEvalColumn) if not c.hidden and not c.never_hidden],
|
182 |
+
value=[
|
183 |
+
c.name
|
184 |
+
for c in fields(AutoEvalColumn)
|
185 |
+
if c.displayed_by_default and not c.hidden and not c.never_hidden
|
186 |
+
],
|
187 |
+
label="Select tasks to show",
|
188 |
+
elem_id="column-select",
|
189 |
+
interactive=True,
|
190 |
+
)
|
191 |
+
|
192 |
+
# with gr.Column():
|
193 |
+
# filter_llm = gr.CheckboxGroup(
|
194 |
+
# choices=list(original_df["Model"].unique()),
|
195 |
+
# value=list(original_df["Model"].unique()),
|
196 |
+
# label="Model",
|
197 |
+
# info="",
|
198 |
+
# interactive=True,
|
199 |
+
# )
|
200 |
+
# with gr.Column():
|
201 |
+
# with gr.Row():
|
202 |
+
# filter_llm_provider = gr.CheckboxGroup(
|
203 |
+
# choices=list(original_df["LLM Provider"].unique()),
|
204 |
+
# value=list(original_df["LLM Provider"].unique()),
|
205 |
+
# label="LLM Provider",
|
206 |
+
# info="",
|
207 |
+
# interactive=True,
|
208 |
+
# )
|
209 |
+
# with gr.Row():
|
210 |
+
# filter_metric_area = gr.CheckboxGroup(
|
211 |
+
# choices=["Accuracy", "Speed (Latency)", "Trust & Safety", "Cost"],
|
212 |
+
# value=["Accuracy", "Speed (Latency)", "Trust & Safety", "Cost"],
|
213 |
+
# label="Metric Area",
|
214 |
+
# info="",
|
215 |
+
# interactive=True,
|
216 |
+
# )
|
217 |
+
# with gr.Row():
|
218 |
+
# filter_use_case = gr.CheckboxGroup(
|
219 |
+
# choices=list(original_df["Use Case Name"].unique()),
|
220 |
+
# value=list(original_df["Use Case Name"].unique()),
|
221 |
+
# label="Use Case",
|
222 |
+
# info="",
|
223 |
+
# # multiselect=True,
|
224 |
+
# interactive=True,
|
225 |
+
# )
|
226 |
+
# with gr.Row():
|
227 |
+
# with gr.Column():
|
228 |
+
# filter_use_case_area = gr.CheckboxGroup(
|
229 |
+
# choices=["Service", "Sales"],
|
230 |
+
# value=["Service", "Sales"],
|
231 |
+
# label="Use Case Area",
|
232 |
+
# info="",
|
233 |
+
# interactive=True,
|
234 |
+
# )
|
235 |
+
# with gr.Column():
|
236 |
+
# filter_use_case_type = gr.CheckboxGroup(
|
237 |
+
# choices=["Summary", "Generation"],
|
238 |
+
# value=["Summary", "Generation"],
|
239 |
+
# label="Use Case Type",
|
240 |
+
# info="",
|
241 |
+
# interactive=True,
|
242 |
+
# )
|
243 |
+
# with gr.Column():
|
244 |
+
# filter_use_case = gr.Dropdown(
|
245 |
+
# choices=list(original_df["Use Case Name"].unique()),
|
246 |
+
# value=list(original_df["Use Case Name"].unique()),
|
247 |
+
# label="Use Case",
|
248 |
+
# info="",
|
249 |
+
# multiselect=True,
|
250 |
+
# interactive=True,
|
251 |
+
# )
|
252 |
+
# with gr.Column():
|
253 |
+
# filter_accuracy_method = gr.Radio(
|
254 |
+
# choices=["Manual", "Auto"],
|
255 |
+
# value="Manual",
|
256 |
+
# label="Accuracy Method",
|
257 |
+
# info="",
|
258 |
+
# interactive=True,
|
259 |
+
# )
|
260 |
+
# with gr.Column():
|
261 |
+
# filter_accuracy_threshold = gr.Number(
|
262 |
+
# value="0",
|
263 |
+
# label="Accuracy Threshold",
|
264 |
+
# info="Range: 0.0 to 4.0",
|
265 |
+
# interactive=True,
|
266 |
+
# )
|
267 |
|
268 |
+
leaderboard_table = gr.components.Dataframe(
|
269 |
+
# value=leaderboard_df[[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value],
|
270 |
+
value=init_leaderboard_df(
|
271 |
+
leaderboard_df,
|
272 |
+
shown_columns.value,
|
273 |
+
filter_agentic_framework.value
|
274 |
+
# filter_llm.value,
|
275 |
+
# filter_llm_provider.value,
|
276 |
+
# filter_accuracy_method.value,
|
277 |
+
# filter_accuracy_threshold.value,
|
278 |
+
# filter_use_case_area.value,
|
279 |
+
# filter_use_case.value,
|
280 |
+
# filter_use_case_type.value,
|
281 |
+
# filter_metric_area.value,
|
282 |
+
),
|
283 |
+
headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
|
284 |
+
datatype=TYPES,
|
285 |
+
elem_id="leaderboard-table",
|
286 |
+
interactive=False,
|
287 |
+
visible=True,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
)
|
289 |
|
290 |
+
# Dummy leaderboard for handling the case when the user uses backspace key
|
291 |
+
hidden_leaderboard_table_for_search = gr.components.Dataframe(
|
292 |
+
value=original_df[COLS],
|
293 |
+
headers=COLS,
|
294 |
+
datatype=TYPES,
|
295 |
+
visible=False,
|
296 |
+
)
|
297 |
+
for selector in [
|
298 |
+
shown_columns,
|
299 |
+
filter_agentic_framework
|
300 |
+
# filter_llm,
|
301 |
+
# filter_llm_provider,
|
302 |
+
# filter_accuracy_method,
|
303 |
+
# filter_accuracy_threshold,
|
304 |
+
# filter_use_case_area,
|
305 |
+
# filter_use_case,
|
306 |
+
# filter_use_case_type,
|
307 |
+
# filter_metric_area,
|
308 |
+
]:
|
309 |
+
selector.change(
|
310 |
+
update_table,
|
311 |
+
[
|
312 |
+
hidden_leaderboard_table_for_search,
|
313 |
+
shown_columns,
|
314 |
+
filter_agentic_framework,
|
315 |
+
# filter_llm,
|
316 |
+
# filter_llm_provider,
|
317 |
+
# filter_accuracy_method,
|
318 |
+
# filter_accuracy_threshold,
|
319 |
+
# filter_use_case_area,
|
320 |
+
# filter_use_case,
|
321 |
+
# filter_use_case_type,
|
322 |
+
# filter_metric_area,
|
323 |
+
],
|
324 |
+
leaderboard_table,
|
325 |
+
queue=True,
|
326 |
+
)
|
327 |
+
with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=3):
|
328 |
+
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
329 |
+
|
330 |
+
with gr.TabItem("🚀 Submit", elem_id="llm-benchmark-tab-table", id=4):
|
331 |
+
gr.Markdown(SUBMIT_TEXT, elem_classes="markdown-text")
|
332 |
+
|
333 |
with gr.Row():
|
334 |
with gr.Accordion("📙 Citation", open=False):
|
335 |
citation_button = gr.Textbox(
|
|
|
340 |
show_copy_button=True,
|
341 |
)
|
342 |
|
343 |
+
# scheduler = BackgroundScheduler()
|
344 |
+
# scheduler.add_job(restart_space, "interval", seconds=1800)
|
345 |
+
# scheduler.start()
|
346 |
+
demo.queue(default_concurrency_limit=40).launch()
|
crmarena_results/all_results.csv
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
,Model,Agentic Framework,NCR,HTU,TCU,NED,PVI,KQA,TII,MTA,BRI,Overall ⬆️
|
2 |
+
0,gpt-4o,Act,43.1,10.0,17.7,30.8,28.5,29.3,68.5,29.2,7.7,29.4
|
3 |
+
1,gpt-4o-mini,Act,0.8,38.5,23.8,9.2,0.0,43.1,26.9,3.8,3.8,16.7
|
4 |
+
2,claude-3.5-sonnet,Act,78.5,24.6,15.4,51.5,28.5,44.7,45.4,20.8,26.9,37.4
|
5 |
+
3,claude-3-sonnet,Act,9.2,26.9,24.6,30.8,23.8,16.6,16.2,1.5,0.0,16.6
|
6 |
+
4,llama3.1-405b,Act,46.2,17.7,17.7,13.9,30.0,47.0,15.4,5.4,6.9,22.2
|
7 |
+
5,llama3.1-70b,Act,28.5,20.0,24.6,6.2,30.0,47.9,8.5,0.0,1.5,18.6
|
8 |
+
6,gpt-4o,ReAct,70.0,39.2,22.3,30.8,35.4,50.2,64.6,20.9,10.8,38.2
|
9 |
+
7,gpt-4o-mini,ReAct,40.8,36.9,25.4,31.5,24.6,52.8,30.0,6.2,6.2,28.3
|
10 |
+
8,claude-3.5-sonnet,ReAct,62.9,20.0,11.5,52.3,30.0,45.0,43.9,20.8,21.5,34.3
|
11 |
+
9,claude-3-sonnet,ReAct,7.7,24.6,26.9,29.2,28.5,16.0,22.3,0.8,0.0,17.3
|
12 |
+
10,llama3.1-405b,ReAct,81.5,22.3,15.4,33.9,34.6,55.3,34.6,13.9,13.1,33.8
|
13 |
+
11,llama3.1-70b,ReAct,48.5,20.0,13.9,33.1,37.7,48.7,23.9,13.9,10.8,27.8
|
14 |
+
12,gpt-4o,Function Calling,60.0,47.7,81.5,46.2,39.2,30.4,97.7,27.7,59.2,54.4
|
15 |
+
13,gpt-4o-mini,Function Calling,0.8,10.8,10.8,17.7,13.8,39.7,60.0,0.0,21.5,19.5
|
16 |
+
14,claude-3.5-sonnet,Function Calling,4.6,33.1,82.3,52.3,30.0,40.5,69.2,26.9,36.9,41.8
|
17 |
+
15,claude-3-sonnet,Function Calling,0.8,1.5,30.0,25.4,41.5,23.2,12.3,1.5,0.0,15.1
|
18 |
+
16,llama3.1-405b,Function Calling,16.2,31.5,64.6,50.0,26.9,47.6,95.4,86.9,42.3,51.3
|
19 |
+
17,llama3.1-70b,Function Calling,1.5,23.1,44.6,53.8,37.4,42.4,93.8,43.8,29.2,41.1
|
src/about.py
CHANGED
@@ -1,72 +1,40 @@
|
|
1 |
-
from dataclasses import dataclass
|
2 |
-
from enum import Enum
|
3 |
-
|
4 |
-
@dataclass
|
5 |
-
class Task:
|
6 |
-
benchmark: str
|
7 |
-
metric: str
|
8 |
-
col_name: str
|
9 |
-
|
10 |
-
|
11 |
-
# Select your tasks here
|
12 |
-
# ---------------------------------------------------
|
13 |
-
class Tasks(Enum):
|
14 |
-
# task_key in the json file, metric_key in the json file, name to display in the leaderboard
|
15 |
-
task0 = Task("anli_r1", "acc", "ANLI")
|
16 |
-
task1 = Task("logiqa", "acc_norm", "LogiQA")
|
17 |
-
|
18 |
-
NUM_FEWSHOT = 0 # Change with your few shot
|
19 |
-
# ---------------------------------------------------
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
# Your leaderboard name
|
24 |
-
TITLE = """<h1 align="center" id="space-title">
|
|
|
|
|
25 |
|
26 |
# What does your leaderboard evaluate?
|
27 |
INTRODUCTION_TEXT = """
|
28 |
-
Intro text
|
29 |
-
"""
|
30 |
-
|
31 |
-
# Which evaluations are you running? how can people reproduce what you have?
|
32 |
-
LLM_BENCHMARKS_TEXT = f"""
|
33 |
-
## How it works
|
34 |
-
|
35 |
-
## Reproducibility
|
36 |
-
To reproduce our results, here is the commands you can run:
|
37 |
|
38 |
"""
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
###
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
### 3) Make sure your model has an open license!
|
59 |
-
This is a leaderboard for Open LLMs, and we'd love for as many people as possible to know they can use your model 🤗
|
60 |
-
|
61 |
-
### 4) Fill up your model card
|
62 |
-
When we add extra information about models to the leaderboard, it will be automatically taken from the model card
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
Make sure you have followed the above steps first.
|
67 |
-
If everything is done, check you can launch the EleutherAIHarness on your model locally, using the above command without modifications (you can add `--limit` to limit the number of examples per task).
|
68 |
"""
|
69 |
|
70 |
-
CITATION_BUTTON_LABEL = "
|
71 |
CITATION_BUTTON_TEXT = r"""
|
|
|
|
|
|
|
|
|
|
|
72 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Your leaderboard name
|
2 |
+
TITLE = """<h1 align="center" id="space-title">CRMArena Leaderboard</h1>
|
3 |
+
CRMArena is a novel benchmark designed to assess LLM agents on realistic customer service tasks within professional environments. By working with CRM experts, CRMArena offers nine challenging tasks across three personas—service agent, analyst, and manager—populated within a simulated organization using 16 interrelated industrial objects. This benchmark invites the community to improve AI agent capabilities in function-calling and work task understanding, demonstrating tangible business value in a realistic Salesforce Org.
|
4 |
+
"""
|
5 |
|
6 |
# What does your leaderboard evaluate?
|
7 |
INTRODUCTION_TEXT = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
"""
|
10 |
|
11 |
+
LLM_BENCHMARKS_TEXT = """
|
12 |
+
### Overview
|
13 |
+
Customer Relationship Management (CRM) systems are vital for modern enterprises, providing a foundation for managing customer interactions and data. Integrating AI agents into CRM systems can automate routine processes and enhance personalized service. However, deploying and evaluating these agents is challenging due to the lack of realistic benchmarks that reflect the complexity of real-world CRM tasks. To address this issue, we introduce CRMArena, a novel benchmark designed to evaluate AI agents on realistic tasks grounded in professional work environments. We worked with CRM experts to design nine customer service tasks distributed across three personas: service agent, analyst, and manager. We synthesize a large-scale simulated organization, populating 16 commonly-used industrial objects (e.g., account, order, knowledge article, case) with high interconnectivity, and upload it into a real Salesforce CRM organization. UI and API access to the CRM is provided to systems that attempt to complete the tasks in CRMArena. Experimental results reveal that state-of-the-art LLM agents succeed in less than 40% of the tasks with ReAct prompting and less than 55% even when provided manually-crafted function-calling tools. Our findings highlight the need for enhanced agent capabilities in function-calling and rule-following to be deployed in real-world work environments. CRMArena is an open challenge to the community: systems that can reliably complete tasks showcase direct business value in a popular work environment.
|
14 |
+
### Task Definitions
|
15 |
+
|
16 |
+
| Task | Description |
|
17 |
+
|------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
18 |
+
| **New Case Routing (NCR)** | Assign the best human agent to an incoming case based on case subject and description to optimize performance metrics. Involves matching cases to agents using case histories, skills, and availability. |
|
19 |
+
| **Handle Time Understanding (HTU)**| Identify the agent with the shortest/longest average handle time based on case history data, evaluating the LLM agent's ability to analyze performance data accurately. |
|
20 |
+
| **Transfer Count Understanding (TCU)** | Determine which human agent transferred cases the least/most over a given period, assessing the LLM agent's capacity to analyze transfer performance accurately. |
|
21 |
+
| **Name Entity Disambiguation (NED)** | Disambiguate named entities related to customer transactions, focusing on product names. Identify specific orders corresponding to product names within a given timeframe. |
|
22 |
+
| **Policy Violation Identification (PVI)** | Determine if company policies have been breached in a case involving customer-agent interaction by comparing case details against policy rules in knowledge articles. |
|
23 |
+
| **Knowledge Question Answering (KQA)** | Answer specific questions based on knowledge articles, demonstrating the LLM agent's ability to retrieve accurate and relevant information from a CRM knowledge repository. |
|
24 |
+
| **Top Issue Identification (TII)** | Identify the most reported issue for a particular product based on case history, assessing the ability to analyze issue reports for trend analysis. |
|
25 |
+
| **Monthly Trend Analysis (MTA)** | Determine which months have the highest number of cases for a given product and timeframe, demonstrating the LLM agent's ability to recognize trends and patterns over time. |
|
26 |
+
| **Best Region Identification (BRI)** | Identify the regions where cases are closed the fastest by analyzing case closure times across various regions to indicate top-performing regions. |
|
27 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
SUBMIT_TEXT= """
|
30 |
+
To submit your results to CRMArena leaderboard, please send your outputs to us at kh.huang@salesforce.com.
|
|
|
|
|
31 |
"""
|
32 |
|
33 |
+
CITATION_BUTTON_LABEL = "If you find our work helpful, please consider citing our paper!"
|
34 |
CITATION_BUTTON_TEXT = r"""
|
35 |
+
@misc{huang-2024-crmarena,
|
36 |
+
title={CRMArena: Understanding the Capacity of LLM Agents to Perform Professional CRM Tasks in Realistic Environments},
|
37 |
+
author={Huang, Kung-Hsiang and Prabhakar, Akshara and Dhawan, Sidharth and Mao, Yixin and Wang, Huan and Savarese, Silvio and Xiong, Caiming and Laban, Philippe and Wu, Chien-Sheng},
|
38 |
+
year = {2024},
|
39 |
+
}
|
40 |
"""
|
src/display/css_html_js.py
CHANGED
@@ -33,7 +33,7 @@ custom_css = """
|
|
33 |
background: none;
|
34 |
border: none;
|
35 |
}
|
36 |
-
|
37 |
#search-bar {
|
38 |
padding: 0px;
|
39 |
}
|
@@ -77,7 +77,7 @@ table th:first-child {
|
|
77 |
#filter_type label > .wrap{
|
78 |
width: 103px;
|
79 |
}
|
80 |
-
#filter_type label > .wrap .wrap-inner{
|
81 |
padding: 2px;
|
82 |
}
|
83 |
#filter_type label > .wrap .wrap-inner input{
|
|
|
33 |
background: none;
|
34 |
border: none;
|
35 |
}
|
36 |
+
|
37 |
#search-bar {
|
38 |
padding: 0px;
|
39 |
}
|
|
|
77 |
#filter_type label > .wrap{
|
78 |
width: 103px;
|
79 |
}
|
80 |
+
#filter_type label > .wrap .wrap-inner{
|
81 |
padding: 2px;
|
82 |
}
|
83 |
#filter_type label > .wrap .wrap-inner input{
|
src/display/utils.py
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
from dataclasses import dataclass, make_dataclass
|
2 |
-
from enum import Enum
|
3 |
|
4 |
import pandas as pd
|
5 |
|
6 |
-
from src.about import Tasks
|
7 |
|
8 |
def fields(raw_class):
|
9 |
return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
|
@@ -20,91 +18,94 @@ class ColumnContent:
|
|
20 |
hidden: bool = False
|
21 |
never_hidden: bool = False
|
22 |
|
|
|
23 |
## Leaderboard columns
|
|
|
|
|
24 |
auto_eval_column_dict = []
|
|
|
|
|
25 |
# Init
|
26 |
-
auto_eval_column_dict.append(
|
27 |
-
|
28 |
-
|
29 |
-
auto_eval_column_dict.append(["average", ColumnContent, ColumnContent("Average ⬆️", "number", True)])
|
30 |
-
for task in Tasks:
|
31 |
-
auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
|
32 |
-
# Model information
|
33 |
-
auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False)])
|
34 |
-
auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
|
35 |
-
auto_eval_column_dict.append(["weight_type", ColumnContent, ColumnContent("Weight type", "str", False, True)])
|
36 |
-
auto_eval_column_dict.append(["precision", ColumnContent, ColumnContent("Precision", "str", False)])
|
37 |
-
auto_eval_column_dict.append(["license", ColumnContent, ColumnContent("Hub License", "str", False)])
|
38 |
-
auto_eval_column_dict.append(["params", ColumnContent, ColumnContent("#Params (B)", "number", False)])
|
39 |
-
auto_eval_column_dict.append(["likes", ColumnContent, ColumnContent("Hub ❤️", "number", False)])
|
40 |
-
auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False)])
|
41 |
-
auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
|
42 |
-
|
43 |
-
# We use make dataclass to dynamically fill the scores from Tasks
|
44 |
-
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
|
45 |
-
|
46 |
-
## For the queue columns in the submission tab
|
47 |
-
@dataclass(frozen=True)
|
48 |
-
class EvalQueueColumn: # Queue column
|
49 |
-
model = ColumnContent("model", "markdown", True)
|
50 |
-
revision = ColumnContent("revision", "str", True)
|
51 |
-
private = ColumnContent("private", "bool", True)
|
52 |
-
precision = ColumnContent("precision", "str", True)
|
53 |
-
weight_type = ColumnContent("weight_type", "str", "Original")
|
54 |
-
status = ColumnContent("status", "str", True)
|
55 |
-
|
56 |
-
## All the model information that we might need
|
57 |
-
@dataclass
|
58 |
-
class ModelDetails:
|
59 |
-
name: str
|
60 |
-
display_name: str = ""
|
61 |
-
symbol: str = "" # emoji
|
62 |
-
|
63 |
-
|
64 |
-
class ModelType(Enum):
|
65 |
-
PT = ModelDetails(name="pretrained", symbol="🟢")
|
66 |
-
FT = ModelDetails(name="fine-tuned", symbol="🔶")
|
67 |
-
IFT = ModelDetails(name="instruction-tuned", symbol="⭕")
|
68 |
-
RL = ModelDetails(name="RL-tuned", symbol="🟦")
|
69 |
-
Unknown = ModelDetails(name="", symbol="?")
|
70 |
-
|
71 |
-
def to_str(self, separator=" "):
|
72 |
-
return f"{self.value.symbol}{separator}{self.value.name}"
|
73 |
-
|
74 |
-
@staticmethod
|
75 |
-
def from_str(type):
|
76 |
-
if "fine-tuned" in type or "🔶" in type:
|
77 |
-
return ModelType.FT
|
78 |
-
if "pretrained" in type or "🟢" in type:
|
79 |
-
return ModelType.PT
|
80 |
-
if "RL-tuned" in type or "🟦" in type:
|
81 |
-
return ModelType.RL
|
82 |
-
if "instruction-tuned" in type or "⭕" in type:
|
83 |
-
return ModelType.IFT
|
84 |
-
return ModelType.Unknown
|
85 |
-
|
86 |
-
class WeightType(Enum):
|
87 |
-
Adapter = ModelDetails("Adapter")
|
88 |
-
Original = ModelDetails("Original")
|
89 |
-
Delta = ModelDetails("Delta")
|
90 |
-
|
91 |
-
class Precision(Enum):
|
92 |
-
float16 = ModelDetails("float16")
|
93 |
-
bfloat16 = ModelDetails("bfloat16")
|
94 |
-
Unknown = ModelDetails("?")
|
95 |
-
|
96 |
-
def from_str(precision):
|
97 |
-
if precision in ["torch.float16", "float16"]:
|
98 |
-
return Precision.float16
|
99 |
-
if precision in ["torch.bfloat16", "bfloat16"]:
|
100 |
-
return Precision.bfloat16
|
101 |
-
return Precision.Unknown
|
102 |
|
103 |
-
#
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
-
|
107 |
-
|
|
|
|
|
108 |
|
109 |
-
|
|
|
|
|
|
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from dataclasses import dataclass, make_dataclass
|
|
|
2 |
|
3 |
import pandas as pd
|
4 |
|
|
|
5 |
|
6 |
def fields(raw_class):
|
7 |
return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
|
|
|
18 |
hidden: bool = False
|
19 |
never_hidden: bool = False
|
20 |
|
21 |
+
|
22 |
## Leaderboard columns
|
23 |
+
|
24 |
+
|
25 |
auto_eval_column_dict = []
|
26 |
+
|
27 |
+
# 'Model', 'NCR', 'HTU', 'TCU', 'NED', 'PVI', 'KQA', 'TII', 'MTA', 'BRI', 'Overall', 'Agentic Framework']
|
28 |
# Init
|
29 |
+
auto_eval_column_dict.append(
|
30 |
+
["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)]
|
31 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
+
# Agentic Framework
|
34 |
+
auto_eval_column_dict.append(
|
35 |
+
["agentic_framework", ColumnContent, ColumnContent("Agentic Framework", "markdown", True, never_hidden=True)]
|
36 |
+
)
|
37 |
+
|
38 |
+
# NCR
|
39 |
+
auto_eval_column_dict.append(
|
40 |
+
["ncr", ColumnContent, ColumnContent("NCR", "markdown", True)]
|
41 |
+
)
|
42 |
+
|
43 |
+
# HTU
|
44 |
+
auto_eval_column_dict.append(
|
45 |
+
["htu", ColumnContent, ColumnContent("HTU", "markdown", True)]
|
46 |
+
)
|
47 |
+
|
48 |
+
# TCU
|
49 |
+
auto_eval_column_dict.append(
|
50 |
+
["tcu", ColumnContent, ColumnContent("TCU", "markdown", True)]
|
51 |
+
)
|
52 |
|
53 |
+
# NED
|
54 |
+
auto_eval_column_dict.append(
|
55 |
+
["ned", ColumnContent, ColumnContent("NED", "markdown", True)]
|
56 |
+
)
|
57 |
|
58 |
+
# PVI
|
59 |
+
auto_eval_column_dict.append(
|
60 |
+
["pvi", ColumnContent, ColumnContent("PVI", "markdown", True)]
|
61 |
+
)
|
62 |
|
63 |
+
# KQA
|
64 |
+
auto_eval_column_dict.append(
|
65 |
+
["kqa", ColumnContent, ColumnContent("KQA", "markdown", True)]
|
66 |
+
)
|
67 |
+
|
68 |
+
# TII
|
69 |
+
auto_eval_column_dict.append(
|
70 |
+
["tii", ColumnContent, ColumnContent("TII", "markdown", True)]
|
71 |
+
)
|
72 |
+
|
73 |
+
# MTA
|
74 |
+
auto_eval_column_dict.append(
|
75 |
+
["mta", ColumnContent, ColumnContent("MTA", "markdown", True)]
|
76 |
+
)
|
77 |
+
|
78 |
+
# BRI
|
79 |
+
auto_eval_column_dict.append(
|
80 |
+
["bri", ColumnContent, ColumnContent("BRI", "markdown", True)]
|
81 |
+
)
|
82 |
+
|
83 |
+
# Overall
|
84 |
+
auto_eval_column_dict.append(
|
85 |
+
["overall", ColumnContent, ColumnContent("Overall ⬆️", "markdown", True, never_hidden=True)]
|
86 |
+
)
|
87 |
+
|
88 |
+
|
89 |
+
|
90 |
+
# Create AutoEvalColumn class
|
91 |
+
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict)
|
92 |
+
|
93 |
+
|
94 |
+
# Column selection
|
95 |
+
COLS = [c.name for c in fields(AutoEvalColumn) if not c.hidden]
|
96 |
+
TYPES = [c.type for c in fields(AutoEvalColumn) if not c.hidden]
|
97 |
+
COLS_LITE = [c.name for c in fields(AutoEvalColumn) if c.displayed_by_default and not c.hidden]
|
98 |
+
TYPES_LITE = [c.type for c in fields(AutoEvalColumn) if c.displayed_by_default and not c.hidden]
|
99 |
+
|
100 |
+
# BENCHMARK_COLS = [t.value.col_name for t in Tasks]
|
101 |
+
|
102 |
+
NUMERIC_INTERVALS = {
|
103 |
+
"?": pd.Interval(-1, 0, closed="right"),
|
104 |
+
"~1.5": pd.Interval(0, 2, closed="right"),
|
105 |
+
"~3": pd.Interval(2, 4, closed="right"),
|
106 |
+
"~7": pd.Interval(4, 9, closed="right"),
|
107 |
+
"~13": pd.Interval(9, 20, closed="right"),
|
108 |
+
"~35": pd.Interval(20, 45, closed="right"),
|
109 |
+
"~60": pd.Interval(45, 70, closed="right"),
|
110 |
+
"70+": pd.Interval(70, 10000, closed="right"),
|
111 |
+
}
|
src/envs.py
CHANGED
@@ -4,9 +4,9 @@ from huggingface_hub import HfApi
|
|
4 |
|
5 |
# Info to change for your repository
|
6 |
# ----------------------------------
|
7 |
-
TOKEN = os.environ.get("
|
8 |
|
9 |
-
OWNER = "demo-leaderboard-backend"
|
10 |
# ----------------------------------
|
11 |
|
12 |
REPO_ID = f"{OWNER}/leaderboard"
|
@@ -14,11 +14,14 @@ QUEUE_REPO = f"{OWNER}/requests"
|
|
14 |
RESULTS_REPO = f"{OWNER}/results"
|
15 |
|
16 |
# If you setup a cache later, just change HF_HOME
|
17 |
-
CACHE_PATH=os.getenv("HF_HOME", ".")
|
18 |
|
19 |
# Local caches
|
20 |
EVAL_REQUESTS_PATH = os.path.join(CACHE_PATH, "eval-queue")
|
21 |
EVAL_RESULTS_PATH = os.path.join(CACHE_PATH, "eval-results")
|
|
|
|
|
|
|
22 |
EVAL_REQUESTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-queue-bk")
|
23 |
EVAL_RESULTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-results-bk")
|
24 |
|
|
|
4 |
|
5 |
# Info to change for your repository
|
6 |
# ----------------------------------
|
7 |
+
TOKEN = os.environ.get("TOKEN") # A read/write token for your org
|
8 |
|
9 |
+
OWNER = "demo-leaderboard-backend" # Change to your org - don't forget to create a results and request dataset, with the correct format!
|
10 |
# ----------------------------------
|
11 |
|
12 |
REPO_ID = f"{OWNER}/leaderboard"
|
|
|
14 |
RESULTS_REPO = f"{OWNER}/results"
|
15 |
|
16 |
# If you setup a cache later, just change HF_HOME
|
17 |
+
CACHE_PATH = os.getenv("HF_HOME", ".")
|
18 |
|
19 |
# Local caches
|
20 |
EVAL_REQUESTS_PATH = os.path.join(CACHE_PATH, "eval-queue")
|
21 |
EVAL_RESULTS_PATH = os.path.join(CACHE_PATH, "eval-results")
|
22 |
+
|
23 |
+
CRM_RESULTS_PATH = os.path.join(CACHE_PATH, "crmarena_results")
|
24 |
+
|
25 |
EVAL_REQUESTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-queue-bk")
|
26 |
EVAL_RESULTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-results-bk")
|
27 |
|
src/leaderboard/read_evals.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import glob
|
2 |
import json
|
3 |
-
import math
|
4 |
import os
|
5 |
from dataclasses import dataclass
|
6 |
|
@@ -8,28 +7,29 @@ import dateutil
|
|
8 |
import numpy as np
|
9 |
|
10 |
from src.display.formatting import make_clickable_model
|
11 |
-
from src.display.utils import AutoEvalColumn, ModelType,
|
12 |
-
|
|
|
13 |
|
14 |
|
15 |
@dataclass
|
16 |
class EvalResult:
|
17 |
-
"""Represents one full evaluation. Built from a combination of the result and request file for a given run.
|
18 |
-
|
19 |
-
eval_name: str
|
20 |
-
full_model: str
|
21 |
-
org: str
|
22 |
model: str
|
23 |
-
revision: str
|
24 |
results: dict
|
25 |
precision: Precision = Precision.Unknown
|
26 |
-
model_type: ModelType = ModelType.Unknown
|
27 |
-
weight_type: WeightType = WeightType.Original
|
28 |
-
architecture: str = "Unknown"
|
29 |
license: str = "?"
|
30 |
likes: int = 0
|
31 |
num_params: int = 0
|
32 |
-
date: str = ""
|
33 |
still_on_hub: bool = False
|
34 |
|
35 |
@classmethod
|
@@ -57,14 +57,14 @@ class EvalResult:
|
|
57 |
result_key = f"{org}_{model}_{precision.value.name}"
|
58 |
full_model = "/".join(org_and_model)
|
59 |
|
60 |
-
still_on_hub, _, model_config = is_model_on_hub(
|
61 |
-
|
62 |
-
)
|
63 |
architecture = "?"
|
64 |
-
if model_config is not None:
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
|
69 |
# Extract results available in this file (some results are split in several files)
|
70 |
results = {}
|
@@ -85,10 +85,10 @@ class EvalResult:
|
|
85 |
org=org,
|
86 |
model=model,
|
87 |
results=results,
|
88 |
-
precision=precision,
|
89 |
-
revision=
|
90 |
-
still_on_hub=
|
91 |
-
architecture=architecture
|
92 |
)
|
93 |
|
94 |
def update_with_request_file(self, requests_path):
|
@@ -105,7 +105,9 @@ class EvalResult:
|
|
105 |
self.num_params = request.get("params", 0)
|
106 |
self.date = request.get("submitted_time", "")
|
107 |
except Exception:
|
108 |
-
print(
|
|
|
|
|
109 |
|
110 |
def to_dict(self):
|
111 |
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
@@ -146,10 +148,7 @@ def get_request_file_for_model(requests_path, model_name, precision):
|
|
146 |
for tmp_request_file in request_files:
|
147 |
with open(tmp_request_file, "r") as f:
|
148 |
req_content = json.load(f)
|
149 |
-
if (
|
150 |
-
req_content["status"] in ["FINISHED"]
|
151 |
-
and req_content["precision"] == precision.split(".")[-1]
|
152 |
-
):
|
153 |
request_file = tmp_request_file
|
154 |
return request_file
|
155 |
|
@@ -188,7 +187,7 @@ def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResu
|
|
188 |
results = []
|
189 |
for v in eval_results.values():
|
190 |
try:
|
191 |
-
v.to_dict()
|
192 |
results.append(v)
|
193 |
except KeyError: # not all eval values present
|
194 |
continue
|
|
|
1 |
import glob
|
2 |
import json
|
|
|
3 |
import os
|
4 |
from dataclasses import dataclass
|
5 |
|
|
|
7 |
import numpy as np
|
8 |
|
9 |
from src.display.formatting import make_clickable_model
|
10 |
+
from src.display.utils import AutoEvalColumn, ModelType, Precision, Tasks, WeightType
|
11 |
+
|
12 |
+
# from src.submission.check_validity import is_model_on_hub
|
13 |
|
14 |
|
15 |
@dataclass
|
16 |
class EvalResult:
|
17 |
+
"""Represents one full evaluation. Built from a combination of the result and request file for a given run."""
|
18 |
+
|
19 |
+
eval_name: str # org_model_precision (uid)
|
20 |
+
full_model: str # org/model (path on hub)
|
21 |
+
org: str
|
22 |
model: str
|
23 |
+
revision: str # commit hash, "" if main
|
24 |
results: dict
|
25 |
precision: Precision = Precision.Unknown
|
26 |
+
model_type: ModelType = ModelType.Unknown # Pretrained, fine tuned, ...
|
27 |
+
weight_type: WeightType = WeightType.Original # Original or Adapter
|
28 |
+
architecture: str = "Unknown"
|
29 |
license: str = "?"
|
30 |
likes: int = 0
|
31 |
num_params: int = 0
|
32 |
+
date: str = "" # submission date of request file
|
33 |
still_on_hub: bool = False
|
34 |
|
35 |
@classmethod
|
|
|
57 |
result_key = f"{org}_{model}_{precision.value.name}"
|
58 |
full_model = "/".join(org_and_model)
|
59 |
|
60 |
+
# still_on_hub, _, model_config = is_model_on_hub(
|
61 |
+
# full_model, config.get("model_sha", "main"), trust_remote_code=True, test_tokenizer=False
|
62 |
+
# )
|
63 |
architecture = "?"
|
64 |
+
# if model_config is not None:
|
65 |
+
# architectures = getattr(model_config, "architectures", None)
|
66 |
+
# if architectures:
|
67 |
+
# architecture = ";".join(architectures)
|
68 |
|
69 |
# Extract results available in this file (some results are split in several files)
|
70 |
results = {}
|
|
|
85 |
org=org,
|
86 |
model=model,
|
87 |
results=results,
|
88 |
+
precision=precision,
|
89 |
+
revision=config.get("model_sha", ""),
|
90 |
+
still_on_hub=False,
|
91 |
+
architecture=architecture,
|
92 |
)
|
93 |
|
94 |
def update_with_request_file(self, requests_path):
|
|
|
105 |
self.num_params = request.get("params", 0)
|
106 |
self.date = request.get("submitted_time", "")
|
107 |
except Exception:
|
108 |
+
print(
|
109 |
+
f"Could not find request file for {self.org}/{self.model} with precision {self.precision.value.name}"
|
110 |
+
)
|
111 |
|
112 |
def to_dict(self):
|
113 |
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
|
|
148 |
for tmp_request_file in request_files:
|
149 |
with open(tmp_request_file, "r") as f:
|
150 |
req_content = json.load(f)
|
151 |
+
if req_content["status"] in ["FINISHED"] and req_content["precision"] == precision.split(".")[-1]:
|
|
|
|
|
|
|
152 |
request_file = tmp_request_file
|
153 |
return request_file
|
154 |
|
|
|
187 |
results = []
|
188 |
for v in eval_results.values():
|
189 |
try:
|
190 |
+
v.to_dict() # we test if the dict version is complete
|
191 |
results.append(v)
|
192 |
except KeyError: # not all eval values present
|
193 |
continue
|
src/populate.py
CHANGED
@@ -1,58 +1,16 @@
|
|
1 |
-
import json
|
2 |
import os
|
3 |
|
4 |
import pandas as pd
|
5 |
|
6 |
-
from src.display.
|
7 |
-
from src.display.utils import AutoEvalColumn, EvalQueueColumn
|
8 |
-
from src.leaderboard.read_evals import get_raw_eval_results
|
9 |
|
10 |
|
11 |
-
def
|
|
|
|
|
12 |
"""Creates a dataframe from all the individual experiment results"""
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
df = df[cols].round(decimals=2)
|
19 |
-
|
20 |
-
# filter out if any of the benchmarks have not been produced
|
21 |
-
df = df[has_no_nan_values(df, benchmark_cols)]
|
22 |
-
return df
|
23 |
-
|
24 |
-
|
25 |
-
def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
26 |
-
"""Creates the different dataframes for the evaluation queues requestes"""
|
27 |
-
entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
|
28 |
-
all_evals = []
|
29 |
-
|
30 |
-
for entry in entries:
|
31 |
-
if ".json" in entry:
|
32 |
-
file_path = os.path.join(save_path, entry)
|
33 |
-
with open(file_path) as fp:
|
34 |
-
data = json.load(fp)
|
35 |
-
|
36 |
-
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
37 |
-
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
38 |
-
|
39 |
-
all_evals.append(data)
|
40 |
-
elif ".md" not in entry:
|
41 |
-
# this is a folder
|
42 |
-
sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if os.path.isfile(e) and not e.startswith(".")]
|
43 |
-
for sub_entry in sub_entries:
|
44 |
-
file_path = os.path.join(save_path, entry, sub_entry)
|
45 |
-
with open(file_path) as fp:
|
46 |
-
data = json.load(fp)
|
47 |
-
|
48 |
-
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
49 |
-
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
50 |
-
all_evals.append(data)
|
51 |
-
|
52 |
-
pending_list = [e for e in all_evals if e["status"] in ["PENDING", "RERUN"]]
|
53 |
-
running_list = [e for e in all_evals if e["status"] == "RUNNING"]
|
54 |
-
finished_list = [e for e in all_evals if e["status"].startswith("FINISHED") or e["status"] == "PENDING_NEW_EVAL"]
|
55 |
-
df_pending = pd.DataFrame.from_records(pending_list, columns=cols)
|
56 |
-
df_running = pd.DataFrame.from_records(running_list, columns=cols)
|
57 |
-
df_finished = pd.DataFrame.from_records(finished_list, columns=cols)
|
58 |
-
return df_finished[cols], df_running[cols], df_pending[cols]
|
|
|
|
|
1 |
import os
|
2 |
|
3 |
import pandas as pd
|
4 |
|
5 |
+
from src.display.utils import AutoEvalColumn
|
|
|
|
|
6 |
|
7 |
|
8 |
+
def get_leaderboard_df_crm(
|
9 |
+
crm_results_path: str, cols: list
|
10 |
+
) -> tuple[pd.DataFrame, pd.DataFrame]:
|
11 |
"""Creates a dataframe from all the individual experiment results"""
|
12 |
+
model_performance_df = pd.read_csv(os.path.join(crm_results_path, "all_results.csv"))
|
13 |
+
|
14 |
+
model_performance_df = model_performance_df[cols].round(decimals=2)
|
15 |
+
model_performance_df = model_performance_df.sort_values("Overall ⬆️", ascending=False)
|
16 |
+
return model_performance_df
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/submission/check_validity.py
DELETED
@@ -1,99 +0,0 @@
|
|
1 |
-
import json
|
2 |
-
import os
|
3 |
-
import re
|
4 |
-
from collections import defaultdict
|
5 |
-
from datetime import datetime, timedelta, timezone
|
6 |
-
|
7 |
-
import huggingface_hub
|
8 |
-
from huggingface_hub import ModelCard
|
9 |
-
from huggingface_hub.hf_api import ModelInfo
|
10 |
-
from transformers import AutoConfig
|
11 |
-
from transformers.models.auto.tokenization_auto import AutoTokenizer
|
12 |
-
|
13 |
-
def check_model_card(repo_id: str) -> tuple[bool, str]:
|
14 |
-
"""Checks if the model card and license exist and have been filled"""
|
15 |
-
try:
|
16 |
-
card = ModelCard.load(repo_id)
|
17 |
-
except huggingface_hub.utils.EntryNotFoundError:
|
18 |
-
return False, "Please add a model card to your model to explain how you trained/fine-tuned it."
|
19 |
-
|
20 |
-
# Enforce license metadata
|
21 |
-
if card.data.license is None:
|
22 |
-
if not ("license_name" in card.data and "license_link" in card.data):
|
23 |
-
return False, (
|
24 |
-
"License not found. Please add a license to your model card using the `license` metadata or a"
|
25 |
-
" `license_name`/`license_link` pair."
|
26 |
-
)
|
27 |
-
|
28 |
-
# Enforce card content
|
29 |
-
if len(card.text) < 200:
|
30 |
-
return False, "Please add a description to your model card, it is too short."
|
31 |
-
|
32 |
-
return True, ""
|
33 |
-
|
34 |
-
def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_remote_code=False, test_tokenizer=False) -> tuple[bool, str]:
|
35 |
-
"""Checks if the model model_name is on the hub, and whether it (and its tokenizer) can be loaded with AutoClasses."""
|
36 |
-
try:
|
37 |
-
config = AutoConfig.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
38 |
-
if test_tokenizer:
|
39 |
-
try:
|
40 |
-
tk = AutoTokenizer.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
41 |
-
except ValueError as e:
|
42 |
-
return (
|
43 |
-
False,
|
44 |
-
f"uses a tokenizer which is not in a transformers release: {e}",
|
45 |
-
None
|
46 |
-
)
|
47 |
-
except Exception as e:
|
48 |
-
return (False, "'s tokenizer cannot be loaded. Is your tokenizer class in a stable transformers release, and correctly configured?", None)
|
49 |
-
return True, None, config
|
50 |
-
|
51 |
-
except ValueError:
|
52 |
-
return (
|
53 |
-
False,
|
54 |
-
"needs to be launched with `trust_remote_code=True`. For safety reason, we do not allow these models to be automatically submitted to the leaderboard.",
|
55 |
-
None
|
56 |
-
)
|
57 |
-
|
58 |
-
except Exception as e:
|
59 |
-
return False, "was not found on hub!", None
|
60 |
-
|
61 |
-
|
62 |
-
def get_model_size(model_info: ModelInfo, precision: str):
|
63 |
-
"""Gets the model size from the configuration, or the model name if the configuration does not contain the information."""
|
64 |
-
try:
|
65 |
-
model_size = round(model_info.safetensors["total"] / 1e9, 3)
|
66 |
-
except (AttributeError, TypeError):
|
67 |
-
return 0 # Unknown model sizes are indicated as 0, see NUMERIC_INTERVALS in app.py
|
68 |
-
|
69 |
-
size_factor = 8 if (precision == "GPTQ" or "gptq" in model_info.modelId.lower()) else 1
|
70 |
-
model_size = size_factor * model_size
|
71 |
-
return model_size
|
72 |
-
|
73 |
-
def get_model_arch(model_info: ModelInfo):
|
74 |
-
"""Gets the model architecture from the configuration"""
|
75 |
-
return model_info.config.get("architectures", "Unknown")
|
76 |
-
|
77 |
-
def already_submitted_models(requested_models_dir: str) -> set[str]:
|
78 |
-
"""Gather a list of already submitted models to avoid duplicates"""
|
79 |
-
depth = 1
|
80 |
-
file_names = []
|
81 |
-
users_to_submission_dates = defaultdict(list)
|
82 |
-
|
83 |
-
for root, _, files in os.walk(requested_models_dir):
|
84 |
-
current_depth = root.count(os.sep) - requested_models_dir.count(os.sep)
|
85 |
-
if current_depth == depth:
|
86 |
-
for file in files:
|
87 |
-
if not file.endswith(".json"):
|
88 |
-
continue
|
89 |
-
with open(os.path.join(root, file), "r") as f:
|
90 |
-
info = json.load(f)
|
91 |
-
file_names.append(f"{info['model']}_{info['revision']}_{info['precision']}")
|
92 |
-
|
93 |
-
# Select organisation
|
94 |
-
if info["model"].count("/") == 0 or "submitted_time" not in info:
|
95 |
-
continue
|
96 |
-
organisation, _ = info["model"].split("/")
|
97 |
-
users_to_submission_dates[organisation].append(info["submitted_time"])
|
98 |
-
|
99 |
-
return set(file_names), users_to_submission_dates
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/submission/submit.py
DELETED
@@ -1,119 +0,0 @@
|
|
1 |
-
import json
|
2 |
-
import os
|
3 |
-
from datetime import datetime, timezone
|
4 |
-
|
5 |
-
from src.display.formatting import styled_error, styled_message, styled_warning
|
6 |
-
from src.envs import API, EVAL_REQUESTS_PATH, TOKEN, QUEUE_REPO
|
7 |
-
from src.submission.check_validity import (
|
8 |
-
already_submitted_models,
|
9 |
-
check_model_card,
|
10 |
-
get_model_size,
|
11 |
-
is_model_on_hub,
|
12 |
-
)
|
13 |
-
|
14 |
-
REQUESTED_MODELS = None
|
15 |
-
USERS_TO_SUBMISSION_DATES = None
|
16 |
-
|
17 |
-
def add_new_eval(
|
18 |
-
model: str,
|
19 |
-
base_model: str,
|
20 |
-
revision: str,
|
21 |
-
precision: str,
|
22 |
-
weight_type: str,
|
23 |
-
model_type: str,
|
24 |
-
):
|
25 |
-
global REQUESTED_MODELS
|
26 |
-
global USERS_TO_SUBMISSION_DATES
|
27 |
-
if not REQUESTED_MODELS:
|
28 |
-
REQUESTED_MODELS, USERS_TO_SUBMISSION_DATES = already_submitted_models(EVAL_REQUESTS_PATH)
|
29 |
-
|
30 |
-
user_name = ""
|
31 |
-
model_path = model
|
32 |
-
if "/" in model:
|
33 |
-
user_name = model.split("/")[0]
|
34 |
-
model_path = model.split("/")[1]
|
35 |
-
|
36 |
-
precision = precision.split(" ")[0]
|
37 |
-
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
38 |
-
|
39 |
-
if model_type is None or model_type == "":
|
40 |
-
return styled_error("Please select a model type.")
|
41 |
-
|
42 |
-
# Does the model actually exist?
|
43 |
-
if revision == "":
|
44 |
-
revision = "main"
|
45 |
-
|
46 |
-
# Is the model on the hub?
|
47 |
-
if weight_type in ["Delta", "Adapter"]:
|
48 |
-
base_model_on_hub, error, _ = is_model_on_hub(model_name=base_model, revision=revision, token=TOKEN, test_tokenizer=True)
|
49 |
-
if not base_model_on_hub:
|
50 |
-
return styled_error(f'Base model "{base_model}" {error}')
|
51 |
-
|
52 |
-
if not weight_type == "Adapter":
|
53 |
-
model_on_hub, error, _ = is_model_on_hub(model_name=model, revision=revision, token=TOKEN, test_tokenizer=True)
|
54 |
-
if not model_on_hub:
|
55 |
-
return styled_error(f'Model "{model}" {error}')
|
56 |
-
|
57 |
-
# Is the model info correctly filled?
|
58 |
-
try:
|
59 |
-
model_info = API.model_info(repo_id=model, revision=revision)
|
60 |
-
except Exception:
|
61 |
-
return styled_error("Could not get your model information. Please fill it up properly.")
|
62 |
-
|
63 |
-
model_size = get_model_size(model_info=model_info, precision=precision)
|
64 |
-
|
65 |
-
# Were the model card and license filled?
|
66 |
-
try:
|
67 |
-
license = model_info.cardData["license"]
|
68 |
-
except Exception:
|
69 |
-
return styled_error("Please select a license for your model")
|
70 |
-
|
71 |
-
modelcard_OK, error_msg = check_model_card(model)
|
72 |
-
if not modelcard_OK:
|
73 |
-
return styled_error(error_msg)
|
74 |
-
|
75 |
-
# Seems good, creating the eval
|
76 |
-
print("Adding new eval")
|
77 |
-
|
78 |
-
eval_entry = {
|
79 |
-
"model": model,
|
80 |
-
"base_model": base_model,
|
81 |
-
"revision": revision,
|
82 |
-
"precision": precision,
|
83 |
-
"weight_type": weight_type,
|
84 |
-
"status": "PENDING",
|
85 |
-
"submitted_time": current_time,
|
86 |
-
"model_type": model_type,
|
87 |
-
"likes": model_info.likes,
|
88 |
-
"params": model_size,
|
89 |
-
"license": license,
|
90 |
-
"private": False,
|
91 |
-
}
|
92 |
-
|
93 |
-
# Check for duplicate submission
|
94 |
-
if f"{model}_{revision}_{precision}" in REQUESTED_MODELS:
|
95 |
-
return styled_warning("This model has been already submitted.")
|
96 |
-
|
97 |
-
print("Creating eval file")
|
98 |
-
OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
|
99 |
-
os.makedirs(OUT_DIR, exist_ok=True)
|
100 |
-
out_path = f"{OUT_DIR}/{model_path}_eval_request_False_{precision}_{weight_type}.json"
|
101 |
-
|
102 |
-
with open(out_path, "w") as f:
|
103 |
-
f.write(json.dumps(eval_entry))
|
104 |
-
|
105 |
-
print("Uploading eval file")
|
106 |
-
API.upload_file(
|
107 |
-
path_or_fileobj=out_path,
|
108 |
-
path_in_repo=out_path.split("eval-queue/")[1],
|
109 |
-
repo_id=QUEUE_REPO,
|
110 |
-
repo_type="dataset",
|
111 |
-
commit_message=f"Add {model} to eval queue",
|
112 |
-
)
|
113 |
-
|
114 |
-
# Remove the local file
|
115 |
-
os.remove(out_path)
|
116 |
-
|
117 |
-
return styled_message(
|
118 |
-
"Your request has been submitted to the evaluation queue!\nPlease wait for up to an hour for the model to show in the PENDING list."
|
119 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|