Spaces:
Running
Running
XufengDuan
commited on
Commit
•
56bf4e8
1
Parent(s):
06b8478
Update space
Browse files- README.md +20 -17
- app.py +205 -81
- requirements.txt +15 -14
- src/display/css_html_js.py +7 -1
- src/display/formatting.py +9 -0
- src/display/utils.py +31 -5
- src/envs.py +29 -8
- src/leaderboard/read_evals.py +70 -72
- src/populate.py +15 -14
- src/submission/check_validity.py +5 -7
- src/submission/submit.py +22 -26
README.md
CHANGED
@@ -1,20 +1,32 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
emoji: 🥇
|
4 |
-
colorFrom:
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
|
|
7 |
app_file: app.py
|
8 |
pinned: true
|
9 |
-
license:
|
|
|
|
|
|
|
|
|
10 |
---
|
11 |
|
12 |
-
# Start the configuration
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
18 |
{
|
19 |
"config": {
|
20 |
"model_dtype": "torch.float16", # or torch.bfloat16 or 8bit or 4bit
|
@@ -32,13 +44,4 @@ Results files should have the following format and be stored as json files:
|
|
32 |
}
|
33 |
```
|
34 |
|
35 |
-
Request files are created automatically by this tool.
|
36 |
-
|
37 |
-
If you encounter problem on the space, don't hesitate to restart it to remove the create eval-queue, eval-queue-bk, eval-results and eval-results-bk created folder.
|
38 |
-
|
39 |
-
# Code logic for more complex edits
|
40 |
-
|
41 |
-
You'll find
|
42 |
-
- the main table' columns names and properties in `src/display/utils.py`
|
43 |
-
- the logic to read all results and request files, then convert them in dataframe lines, in `src/leaderboard/read_evals.py`, and `src/populate.py`
|
44 |
-
- teh logic to allow or filter submissions in `src/submission/submit.py` and `src/submission/check_validity.py`
|
|
|
1 |
---
|
2 |
+
title: Humanlike Evaluation Leaderboard
|
3 |
emoji: 🥇
|
4 |
+
colorFrom: blue
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.37.1
|
8 |
app_file: app.py
|
9 |
pinned: true
|
10 |
+
license: apache-2.0
|
11 |
+
tags:
|
12 |
+
- leaderboard
|
13 |
+
models:
|
14 |
+
- google/gemma-2-9b
|
15 |
---
|
16 |
|
|
|
17 |
|
18 |
+
python>3.10
|
19 |
+
pip spacy
|
20 |
+
python -m spacy download en_core_web_sm
|
21 |
+
pip install google.generativeai
|
22 |
+
python -m spacy download en_core_web_trf
|
23 |
|
24 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
25 |
+
|
26 |
+
Most of the variables to change for a default leaderboard are in env (replace the path for your leaderboard) and src/display/about.
|
27 |
+
|
28 |
+
Results files should have the following format:
|
29 |
+
```
|
30 |
{
|
31 |
"config": {
|
32 |
"model_dtype": "torch.float16", # or torch.bfloat16 or 8bit or 4bit
|
|
|
44 |
}
|
45 |
```
|
46 |
|
47 |
+
Request files are created automatically by this tool.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
@@ -1,110 +1,234 @@
|
|
1 |
import gradio as gr
|
2 |
-
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
3 |
import pandas as pd
|
4 |
from apscheduler.schedulers.background import BackgroundScheduler
|
5 |
from huggingface_hub import snapshot_download
|
6 |
|
7 |
-
|
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 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
EVAL_TYPES,
|
21 |
-
AutoEvalColumn,
|
22 |
-
ModelType,
|
23 |
-
fields,
|
24 |
-
WeightType,
|
25 |
-
Precision
|
26 |
-
)
|
27 |
-
from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REPO_ID, RESULTS_REPO, TOKEN
|
28 |
-
from src.populate import get_evaluation_queue_df, get_leaderboard_df
|
29 |
-
from src.submission.submit import add_new_eval
|
30 |
|
31 |
|
32 |
def restart_space():
|
33 |
-
API.restart_space(repo_id=REPO_ID)
|
34 |
|
35 |
-
### Space initialisation
|
36 |
try:
|
37 |
-
print(EVAL_REQUESTS_PATH)
|
38 |
snapshot_download(
|
39 |
-
repo_id=QUEUE_REPO, local_dir=EVAL_REQUESTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30
|
40 |
)
|
41 |
except Exception:
|
42 |
restart_space()
|
43 |
try:
|
44 |
-
print(EVAL_RESULTS_PATH)
|
45 |
snapshot_download(
|
46 |
-
repo_id=RESULTS_REPO, local_dir=EVAL_RESULTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30
|
47 |
)
|
48 |
except Exception:
|
49 |
restart_space()
|
50 |
|
51 |
-
|
52 |
-
|
53 |
|
54 |
(
|
55 |
finished_eval_queue_df,
|
56 |
running_eval_queue_df,
|
57 |
pending_eval_queue_df,
|
58 |
-
) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
|
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("🏅 LLM Benchmark", elem_id="llm-benchmark-tab-table", id=0):
|
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(
|
@@ -114,8 +238,8 @@ with demo:
|
|
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(
|
@@ -125,8 +249,8 @@ with demo:
|
|
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 |
|
@@ -137,8 +261,8 @@ with demo:
|
|
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():
|
@@ -149,7 +273,7 @@ with demo:
|
|
149 |
model_name_textbox = gr.Textbox(label="Model name")
|
150 |
revision_name_textbox = gr.Textbox(label="Revision commit", placeholder="main")
|
151 |
model_type = gr.Dropdown(
|
152 |
-
choices=[t.to_str(" : ") for t in ModelType if t != ModelType.Unknown],
|
153 |
label="Model type",
|
154 |
multiselect=False,
|
155 |
value=None,
|
@@ -158,14 +282,14 @@ with demo:
|
|
158 |
|
159 |
with gr.Column():
|
160 |
precision = gr.Dropdown(
|
161 |
-
choices=[i.value.name for i in Precision if i != Precision.Unknown],
|
162 |
label="Precision",
|
163 |
multiselect=False,
|
164 |
value="float16",
|
165 |
interactive=True,
|
166 |
)
|
167 |
weight_type = gr.Dropdown(
|
168 |
-
choices=[i.value.name for i in WeightType],
|
169 |
label="Weights type",
|
170 |
multiselect=False,
|
171 |
value="Original",
|
@@ -176,7 +300,7 @@ with demo:
|
|
176 |
submit_button = gr.Button("Submit Eval")
|
177 |
submission_result = gr.Markdown()
|
178 |
submit_button.click(
|
179 |
-
add_new_eval,
|
180 |
[
|
181 |
model_name_textbox,
|
182 |
base_model_name_textbox,
|
@@ -191,8 +315,8 @@ with demo:
|
|
191 |
with gr.Row():
|
192 |
with gr.Accordion("📙 Citation", open=False):
|
193 |
citation_button = gr.Textbox(
|
194 |
-
value=CITATION_BUTTON_TEXT,
|
195 |
-
label=CITATION_BUTTON_LABEL,
|
196 |
lines=20,
|
197 |
elem_id="citation-button",
|
198 |
show_copy_button=True,
|
@@ -201,4 +325,4 @@ with demo:
|
|
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 |
from apscheduler.schedulers.background import BackgroundScheduler
|
4 |
from huggingface_hub import snapshot_download
|
5 |
|
6 |
+
import src.display.about as about
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
from src.display.css_html_js import custom_css
|
8 |
+
import src.display.utils as utils
|
9 |
+
import src.envs as envs
|
10 |
+
import src.populate as populate
|
11 |
+
import src.submission.submit as submit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
|
14 |
def restart_space():
|
15 |
+
envs.API.restart_space(repo_id=envs.REPO_ID, token=envs.TOKEN)
|
16 |
|
|
|
17 |
try:
|
18 |
+
print(envs.EVAL_REQUESTS_PATH)
|
19 |
snapshot_download(
|
20 |
+
repo_id=envs.QUEUE_REPO, local_dir=envs.EVAL_REQUESTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30
|
21 |
)
|
22 |
except Exception:
|
23 |
restart_space()
|
24 |
try:
|
25 |
+
print(envs.EVAL_RESULTS_PATH)
|
26 |
snapshot_download(
|
27 |
+
repo_id=envs.RESULTS_REPO, local_dir=envs.EVAL_RESULTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30
|
28 |
)
|
29 |
except Exception:
|
30 |
restart_space()
|
31 |
|
32 |
+
raw_data, original_df = populate.get_leaderboard_df(envs.EVAL_RESULTS_PATH, envs.EVAL_REQUESTS_PATH, utils.COLS, utils.BENCHMARK_COLS)
|
33 |
+
leaderboard_df = original_df.copy()
|
34 |
|
35 |
(
|
36 |
finished_eval_queue_df,
|
37 |
running_eval_queue_df,
|
38 |
pending_eval_queue_df,
|
39 |
+
) = populate.get_evaluation_queue_df(envs.EVAL_REQUESTS_PATH, utils.EVAL_COLS)
|
40 |
+
|
41 |
+
|
42 |
+
# Searching and filtering
|
43 |
+
def update_table(
|
44 |
+
hidden_df: pd.DataFrame,
|
45 |
+
columns: list,
|
46 |
+
type_query: list,
|
47 |
+
precision_query: str,
|
48 |
+
size_query: list,
|
49 |
+
show_deleted: bool,
|
50 |
+
query: str,
|
51 |
+
):
|
52 |
+
filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, show_deleted)
|
53 |
+
filtered_df = filter_queries(query, filtered_df)
|
54 |
+
df = select_columns(filtered_df, columns)
|
55 |
+
return df
|
56 |
+
|
57 |
+
|
58 |
+
def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
|
59 |
+
return df[(df[utils.AutoEvalColumn.dummy.name].str.contains(query, case=False))]
|
60 |
+
|
61 |
+
|
62 |
+
def select_columns(df: pd.DataFrame, columns: list) -> pd.DataFrame:
|
63 |
+
always_here_cols = [
|
64 |
+
utils.AutoEvalColumn.model_type_symbol.name,
|
65 |
+
utils.AutoEvalColumn.model.name,
|
66 |
+
]
|
67 |
+
# We use COLS to maintain sorting
|
68 |
+
filtered_df = df[
|
69 |
+
always_here_cols + [c for c in utils.COLS if c in df.columns and c in columns] + [utils.AutoEvalColumn.dummy.name]
|
70 |
+
]
|
71 |
+
return filtered_df
|
72 |
+
|
73 |
+
|
74 |
+
def filter_queries(query: str, filtered_df: pd.DataFrame) -> pd.DataFrame:
|
75 |
+
final_df = []
|
76 |
+
if query != "":
|
77 |
+
queries = [q.strip() for q in query.split(";")]
|
78 |
+
for _q in queries:
|
79 |
+
_q = _q.strip()
|
80 |
+
if _q != "":
|
81 |
+
temp_filtered_df = search_table(filtered_df, _q)
|
82 |
+
if len(temp_filtered_df) > 0:
|
83 |
+
final_df.append(temp_filtered_df)
|
84 |
+
if len(final_df) > 0:
|
85 |
+
filtered_df = pd.concat(final_df)
|
86 |
+
filtered_df = filtered_df.drop_duplicates(
|
87 |
+
subset=[utils.AutoEvalColumn.model.name, utils.AutoEvalColumn.precision.name, utils.AutoEvalColumn.revision.name]
|
88 |
+
)
|
89 |
+
|
90 |
+
return filtered_df
|
91 |
+
|
92 |
+
|
93 |
+
def filter_models(
|
94 |
+
df: pd.DataFrame, type_query: list, size_query: list, precision_query: list, show_deleted: bool
|
95 |
+
) -> pd.DataFrame:
|
96 |
+
# Show all models
|
97 |
+
# if show_deleted:
|
98 |
+
# filtered_df = df
|
99 |
+
# else: # Show only still on the hub models
|
100 |
+
# filtered_df = df[df[utils.AutoEvalColumn.still_on_hub.name]]
|
101 |
+
|
102 |
+
filtered_df = df
|
103 |
+
|
104 |
+
type_emoji = [t[0] for t in type_query]
|
105 |
+
filtered_df = filtered_df.loc[df[utils.AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
|
106 |
+
filtered_df = filtered_df.loc[df[utils.AutoEvalColumn.precision.name].isin(precision_query + ["None"])]
|
107 |
+
|
108 |
+
numeric_interval = pd.IntervalIndex(sorted([utils.NUMERIC_INTERVALS[s] for s in size_query]))
|
109 |
+
params_column = pd.to_numeric(df[utils.AutoEvalColumn.params.name], errors="coerce")
|
110 |
+
mask = params_column.apply(lambda x: any(numeric_interval.contains(x)))
|
111 |
+
filtered_df = filtered_df.loc[mask]
|
112 |
+
|
113 |
+
return filtered_df
|
114 |
|
115 |
|
116 |
demo = gr.Blocks(css=custom_css)
|
117 |
with demo:
|
118 |
+
gr.HTML(about.TITLE)
|
119 |
+
gr.Markdown(about.INTRODUCTION_TEXT, elem_classes="markdown-text")
|
120 |
|
121 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
122 |
with gr.TabItem("🏅 LLM Benchmark", elem_id="llm-benchmark-tab-table", id=0):
|
123 |
+
with gr.Row():
|
124 |
+
with gr.Column():
|
125 |
+
with gr.Row():
|
126 |
+
search_bar = gr.Textbox(
|
127 |
+
placeholder=" 🔍 Search for your model (separate multiple queries with `;`) and press ENTER...",
|
128 |
+
show_label=False,
|
129 |
+
elem_id="search-bar",
|
130 |
+
)
|
131 |
+
with gr.Row():
|
132 |
+
shown_columns = gr.CheckboxGroup(
|
133 |
+
choices=[
|
134 |
+
c.name
|
135 |
+
for c in utils.fields(utils.AutoEvalColumn)
|
136 |
+
if not c.hidden and not c.never_hidden and not c.dummy
|
137 |
+
],
|
138 |
+
value=[
|
139 |
+
c.name
|
140 |
+
for c in utils.fields(utils.AutoEvalColumn)
|
141 |
+
if c.displayed_by_default and not c.hidden and not c.never_hidden
|
142 |
+
],
|
143 |
+
label="Select columns to show",
|
144 |
+
elem_id="column-select",
|
145 |
+
interactive=True,
|
146 |
+
)
|
147 |
+
with gr.Row():
|
148 |
+
deleted_models_visibility = gr.Checkbox(
|
149 |
+
value=False, label="Show gated/private/deleted models", interactive=True
|
150 |
+
)
|
151 |
+
with gr.Column(min_width=320):
|
152 |
+
#with gr.Box(elem_id="box-filter"):
|
153 |
+
filter_columns_type = gr.CheckboxGroup(
|
154 |
+
label="Model types",
|
155 |
+
choices=[t.to_str() for t in utils.ModelType],
|
156 |
+
value=[t.to_str() for t in utils.ModelType],
|
157 |
+
interactive=True,
|
158 |
+
elem_id="filter-columns-type",
|
159 |
+
)
|
160 |
+
filter_columns_precision = gr.CheckboxGroup(
|
161 |
+
label="Precision",
|
162 |
+
choices=[i.value.name for i in utils.Precision],
|
163 |
+
value=[i.value.name for i in utils.Precision],
|
164 |
+
interactive=True,
|
165 |
+
elem_id="filter-columns-precision",
|
166 |
+
)
|
167 |
+
filter_columns_size = gr.CheckboxGroup(
|
168 |
+
label="Model sizes (in billions of parameters)",
|
169 |
+
choices=list(utils.NUMERIC_INTERVALS.keys()),
|
170 |
+
value=list(utils.NUMERIC_INTERVALS.keys()),
|
171 |
+
interactive=True,
|
172 |
+
elem_id="filter-columns-size",
|
173 |
+
)
|
174 |
+
|
175 |
+
leaderboard_table = gr.components.Dataframe(
|
176 |
+
value=leaderboard_df[
|
177 |
+
[c.name for c in utils.fields(utils.AutoEvalColumn) if c.never_hidden]
|
178 |
+
+ shown_columns.value
|
179 |
+
+ [utils.AutoEvalColumn.dummy.name]
|
180 |
+
],
|
181 |
+
headers=[c.name for c in utils.fields(utils.AutoEvalColumn) if c.never_hidden] + shown_columns.value,
|
182 |
+
datatype=utils.TYPES,
|
183 |
+
elem_id="leaderboard-table",
|
184 |
+
interactive=False,
|
185 |
+
visible=True,
|
186 |
+
column_widths=["2%", "33%"]
|
187 |
+
)
|
188 |
+
|
189 |
+
# Dummy leaderboard for handling the case when the user uses backspace key
|
190 |
+
hidden_leaderboard_table_for_search = gr.components.Dataframe(
|
191 |
+
value=original_df[utils.COLS],
|
192 |
+
headers=utils.COLS,
|
193 |
+
datatype=utils.TYPES,
|
194 |
+
visible=False,
|
195 |
+
)
|
196 |
+
search_bar.submit(
|
197 |
+
update_table,
|
198 |
+
[
|
199 |
+
hidden_leaderboard_table_for_search,
|
200 |
+
shown_columns,
|
201 |
+
filter_columns_type,
|
202 |
+
filter_columns_precision,
|
203 |
+
filter_columns_size,
|
204 |
+
deleted_models_visibility,
|
205 |
+
search_bar,
|
206 |
+
],
|
207 |
+
leaderboard_table,
|
208 |
+
)
|
209 |
+
for selector in [shown_columns, filter_columns_type, filter_columns_precision, filter_columns_size, deleted_models_visibility]:
|
210 |
+
selector.change(
|
211 |
+
update_table,
|
212 |
+
[
|
213 |
+
hidden_leaderboard_table_for_search,
|
214 |
+
shown_columns,
|
215 |
+
filter_columns_type,
|
216 |
+
filter_columns_precision,
|
217 |
+
filter_columns_size,
|
218 |
+
deleted_models_visibility,
|
219 |
+
search_bar,
|
220 |
+
],
|
221 |
+
leaderboard_table,
|
222 |
+
queue=True,
|
223 |
+
)
|
224 |
|
225 |
with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=2):
|
226 |
+
gr.Markdown(about.LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
227 |
|
228 |
with gr.TabItem("🚀 Submit here! ", elem_id="llm-benchmark-tab-table", id=3):
|
229 |
with gr.Column():
|
230 |
with gr.Row():
|
231 |
+
gr.Markdown(about.EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
|
232 |
|
233 |
with gr.Column():
|
234 |
with gr.Accordion(
|
|
|
238 |
with gr.Row():
|
239 |
finished_eval_table = gr.components.Dataframe(
|
240 |
value=finished_eval_queue_df,
|
241 |
+
headers=utils.EVAL_COLS,
|
242 |
+
datatype=utils.EVAL_TYPES,
|
243 |
row_count=5,
|
244 |
)
|
245 |
with gr.Accordion(
|
|
|
249 |
with gr.Row():
|
250 |
running_eval_table = gr.components.Dataframe(
|
251 |
value=running_eval_queue_df,
|
252 |
+
headers=utils.EVAL_COLS,
|
253 |
+
datatype=utils.EVAL_TYPES,
|
254 |
row_count=5,
|
255 |
)
|
256 |
|
|
|
261 |
with gr.Row():
|
262 |
pending_eval_table = gr.components.Dataframe(
|
263 |
value=pending_eval_queue_df,
|
264 |
+
headers=utils.EVAL_COLS,
|
265 |
+
datatype=utils.EVAL_TYPES,
|
266 |
row_count=5,
|
267 |
)
|
268 |
with gr.Row():
|
|
|
273 |
model_name_textbox = gr.Textbox(label="Model name")
|
274 |
revision_name_textbox = gr.Textbox(label="Revision commit", placeholder="main")
|
275 |
model_type = gr.Dropdown(
|
276 |
+
choices=[t.to_str(" : ") for t in utils.ModelType if t != utils.ModelType.Unknown],
|
277 |
label="Model type",
|
278 |
multiselect=False,
|
279 |
value=None,
|
|
|
282 |
|
283 |
with gr.Column():
|
284 |
precision = gr.Dropdown(
|
285 |
+
choices=[i.value.name for i in utils.Precision if i != utils.Precision.Unknown],
|
286 |
label="Precision",
|
287 |
multiselect=False,
|
288 |
value="float16",
|
289 |
interactive=True,
|
290 |
)
|
291 |
weight_type = gr.Dropdown(
|
292 |
+
choices=[i.value.name for i in utils.WeightType],
|
293 |
label="Weights type",
|
294 |
multiselect=False,
|
295 |
value="Original",
|
|
|
300 |
submit_button = gr.Button("Submit Eval")
|
301 |
submission_result = gr.Markdown()
|
302 |
submit_button.click(
|
303 |
+
submit.add_new_eval,
|
304 |
[
|
305 |
model_name_textbox,
|
306 |
base_model_name_textbox,
|
|
|
315 |
with gr.Row():
|
316 |
with gr.Accordion("📙 Citation", open=False):
|
317 |
citation_button = gr.Textbox(
|
318 |
+
value=about.CITATION_BUTTON_TEXT,
|
319 |
+
label=about.CITATION_BUTTON_LABEL,
|
320 |
lines=20,
|
321 |
elem_id="citation-button",
|
322 |
show_copy_button=True,
|
|
|
325 |
scheduler = BackgroundScheduler()
|
326 |
scheduler.add_job(restart_space, "interval", seconds=1800)
|
327 |
scheduler.start()
|
328 |
+
demo.queue(default_concurrency_limit=40).launch()
|
requirements.txt
CHANGED
@@ -1,16 +1,17 @@
|
|
1 |
-
APScheduler
|
2 |
-
black
|
3 |
-
|
4 |
-
|
5 |
-
gradio
|
6 |
-
|
7 |
-
gradio_client
|
8 |
huggingface-hub>=0.18.0
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
tokenizers>=0.15.0
|
16 |
-
|
|
|
1 |
+
APScheduler==3.10.1
|
2 |
+
black==23.11.0
|
3 |
+
click==8.1.3
|
4 |
+
datasets==2.14.5
|
5 |
+
gradio==4.4.0
|
6 |
+
gradio_client==0.7.0
|
|
|
7 |
huggingface-hub>=0.18.0
|
8 |
+
litellm==1.15.1
|
9 |
+
matplotlib==3.7.1
|
10 |
+
numpy==1.24.2
|
11 |
+
pandas==2.0.0
|
12 |
+
python-dateutil==2.8.2
|
13 |
+
requests==2.28.2
|
14 |
+
tqdm==4.65.0
|
15 |
+
transformers==4.35.2
|
16 |
tokenizers>=0.15.0
|
17 |
+
sentence-transformers==2.2.2
|
src/display/css_html_js.py
CHANGED
@@ -33,11 +33,17 @@ custom_css = """
|
|
33 |
background: none;
|
34 |
border: none;
|
35 |
}
|
36 |
-
|
37 |
#search-bar {
|
38 |
padding: 0px;
|
39 |
}
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
/* Limit the width of the first AutoEvalColumn so that names don't expand too much */
|
42 |
table td:first-child,
|
43 |
table th:first-child {
|
|
|
33 |
background: none;
|
34 |
border: none;
|
35 |
}
|
36 |
+
|
37 |
#search-bar {
|
38 |
padding: 0px;
|
39 |
}
|
40 |
|
41 |
+
/* Hides the final AutoEvalColumn */
|
42 |
+
#llm-benchmark-tab-table table td:last-child,
|
43 |
+
#llm-benchmark-tab-table table th:last-child {
|
44 |
+
display: none;
|
45 |
+
}
|
46 |
+
|
47 |
/* Limit the width of the first AutoEvalColumn so that names don't expand too much */
|
48 |
table td:first-child,
|
49 |
table th:first-child {
|
src/display/formatting.py
CHANGED
@@ -1,3 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
def model_hyperlink(link, model_name):
|
2 |
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
|
3 |
|
|
|
1 |
+
import os
|
2 |
+
from datetime import datetime, timezone
|
3 |
+
|
4 |
+
from huggingface_hub import HfApi
|
5 |
+
from huggingface_hub.hf_api import ModelInfo
|
6 |
+
|
7 |
+
|
8 |
+
API = HfApi()
|
9 |
+
|
10 |
def model_hyperlink(link, model_name):
|
11 |
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
|
12 |
|
src/display/utils.py
CHANGED
@@ -3,7 +3,7 @@ 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:] != "__"]
|
@@ -19,16 +19,18 @@ class ColumnContent:
|
|
19 |
displayed_by_default: bool
|
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(["model_type_symbol", ColumnContent,
|
27 |
-
|
28 |
-
|
29 |
-
|
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)])
|
@@ -39,6 +41,8 @@ auto_eval_column_dict.append(["params", ColumnContent, ColumnContent("#Params (B
|
|
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)
|
@@ -91,6 +95,9 @@ class WeightType(Enum):
|
|
91 |
class Precision(Enum):
|
92 |
float16 = ModelDetails("float16")
|
93 |
bfloat16 = ModelDetails("bfloat16")
|
|
|
|
|
|
|
94 |
Unknown = ModelDetails("?")
|
95 |
|
96 |
def from_str(precision):
|
@@ -98,13 +105,32 @@ class Precision(Enum):
|
|
98 |
return Precision.float16
|
99 |
if precision in ["torch.bfloat16", "bfloat16"]:
|
100 |
return Precision.bfloat16
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
return Precision.Unknown
|
102 |
|
103 |
# Column selection
|
104 |
COLS = [c.name for c in fields(AutoEvalColumn) if not c.hidden]
|
|
|
|
|
|
|
105 |
|
106 |
EVAL_COLS = [c.name for c in fields(EvalQueueColumn)]
|
107 |
EVAL_TYPES = [c.type for c in fields(EvalQueueColumn)]
|
108 |
|
109 |
BENCHMARK_COLS = [t.value.col_name for t in Tasks]
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
import pandas as pd
|
5 |
|
6 |
+
from src.display.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:] != "__"]
|
|
|
19 |
displayed_by_default: bool
|
20 |
hidden: bool = False
|
21 |
never_hidden: bool = False
|
22 |
+
dummy: bool = False
|
23 |
|
24 |
## Leaderboard columns
|
25 |
auto_eval_column_dict = []
|
26 |
# Init
|
27 |
+
auto_eval_column_dict.append(["model_type_symbol", ColumnContent,
|
28 |
+
ColumnContent("T", "str", True, never_hidden=True)])
|
29 |
+
auto_eval_column_dict.append(["model", ColumnContent,
|
30 |
+
ColumnContent("Model", "markdown", True, never_hidden=True)])
|
31 |
for task in Tasks:
|
32 |
auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
|
33 |
+
|
34 |
# Model information
|
35 |
auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False)])
|
36 |
auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
|
|
|
41 |
auto_eval_column_dict.append(["likes", ColumnContent, ColumnContent("Hub ❤️", "number", False)])
|
42 |
auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False)])
|
43 |
auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
|
44 |
+
# Dummy column for the search bar (hidden by the custom CSS)
|
45 |
+
auto_eval_column_dict.append(["dummy", ColumnContent, ColumnContent("model_name_for_query", "str", False, dummy=True)])
|
46 |
|
47 |
# We use make dataclass to dynamically fill the scores from Tasks
|
48 |
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
|
|
|
95 |
class Precision(Enum):
|
96 |
float16 = ModelDetails("float16")
|
97 |
bfloat16 = ModelDetails("bfloat16")
|
98 |
+
qt_8bit = ModelDetails("8bit")
|
99 |
+
qt_4bit = ModelDetails("4bit")
|
100 |
+
qt_GPTQ = ModelDetails("GPTQ")
|
101 |
Unknown = ModelDetails("?")
|
102 |
|
103 |
def from_str(precision):
|
|
|
105 |
return Precision.float16
|
106 |
if precision in ["torch.bfloat16", "bfloat16"]:
|
107 |
return Precision.bfloat16
|
108 |
+
if precision in ["8bit"]:
|
109 |
+
return Precision.qt_8bit
|
110 |
+
if precision in ["4bit"]:
|
111 |
+
return Precision.qt_4bit
|
112 |
+
if precision in ["GPTQ", "None"]:
|
113 |
+
return Precision.qt_GPTQ
|
114 |
return Precision.Unknown
|
115 |
|
116 |
# Column selection
|
117 |
COLS = [c.name for c in fields(AutoEvalColumn) if not c.hidden]
|
118 |
+
TYPES = [c.type for c in fields(AutoEvalColumn) if not c.hidden]
|
119 |
+
COLS_LITE = [c.name for c in fields(AutoEvalColumn) if c.displayed_by_default and not c.hidden]
|
120 |
+
TYPES_LITE = [c.type for c in fields(AutoEvalColumn) if c.displayed_by_default and not c.hidden]
|
121 |
|
122 |
EVAL_COLS = [c.name for c in fields(EvalQueueColumn)]
|
123 |
EVAL_TYPES = [c.type for c in fields(EvalQueueColumn)]
|
124 |
|
125 |
BENCHMARK_COLS = [t.value.col_name for t in Tasks]
|
126 |
|
127 |
+
NUMERIC_INTERVALS = {
|
128 |
+
"?": pd.Interval(-1, 0, closed="right"),
|
129 |
+
"~1.5": pd.Interval(0, 2, closed="right"),
|
130 |
+
"~3": pd.Interval(2, 4, closed="right"),
|
131 |
+
"~7": pd.Interval(4, 9, closed="right"),
|
132 |
+
"~13": pd.Interval(9, 20, closed="right"),
|
133 |
+
"~35": pd.Interval(20, 45, closed="right"),
|
134 |
+
"~60": pd.Interval(45, 70, closed="right"),
|
135 |
+
"70+": pd.Interval(70, 10000, closed="right"),
|
136 |
+
}
|
src/envs.py
CHANGED
@@ -1,19 +1,25 @@
|
|
1 |
import os
|
2 |
-
|
3 |
from huggingface_hub import HfApi
|
4 |
|
5 |
-
# Info to change for your repository
|
6 |
-
# ----------------------------------
|
7 |
-
TOKEN = os.environ.get("HF_TOKEN") # A read/write token for your org
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
# ----------------------------------
|
11 |
|
12 |
-
REPO_ID = f"{OWNER}/
|
13 |
QUEUE_REPO = f"{OWNER}/requests"
|
14 |
RESULTS_REPO = f"{OWNER}/results"
|
15 |
|
16 |
-
#
|
17 |
CACHE_PATH=os.getenv("HF_HOME", ".")
|
18 |
|
19 |
# Local caches
|
@@ -21,5 +27,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 |
-
|
|
|
|
|
25 |
API = HfApi(token=TOKEN)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
+
import torch
|
3 |
from huggingface_hub import HfApi
|
4 |
|
|
|
|
|
|
|
5 |
|
6 |
+
# replace this with our token
|
7 |
+
TOKEN = os.environ.get("HF_TOKEN", None)
|
8 |
+
# print(TOKEN)
|
9 |
+
# OWNER = "vectara"
|
10 |
+
# REPO_ID = f"{OWNER}/Humanlike"
|
11 |
+
# QUEUE_REPO = f"{OWNER}/requests"
|
12 |
+
# RESULTS_REPO = f"{OWNER}/results"
|
13 |
+
|
14 |
+
|
15 |
+
OWNER = "Simondon" # Change to your org - don't forget to create a results and request dataset, with the correct format!
|
16 |
# ----------------------------------
|
17 |
|
18 |
+
REPO_ID = f"{OWNER}/Humanlike"
|
19 |
QUEUE_REPO = f"{OWNER}/requests"
|
20 |
RESULTS_REPO = f"{OWNER}/results"
|
21 |
|
22 |
+
# print(RESULTS_REPO)
|
23 |
CACHE_PATH=os.getenv("HF_HOME", ".")
|
24 |
|
25 |
# Local caches
|
|
|
27 |
EVAL_RESULTS_PATH = os.path.join(CACHE_PATH, "eval-results")
|
28 |
EVAL_REQUESTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-queue-bk")
|
29 |
EVAL_RESULTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-results-bk")
|
30 |
+
# print(EVAL_RESULTS_PATH)
|
31 |
+
# exit()
|
32 |
+
DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu') #"cpu"
|
33 |
API = HfApi(token=TOKEN)
|
34 |
+
|
35 |
+
DATASET_PATH = "./src/datasets/Material_Llama2_0603.xlsx" #experiment data
|
36 |
+
PROMPT_PATH = "./src/datasets/prompt.xlsx" #prompt for each experiment
|
37 |
+
HEM_PATH = 'vectara/hallucination_evaluation_model'
|
38 |
+
HUMAN_DATA = "./src/datasets/human_data.csv" #experiment data
|
39 |
+
ITEM_4_DATA = "./src/datasets/associataion_dataset.csv" #database
|
40 |
+
ITEM_5_DATA = "./src/datasets/Items_5.csv" #experiment 5 need verb words
|
41 |
+
|
42 |
+
# SYSTEM_PROMPT = "You are a chat bot answering questions using data. You must stick to the answers provided solely by the text in the passage provided."
|
43 |
+
SYSTEM_PROMPT = "You are a participant of a psycholinguistic experiment. You will do a task on English language use."
|
44 |
+
'''prompt'''
|
45 |
+
# USER_PROMPT = "You are asked the question 'Provide a concise summary of the following passage, covering the core pieces of information described': "
|
46 |
+
USER_PROMPT = ""
|
src/leaderboard/read_evals.py
CHANGED
@@ -1,35 +1,32 @@
|
|
1 |
import glob
|
2 |
import json
|
3 |
-
import math
|
4 |
import os
|
5 |
from dataclasses import dataclass
|
6 |
|
7 |
-
import dateutil
|
8 |
import numpy as np
|
|
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
14 |
|
15 |
@dataclass
|
16 |
class EvalResult:
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
full_model: str # org/model (path on hub)
|
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
|
@@ -41,43 +38,35 @@ class EvalResult:
|
|
41 |
config = data.get("config")
|
42 |
|
43 |
# Precision
|
44 |
-
precision = Precision.from_str(config.get("model_dtype"))
|
45 |
|
46 |
# Get model and org
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
if
|
51 |
-
org = None
|
52 |
-
model = org_and_model[0]
|
53 |
-
result_key = f"{model}_{precision.value.name}"
|
54 |
-
else:
|
55 |
-
org = org_and_model[0]
|
56 |
-
model = org_and_model[1]
|
57 |
result_key = f"{org}_{model}_{precision.value.name}"
|
58 |
-
|
|
|
59 |
|
60 |
-
still_on_hub, _, model_config = is_model_on_hub(
|
61 |
-
full_model, config.get("model_sha", "main"), trust_remote_code=True,
|
62 |
-
|
63 |
-
|
64 |
-
if model_config
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
|
69 |
# Extract results available in this file (some results are split in several files)
|
70 |
results = {}
|
71 |
-
for task in Tasks:
|
72 |
task = task.value
|
73 |
|
74 |
# We average all scores of a given metric (not all metrics are present in all files)
|
75 |
accs = np.array([v.get(task.metric, None) for k, v in data["results"].items() if task.benchmark == k])
|
76 |
-
if accs.size == 0 or any([acc is None for acc in accs]):
|
77 |
-
continue
|
78 |
|
79 |
-
|
80 |
-
results[task.benchmark] = mean_acc
|
81 |
|
82 |
return self(
|
83 |
eval_name=result_key,
|
@@ -85,7 +74,7 @@ class EvalResult:
|
|
85 |
org=org,
|
86 |
model=model,
|
87 |
results=results,
|
88 |
-
precision=precision,
|
89 |
revision= config.get("model_sha", ""),
|
90 |
still_on_hub=still_on_hub,
|
91 |
architecture=architecture
|
@@ -93,40 +82,43 @@ class EvalResult:
|
|
93 |
|
94 |
def update_with_request_file(self, requests_path):
|
95 |
"""Finds the relevant request file for the current model and updates info with it"""
|
96 |
-
request_file = get_request_file_for_model(requests_path, self.full_model,
|
|
|
97 |
|
98 |
try:
|
99 |
with open(request_file, "r") as f:
|
100 |
request = json.load(f)
|
101 |
-
self.model_type = ModelType.from_str(request.get("model_type", ""))
|
102 |
-
self.weight_type = WeightType[request.get("weight_type", "Original")]
|
103 |
self.license = request.get("license", "?")
|
104 |
self.likes = request.get("likes", 0)
|
105 |
self.num_params = request.get("params", 0)
|
106 |
self.date = request.get("submitted_time", "")
|
107 |
-
except
|
108 |
-
print(f"Could not find request file for {self.org}/{self.model}
|
|
|
|
|
109 |
|
110 |
def to_dict(self):
|
111 |
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
112 |
-
|
113 |
data_dict = {
|
114 |
"eval_name": self.eval_name, # not a column, just a save name,
|
115 |
-
AutoEvalColumn.precision.name: self.precision.value.name,
|
116 |
-
AutoEvalColumn.model_type.name: self.model_type.value.name,
|
117 |
-
AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
118 |
-
AutoEvalColumn.weight_type.name: self.weight_type.value.name,
|
119 |
-
AutoEvalColumn.architecture.name: self.architecture,
|
120 |
-
AutoEvalColumn.model.name: make_clickable_model(self.full_model),
|
121 |
-
AutoEvalColumn.
|
122 |
-
AutoEvalColumn.
|
123 |
-
AutoEvalColumn.license.name: self.license,
|
124 |
-
AutoEvalColumn.likes.name: self.likes,
|
125 |
-
AutoEvalColumn.params.name: self.num_params,
|
126 |
-
AutoEvalColumn.still_on_hub.name: self.still_on_hub,
|
127 |
}
|
128 |
|
129 |
-
for task in Tasks:
|
130 |
data_dict[task.value.col_name] = self.results[task.value.benchmark]
|
131 |
|
132 |
return data_dict
|
@@ -157,21 +149,26 @@ def get_request_file_for_model(requests_path, model_name, precision):
|
|
157 |
def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResult]:
|
158 |
"""From the path of the results folder root, extract all needed info for results"""
|
159 |
model_result_filepaths = []
|
160 |
-
|
161 |
for root, _, files in os.walk(results_path):
|
162 |
# We should only have json files in model results
|
163 |
-
|
164 |
-
continue
|
165 |
|
166 |
-
#
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
for file in files:
|
173 |
-
model_result_filepaths.append(os.path.join(root, file))
|
174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
eval_results = {}
|
176 |
for model_result_filepath in model_result_filepaths:
|
177 |
# Creation of result
|
@@ -181,7 +178,8 @@ def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResu
|
|
181 |
# Store results of same eval together
|
182 |
eval_name = eval_result.eval_name
|
183 |
if eval_name in eval_results.keys():
|
184 |
-
eval_results[eval_name].results.update({k: v for k, v in
|
|
|
185 |
else:
|
186 |
eval_results[eval_name] = eval_result
|
187 |
|
|
|
1 |
import glob
|
2 |
import json
|
|
|
3 |
import os
|
4 |
from dataclasses import dataclass
|
5 |
|
|
|
6 |
import numpy as np
|
7 |
+
import dateutil
|
8 |
|
9 |
+
import src.display.formatting as formatting
|
10 |
+
import src.display.utils as utils
|
11 |
+
import src.submission.check_validity as check_validity
|
12 |
|
13 |
|
14 |
@dataclass
|
15 |
class EvalResult:
|
16 |
+
eval_name: str # org_model_precision (uid)
|
17 |
+
full_model: str # org/model (path on hub)
|
18 |
+
org: str
|
|
|
|
|
19 |
model: str
|
20 |
+
revision: str # commit hash, "" if main
|
21 |
results: dict
|
22 |
+
precision: utils.Precision = utils.Precision.Unknown
|
23 |
+
model_type: utils.ModelType = utils.ModelType.Unknown # Pretrained, fine tuned, ...
|
24 |
+
weight_type: utils.WeightType = utils.WeightType.Original # Original or Adapter
|
25 |
+
architecture: str = "Unknown"
|
26 |
license: str = "?"
|
27 |
likes: int = 0
|
28 |
num_params: int = 0
|
29 |
+
date: str = "" # submission date of request file
|
30 |
still_on_hub: bool = False
|
31 |
|
32 |
@classmethod
|
|
|
38 |
config = data.get("config")
|
39 |
|
40 |
# Precision
|
41 |
+
precision = utils.Precision.from_str(config.get("model_dtype"))
|
42 |
|
43 |
# Get model and org
|
44 |
+
full_model = config.get("model_name", config.get("model_args", None))
|
45 |
+
org, model = full_model.split("/", 1) if "/" in full_model else (None, full_model)
|
46 |
|
47 |
+
if org:
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
result_key = f"{org}_{model}_{precision.value.name}"
|
49 |
+
else:
|
50 |
+
result_key = f"{model}_{precision.value.name}"
|
51 |
|
52 |
+
still_on_hub, _, model_config = check_validity.is_model_on_hub(
|
53 |
+
full_model, config.get("model_sha", "main"), trust_remote_code=True,
|
54 |
+
test_tokenizer=False)
|
55 |
+
|
56 |
+
if model_config:
|
57 |
+
architecture = ";".join(getattr(model_config, "architectures", ["?"]))
|
58 |
+
else:
|
59 |
+
architecture = "?"
|
60 |
|
61 |
# Extract results available in this file (some results are split in several files)
|
62 |
results = {}
|
63 |
+
for task in utils.Tasks:
|
64 |
task = task.value
|
65 |
|
66 |
# We average all scores of a given metric (not all metrics are present in all files)
|
67 |
accs = np.array([v.get(task.metric, None) for k, v in data["results"].items() if task.benchmark == k])
|
|
|
|
|
68 |
|
69 |
+
results[task.benchmark] = accs
|
|
|
70 |
|
71 |
return self(
|
72 |
eval_name=result_key,
|
|
|
74 |
org=org,
|
75 |
model=model,
|
76 |
results=results,
|
77 |
+
precision=precision,
|
78 |
revision= config.get("model_sha", ""),
|
79 |
still_on_hub=still_on_hub,
|
80 |
architecture=architecture
|
|
|
82 |
|
83 |
def update_with_request_file(self, requests_path):
|
84 |
"""Finds the relevant request file for the current model and updates info with it"""
|
85 |
+
request_file = get_request_file_for_model(requests_path, self.full_model,
|
86 |
+
self.precision.value.name)
|
87 |
|
88 |
try:
|
89 |
with open(request_file, "r") as f:
|
90 |
request = json.load(f)
|
91 |
+
self.model_type = utils.ModelType.from_str(request.get("model_type", ""))
|
92 |
+
self.weight_type = utils.WeightType[request.get("weight_type", "Original")]
|
93 |
self.license = request.get("license", "?")
|
94 |
self.likes = request.get("likes", 0)
|
95 |
self.num_params = request.get("params", 0)
|
96 |
self.date = request.get("submitted_time", "")
|
97 |
+
except FileNotFoundError:
|
98 |
+
print(f"Could not find request file for {self.org}/{self.model}")
|
99 |
+
except json.JSONDecodeError:
|
100 |
+
print(f"Error decoding JSON in request file for {self.org}/{self.model}")
|
101 |
|
102 |
def to_dict(self):
|
103 |
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
104 |
+
|
105 |
data_dict = {
|
106 |
"eval_name": self.eval_name, # not a column, just a save name,
|
107 |
+
utils.AutoEvalColumn.precision.name: self.precision.value.name,
|
108 |
+
utils.AutoEvalColumn.model_type.name: self.model_type.value.name,
|
109 |
+
utils.AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
110 |
+
utils.AutoEvalColumn.weight_type.name: self.weight_type.value.name,
|
111 |
+
utils.AutoEvalColumn.architecture.name: self.architecture,
|
112 |
+
utils.AutoEvalColumn.model.name: formatting.make_clickable_model(self.full_model),
|
113 |
+
utils.AutoEvalColumn.dummy.name: self.full_model,
|
114 |
+
utils.AutoEvalColumn.revision.name: self.revision,
|
115 |
+
utils.AutoEvalColumn.license.name: self.license,
|
116 |
+
utils.AutoEvalColumn.likes.name: self.likes,
|
117 |
+
utils.AutoEvalColumn.params.name: self.num_params,
|
118 |
+
utils.AutoEvalColumn.still_on_hub.name: self.still_on_hub,
|
119 |
}
|
120 |
|
121 |
+
for task in utils.Tasks:
|
122 |
data_dict[task.value.col_name] = self.results[task.value.benchmark]
|
123 |
|
124 |
return data_dict
|
|
|
149 |
def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResult]:
|
150 |
"""From the path of the results folder root, extract all needed info for results"""
|
151 |
model_result_filepaths = []
|
152 |
+
print("results_path", results_path)
|
153 |
for root, _, files in os.walk(results_path):
|
154 |
# We should only have json files in model results
|
155 |
+
print("file",files)
|
|
|
156 |
|
157 |
+
# if not files or any([not f.endswith(".json") for f in files]):
|
158 |
+
|
159 |
+
# continue
|
160 |
+
for f in files:
|
161 |
+
if f.endswith(".json"):
|
|
|
|
|
|
|
162 |
|
163 |
+
# Sort the files by date
|
164 |
+
# try:
|
165 |
+
# files.sort(key=lambda x: x.removesuffix(".json").removeprefix("results_")[:-7])
|
166 |
+
# except dateutil.parser._parser.ParserError:
|
167 |
+
# files = [files[-1]]
|
168 |
+
|
169 |
+
model_result_filepaths.extend([os.path.join(root, f)])
|
170 |
+
print("model_result_filepaths", model_result_filepaths)
|
171 |
+
# exit()
|
172 |
eval_results = {}
|
173 |
for model_result_filepath in model_result_filepaths:
|
174 |
# Creation of result
|
|
|
178 |
# Store results of same eval together
|
179 |
eval_name = eval_result.eval_name
|
180 |
if eval_name in eval_results.keys():
|
181 |
+
eval_results[eval_name].results.update({k: v for k, v in
|
182 |
+
eval_result.results.items() if v is not None})
|
183 |
else:
|
184 |
eval_results[eval_name] = eval_result
|
185 |
|
src/populate.py
CHANGED
@@ -3,27 +3,28 @@ import os
|
|
3 |
|
4 |
import pandas as pd
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
|
10 |
|
11 |
def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
|
12 |
-
|
13 |
-
raw_data = get_raw_eval_results(results_path, requests_path)
|
14 |
all_data_json = [v.to_dict() for v in raw_data]
|
15 |
-
|
|
|
16 |
df = pd.DataFrame.from_records(all_data_json)
|
17 |
-
df
|
|
|
|
|
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 |
|
@@ -33,8 +34,8 @@ def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
|
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:
|
@@ -45,8 +46,8 @@ def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
|
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"]]
|
|
|
3 |
|
4 |
import pandas as pd
|
5 |
|
6 |
+
import src.display.formatting as formatting
|
7 |
+
import src.display.utils as utils
|
8 |
+
import src.leaderboard.read_evals as read_evals
|
9 |
|
10 |
|
11 |
def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
|
12 |
+
raw_data = read_evals.get_raw_eval_results(results_path, requests_path)
|
|
|
13 |
all_data_json = [v.to_dict() for v in raw_data]
|
14 |
+
print(results_path, requests_path)
|
15 |
+
print(all_data_json)
|
16 |
df = pd.DataFrame.from_records(all_data_json)
|
17 |
+
print(df)
|
18 |
+
# exit()
|
19 |
+
df = df.sort_values(by=[utils.AutoEvalColumn.hallucination_rate.name], ascending=True)
|
20 |
df = df[cols].round(decimals=2)
|
21 |
|
22 |
# filter out if any of the benchmarks have not been produced
|
23 |
+
df = df[formatting.has_no_nan_values(df, benchmark_cols)]
|
24 |
+
return raw_data, df
|
25 |
|
26 |
|
27 |
def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
|
|
28 |
entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
|
29 |
all_evals = []
|
30 |
|
|
|
34 |
with open(file_path) as fp:
|
35 |
data = json.load(fp)
|
36 |
|
37 |
+
data[utils.EvalQueueColumn.model.name] = formatting.make_clickable_model(data["model"])
|
38 |
+
data[utils.EvalQueueColumn.revision.name] = data.get("revision", "main")
|
39 |
|
40 |
all_evals.append(data)
|
41 |
elif ".md" not in entry:
|
|
|
46 |
with open(file_path) as fp:
|
47 |
data = json.load(fp)
|
48 |
|
49 |
+
data[utils.EvalQueueColumn.model.name] = formatting.make_clickable_model(data["model"])
|
50 |
+
data[utils.EvalQueueColumn.revision.name] = data.get("revision", "main")
|
51 |
all_evals.append(data)
|
52 |
|
53 |
pending_list = [e for e in all_evals if e["status"] in ["PENDING", "RERUN"]]
|
src/submission/check_validity.py
CHANGED
@@ -1,14 +1,12 @@
|
|
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
|
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"""
|
@@ -31,8 +29,8 @@ def check_model_card(repo_id: str) -> tuple[bool, str]:
|
|
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:
|
@@ -56,7 +54,8 @@ def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_rem
|
|
56 |
)
|
57 |
|
58 |
except Exception as e:
|
59 |
-
return False, "was not found on hub
|
|
|
60 |
|
61 |
|
62 |
def get_model_size(model_info: ModelInfo, precision: str):
|
@@ -75,7 +74,6 @@ def get_model_arch(model_info: ModelInfo):
|
|
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)
|
|
|
1 |
import json
|
2 |
import os
|
|
|
3 |
from collections import defaultdict
|
|
|
4 |
|
5 |
import huggingface_hub
|
6 |
from huggingface_hub import ModelCard
|
7 |
from huggingface_hub.hf_api import ModelInfo
|
8 |
+
from transformers import AutoConfig, AutoTokenizer
|
9 |
+
from transformers.models.auto.tokenization_auto import tokenizer_class_from_name, get_tokenizer_config
|
10 |
|
11 |
def check_model_card(repo_id: str) -> tuple[bool, str]:
|
12 |
"""Checks if the model card and license exist and have been filled"""
|
|
|
29 |
|
30 |
return True, ""
|
31 |
|
32 |
+
|
33 |
def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_remote_code=False, test_tokenizer=False) -> tuple[bool, str]:
|
|
|
34 |
try:
|
35 |
config = AutoConfig.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
36 |
if test_tokenizer:
|
|
|
54 |
)
|
55 |
|
56 |
except Exception as e:
|
57 |
+
return False, f"was not found on hub!: {e}", None
|
58 |
+
|
59 |
|
60 |
|
61 |
def get_model_size(model_info: ModelInfo, precision: str):
|
|
|
74 |
return model_info.config.get("architectures", "Unknown")
|
75 |
|
76 |
def already_submitted_models(requested_models_dir: str) -> set[str]:
|
|
|
77 |
depth = 1
|
78 |
file_names = []
|
79 |
users_to_submission_dates = defaultdict(list)
|
src/submission/submit.py
CHANGED
@@ -2,14 +2,10 @@ import json
|
|
2 |
import os
|
3 |
from datetime import datetime, timezone
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
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
|
@@ -25,7 +21,7 @@ def add_new_eval(
|
|
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
|
@@ -37,7 +33,7 @@ def add_new_eval(
|
|
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 == "":
|
@@ -45,32 +41,32 @@ def add_new_eval(
|
|
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,
|
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")
|
@@ -87,15 +83,15 @@ def add_new_eval(
|
|
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 |
-
|
|
|
99 |
os.makedirs(OUT_DIR, exist_ok=True)
|
100 |
out_path = f"{OUT_DIR}/{model_path}_eval_request_False_{precision}_{weight_type}.json"
|
101 |
|
@@ -103,10 +99,10 @@ def add_new_eval(
|
|
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 |
)
|
@@ -114,6 +110,6 @@ def add_new_eval(
|
|
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 |
)
|
|
|
2 |
import os
|
3 |
from datetime import datetime, timezone
|
4 |
|
5 |
+
import src.display.formatting as formatting
|
6 |
+
import src.envs as envs
|
7 |
+
import src.submission.check_validity as check_validity
|
8 |
+
|
|
|
|
|
|
|
|
|
9 |
|
10 |
REQUESTED_MODELS = None
|
11 |
USERS_TO_SUBMISSION_DATES = None
|
|
|
21 |
global REQUESTED_MODELS
|
22 |
global USERS_TO_SUBMISSION_DATES
|
23 |
if not REQUESTED_MODELS:
|
24 |
+
REQUESTED_MODELS, USERS_TO_SUBMISSION_DATES = check_validity.already_submitted_models(envs.EVAL_REQUESTS_PATH)
|
25 |
|
26 |
user_name = ""
|
27 |
model_path = model
|
|
|
33 |
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
34 |
|
35 |
if model_type is None or model_type == "":
|
36 |
+
return formatting.styled_error("Please select a model type.")
|
37 |
|
38 |
# Does the model actually exist?
|
39 |
if revision == "":
|
|
|
41 |
|
42 |
# Is the model on the hub?
|
43 |
if weight_type in ["Delta", "Adapter"]:
|
44 |
+
base_model_on_hub, error, _ = check_validity.is_model_on_hub(model_name=base_model, revision=revision, token=envs.TOKEN, test_tokenizer=True)
|
45 |
if not base_model_on_hub:
|
46 |
+
return formatting.styled_error(f'Base model "{base_model}" {error}')
|
47 |
|
48 |
if not weight_type == "Adapter":
|
49 |
+
model_on_hub, error, _ = check_validity.is_model_on_hub(model_name=model, revision=revision, test_tokenizer=True)
|
50 |
if not model_on_hub:
|
51 |
+
return formatting.styled_error(f'Model "{model}" {error}')
|
52 |
|
53 |
# Is the model info correctly filled?
|
54 |
try:
|
55 |
+
model_info = envs.API.model_info(repo_id=model, revision=revision)
|
56 |
except Exception:
|
57 |
+
return formatting.styled_error("Could not get your model information. Please fill it up properly.")
|
58 |
|
59 |
+
model_size = check_validity.get_model_size(model_info=model_info, precision=precision)
|
60 |
|
61 |
# Were the model card and license filled?
|
62 |
try:
|
63 |
license = model_info.cardData["license"]
|
64 |
except Exception:
|
65 |
+
return formatting.styled_error("Please select a license for your model")
|
66 |
|
67 |
+
modelcard_OK, error_msg = check_validity.check_model_card(model)
|
68 |
if not modelcard_OK:
|
69 |
+
return formatting.styled_error(error_msg)
|
70 |
|
71 |
# Seems good, creating the eval
|
72 |
print("Adding new eval")
|
|
|
83 |
"likes": model_info.likes,
|
84 |
"params": model_size,
|
85 |
"license": license,
|
|
|
86 |
}
|
87 |
|
88 |
# Check for duplicate submission
|
89 |
if f"{model}_{revision}_{precision}" in REQUESTED_MODELS:
|
90 |
+
return formatting.styled_warning("This model has been already submitted.")
|
91 |
|
92 |
print("Creating eval file")
|
93 |
+
|
94 |
+
OUT_DIR = f"{envs.EVAL_REQUESTS_PATH}/{user_name}"
|
95 |
os.makedirs(OUT_DIR, exist_ok=True)
|
96 |
out_path = f"{OUT_DIR}/{model_path}_eval_request_False_{precision}_{weight_type}.json"
|
97 |
|
|
|
99 |
f.write(json.dumps(eval_entry))
|
100 |
|
101 |
print("Uploading eval file")
|
102 |
+
envs.API.upload_file(
|
103 |
path_or_fileobj=out_path,
|
104 |
path_in_repo=out_path.split("eval-queue/")[1],
|
105 |
+
repo_id=envs.QUEUE_REPO,
|
106 |
repo_type="dataset",
|
107 |
commit_message=f"Add {model} to eval queue",
|
108 |
)
|
|
|
110 |
# Remove the local file
|
111 |
os.remove(out_path)
|
112 |
|
113 |
+
return formatting.styled_message(
|
114 |
"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."
|
115 |
)
|