Spaces:
Running
Running
isakzhang
commited on
Commit
•
6204efe
0
Parent(s):
upload the leaderboard design
Browse files- .gitattributes +35 -0
- README.md +13 -0
- app.py +190 -0
- requirements.txt +15 -0
- src/.DS_Store +0 -0
- src/__pycache__/envs.cpython-39.pyc +0 -0
- src/display/__pycache__/about.cpython-39.pyc +0 -0
- src/display/__pycache__/css_html_js.cpython-39.pyc +0 -0
- src/display/about.py +53 -0
- src/display/css_html_js.py +111 -0
- src/display/formatting.py +36 -0
- src/display/utils.py +135 -0
- src/envs.py +21 -0
- src/leaderboard/__pycache__/load_results.cpython-39.pyc +0 -0
- src/leaderboard/load_results.py +59 -0
- src/leaderboard/read_evals.py +195 -0
- src/populate.py +56 -0
- src/results/auto-arena-llms-results-20240529.csv +200 -0
- src/submission/check_validity.py +103 -0
- src/submission/submit.py +118 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: SeaExam Leaderboard
|
3 |
+
emoji: 🥇
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: yellow
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 4.27.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: apache-2.0
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
import os
|
4 |
+
from huggingface_hub import snapshot_download, login
|
5 |
+
from apscheduler.schedulers.background import BackgroundScheduler
|
6 |
+
|
7 |
+
from src.display.about import (
|
8 |
+
CITATION_BUTTON_LABEL,
|
9 |
+
CITATION_BUTTON_TEXT,
|
10 |
+
CONTACT_TEXT,
|
11 |
+
EVALUATION_QUEUE_TEXT,
|
12 |
+
INTRODUCTION_TEXT,
|
13 |
+
LLM_BENCHMARKS_TEXT,
|
14 |
+
TITLE,
|
15 |
+
SUB_TITLE,
|
16 |
+
)
|
17 |
+
from src.display.css_html_js import custom_css
|
18 |
+
from src.envs import API
|
19 |
+
from src.leaderboard.load_results import load_data
|
20 |
+
|
21 |
+
|
22 |
+
def restart_space():
|
23 |
+
API.restart_space(repo_id="Auto-Arena/Leaderboard")
|
24 |
+
|
25 |
+
|
26 |
+
csv_path = f"./src/results/auto-arena-llms-results-20240529.csv"
|
27 |
+
df_results = load_data(csv_path)
|
28 |
+
|
29 |
+
all_columns = ['Rank', 'Model', 'From', 'Open?', 'Params(B)', 'Cost', 'Score']
|
30 |
+
show_columns = ['Rank', 'Model', 'From', 'Open?', 'Params(B)', 'Cost', 'Score']
|
31 |
+
TYPES = ['number', 'markdown', 'str', 'str', 'str', 'str', 'number']
|
32 |
+
|
33 |
+
df_results_init = df_results.copy()[show_columns]
|
34 |
+
|
35 |
+
def update_table(
|
36 |
+
hidden_df: pd.DataFrame,
|
37 |
+
# columns: list,
|
38 |
+
#type_query: list,
|
39 |
+
open_query: list,
|
40 |
+
# precision_query: str,
|
41 |
+
# size_query: list,
|
42 |
+
# show_deleted: bool,
|
43 |
+
query: str,
|
44 |
+
):
|
45 |
+
# filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, show_deleted)
|
46 |
+
# filtered_df = filter_queries(query, filtered_df)
|
47 |
+
# df = select_columns(filtered_df, columns)
|
48 |
+
filtered_df = hidden_df.copy()
|
49 |
+
|
50 |
+
# filtered_df = filtered_df[filtered_df['type'].isin(type_query)]
|
51 |
+
map_open = {'open': 'Yes', 'closed': 'No'}
|
52 |
+
filtered_df = filtered_df[filtered_df['Open?'].isin([map_open[o] for o in open_query])]
|
53 |
+
|
54 |
+
filtered_df = filter_queries(query, filtered_df)
|
55 |
+
# filtered_df = filtered_df[[map_columns[k] for k in columns]]
|
56 |
+
# deduplication
|
57 |
+
# df = df.drop_duplicates(subset=["Model"])
|
58 |
+
df = filtered_df.drop_duplicates()
|
59 |
+
df = df[show_columns]
|
60 |
+
return df
|
61 |
+
|
62 |
+
|
63 |
+
def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
|
64 |
+
return df[(df['Model'].str.contains(query, case=False))]
|
65 |
+
|
66 |
+
|
67 |
+
def filter_queries(query: str, filtered_df: pd.DataFrame) -> pd.DataFrame:
|
68 |
+
final_df = []
|
69 |
+
if query != "":
|
70 |
+
queries = [q.strip() for q in query.split(";")]
|
71 |
+
for _q in queries:
|
72 |
+
_q = _q.strip()
|
73 |
+
if _q != "":
|
74 |
+
temp_filtered_df = search_table(filtered_df, _q)
|
75 |
+
if len(temp_filtered_df) > 0:
|
76 |
+
final_df.append(temp_filtered_df)
|
77 |
+
if len(final_df) > 0:
|
78 |
+
filtered_df = pd.concat(final_df)
|
79 |
+
|
80 |
+
return filtered_df
|
81 |
+
|
82 |
+
|
83 |
+
demo = gr.Blocks(css=custom_css)
|
84 |
+
with demo:
|
85 |
+
gr.HTML(TITLE)
|
86 |
+
gr.HTML(SUB_TITLE)
|
87 |
+
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
88 |
+
|
89 |
+
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
90 |
+
# the first tab
|
91 |
+
with gr.TabItem("🏅 Overall", elem_id="llm-benchmark-Sum", id=0):
|
92 |
+
# meta-info
|
93 |
+
with gr.Row():
|
94 |
+
with gr.Column():
|
95 |
+
search_bar = gr.Textbox(
|
96 |
+
placeholder=" 🔍 Search for models you are interested in (separate multiple models with `;`) and press ENTER...",
|
97 |
+
show_label=False,
|
98 |
+
elem_id="search-bar",
|
99 |
+
)
|
100 |
+
# with gr.Row():
|
101 |
+
# with gr.Column():
|
102 |
+
# type_query = gr.CheckboxGroup(
|
103 |
+
# choices=["🟢 base", "🔶 chat"],
|
104 |
+
# value=["🔶 chat" ],
|
105 |
+
# label="model types to show",
|
106 |
+
# elem_id="type-select",
|
107 |
+
# interactive=True,
|
108 |
+
# )
|
109 |
+
with gr.Column():
|
110 |
+
open_query = gr.CheckboxGroup(
|
111 |
+
choices=["open", "closed"],
|
112 |
+
value=["open", "closed"],
|
113 |
+
label="open-source OR closed-source models?",
|
114 |
+
elem_id="open-select",
|
115 |
+
interactive=True,
|
116 |
+
)
|
117 |
+
|
118 |
+
leaderboard_table = gr.components.Dataframe(
|
119 |
+
value = df_results,
|
120 |
+
datatype = TYPES,
|
121 |
+
elem_id = "leaderboard-table",
|
122 |
+
interactive = False,
|
123 |
+
visible=True,
|
124 |
+
# column_widths=["20%", "6%", "8%", "6%", "8%", "8%", "6%", "6%", "6%", "6%", "6%"],
|
125 |
+
)
|
126 |
+
|
127 |
+
hidden_leaderboard_table_for_search = gr.components.Dataframe(
|
128 |
+
value=df_results_init,
|
129 |
+
# elem_id="leaderboard-table",
|
130 |
+
interactive=False,
|
131 |
+
visible=False,
|
132 |
+
)
|
133 |
+
|
134 |
+
search_bar.submit(
|
135 |
+
update_table,
|
136 |
+
[
|
137 |
+
# df_avg,
|
138 |
+
hidden_leaderboard_table_for_search,
|
139 |
+
# shown_columns,
|
140 |
+
#type_query,
|
141 |
+
open_query,
|
142 |
+
# filter_columns_type,
|
143 |
+
# filter_columns_precision,
|
144 |
+
# filter_columns_size,
|
145 |
+
# deleted_models_visibility,
|
146 |
+
search_bar,
|
147 |
+
],
|
148 |
+
leaderboard_table,
|
149 |
+
)
|
150 |
+
|
151 |
+
#for selector in [type_query, open_query]:
|
152 |
+
for selector in [open_query]:
|
153 |
+
selector.change(
|
154 |
+
update_table,
|
155 |
+
[
|
156 |
+
# df_avg,
|
157 |
+
hidden_leaderboard_table_for_search,
|
158 |
+
# shown_columns,
|
159 |
+
#type_query,
|
160 |
+
open_query,
|
161 |
+
# filter_columns_type,
|
162 |
+
# filter_columns_precision,
|
163 |
+
# filter_columns_size,
|
164 |
+
# deleted_models_visibility,
|
165 |
+
search_bar,
|
166 |
+
],
|
167 |
+
leaderboard_table,
|
168 |
+
)
|
169 |
+
|
170 |
+
# with gr.TabItem("📝 About", elem_id="llm-benchmark-tab-table", id=1):
|
171 |
+
# gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
|
172 |
+
|
173 |
+
# with gr.Row():
|
174 |
+
# with gr.Accordion("📙 Citation", open=False):
|
175 |
+
# citation_button = gr.Textbox(
|
176 |
+
# value=CITATION_BUTTON_TEXT,
|
177 |
+
# label=CITATION_BUTTON_LABEL,
|
178 |
+
# lines=20,
|
179 |
+
# elem_id="citation-button",
|
180 |
+
# show_copy_button=True,
|
181 |
+
# )
|
182 |
+
|
183 |
+
gr.Markdown(CONTACT_TEXT, elem_classes="markdown-text")
|
184 |
+
|
185 |
+
demo.launch()
|
186 |
+
|
187 |
+
scheduler = BackgroundScheduler()
|
188 |
+
scheduler.add_job(restart_space, "interval", seconds=1800)
|
189 |
+
scheduler.start()
|
190 |
+
demo.queue(default_concurrency_limit=40).launch(share=True)
|
requirements.txt
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
matplotlib==3.7.1
|
9 |
+
numpy==1.24.2
|
10 |
+
pandas==2.0.0
|
11 |
+
python-dateutil==2.8.2
|
12 |
+
requests==2.28.2
|
13 |
+
tqdm==4.65.0
|
14 |
+
transformers==4.35.2
|
15 |
+
tokenizers>=0.15.0
|
src/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
src/__pycache__/envs.cpython-39.pyc
ADDED
Binary file (615 Bytes). View file
|
|
src/display/__pycache__/about.cpython-39.pyc
ADDED
Binary file (1.41 kB). View file
|
|
src/display/__pycache__/css_html_js.cpython-39.pyc
ADDED
Binary file (2.07 kB). View file
|
|
src/display/about.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
# Init: to update with your specific keys
|
12 |
+
class Tasks(Enum):
|
13 |
+
# task_key in the json file, metric_key in the json file, name to display in the leaderboard
|
14 |
+
task0 = Task("task_name1", "metric_name", "First task")
|
15 |
+
task1 = Task("task_name2", "metric_name", "Second task")
|
16 |
+
|
17 |
+
|
18 |
+
# Your leaderboard name
|
19 |
+
TITLE = """<h1 align="center" id="space-title">🏆 Auto Arena of LLMs</h1>"""
|
20 |
+
|
21 |
+
# subtitle
|
22 |
+
SUB_TITLE = """<h2 align="center" id="space-title">Automating LLM Evaluations with Agent Peer-battles and Committee Discussions</h1>"""
|
23 |
+
|
24 |
+
# What does your leaderboard evaluate?
|
25 |
+
INTRODUCTION_TEXT = """
|
26 |
+
This leaderboard is from a completely automated large language model (LLM) evaluation framework by employing various LLM agents in peer-battles and committee discussions.
|
27 |
+
You can find more details from the [project page](https://auto-arena.github.io/) and our [paper]().
|
28 |
+
"""
|
29 |
+
|
30 |
+
# For additional details such as datasets, evaluation criteria, and reproducibility, please refer to the "📝 About" tab.
|
31 |
+
|
32 |
+
# Stay tuned for the *SeaBench leaderboard* - focusing on evaluating the model's ability to respond to general human instructions in real-world multi-turn settings.
|
33 |
+
# """
|
34 |
+
|
35 |
+
# Which evaluations are you running? how can people reproduce what you have?
|
36 |
+
LLM_BENCHMARKS_TEXT = f"""
|
37 |
+
|
38 |
+
```
|
39 |
+
|
40 |
+
"""
|
41 |
+
|
42 |
+
# You can find the detailed numerical results in the results Hugging Face dataset: https://huggingface.co/datasets/SeaLLMs/SeaExam-results
|
43 |
+
|
44 |
+
EVALUATION_QUEUE_TEXT = """
|
45 |
+
"""
|
46 |
+
|
47 |
+
CITATION_BUTTON_LABEL = ""
|
48 |
+
CITATION_BUTTON_TEXT = r"""
|
49 |
+
"""
|
50 |
+
|
51 |
+
CONTACT_TEXT = f"""
|
52 |
+
## Contact
|
53 |
+
"""
|
src/display/css_html_js.py
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
custom_css = """
|
2 |
+
|
3 |
+
.markdown-text {
|
4 |
+
font-size: 16px !important;
|
5 |
+
}
|
6 |
+
|
7 |
+
#models-to-add-text {
|
8 |
+
font-size: 18px !important;
|
9 |
+
}
|
10 |
+
|
11 |
+
#citation-button span {
|
12 |
+
font-size: 16px !important;
|
13 |
+
}
|
14 |
+
|
15 |
+
#citation-button textarea {
|
16 |
+
font-size: 16px !important;
|
17 |
+
}
|
18 |
+
|
19 |
+
#citation-button > label > button {
|
20 |
+
margin: 6px;
|
21 |
+
transform: scale(1.3);
|
22 |
+
}
|
23 |
+
|
24 |
+
#leaderboard-table {
|
25 |
+
margin-top: 15px
|
26 |
+
}
|
27 |
+
|
28 |
+
#leaderboard-table-lite {
|
29 |
+
margin-top: 15px
|
30 |
+
}
|
31 |
+
|
32 |
+
#search-bar-table-box > div: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 {
|
50 |
+
max-width: 400px;
|
51 |
+
overflow: auto;
|
52 |
+
white-space: nowrap;
|
53 |
+
}
|
54 |
+
|
55 |
+
.tab-buttons button {
|
56 |
+
font-size: 20px;
|
57 |
+
}
|
58 |
+
|
59 |
+
#scale-logo {
|
60 |
+
border-style: none !important;
|
61 |
+
box-shadow: none;
|
62 |
+
display: block;
|
63 |
+
margin-left: auto;
|
64 |
+
margin-right: auto;
|
65 |
+
max-width: 600px;
|
66 |
+
}
|
67 |
+
|
68 |
+
#scale-logo .download {
|
69 |
+
display: none;
|
70 |
+
}
|
71 |
+
#filter_type{
|
72 |
+
border: 0;
|
73 |
+
padding-left: 0;
|
74 |
+
padding-top: 0;
|
75 |
+
}
|
76 |
+
#filter_type label {
|
77 |
+
display: flex;
|
78 |
+
}
|
79 |
+
#filter_type label > span{
|
80 |
+
margin-top: var(--spacing-lg);
|
81 |
+
margin-right: 0.5em;
|
82 |
+
}
|
83 |
+
#filter_type label > .wrap{
|
84 |
+
width: 103px;
|
85 |
+
}
|
86 |
+
#filter_type label > .wrap .wrap-inner{
|
87 |
+
padding: 2px;
|
88 |
+
}
|
89 |
+
#filter_type label > .wrap .wrap-inner input{
|
90 |
+
width: 1px
|
91 |
+
}
|
92 |
+
#filter-columns-type{
|
93 |
+
border:0;
|
94 |
+
padding:0.5;
|
95 |
+
}
|
96 |
+
#filter-columns-size{
|
97 |
+
border:0;
|
98 |
+
padding:0.5;
|
99 |
+
}
|
100 |
+
#box-filter > .form{
|
101 |
+
border: 0
|
102 |
+
}
|
103 |
+
"""
|
104 |
+
|
105 |
+
get_window_url_params = """
|
106 |
+
function(url_params) {
|
107 |
+
const params = new URLSearchParams(window.location.search);
|
108 |
+
url_params = Object.fromEntries(params);
|
109 |
+
return url_params;
|
110 |
+
}
|
111 |
+
"""
|
src/display/formatting.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
13 |
+
|
14 |
+
def make_clickable_model(model_name):
|
15 |
+
link = f"https://huggingface.co/{model_name}"
|
16 |
+
return model_hyperlink(link, model_name)
|
17 |
+
|
18 |
+
|
19 |
+
def styled_error(error):
|
20 |
+
return f"<p style='color: red; font-size: 20px; text-align: center;'>{error}</p>"
|
21 |
+
|
22 |
+
|
23 |
+
def styled_warning(warn):
|
24 |
+
return f"<p style='color: orange; font-size: 20px; text-align: center;'>{warn}</p>"
|
25 |
+
|
26 |
+
|
27 |
+
def styled_message(message):
|
28 |
+
return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"
|
29 |
+
|
30 |
+
|
31 |
+
def has_no_nan_values(df, columns):
|
32 |
+
return df[columns].notna().all(axis=1)
|
33 |
+
|
34 |
+
|
35 |
+
def has_nan_values(df, columns):
|
36 |
+
return df[columns].isna().any(axis=1)
|
src/display/utils.py
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dataclasses import dataclass, make_dataclass
|
2 |
+
from enum import Enum
|
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:] != "__"]
|
10 |
+
|
11 |
+
|
12 |
+
# These classes are for user facing column names,
|
13 |
+
# to avoid having to change them all around the code
|
14 |
+
# when a modif is needed
|
15 |
+
@dataclass
|
16 |
+
class ColumnContent:
|
17 |
+
name: str
|
18 |
+
type: str
|
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, ColumnContent("T", "str", True, never_hidden=True)])
|
28 |
+
auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
|
29 |
+
#Scores
|
30 |
+
auto_eval_column_dict.append(["average", ColumnContent, ColumnContent("Average ⬆️", "number", True)])
|
31 |
+
for task in Tasks:
|
32 |
+
auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
|
33 |
+
# Model information
|
34 |
+
auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False)])
|
35 |
+
auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
|
36 |
+
auto_eval_column_dict.append(["weight_type", ColumnContent, ColumnContent("Weight type", "str", False, True)])
|
37 |
+
auto_eval_column_dict.append(["precision", ColumnContent, ColumnContent("Precision", "str", False)])
|
38 |
+
auto_eval_column_dict.append(["license", ColumnContent, ColumnContent("Hub License", "str", False)])
|
39 |
+
auto_eval_column_dict.append(["params", ColumnContent, ColumnContent("#Params (B)", "number", False)])
|
40 |
+
auto_eval_column_dict.append(["likes", ColumnContent, ColumnContent("Hub ❤️", "number", False)])
|
41 |
+
auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False)])
|
42 |
+
auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
|
43 |
+
# Dummy column for the search bar (hidden by the custom CSS)
|
44 |
+
auto_eval_column_dict.append(["dummy", ColumnContent, ColumnContent("model_name_for_query", "str", False, dummy=True)])
|
45 |
+
|
46 |
+
# We use make dataclass to dynamically fill the scores from Tasks
|
47 |
+
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
|
48 |
+
|
49 |
+
## For the queue columns in the submission tab
|
50 |
+
@dataclass(frozen=True)
|
51 |
+
class EvalQueueColumn: # Queue column
|
52 |
+
model = ColumnContent("model", "markdown", True)
|
53 |
+
revision = ColumnContent("revision", "str", True)
|
54 |
+
private = ColumnContent("private", "bool", True)
|
55 |
+
precision = ColumnContent("precision", "str", True)
|
56 |
+
weight_type = ColumnContent("weight_type", "str", "Original")
|
57 |
+
status = ColumnContent("status", "str", True)
|
58 |
+
|
59 |
+
## All the model information that we might need
|
60 |
+
@dataclass
|
61 |
+
class ModelDetails:
|
62 |
+
name: str
|
63 |
+
display_name: str = ""
|
64 |
+
symbol: str = "" # emoji
|
65 |
+
|
66 |
+
|
67 |
+
class ModelType(Enum):
|
68 |
+
PT = ModelDetails(name="pretrained", symbol="🟢")
|
69 |
+
FT = ModelDetails(name="fine-tuned", symbol="🔶")
|
70 |
+
IFT = ModelDetails(name="instruction-tuned", symbol="⭕")
|
71 |
+
RL = ModelDetails(name="RL-tuned", symbol="🟦")
|
72 |
+
Unknown = ModelDetails(name="", symbol="?")
|
73 |
+
|
74 |
+
def to_str(self, separator=" "):
|
75 |
+
return f"{self.value.symbol}{separator}{self.value.name}"
|
76 |
+
|
77 |
+
@staticmethod
|
78 |
+
def from_str(type):
|
79 |
+
if "fine-tuned" in type or "🔶" in type:
|
80 |
+
return ModelType.FT
|
81 |
+
if "pretrained" in type or "🟢" in type:
|
82 |
+
return ModelType.PT
|
83 |
+
if "RL-tuned" in type or "🟦" in type:
|
84 |
+
return ModelType.RL
|
85 |
+
if "instruction-tuned" in type or "⭕" in type:
|
86 |
+
return ModelType.IFT
|
87 |
+
return ModelType.Unknown
|
88 |
+
|
89 |
+
class WeightType(Enum):
|
90 |
+
Adapter = ModelDetails("Adapter")
|
91 |
+
Original = ModelDetails("Original")
|
92 |
+
Delta = ModelDetails("Delta")
|
93 |
+
|
94 |
+
class Precision(Enum):
|
95 |
+
float16 = ModelDetails("float16")
|
96 |
+
bfloat16 = ModelDetails("bfloat16")
|
97 |
+
qt_8bit = ModelDetails("8bit")
|
98 |
+
qt_4bit = ModelDetails("4bit")
|
99 |
+
qt_GPTQ = ModelDetails("GPTQ")
|
100 |
+
Unknown = ModelDetails("?")
|
101 |
+
|
102 |
+
def from_str(precision):
|
103 |
+
if precision in ["torch.float16", "float16"]:
|
104 |
+
return Precision.float16
|
105 |
+
if precision in ["torch.bfloat16", "bfloat16"]:
|
106 |
+
return Precision.bfloat16
|
107 |
+
if precision in ["8bit"]:
|
108 |
+
return Precision.qt_8bit
|
109 |
+
if precision in ["4bit"]:
|
110 |
+
return Precision.qt_4bit
|
111 |
+
if precision in ["GPTQ", "None"]:
|
112 |
+
return Precision.qt_GPTQ
|
113 |
+
return Precision.Unknown
|
114 |
+
|
115 |
+
# Column selection
|
116 |
+
COLS = [c.name for c in fields(AutoEvalColumn) if not c.hidden]
|
117 |
+
TYPES = [c.type for c in fields(AutoEvalColumn) if not c.hidden]
|
118 |
+
COLS_LITE = [c.name for c in fields(AutoEvalColumn) if c.displayed_by_default and not c.hidden]
|
119 |
+
TYPES_LITE = [c.type for c in fields(AutoEvalColumn) if c.displayed_by_default and not c.hidden]
|
120 |
+
|
121 |
+
EVAL_COLS = [c.name for c in fields(EvalQueueColumn)]
|
122 |
+
EVAL_TYPES = [c.type for c in fields(EvalQueueColumn)]
|
123 |
+
|
124 |
+
BENCHMARK_COLS = [t.value.col_name for t in Tasks]
|
125 |
+
|
126 |
+
NUMERIC_INTERVALS = {
|
127 |
+
"?": pd.Interval(-1, 0, closed="right"),
|
128 |
+
"~1.5": pd.Interval(0, 2, closed="right"),
|
129 |
+
"~3": pd.Interval(2, 4, closed="right"),
|
130 |
+
"~7": pd.Interval(4, 9, closed="right"),
|
131 |
+
"~13": pd.Interval(9, 20, closed="right"),
|
132 |
+
"~35": pd.Interval(20, 45, closed="right"),
|
133 |
+
"~60": pd.Interval(45, 70, closed="right"),
|
134 |
+
"70+": pd.Interval(70, 10000, closed="right"),
|
135 |
+
}
|
src/envs.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
from huggingface_hub import HfApi
|
4 |
+
|
5 |
+
# clone / pull the lmeh eval data
|
6 |
+
TOKEN = os.environ.get("TOKEN", None)
|
7 |
+
|
8 |
+
OWNER = "SeaLLMs"
|
9 |
+
REPO_ID = f"{OWNER}/SeaExam_leaderboard"
|
10 |
+
QUEUE_REPO = f"SeaExam_leaderboard/requests"
|
11 |
+
# RESULTS_REPO = f"SeaExam_leaderboard/results"
|
12 |
+
RESULTS_REPO = f"SeaExam_leaderboard/SeaExam-results"
|
13 |
+
|
14 |
+
CACHE_PATH=os.getenv("HF_HOME", ".")
|
15 |
+
|
16 |
+
|
17 |
+
# Local caches
|
18 |
+
EVAL_REQUESTS_PATH = os.path.join(CACHE_PATH, "eval-queue")
|
19 |
+
EVAL_RESULTS_PATH = os.path.join(CACHE_PATH, "eval-results")
|
20 |
+
|
21 |
+
API = HfApi(token=TOKEN)
|
src/leaderboard/__pycache__/load_results.cpython-39.pyc
ADDED
Binary file (1.82 kB). View file
|
|
src/leaderboard/load_results.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import re
|
3 |
+
from huggingface_hub import HfApi
|
4 |
+
api = HfApi()
|
5 |
+
|
6 |
+
|
7 |
+
def get_model_size(model_name, precision: str = "BF16", revision: str = "main"):
|
8 |
+
if len(model_name.split("/")) == 1:
|
9 |
+
return None
|
10 |
+
|
11 |
+
model_info = api.model_info(repo_id=model_name, revision=revision)
|
12 |
+
# model_size = get_model_size(model_info=model_info, precision=precision)
|
13 |
+
size_pattern = size_pattern = re.compile(r"(\d\.)?\d+(b|m)")
|
14 |
+
try:
|
15 |
+
model_size = round(model_info.safetensors["total"] / 1e9, 1)
|
16 |
+
except (AttributeError, TypeError):
|
17 |
+
try:
|
18 |
+
size_match = re.search(size_pattern, model_info.modelId.lower())
|
19 |
+
model_size = size_match.group(0)
|
20 |
+
model_size = round(float(model_size[:-1]) if model_size[-1] == "b" else float(model_size[:-1]) / 1e3, 1)
|
21 |
+
except AttributeError:
|
22 |
+
return 0 # Unknown model sizes are indicated as 0, see NUMERIC_INTERVALS in app.py
|
23 |
+
|
24 |
+
size_factor = 8 if (precision == "GPTQ" or "gptq" in model_info.modelId.lower()) else 1
|
25 |
+
model_size = size_factor * model_size
|
26 |
+
return model_size
|
27 |
+
|
28 |
+
|
29 |
+
def make_clickable_model(model_name, link=None):
|
30 |
+
if len(model_name.split("/")) == 2:
|
31 |
+
link = "https://huggingface.co/" + model_name
|
32 |
+
return (
|
33 |
+
f'<a target="_blank" style="text-decoration: underline" href="{link}">{model_name.split("/")[-1]}</a>'
|
34 |
+
)
|
35 |
+
return model_name
|
36 |
+
|
37 |
+
|
38 |
+
def load_data(data_path):
|
39 |
+
columns = ['Rank', 'Model', 'From', 'Open?', 'Params(B)', 'Cost', 'Score']
|
40 |
+
columns_sorted = ['Rank', 'Model', 'From', 'Open?', 'Params(B)', 'Cost', 'Score']
|
41 |
+
|
42 |
+
df = pd.read_csv(data_path, usecols=columns).dropna()
|
43 |
+
df['Score'] = df['Score'].round(0)
|
44 |
+
|
45 |
+
# rank according to the Score column
|
46 |
+
df = df.sort_values(by='Score', ascending=False)
|
47 |
+
# reorder the columns
|
48 |
+
df = df[columns_sorted]
|
49 |
+
|
50 |
+
# make the 'Model' column clickable
|
51 |
+
df['Model'] = df['Model'].apply(make_clickable_model)
|
52 |
+
|
53 |
+
return df
|
54 |
+
|
55 |
+
|
56 |
+
if __name__ == "__main__":
|
57 |
+
model_name = "SeaLLMs/SeaLLM-7B-v2"
|
58 |
+
model_size = get_model_size(model_name)
|
59 |
+
print(model_size)
|
src/leaderboard/read_evals.py
ADDED
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
from src.display.formatting import make_clickable_model
|
11 |
+
from src.display.utils import AutoEvalColumn, ModelType, Tasks, Precision, WeightType
|
12 |
+
from src.submission.check_validity import is_model_on_hub
|
13 |
+
|
14 |
+
|
15 |
+
@dataclass
|
16 |
+
class EvalResult:
|
17 |
+
eval_name: str # org_model_precision (uid)
|
18 |
+
full_model: str # org/model (path on hub)
|
19 |
+
org: str
|
20 |
+
model: str
|
21 |
+
revision: str # commit hash, "" if main
|
22 |
+
results: dict
|
23 |
+
precision: Precision = Precision.Unknown
|
24 |
+
model_type: ModelType = ModelType.Unknown # Pretrained, fine tuned, ...
|
25 |
+
weight_type: WeightType = WeightType.Original # Original or Adapter
|
26 |
+
architecture: str = "Unknown"
|
27 |
+
license: str = "?"
|
28 |
+
likes: int = 0
|
29 |
+
num_params: int = 0
|
30 |
+
date: str = "" # submission date of request file
|
31 |
+
still_on_hub: bool = False
|
32 |
+
|
33 |
+
@classmethod
|
34 |
+
def init_from_json_file(self, json_filepath):
|
35 |
+
"""Inits the result from the specific model result file"""
|
36 |
+
with open(json_filepath) as fp:
|
37 |
+
data = json.load(fp)
|
38 |
+
|
39 |
+
config = data.get("config")
|
40 |
+
|
41 |
+
# Precision
|
42 |
+
precision = Precision.from_str(config.get("model_dtype"))
|
43 |
+
|
44 |
+
# Get model and org
|
45 |
+
org_and_model = config.get("model_name", config.get("model_args", None))
|
46 |
+
org_and_model = org_and_model.split("/", 1)
|
47 |
+
|
48 |
+
if len(org_and_model) == 1:
|
49 |
+
org = None
|
50 |
+
model = org_and_model[0]
|
51 |
+
result_key = f"{model}_{precision.value.name}"
|
52 |
+
else:
|
53 |
+
org = org_and_model[0]
|
54 |
+
model = org_and_model[1]
|
55 |
+
result_key = f"{org}_{model}_{precision.value.name}"
|
56 |
+
full_model = "/".join(org_and_model)
|
57 |
+
|
58 |
+
still_on_hub, _, model_config = is_model_on_hub(
|
59 |
+
full_model, config.get("model_sha", "main"), trust_remote_code=True, test_tokenizer=False
|
60 |
+
)
|
61 |
+
architecture = "?"
|
62 |
+
if model_config is not None:
|
63 |
+
architectures = getattr(model_config, "architectures", None)
|
64 |
+
if architectures:
|
65 |
+
architecture = ";".join(architectures)
|
66 |
+
|
67 |
+
# Extract results available in this file (some results are split in several files)
|
68 |
+
results = {}
|
69 |
+
for task in Tasks:
|
70 |
+
task = task.value
|
71 |
+
|
72 |
+
# We average all scores of a given metric (not all metrics are present in all files)
|
73 |
+
accs = np.array([v.get(task.metric, None) for k, v in data["results"].items() if task.benchmark == k])
|
74 |
+
if accs.size == 0 or any([acc is None for acc in accs]):
|
75 |
+
continue
|
76 |
+
|
77 |
+
mean_acc = np.mean(accs) * 100.0
|
78 |
+
results[task.benchmark] = mean_acc
|
79 |
+
|
80 |
+
return self(
|
81 |
+
eval_name=result_key,
|
82 |
+
full_model=full_model,
|
83 |
+
org=org,
|
84 |
+
model=model,
|
85 |
+
results=results,
|
86 |
+
precision=precision,
|
87 |
+
revision= config.get("model_sha", ""),
|
88 |
+
still_on_hub=still_on_hub,
|
89 |
+
architecture=architecture
|
90 |
+
)
|
91 |
+
|
92 |
+
def update_with_request_file(self, requests_path):
|
93 |
+
"""Finds the relevant request file for the current model and updates info with it"""
|
94 |
+
request_file = get_request_file_for_model(requests_path, self.full_model, self.precision.value.name)
|
95 |
+
|
96 |
+
try:
|
97 |
+
with open(request_file, "r") as f:
|
98 |
+
request = json.load(f)
|
99 |
+
self.model_type = ModelType.from_str(request.get("model_type", ""))
|
100 |
+
self.weight_type = WeightType[request.get("weight_type", "Original")]
|
101 |
+
self.license = request.get("license", "?")
|
102 |
+
self.likes = request.get("likes", 0)
|
103 |
+
self.num_params = request.get("params", 0)
|
104 |
+
self.date = request.get("submitted_time", "")
|
105 |
+
except Exception:
|
106 |
+
print(f"Could not find request file for {self.org}/{self.model}")
|
107 |
+
|
108 |
+
def to_dict(self):
|
109 |
+
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
110 |
+
average = sum([v for v in self.results.values() if v is not None]) / len(Tasks)
|
111 |
+
data_dict = {
|
112 |
+
"eval_name": self.eval_name, # not a column, just a save name,
|
113 |
+
AutoEvalColumn.precision.name: self.precision.value.name,
|
114 |
+
AutoEvalColumn.model_type.name: self.model_type.value.name,
|
115 |
+
AutoEvalColumn.model_type_symbol.name: self.model_type.value.symbol,
|
116 |
+
AutoEvalColumn.weight_type.name: self.weight_type.value.name,
|
117 |
+
AutoEvalColumn.architecture.name: self.architecture,
|
118 |
+
AutoEvalColumn.model.name: make_clickable_model(self.full_model),
|
119 |
+
AutoEvalColumn.dummy.name: self.full_model,
|
120 |
+
AutoEvalColumn.revision.name: self.revision,
|
121 |
+
AutoEvalColumn.average.name: average,
|
122 |
+
AutoEvalColumn.license.name: self.license,
|
123 |
+
AutoEvalColumn.likes.name: self.likes,
|
124 |
+
AutoEvalColumn.params.name: self.num_params,
|
125 |
+
AutoEvalColumn.still_on_hub.name: self.still_on_hub,
|
126 |
+
}
|
127 |
+
|
128 |
+
for task in Tasks:
|
129 |
+
data_dict[task.value.col_name] = self.results[task.value.benchmark]
|
130 |
+
|
131 |
+
return data_dict
|
132 |
+
|
133 |
+
|
134 |
+
def get_request_file_for_model(requests_path, model_name, precision):
|
135 |
+
"""Selects the correct request file for a given model. Only keeps runs tagged as FINISHED"""
|
136 |
+
request_files = os.path.join(
|
137 |
+
requests_path,
|
138 |
+
f"{model_name}_eval_request_*.json",
|
139 |
+
)
|
140 |
+
request_files = glob.glob(request_files)
|
141 |
+
|
142 |
+
# Select correct request file (precision)
|
143 |
+
request_file = ""
|
144 |
+
request_files = sorted(request_files, reverse=True)
|
145 |
+
for tmp_request_file in request_files:
|
146 |
+
with open(tmp_request_file, "r") as f:
|
147 |
+
req_content = json.load(f)
|
148 |
+
if (
|
149 |
+
req_content["status"] in ["FINISHED"]
|
150 |
+
and req_content["precision"] == precision.split(".")[-1]
|
151 |
+
):
|
152 |
+
request_file = tmp_request_file
|
153 |
+
return request_file
|
154 |
+
|
155 |
+
|
156 |
+
def get_raw_eval_results(results_path: str, requests_path: str) -> list[EvalResult]:
|
157 |
+
"""From the path of the results folder root, extract all needed info for results"""
|
158 |
+
model_result_filepaths = []
|
159 |
+
|
160 |
+
for root, _, files in os.walk(results_path):
|
161 |
+
# We should only have json files in model results
|
162 |
+
if len(files) == 0 or any([not f.endswith(".json") for f in files]):
|
163 |
+
continue
|
164 |
+
|
165 |
+
# Sort the files by date
|
166 |
+
try:
|
167 |
+
files.sort(key=lambda x: x.removesuffix(".json").removeprefix("results_")[:-7])
|
168 |
+
except dateutil.parser._parser.ParserError:
|
169 |
+
files = [files[-1]]
|
170 |
+
|
171 |
+
for file in files:
|
172 |
+
model_result_filepaths.append(os.path.join(root, file))
|
173 |
+
|
174 |
+
eval_results = {}
|
175 |
+
for model_result_filepath in model_result_filepaths:
|
176 |
+
# Creation of result
|
177 |
+
eval_result = EvalResult.init_from_json_file(model_result_filepath)
|
178 |
+
eval_result.update_with_request_file(requests_path)
|
179 |
+
|
180 |
+
# Store results of same eval together
|
181 |
+
eval_name = eval_result.eval_name
|
182 |
+
if eval_name in eval_results.keys():
|
183 |
+
eval_results[eval_name].results.update({k: v for k, v in eval_result.results.items() if v is not None})
|
184 |
+
else:
|
185 |
+
eval_results[eval_name] = eval_result
|
186 |
+
|
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
|
194 |
+
|
195 |
+
return results
|
src/populate.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
|
4 |
+
import pandas as pd
|
5 |
+
|
6 |
+
from src.display.formatting import has_no_nan_values, make_clickable_model
|
7 |
+
from src.display.utils import AutoEvalColumn, EvalQueueColumn
|
8 |
+
from src.leaderboard.read_evals import get_raw_eval_results
|
9 |
+
|
10 |
+
|
11 |
+
def get_leaderboard_df(results_path: str, requests_path: str, cols: list, benchmark_cols: list) -> pd.DataFrame:
|
12 |
+
raw_data = get_raw_eval_results(results_path, requests_path)
|
13 |
+
all_data_json = [v.to_dict() for v in raw_data]
|
14 |
+
|
15 |
+
df = pd.DataFrame.from_records(all_data_json)
|
16 |
+
df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
|
17 |
+
df = df[cols].round(decimals=2)
|
18 |
+
|
19 |
+
# filter out if any of the benchmarks have not been produced
|
20 |
+
df = df[has_no_nan_values(df, benchmark_cols)]
|
21 |
+
return raw_data, df
|
22 |
+
|
23 |
+
|
24 |
+
def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
25 |
+
entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
|
26 |
+
all_evals = []
|
27 |
+
|
28 |
+
for entry in entries:
|
29 |
+
if ".json" in entry:
|
30 |
+
file_path = os.path.join(save_path, entry)
|
31 |
+
with open(file_path) as fp:
|
32 |
+
data = json.load(fp)
|
33 |
+
|
34 |
+
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
35 |
+
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
36 |
+
|
37 |
+
all_evals.append(data)
|
38 |
+
elif ".md" not in entry:
|
39 |
+
# this is a folder
|
40 |
+
sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if not e.startswith(".")]
|
41 |
+
for sub_entry in sub_entries:
|
42 |
+
file_path = os.path.join(save_path, entry, sub_entry)
|
43 |
+
with open(file_path) as fp:
|
44 |
+
data = json.load(fp)
|
45 |
+
|
46 |
+
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
47 |
+
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
48 |
+
all_evals.append(data)
|
49 |
+
|
50 |
+
pending_list = [e for e in all_evals if e["status"] in ["PENDING", "RERUN"]]
|
51 |
+
running_list = [e for e in all_evals if e["status"] == "RUNNING"]
|
52 |
+
finished_list = [e for e in all_evals if e["status"].startswith("FINISHED") or e["status"] == "PENDING_NEW_EVAL"]
|
53 |
+
df_pending = pd.DataFrame.from_records(pending_list, columns=cols)
|
54 |
+
df_running = pd.DataFrame.from_records(running_list, columns=cols)
|
55 |
+
df_finished = pd.DataFrame.from_records(finished_list, columns=cols)
|
56 |
+
return df_finished[cols], df_running[cols], df_pending[cols]
|
src/results/auto-arena-llms-results-20240529.csv
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Model,Rank,MT-Bench Hard,MT-Bench,MT-Bench,LC-AlpacaEval,openLLM,MMLU,From,Open?,Params(B),Cost,Score,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
2 |
+
gpt-4o-2024-05-13,1,,,,57.5,,87.2,OpenAI,No,-,15,1197.26,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
3 |
+
GPT-4-turbo-0409,2,82.6,,,55,86.27,86.5,OpenAI,No,-,30,1137.712,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
4 |
+
minimax-abab6.5-chat,3,,,,,,78.7,minimax,No,-,4.2,1090.027116,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
5 |
+
meta-llama/Llama-3-70b-chat-hf,4,41.1,,,34.4,77.88,80.06,meta,Yes,70B,-,1076.688,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
6 |
+
glm-4,5,,,,,,81.5,Zhipu AI,No,-,13.8,1063.642,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
7 |
+
reka-core-20240501,7,,,,,,83.2,Reka AI,No,-,25,1027.868,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
8 |
+
command-r-plus,6,33.1,,,,74.62,75.7,Cohere,Yes,104B,15,1048.063,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
9 |
+
claude-3-haiku-20240307,8,41.5,9.1,9.1,,84.8,75.2,Anthropic,No,-,1.25,1025.715,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
10 |
+
Qwen1.5-72B-chat,9,36.1,8.61,8.61,36.6,72.91,77.2,Alibaba,Yes,72B,-,1024.823,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
11 |
+
SenseChat-5,10,,,,,,84.7,SenseTime,No,-,13.8,1007.46,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
12 |
+
Mixtral-8x7B-Instruct-v0.1,11,23.4,8.3,8.3,23.7,72.71,71.4,Mistral AI,Yes,7B,-,963.534,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
13 |
+
wenxin-4,12,,,,,,,Baidu,No,-,16.6,955.096,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
14 |
+
zero-one-ai/Yi-34B-Chat,13,23.1,7,7,27.2,63.17,74.87,Zero One AI,Yes,34B,-,942.011,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
15 |
+
mistral-large-2402,14,37.7,8.63,8.63,32.7,,81.2,Mistral AI,No,-,12,926.585,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
16 |
+
GPT-3.5-Turbo-0125,15,23.3,7.94,7.94,17.7,71.02,70,OpenAI,No,-,1.5,890.189,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
17 |
+
deepseek-ai/deepseek-llm-67b-chat,16,,,,17.8,,71.3,Deepseek AI,Yes,67B,-,841.463,,,,,,,,,,,,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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 tokenizer_class_from_name, get_tokenizer_config
|
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 |
+
|
35 |
+
def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_remote_code=False, test_tokenizer=False) -> tuple[bool, str]:
|
36 |
+
"""Makes sure the model is on the hub, and uses a valid configuration (in the latest transformers version)"""
|
37 |
+
try:
|
38 |
+
config = AutoConfig.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
39 |
+
if test_tokenizer:
|
40 |
+
tokenizer_config = get_tokenizer_config(model_name)
|
41 |
+
if tokenizer_config is not None:
|
42 |
+
tokenizer_class_candidate = tokenizer_config.get("tokenizer_class", None)
|
43 |
+
else:
|
44 |
+
tokenizer_class_candidate = config.tokenizer_class
|
45 |
+
|
46 |
+
|
47 |
+
tokenizer_class = tokenizer_class_from_name(tokenizer_class_candidate)
|
48 |
+
if tokenizer_class is None:
|
49 |
+
return (
|
50 |
+
False,
|
51 |
+
f"uses {tokenizer_class_candidate}, which is not in a transformers release, therefore not supported at the moment.",
|
52 |
+
None
|
53 |
+
)
|
54 |
+
return True, None, config
|
55 |
+
|
56 |
+
except ValueError:
|
57 |
+
return (
|
58 |
+
False,
|
59 |
+
"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.",
|
60 |
+
None
|
61 |
+
)
|
62 |
+
|
63 |
+
except Exception as e:
|
64 |
+
return False, "was not found on hub!", None
|
65 |
+
|
66 |
+
|
67 |
+
def get_model_size(model_info: ModelInfo, precision: str):
|
68 |
+
"""Gets the model size from the configuration, or the model name if the configuration does not contain the information."""
|
69 |
+
try:
|
70 |
+
model_size = round(model_info.safetensors["total"] / 1e9, 3)
|
71 |
+
except (AttributeError, TypeError):
|
72 |
+
return 0 # Unknown model sizes are indicated as 0, see NUMERIC_INTERVALS in app.py
|
73 |
+
|
74 |
+
size_factor = 8 if (precision == "GPTQ" or "gptq" in model_info.modelId.lower()) else 1
|
75 |
+
model_size = size_factor * model_size
|
76 |
+
return model_size
|
77 |
+
|
78 |
+
def get_model_arch(model_info: ModelInfo):
|
79 |
+
"""Gets the model architecture from the configuration"""
|
80 |
+
return model_info.config.get("architectures", "Unknown")
|
81 |
+
|
82 |
+
def already_submitted_models(requested_models_dir: str) -> set[str]:
|
83 |
+
depth = 1
|
84 |
+
file_names = []
|
85 |
+
users_to_submission_dates = defaultdict(list)
|
86 |
+
|
87 |
+
for root, _, files in os.walk(requested_models_dir):
|
88 |
+
current_depth = root.count(os.sep) - requested_models_dir.count(os.sep)
|
89 |
+
if current_depth == depth:
|
90 |
+
for file in files:
|
91 |
+
if not file.endswith(".json"):
|
92 |
+
continue
|
93 |
+
with open(os.path.join(root, file), "r") as f:
|
94 |
+
info = json.load(f)
|
95 |
+
file_names.append(f"{info['model']}_{info['revision']}_{info['precision']}")
|
96 |
+
|
97 |
+
# Select organisation
|
98 |
+
if info["model"].count("/") == 0 or "submitted_time" not in info:
|
99 |
+
continue
|
100 |
+
organisation, _ = info["model"].split("/")
|
101 |
+
users_to_submission_dates[organisation].append(info["submitted_time"])
|
102 |
+
|
103 |
+
return set(file_names), users_to_submission_dates
|
src/submission/submit.py
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, 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 |
+
}
|
91 |
+
|
92 |
+
# Check for duplicate submission
|
93 |
+
if f"{model}_{revision}_{precision}" in REQUESTED_MODELS:
|
94 |
+
return styled_warning("This model has been already submitted.")
|
95 |
+
|
96 |
+
print("Creating eval file")
|
97 |
+
OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
|
98 |
+
os.makedirs(OUT_DIR, exist_ok=True)
|
99 |
+
out_path = f"{OUT_DIR}/{model_path}_eval_request_False_{precision}_{weight_type}.json"
|
100 |
+
|
101 |
+
with open(out_path, "w") as f:
|
102 |
+
f.write(json.dumps(eval_entry))
|
103 |
+
|
104 |
+
print("Uploading eval file")
|
105 |
+
API.upload_file(
|
106 |
+
path_or_fileobj=out_path,
|
107 |
+
path_in_repo=out_path.split("eval-queue/")[1],
|
108 |
+
repo_id=QUEUE_REPO,
|
109 |
+
repo_type="dataset",
|
110 |
+
commit_message=f"Add {model} to eval queue",
|
111 |
+
)
|
112 |
+
|
113 |
+
# Remove the local file
|
114 |
+
os.remove(out_path)
|
115 |
+
|
116 |
+
return styled_message(
|
117 |
+
"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."
|
118 |
+
)
|