Spaces:
Running
Running
Commit
·
65e4811
1
Parent(s):
2ca87bb
Update space
Browse files- Makefile +0 -13
- README.md +2 -36
- about.py +3 -0
- app.py +141 -185
- src/display/css_html_js.py → css_html_js.py +17 -12
- main.py +6 -0
- parse.py +106 -0
- pyproject.toml +11 -13
- requirements.txt +2 -1
- results.csv +23 -0
- results.json +0 -0
- src/about.py +0 -72
- src/display/formatting.py +0 -27
- src/display/utils.py +0 -110
- src/envs.py +0 -25
- src/leaderboard/read_evals.py +0 -196
- src/populate.py +0 -58
- src/submission/check_validity.py +0 -99
- src/submission/submit.py +0 -119
- utils.py +46 -0
Makefile
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
.PHONY: style format
|
2 |
-
|
3 |
-
|
4 |
-
style:
|
5 |
-
python -m black --line-length 119 .
|
6 |
-
python -m isort .
|
7 |
-
ruff check --fix .
|
8 |
-
|
9 |
-
|
10 |
-
quality:
|
11 |
-
python -m black --check --line-length 119 .
|
12 |
-
python -m isort --check-only .
|
13 |
-
ruff check .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title: TuRTLe Leaderboard
|
3 |
emoji: 🥇
|
4 |
colorFrom: green
|
5 |
colorTo: indigo
|
@@ -7,40 +7,6 @@ sdk: gradio
|
|
7 |
app_file: app.py
|
8 |
pinned: true
|
9 |
license: apache-2.0
|
10 |
-
short_description:
|
11 |
sdk_version: 5.19.0
|
12 |
---
|
13 |
-
|
14 |
-
# Start the configuration
|
15 |
-
|
16 |
-
Most of the variables to change for a default leaderboard are in `src/env.py` (replace the path for your leaderboard) and `src/about.py` (for tasks).
|
17 |
-
|
18 |
-
Results files should have the following format and be stored as json files:
|
19 |
-
```json
|
20 |
-
{
|
21 |
-
"config": {
|
22 |
-
"model_dtype": "torch.float16", # or torch.bfloat16 or 8bit or 4bit
|
23 |
-
"model_name": "path of the model on the hub: org/model",
|
24 |
-
"model_sha": "revision on the hub",
|
25 |
-
},
|
26 |
-
"results": {
|
27 |
-
"task_name": {
|
28 |
-
"metric_name": score,
|
29 |
-
},
|
30 |
-
"task_name2": {
|
31 |
-
"metric_name": score,
|
32 |
-
}
|
33 |
-
}
|
34 |
-
}
|
35 |
-
```
|
36 |
-
|
37 |
-
Request files are created automatically by this tool.
|
38 |
-
|
39 |
-
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.
|
40 |
-
|
41 |
-
# Code logic for more complex edits
|
42 |
-
|
43 |
-
You'll find
|
44 |
-
- the main table' columns names and properties in `src/display/utils.py`
|
45 |
-
- 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`
|
46 |
-
- the logic to allow or filter submissions in `src/submission/submit.py` and `src/submission/check_validity.py`
|
|
|
1 |
---
|
2 |
+
title: TuRTLe Model Leaderboard
|
3 |
emoji: 🥇
|
4 |
colorFrom: green
|
5 |
colorTo: indigo
|
|
|
7 |
app_file: app.py
|
8 |
pinned: true
|
9 |
license: apache-2.0
|
10 |
+
short_description: Duplicate this leaderboard to initialize your own!
|
11 |
sdk_version: 5.19.0
|
12 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
about.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
|
2 |
+
CITATION_BUTTON_TEXT = r"""
|
3 |
+
"""
|
app.py
CHANGED
@@ -1,193 +1,122 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
3 |
-
|
4 |
-
from
|
5 |
-
from
|
6 |
-
|
7 |
-
from
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
)
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
)
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
snapshot_download(
|
46 |
-
repo_id=RESULTS_REPO, local_dir=EVAL_RESULTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30, token=TOKEN
|
47 |
)
|
48 |
-
|
49 |
-
|
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 |
-
def init_leaderboard(dataframe):
|
61 |
-
if dataframe is None or dataframe.empty:
|
62 |
-
raise ValueError("Leaderboard DataFrame is empty or None.")
|
63 |
-
return Leaderboard(
|
64 |
-
value=dataframe,
|
65 |
-
datatype=[c.type for c in fields(AutoEvalColumn)],
|
66 |
-
select_columns=SelectColumns(
|
67 |
-
default_selection=[c.name for c in fields(AutoEvalColumn) if c.displayed_by_default],
|
68 |
-
cant_deselect=[c.name for c in fields(AutoEvalColumn) if c.never_hidden],
|
69 |
-
label="Select Columns to Display:",
|
70 |
),
|
71 |
-
|
72 |
-
|
73 |
-
filter_columns=[
|
74 |
-
ColumnFilter(AutoEvalColumn.model_type.name, type="checkboxgroup", label="Model types"),
|
75 |
-
ColumnFilter(AutoEvalColumn.precision.name, type="checkboxgroup", label="Precision"),
|
76 |
-
ColumnFilter(
|
77 |
-
AutoEvalColumn.params.name,
|
78 |
-
type="slider",
|
79 |
-
min=0.01,
|
80 |
-
max=150,
|
81 |
-
label="Select the number of parameters (B)",
|
82 |
-
),
|
83 |
-
ColumnFilter(
|
84 |
-
AutoEvalColumn.still_on_hub.name, type="boolean", label="Deleted/incomplete", default=True
|
85 |
-
),
|
86 |
-
],
|
87 |
-
bool_checkboxgroup_label="Hide models",
|
88 |
-
interactive=False,
|
89 |
)
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
with
|
94 |
-
|
95 |
-
gr.Markdown(
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
with gr.TabItem("🚀 Submit here! ", elem_id="llm-benchmark-tab-table", id=3):
|
105 |
-
with gr.Column():
|
106 |
-
with gr.Row():
|
107 |
-
gr.Markdown(EVALUATION_QUEUE_TEXT, elem_classes="markdown-text")
|
108 |
-
|
109 |
-
with gr.Column():
|
110 |
-
with gr.Accordion(
|
111 |
-
f"✅ Finished Evaluations ({len(finished_eval_queue_df)})",
|
112 |
-
open=False,
|
113 |
-
):
|
114 |
-
with gr.Row():
|
115 |
-
finished_eval_table = gr.components.Dataframe(
|
116 |
-
value=finished_eval_queue_df,
|
117 |
-
headers=EVAL_COLS,
|
118 |
-
datatype=EVAL_TYPES,
|
119 |
-
row_count=5,
|
120 |
-
)
|
121 |
-
with gr.Accordion(
|
122 |
-
f"🔄 Running Evaluation Queue ({len(running_eval_queue_df)})",
|
123 |
-
open=False,
|
124 |
-
):
|
125 |
-
with gr.Row():
|
126 |
-
running_eval_table = gr.components.Dataframe(
|
127 |
-
value=running_eval_queue_df,
|
128 |
-
headers=EVAL_COLS,
|
129 |
-
datatype=EVAL_TYPES,
|
130 |
-
row_count=5,
|
131 |
-
)
|
132 |
-
|
133 |
-
with gr.Accordion(
|
134 |
-
f"⏳ Pending Evaluation Queue ({len(pending_eval_queue_df)})",
|
135 |
-
open=False,
|
136 |
-
):
|
137 |
-
with gr.Row():
|
138 |
-
pending_eval_table = gr.components.Dataframe(
|
139 |
-
value=pending_eval_queue_df,
|
140 |
-
headers=EVAL_COLS,
|
141 |
-
datatype=EVAL_TYPES,
|
142 |
-
row_count=5,
|
143 |
-
)
|
144 |
with gr.Row():
|
145 |
-
gr.
|
146 |
-
|
|
|
147 |
with gr.Row():
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
interactive=True,
|
173 |
-
)
|
174 |
-
base_model_name_textbox = gr.Textbox(label="Base model (for delta or adapter weights)")
|
175 |
-
|
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,
|
183 |
-
revision_name_textbox,
|
184 |
-
precision,
|
185 |
-
weight_type,
|
186 |
-
model_type,
|
187 |
-
],
|
188 |
-
submission_result,
|
189 |
-
)
|
190 |
-
|
191 |
with gr.Row():
|
192 |
with gr.Accordion("📙 Citation", open=False):
|
193 |
citation_button = gr.Textbox(
|
@@ -197,8 +126,35 @@ with demo:
|
|
197 |
elem_id="citation-button",
|
198 |
show_copy_button=True,
|
199 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
|
201 |
-
|
202 |
-
scheduler.add_job(restart_space, "interval", seconds=1800)
|
203 |
-
scheduler.start()
|
204 |
-
demo.queue(default_concurrency_limit=40).launch()
|
|
|
1 |
+
import json
|
2 |
+
import pandas as pd
|
3 |
import gradio as gr
|
4 |
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
5 |
+
from css_html_js import custom_css
|
6 |
+
from parse import read_json, read_data
|
7 |
+
from utils import model_hyperlink, filter_RTLRepo, filter_bench, handle_special_cases
|
8 |
+
from typing import Union
|
9 |
+
from about import CITATION_BUTTON_LABEL, CITATION_BUTTON_TEXT
|
10 |
+
import numpy as np
|
11 |
+
import plotly.graph_objects as go
|
12 |
+
import plotly.express as px
|
13 |
+
|
14 |
+
def filter_leaderboard(benchmark, model_type, search_query, max_params):
|
15 |
+
subset = df[df['Benchmark'] == benchmark]
|
16 |
+
if model_type != 'All':
|
17 |
+
subset = subset[subset['Model Type'] == model_type]
|
18 |
+
if search_query:
|
19 |
+
subset = subset[subset['Model'].str.contains(search_query, case=False, na=False)]
|
20 |
+
max_params = float(max_params)
|
21 |
+
subset = subset[subset['Params'] <= max_params]
|
22 |
+
|
23 |
+
if benchmark == 'RTL-Repo':
|
24 |
+
return filter_RTLRepo(subset)
|
25 |
+
else:
|
26 |
+
return filter_bench(subset)
|
27 |
+
|
28 |
+
def generate_scatter_plot(benchmark, metric):
|
29 |
+
benchmark, metric = handle_special_cases(benchmark, metric)
|
30 |
+
|
31 |
+
subset = df[df['Benchmark'] == benchmark]
|
32 |
+
if benchmark == "RTL-Repo":
|
33 |
+
subset = subset[subset['Metric'].str.contains('EM', case=False, na=False)]
|
34 |
+
detailed_scores = subset.groupby('Model', as_index=False)['Score'].mean()
|
35 |
+
detailed_scores.rename(columns={'Score': 'EM'}, inplace=True)
|
36 |
+
detailed_scores['Average ⬆️'] = detailed_scores['EM']
|
37 |
+
else:
|
38 |
+
detailed_scores = subset.pivot_table(index='Model', columns='Metric', values='Score').reset_index()
|
39 |
+
detailed_scores['Average ⬆️'] = detailed_scores[['Syntax (STX)', 'Functionality (FNC)', 'Synthesis (SYN)', 'Power', 'Performance', 'Area']].mean(axis=1)
|
40 |
+
|
41 |
+
details = df[['Model', 'Params', 'Model Type']].drop_duplicates('Model')
|
42 |
+
scatter_data = pd.merge(detailed_scores, details, on='Model', how='left').dropna(subset=['Params', metric])
|
43 |
+
|
44 |
+
scatter_data['x'] = scatter_data['Params']
|
45 |
+
scatter_data['y'] = scatter_data[metric]
|
46 |
+
scatter_data['size'] = (scatter_data['x'] ** 0.3) * 40
|
47 |
+
|
48 |
+
type_colors = {"General": "green", "Coding": "yellow", "RTL-Specific": "blue"}
|
49 |
+
scatter_data['color'] = scatter_data['Model Type'].map(type_colors).fillna('gray')
|
50 |
+
|
51 |
+
y_axis_limits = {
|
52 |
+
'Functionality (FNC)': [5, 90], 'Syntax (STX)': [20, 100], 'Synthesis (SYN)': [5, 90],
|
53 |
+
'Power': [0, 50], 'Performance': [0, 50], 'Area': [0, 50], 'Exact Matching (EM)': [0, 50],
|
54 |
+
'Average ⬆️': [0, 80]
|
55 |
+
}
|
56 |
+
y_range = y_axis_limits.get(metric, [0, 80])
|
57 |
+
|
58 |
+
fig = px.scatter(
|
59 |
+
scatter_data, x='x', y='y', log_x=True, size='size', color='color', text='Model',
|
60 |
+
hover_data={metric: ':.2f'}, title=f'Params vs. {metric} for {benchmark}',
|
61 |
+
labels={'x': '# Params (Log Scale)', 'y': metric}, template="plotly_white",
|
62 |
+
height=600, width=1200
|
63 |
)
|
64 |
+
|
65 |
+
fig.update_traces(
|
66 |
+
textposition='top center', textfont_size=10,
|
67 |
+
marker=dict(opacity=0.8, line=dict(width=0.5, color='black'))
|
|
|
|
|
68 |
)
|
69 |
+
fig.update_layout(
|
70 |
+
xaxis=dict(
|
71 |
+
showgrid=True, type='log', tickmode='array',
|
72 |
+
tickvals=[8, 14, 32, 72, 200, 700],
|
73 |
+
ticktext=['8', '14', '32', '72', '200', '700']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
),
|
75 |
+
showlegend=False, yaxis=dict(range=y_range),
|
76 |
+
margin=dict(l=50, r=50, t=50, b=50), plot_bgcolor='white'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
)
|
78 |
|
79 |
+
return fig
|
80 |
+
|
81 |
+
with gr.Blocks(css=custom_css) as app:
|
82 |
+
df, benchmarks, metrics, default_metric = read_data()
|
83 |
+
gr.Markdown("""# TuRTLe 🐢 Model Leaderboard
|
84 |
+
Welcome to the TuRTLe Model Leaderboard! Use the filters below to explore different RTL benchmarks and models.
|
85 |
+
[GitHub Repository](https://github.com/https://github.com/HPAI-BSC) | [arXiv Preprint](https://arxiv.org/) | [How to submit](https://github.com/https://github.com/HPAI-BSC)<br/>
|
86 |
+
Contact us: hpai@bsc.es
|
87 |
+
""")
|
88 |
+
|
89 |
+
with gr.Tabs():
|
90 |
+
with gr.Tab("Leaderboard"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
with gr.Row():
|
92 |
+
benchmark_radio = gr.Radio(choices=benchmarks, label="Select Benchmark", value='VerilogEval S2R', scale=7)
|
93 |
+
model_type_radio = gr.Radio(choices=['All', 'General', 'Coding', 'RTL-Specific'], label="Select Model Type", value='All', scale=4)
|
94 |
+
|
95 |
with gr.Row():
|
96 |
+
search_box = gr.Textbox(label="Search Model", placeholder="Type model name...")
|
97 |
+
params_slider = gr.Slider(
|
98 |
+
minimum=df['Params'].min(),
|
99 |
+
maximum=700,
|
100 |
+
value=700,
|
101 |
+
label="Max Params",
|
102 |
+
step=1
|
103 |
+
)
|
104 |
+
|
105 |
+
leaderboard = gr.DataFrame(
|
106 |
+
value=filter_leaderboard('VerilogEval S2R', 'All', "", 700),
|
107 |
+
headers="first row",
|
108 |
+
wrap=True,
|
109 |
+
datatype=["markdown", "markdown", "html",],
|
110 |
+
interactive=False,
|
111 |
+
column_widths=["4%", "5%", "28%", "10%", "14%"],)
|
112 |
+
|
113 |
+
with gr.Tab("Interactive Bubble Plot"):
|
114 |
+
with gr.Row():
|
115 |
+
bubble_benchmark = gr.Radio(choices=benchmarks, label="Select Benchmark", value='VerilogEval S2R')
|
116 |
+
bubble_metric = gr.Radio(choices=metrics, label="Select Metric", value=default_metric)
|
117 |
+
gr.Markdown("We show in 🟢 General Models, in 🟡 Coding Models and in 🔵 RTL-Specific Models. Detailed information is shown when hovering over each model in the plot.")
|
118 |
+
scatter_plot = gr.Plot(value=generate_scatter_plot('VerilogEval S2R', default_metric), label="Bubble Chart", elem_id="full-width-plot")
|
119 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
with gr.Row():
|
121 |
with gr.Accordion("📙 Citation", open=False):
|
122 |
citation_button = gr.Textbox(
|
|
|
126 |
elem_id="citation-button",
|
127 |
show_copy_button=True,
|
128 |
)
|
129 |
+
|
130 |
+
# event handlers, ugly way but it works
|
131 |
+
benchmark_radio.change(fn=filter_leaderboard, inputs=[benchmark_radio, model_type_radio, search_box, params_slider], outputs=leaderboard)
|
132 |
+
model_type_radio.change(fn=filter_leaderboard, inputs=[benchmark_radio, model_type_radio, search_box, params_slider], outputs=leaderboard)
|
133 |
+
search_box.change(fn=filter_leaderboard, inputs=[benchmark_radio, model_type_radio, search_box, params_slider], outputs=leaderboard)
|
134 |
+
params_slider.change(fn=filter_leaderboard, inputs=[benchmark_radio, model_type_radio, search_box, params_slider], outputs=leaderboard)
|
135 |
+
|
136 |
+
# RTL-Repo Bubble plot handlres
|
137 |
+
def on_benchmark_change(benchmark, metric):
|
138 |
+
benchmark, metric = handle_special_cases(benchmark, metric)
|
139 |
+
fig = generate_scatter_plot(benchmark, metric)
|
140 |
+
return gr.update(value=metric), fig
|
141 |
+
|
142 |
+
def on_metric_change(benchmark, metric):
|
143 |
+
benchmark, metric = handle_special_cases(benchmark, metric)
|
144 |
+
fig = generate_scatter_plot(benchmark, metric)
|
145 |
+
return gr.update(value=benchmark), fig
|
146 |
+
|
147 |
+
bubble_benchmark.change(
|
148 |
+
fn=on_benchmark_change,
|
149 |
+
inputs=[bubble_benchmark, bubble_metric],
|
150 |
+
outputs=[bubble_metric, scatter_plot]
|
151 |
+
)
|
152 |
+
|
153 |
+
bubble_metric.change(
|
154 |
+
fn=on_metric_change,
|
155 |
+
inputs=[bubble_benchmark, bubble_metric],
|
156 |
+
outputs=[bubble_benchmark, scatter_plot]
|
157 |
+
)
|
158 |
+
|
159 |
|
160 |
+
app.launch()
|
|
|
|
|
|
src/display/css_html_js.py → css_html_js.py
RENAMED
@@ -1,34 +1,43 @@
|
|
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;
|
@@ -37,7 +46,6 @@ custom_css = """
|
|
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 |
#leaderboard-table td:nth-child(2),
|
43 |
#leaderboard-table th:nth-child(2) {
|
@@ -45,11 +53,9 @@ custom_css = """
|
|
45 |
overflow: auto;
|
46 |
white-space: nowrap;
|
47 |
}
|
48 |
-
|
49 |
.tab-buttons button {
|
50 |
font-size: 20px;
|
51 |
}
|
52 |
-
|
53 |
#scale-logo {
|
54 |
border-style: none !important;
|
55 |
box-shadow: none;
|
@@ -58,7 +64,6 @@ custom_css = """
|
|
58 |
margin-right: auto;
|
59 |
max-width: 600px;
|
60 |
}
|
61 |
-
|
62 |
#scale-logo .download {
|
63 |
display: none;
|
64 |
}
|
|
|
1 |
custom_css = """
|
2 |
+
#component-0 {
|
3 |
+
width: 75vw;
|
4 |
+
margin: 0 auto;
|
5 |
+
padding: 0px 40px;
|
6 |
+
}
|
7 |
+
@media (max-width: 1600px) {
|
8 |
+
#component-0 {
|
9 |
+
width: 85vw;
|
10 |
+
padding: 0px;
|
11 |
+
}
|
12 |
+
}
|
13 |
+
@media (max-width: 1100px) {
|
14 |
+
#component-0 {
|
15 |
+
width: 95vw;
|
16 |
+
padding: 0px;
|
17 |
+
}
|
18 |
+
}
|
19 |
.markdown-text {
|
20 |
font-size: 16px !important;
|
21 |
}
|
|
|
22 |
#models-to-add-text {
|
23 |
font-size: 18px !important;
|
24 |
}
|
|
|
25 |
#citation-button span {
|
26 |
font-size: 16px !important;
|
27 |
}
|
|
|
28 |
#citation-button textarea {
|
29 |
font-size: 16px !important;
|
30 |
}
|
|
|
31 |
#citation-button > label > button {
|
32 |
margin: 6px;
|
33 |
transform: scale(1.3);
|
34 |
}
|
|
|
35 |
#leaderboard-table {
|
36 |
margin-top: 15px
|
37 |
}
|
|
|
38 |
#leaderboard-table-lite {
|
39 |
margin-top: 15px
|
40 |
}
|
|
|
41 |
#search-bar-table-box > div:first-child {
|
42 |
background: none;
|
43 |
border: none;
|
|
|
46 |
#search-bar {
|
47 |
padding: 0px;
|
48 |
}
|
|
|
49 |
/* Limit the width of the first AutoEvalColumn so that names don't expand too much */
|
50 |
#leaderboard-table td:nth-child(2),
|
51 |
#leaderboard-table th:nth-child(2) {
|
|
|
53 |
overflow: auto;
|
54 |
white-space: nowrap;
|
55 |
}
|
|
|
56 |
.tab-buttons button {
|
57 |
font-size: 20px;
|
58 |
}
|
|
|
59 |
#scale-logo {
|
60 |
border-style: none !important;
|
61 |
box-shadow: none;
|
|
|
64 |
margin-right: auto;
|
65 |
max-width: 600px;
|
66 |
}
|
|
|
67 |
#scale-logo .download {
|
68 |
display: none;
|
69 |
}
|
main.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def main():
|
2 |
+
print("Hello from tortuga!")
|
3 |
+
|
4 |
+
|
5 |
+
if __name__ == "__main__":
|
6 |
+
main()
|
parse.py
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import pandas as pd
|
3 |
+
import csv
|
4 |
+
from typing import Dict, Union
|
5 |
+
import locale
|
6 |
+
|
7 |
+
model_details = {
|
8 |
+
"DeepSeek R1": ("https://huggingface.co/deepseek-ai/DeepSeek-R1", 685, "General"),
|
9 |
+
"Llama 3.1 405B": ("https://huggingface.co/meta-llama/Llama-3.1-405B", 406, "General"),
|
10 |
+
"Llama 3.(1-3) 70B": ("https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct", 70.6, "General"),
|
11 |
+
"Qwen2.5 72B": ("https://huggingface.co/Qwen/Qwen2.5-72B-Instruct", 72.7, "General"),
|
12 |
+
"Qwen2.5 32B": ("https://huggingface.co/Qwen/Qwen2.5-32B", 32.5, "General"),
|
13 |
+
"StarChat2 15B v0.1": ("https://huggingface.co/HuggingFaceH4/starchat2-15b-v0.1", 16, "General"),
|
14 |
+
"DeepSeek R1 Distill Qwen 14B": ("https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-14B", 14.8, "General"),
|
15 |
+
|
16 |
+
"CodeLlama 70B": ("https://huggingface.co/codellama/CodeLlama-70b-hf", 69, "Coding"),
|
17 |
+
"QwenCoder 2.5 32B": ("https://huggingface.co/Qwen/Qwen2.5-Coder-32B-Instruct", 32.5, "Coding"),
|
18 |
+
"DeepSeek Coder 33B": ("https://huggingface.co/deepseek-ai/deepseek-coder-33b-instruct", 33.3, "Coding"),
|
19 |
+
"QwenCoder 2.5 14B": ("https://huggingface.co/Qwen/Qwen2.5-Coder-14B-Instruct", 14.7, "Coding"),
|
20 |
+
"OpenCoder 8B": ("https://huggingface.co/infly/OpenCoder-8B-Instruct", 7.77, "Coding"),
|
21 |
+
"QwenCoder 2.5 7B": ("https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct", 7.61, "Coding"),
|
22 |
+
"DeepSeek Coder 6,7B": ("https://huggingface.co/deepseek-ai/deepseek-coder-6.7b-instruct", 6.74, "Coding"),
|
23 |
+
|
24 |
+
"HaVen-CodeQwen": ("https://huggingface.co/yangyiyao/HaVen-CodeQwen", 7.25, "RTL-Specific"),
|
25 |
+
"CodeV-CL-7B": ("https://huggingface.co/yang-z/CodeV-CL-7B", 6.74, "RTL-Specific"),
|
26 |
+
"CodeV-QW-7B": ("https://huggingface.co/yang-z/CodeV-QW-7B", 7.25, "RTL-Specific"),
|
27 |
+
"CodeV-DS-6.7B": ("https://huggingface.co/yang-z/CodeV-DS-6.7B", 6.74, "RTL-Specific"),
|
28 |
+
"RTLCoder Mistral": ("https://huggingface.co/ishorn5/RTLCoder-v1.1", 7.24, "RTL-Specific"),
|
29 |
+
"RTLCoder DeepSeek": ("https://huggingface.co/ishorn5/RTLCoder-Deepseek-v1.1", 6.74, "RTL-Specific"),
|
30 |
+
"OriGen": ("https://huggingface.co/henryen/OriGen_Fix", 6.74, "RTL-Specific")
|
31 |
+
}
|
32 |
+
|
33 |
+
def get_headers(reader) -> Union[list, list]:
|
34 |
+
metrics, benchs = [], []
|
35 |
+
for i, row in enumerate(reader):
|
36 |
+
if i == 0:
|
37 |
+
metrics = row[1:]
|
38 |
+
elif i == 1:
|
39 |
+
benchs = row[1:]
|
40 |
+
break
|
41 |
+
return metrics, benchs
|
42 |
+
|
43 |
+
def get_model_params_and_url(model) -> Union[str, str, float]:
|
44 |
+
if model not in model_details:
|
45 |
+
return "-", "-", "-"
|
46 |
+
url = model_details[model][0]
|
47 |
+
params = model_details[model][1]
|
48 |
+
type = model_details[model][2]
|
49 |
+
return url, params, type
|
50 |
+
|
51 |
+
def parse_results(csv_path: str) -> list[dict]:
|
52 |
+
"""
|
53 |
+
Each row has the following format:
|
54 |
+
MODEL | BENCHMARK | TASK | METRIC | RESULT
|
55 |
+
"""
|
56 |
+
dataset = []
|
57 |
+
models = []
|
58 |
+
with open(csv_path, newline='') as csvfile:
|
59 |
+
reader = csv.reader(csvfile, delimiter=',')
|
60 |
+
metrics, benchs = get_headers(reader)
|
61 |
+
for i, row in enumerate(reader):
|
62 |
+
model = row[0]
|
63 |
+
url, params, type = get_model_params_and_url(model)
|
64 |
+
models.append(model)
|
65 |
+
row = row[1:]
|
66 |
+
ctr = 0
|
67 |
+
for metric, bench in zip(metrics, benchs):
|
68 |
+
record = {}
|
69 |
+
record["Model"] = model
|
70 |
+
record["Model Type"] = type
|
71 |
+
record["Benchmark"] = bench
|
72 |
+
record["Task"] = metric
|
73 |
+
record["Result"] = float(row[ctr].replace(',','.'))
|
74 |
+
record["Model URL"] = url
|
75 |
+
record["Params"] = params
|
76 |
+
dataset.append(record)
|
77 |
+
ctr += 1
|
78 |
+
print(models)
|
79 |
+
return dataset
|
80 |
+
|
81 |
+
def writeJson(data: list):
|
82 |
+
with open('results.json', 'w') as f:
|
83 |
+
json.dump(data, f, indent=4, ensure_ascii=False)
|
84 |
+
print("Done")
|
85 |
+
|
86 |
+
def read_json():
|
87 |
+
json_path = "./results.json"
|
88 |
+
with open(json_path, "r", encoding="utf-8") as file:
|
89 |
+
data = json.load(file)
|
90 |
+
return data
|
91 |
+
|
92 |
+
def read_data() -> Union[pd.DataFrame, list, list, str]:
|
93 |
+
data = read_json()
|
94 |
+
df = pd.DataFrame(data)
|
95 |
+
df.rename(columns={'Model': 'Model', 'Benchmark': 'Benchmark', 'Task': 'Metric', 'Result': 'Score'}, inplace=True)
|
96 |
+
df['Params'] = pd.to_numeric(df['Params'], errors='coerce')
|
97 |
+
benchmarks = sorted(df['Benchmark'].unique().tolist(), reverse=True)
|
98 |
+
metrics = df['Metric'].unique().tolist()
|
99 |
+
default_metric = 'Functionality (FNC)' if 'Functionality (FNC)' in metrics else metrics[0]
|
100 |
+
return df, benchmarks, metrics, default_metric
|
101 |
+
|
102 |
+
|
103 |
+
if __name__ == "__main__":
|
104 |
+
csv_path = "./results.csv"
|
105 |
+
d = parse_results(csv_path)
|
106 |
+
writeJson(d)
|
pyproject.toml
CHANGED
@@ -1,13 +1,11 @@
|
|
1 |
-
[
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
[tool.black]
|
13 |
-
line-length = 119
|
|
|
1 |
+
[project]
|
2 |
+
name = "tortuga"
|
3 |
+
version = "0.1.0"
|
4 |
+
description = "Add your description here"
|
5 |
+
readme = "README.md"
|
6 |
+
requires-python = ">=3.13"
|
7 |
+
dependencies = [
|
8 |
+
"gradio>=5.21.0",
|
9 |
+
"gradio-leaderboard>=0.0.13",
|
10 |
+
"pandas>=2.2.3",
|
11 |
+
]
|
|
|
|
requirements.txt
CHANGED
@@ -13,4 +13,5 @@ python-dateutil
|
|
13 |
tqdm
|
14 |
transformers
|
15 |
tokenizers>=0.15.0
|
16 |
-
sentencepiece
|
|
|
|
13 |
tqdm
|
14 |
transformers
|
15 |
tokenizers>=0.15.0
|
16 |
+
sentencepiece
|
17 |
+
plotly
|
results.csv
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
,Syntax (STX),Syntax (STX),Functionality (FNC),Functionality (FNC),Synthesis (SYN),Synthesis (SYN),Power,Power,Performance,Performance,Area,Area,EM,Syntax (STX),Syntax (STX),Functionality (FNC),Functionality (FNC),Synthesis (SYN),Synthesis (SYN),Power,Power,Performance,Performance,Area,Area
|
2 |
+
,VerilogEval S2R,RTLLM,VerilogEval S2R,RTLLM,VerilogEval S2R,RTLLM,VerilogEval S2R,RTLLM,VerilogEval S2R,RTLLM,VerilogEval S2R,RTLLM,RTL-Repo,VerilogEval MC,VeriGen,VerilogEval MC,VeriGen,VerilogEval MC,VeriGen,VerilogEval MC,VeriGen,VerilogEval MC,VeriGen,VerilogEval MC,VeriGen
|
3 |
+
DeepSeek R1,"96,54","91,43","79,74","67,76","78,97","63,27","38,94","35,64","37,82","31,95","38,76","34,5","33,02","97,95","94,12","80,26",60,"79,62","54,12","39,35","26,62","38,16","26,97","39,21","28,01"
|
4 |
+
Llama 3.1 405B,"89,1","65,71","57,05","37,55","56,67","35,92","27,18","19,7",27,"16,04","26,79","18,91","33,29","91,41","72,94","44,74","45,88","44,1","44,71","21,98","19,24","20,74","22,19","21,66","21,08"
|
5 |
+
Llama 3.(1-3) 70B,"67,69","73,88",40,"43,27","39,87","39,18","19,76","20,58","18,69","19,32","19,51","20,28","28,62","70,51","78,82","38,59","48,24","37,95","48,24","18,97","23,22","18,35","24,15","18,86","24,71"
|
6 |
+
Qwen2.5 72B,"81,15","82,04","51,15","47,35","50,38","46,53","25,4","24,83","23,83","23,88","24,52","25,46","37,19","81,67","70,59","53,08","27,06","52,56","27,06","26,08","12,74","24,92","13,5","25,83","13,89"
|
7 |
+
Qwen2.5 32B,"89,36","86,94","52,95","50,61","51,67","46,94","26,02","25,9","24,46","23,87","25,32","26,29","28,67","93,46","67,06","43,08","32,94","42,31","30,59","21,14",15,"20,48","15,38","21,15","15,31"
|
8 |
+
StarChat2 15B v0.1,"86,54","85,71","38,72","42,45","38,59","42,45","19,18","22,44","17,99","21,03",19,"22,53","13,24","81,54","92,94","39,36","50,59","38,59","50,59","19,21","24,02","18,28","25,23","19,05","25,73"
|
9 |
+
DeepSeek R1 Distill Qwen 14B,"41,28","40,82","23,85","20,82","23,72","20,41","11,81","12,46","11,25","10,24","11,76","10,7","20,65","42,18","62,35","24,36","25,88","24,1","25,88","11,96","11,54","11,38","12,93","11,86","12,9"
|
10 |
+
CodeLlama 70B,"72,05","41,63","35,51","23,27","35,38","22,86","17,32","11,92","16,74","10,85","17,2","11,71","24,58","89,36","89,41","30,9","45,88","30,9","45,88","15,3","21,74","14,19","22,88","15,21","22,82"
|
11 |
+
QwenCoder 2.5 32B,"87,69","79,59","45,64","43,27","43,33","42,04","21,51","22,02","20,72","20,95","21,17","22,03","30,44","84,87","72,94","45,51","41,18","44,87","41,18","22,26","20,56","21,48","20,67","22,2","20,87"
|
12 |
+
DeepSeek Coder 33B,"57,82","83,67","19,87","43,67","19,87","42,86","9,94","23,28","9,83","21,19","9,47","23,2","30,58","78,72","83,53","39,49","29,41","38,33","29,41","18,92","14,52","18,2","14,74","18,76","14,67"
|
13 |
+
QwenCoder 2.5 14B,"79,74","78,37","37,82","41,63","37,05","40,41","18,03","20,14","17,6","20,1","17,78","20,25","37,16","79,36","67,06","40,26","34,12","39,49","34,12","19,74","16,5","19,07","17,07","19,73","16,75"
|
14 |
+
OpenCoder 8B,"75,77","75,1","28,59","46,53","28,21","42,86","13,81","22,24","13,16","21,47","13,71","21,73","16,63","79,87","92,94","36,03","43,53","35,51","37,65","17,57","17,19","16,74","18,76","17,52","19,06"
|
15 |
+
QwenCoder 2.5 7B,"19,62","77,96","6,41","37,96","6,41","35,51","3,12","19,26","3,18","17,98","3,16","18,87","28,45","75,9","71,76","32,44","37,65","32,44","37,65","16,2","18,38","15,26","18,91","16,16","18,92"
|
16 |
+
"DeepSeek Coder 6,7B","80,12","78,37","29,87","40,41","29,36","37,96","14,71","20,72","13,69","19,25","14,64","21,03","24,57","68,85","81,18","32,82","27,06","31,15","27,06","15,53","12,94","14,62","13,39","15,46","13,58"
|
17 |
+
RTLCoder Mistral,"52,05","38,78","23,59","19,18","23,59","19,18","11,67","10,08","10,87","8,7","11,56","9,95","14,97","63,59","85,88","26,92","35,29","26,92","35,29","13,43","18,49","12,53","17,61","13,36","18,35"
|
18 |
+
RTLCoder DeepSeek,"75,26","68,57","33,33","37,14","32,95","33,06","16,02","17,29","15,71","16,35","15,9","16,82","19,76","84,1","84,71","39,23","38,82","38,59","38,82","19,08","19,1","18,31","19,35","18,82","19,76"
|
19 |
+
OriGen,"91,02","23,67","46,54","12,65","46,92","10,61","23,38","5,33","22,18","4,61","23,44","4,79","19,45","79,35","87,06","43,07","35,29","42,95","35,29","21,5","16,55","20,13","17,7","21,33","18,35"
|
20 |
+
HaVen-CodeQwen,"90,26","82,45","45,9","40,41","44,36","38,37","21,77","19,1","21,23","18,31","21,46","18,92","25,38","93,33","97,65",50,"48,24","48,72","42,35","23,37","20,21","23,39","21,15","23,09","21,25"
|
21 |
+
CodeV-CL-7B,"55,38","69,8","27,05","37,14","26,79","35,1","13,2","18,92","12,39","16,88","13,03","17,89","12,39","91,92","98,82","36,79","44,71","36,41","38,82","18,15","19,06","16,88","19,38","18,05","19,35"
|
22 |
+
CodeV-QW-7B,"41,79","71,02","19,1","35,51","18,72","27,76","9,36","14,85","9,36","12,21","9,38","13,78","20,56","93,85","57,65","52,56","25,88","51,15",20,"25,64","9,39","24,22","9,99","25,56","9,94"
|
23 |
+
CodeV-DS-6.7B,"30,77","62,45","14,87","33,88","14,62","30,61","7,3","15,49","6,9","14,75","7,22","15,35","21,06","95,13","58,82","48,85","23,53","48,33","17,65","24,02","8,26","22,82","8,81","23,73","8,47"
|
results.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
src/about.py
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
from dataclasses import dataclass
|
2 |
-
from enum import Enum
|
3 |
-
|
4 |
-
@dataclass
|
5 |
-
class Task:
|
6 |
-
benchmark: str
|
7 |
-
metric: str
|
8 |
-
col_name: str
|
9 |
-
|
10 |
-
|
11 |
-
# Select your tasks here
|
12 |
-
# ---------------------------------------------------
|
13 |
-
class Tasks(Enum):
|
14 |
-
# task_key in the json file, metric_key in the json file, name to display in the leaderboard
|
15 |
-
task0 = Task("anli_r1", "acc", "ANLI")
|
16 |
-
task1 = Task("logiqa", "acc_norm", "LogiQA")
|
17 |
-
|
18 |
-
NUM_FEWSHOT = 0 # Change with your few shot
|
19 |
-
# ---------------------------------------------------
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
# Your leaderboard name
|
24 |
-
TITLE = """<h1 align="center" id="space-title">Demo leaderboard</h1>"""
|
25 |
-
|
26 |
-
# What does your leaderboard evaluate?
|
27 |
-
INTRODUCTION_TEXT = """
|
28 |
-
Intro text
|
29 |
-
"""
|
30 |
-
|
31 |
-
# Which evaluations are you running? how can people reproduce what you have?
|
32 |
-
LLM_BENCHMARKS_TEXT = f"""
|
33 |
-
## How it works
|
34 |
-
|
35 |
-
## Reproducibility
|
36 |
-
To reproduce our results, here is the commands you can run:
|
37 |
-
|
38 |
-
"""
|
39 |
-
|
40 |
-
EVALUATION_QUEUE_TEXT = """
|
41 |
-
## Some good practices before submitting a model
|
42 |
-
|
43 |
-
### 1) Make sure you can load your model and tokenizer using AutoClasses:
|
44 |
-
```python
|
45 |
-
from transformers import AutoConfig, AutoModel, AutoTokenizer
|
46 |
-
config = AutoConfig.from_pretrained("your model name", revision=revision)
|
47 |
-
model = AutoModel.from_pretrained("your model name", revision=revision)
|
48 |
-
tokenizer = AutoTokenizer.from_pretrained("your model name", revision=revision)
|
49 |
-
```
|
50 |
-
If this step fails, follow the error messages to debug your model before submitting it. It's likely your model has been improperly uploaded.
|
51 |
-
|
52 |
-
Note: make sure your model is public!
|
53 |
-
Note: if your model needs `use_remote_code=True`, we do not support this option yet but we are working on adding it, stay posted!
|
54 |
-
|
55 |
-
### 2) Convert your model weights to [safetensors](https://huggingface.co/docs/safetensors/index)
|
56 |
-
It's a new format for storing weights which is safer and faster to load and use. It will also allow us to add the number of parameters of your model to the `Extended Viewer`!
|
57 |
-
|
58 |
-
### 3) Make sure your model has an open license!
|
59 |
-
This is a leaderboard for Open LLMs, and we'd love for as many people as possible to know they can use your model 🤗
|
60 |
-
|
61 |
-
### 4) Fill up your model card
|
62 |
-
When we add extra information about models to the leaderboard, it will be automatically taken from the model card
|
63 |
-
|
64 |
-
## In case of model failure
|
65 |
-
If your model is displayed in the `FAILED` category, its execution stopped.
|
66 |
-
Make sure you have followed the above steps first.
|
67 |
-
If everything is done, check you can launch the EleutherAIHarness on your model locally, using the above command without modifications (you can add `--limit` to limit the number of examples per task).
|
68 |
-
"""
|
69 |
-
|
70 |
-
CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
|
71 |
-
CITATION_BUTTON_TEXT = r"""
|
72 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/display/formatting.py
DELETED
@@ -1,27 +0,0 @@
|
|
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 |
-
|
4 |
-
|
5 |
-
def make_clickable_model(model_name):
|
6 |
-
link = f"https://huggingface.co/{model_name}"
|
7 |
-
return model_hyperlink(link, model_name)
|
8 |
-
|
9 |
-
|
10 |
-
def styled_error(error):
|
11 |
-
return f"<p style='color: red; font-size: 20px; text-align: center;'>{error}</p>"
|
12 |
-
|
13 |
-
|
14 |
-
def styled_warning(warn):
|
15 |
-
return f"<p style='color: orange; font-size: 20px; text-align: center;'>{warn}</p>"
|
16 |
-
|
17 |
-
|
18 |
-
def styled_message(message):
|
19 |
-
return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"
|
20 |
-
|
21 |
-
|
22 |
-
def has_no_nan_values(df, columns):
|
23 |
-
return df[columns].notna().all(axis=1)
|
24 |
-
|
25 |
-
|
26 |
-
def has_nan_values(df, columns):
|
27 |
-
return df[columns].isna().any(axis=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/display/utils.py
DELETED
@@ -1,110 +0,0 @@
|
|
1 |
-
from dataclasses import dataclass, make_dataclass
|
2 |
-
from enum import Enum
|
3 |
-
|
4 |
-
import pandas as pd
|
5 |
-
|
6 |
-
from src.about import Tasks
|
7 |
-
|
8 |
-
def fields(raw_class):
|
9 |
-
return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
|
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 |
-
|
23 |
-
## Leaderboard columns
|
24 |
-
auto_eval_column_dict = []
|
25 |
-
# Init
|
26 |
-
auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("T", "str", True, never_hidden=True)])
|
27 |
-
auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
|
28 |
-
#Scores
|
29 |
-
auto_eval_column_dict.append(["average", ColumnContent, ColumnContent("Average ⬆️", "number", True)])
|
30 |
-
for task in Tasks:
|
31 |
-
auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
|
32 |
-
# Model information
|
33 |
-
auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False)])
|
34 |
-
auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
|
35 |
-
auto_eval_column_dict.append(["weight_type", ColumnContent, ColumnContent("Weight type", "str", False, True)])
|
36 |
-
auto_eval_column_dict.append(["precision", ColumnContent, ColumnContent("Precision", "str", False)])
|
37 |
-
auto_eval_column_dict.append(["license", ColumnContent, ColumnContent("Hub License", "str", False)])
|
38 |
-
auto_eval_column_dict.append(["params", ColumnContent, ColumnContent("#Params (B)", "number", False)])
|
39 |
-
auto_eval_column_dict.append(["likes", ColumnContent, ColumnContent("Hub ❤️", "number", False)])
|
40 |
-
auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False)])
|
41 |
-
auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
|
42 |
-
|
43 |
-
# We use make dataclass to dynamically fill the scores from Tasks
|
44 |
-
AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
|
45 |
-
|
46 |
-
## For the queue columns in the submission tab
|
47 |
-
@dataclass(frozen=True)
|
48 |
-
class EvalQueueColumn: # Queue column
|
49 |
-
model = ColumnContent("model", "markdown", True)
|
50 |
-
revision = ColumnContent("revision", "str", True)
|
51 |
-
private = ColumnContent("private", "bool", True)
|
52 |
-
precision = ColumnContent("precision", "str", True)
|
53 |
-
weight_type = ColumnContent("weight_type", "str", "Original")
|
54 |
-
status = ColumnContent("status", "str", True)
|
55 |
-
|
56 |
-
## All the model information that we might need
|
57 |
-
@dataclass
|
58 |
-
class ModelDetails:
|
59 |
-
name: str
|
60 |
-
display_name: str = ""
|
61 |
-
symbol: str = "" # emoji
|
62 |
-
|
63 |
-
|
64 |
-
class ModelType(Enum):
|
65 |
-
PT = ModelDetails(name="pretrained", symbol="🟢")
|
66 |
-
FT = ModelDetails(name="fine-tuned", symbol="🔶")
|
67 |
-
IFT = ModelDetails(name="instruction-tuned", symbol="⭕")
|
68 |
-
RL = ModelDetails(name="RL-tuned", symbol="🟦")
|
69 |
-
Unknown = ModelDetails(name="", symbol="?")
|
70 |
-
|
71 |
-
def to_str(self, separator=" "):
|
72 |
-
return f"{self.value.symbol}{separator}{self.value.name}"
|
73 |
-
|
74 |
-
@staticmethod
|
75 |
-
def from_str(type):
|
76 |
-
if "fine-tuned" in type or "🔶" in type:
|
77 |
-
return ModelType.FT
|
78 |
-
if "pretrained" in type or "🟢" in type:
|
79 |
-
return ModelType.PT
|
80 |
-
if "RL-tuned" in type or "🟦" in type:
|
81 |
-
return ModelType.RL
|
82 |
-
if "instruction-tuned" in type or "⭕" in type:
|
83 |
-
return ModelType.IFT
|
84 |
-
return ModelType.Unknown
|
85 |
-
|
86 |
-
class WeightType(Enum):
|
87 |
-
Adapter = ModelDetails("Adapter")
|
88 |
-
Original = ModelDetails("Original")
|
89 |
-
Delta = ModelDetails("Delta")
|
90 |
-
|
91 |
-
class Precision(Enum):
|
92 |
-
float16 = ModelDetails("float16")
|
93 |
-
bfloat16 = ModelDetails("bfloat16")
|
94 |
-
Unknown = ModelDetails("?")
|
95 |
-
|
96 |
-
def from_str(precision):
|
97 |
-
if precision in ["torch.float16", "float16"]:
|
98 |
-
return Precision.float16
|
99 |
-
if precision in ["torch.bfloat16", "bfloat16"]:
|
100 |
-
return Precision.bfloat16
|
101 |
-
return Precision.Unknown
|
102 |
-
|
103 |
-
# 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/envs.py
DELETED
@@ -1,25 +0,0 @@
|
|
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 |
-
OWNER = "demo-leaderboard-backend" # Change to your org - don't forget to create a results and request dataset, with the correct format!
|
10 |
-
# ----------------------------------
|
11 |
-
|
12 |
-
REPO_ID = f"{OWNER}/leaderboard"
|
13 |
-
QUEUE_REPO = f"{OWNER}/requests"
|
14 |
-
RESULTS_REPO = f"{OWNER}/results"
|
15 |
-
|
16 |
-
# If you setup a cache later, just change HF_HOME
|
17 |
-
CACHE_PATH=os.getenv("HF_HOME", ".")
|
18 |
-
|
19 |
-
# Local caches
|
20 |
-
EVAL_REQUESTS_PATH = os.path.join(CACHE_PATH, "eval-queue")
|
21 |
-
EVAL_RESULTS_PATH = os.path.join(CACHE_PATH, "eval-results")
|
22 |
-
EVAL_REQUESTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-queue-bk")
|
23 |
-
EVAL_RESULTS_PATH_BACKEND = os.path.join(CACHE_PATH, "eval-results-bk")
|
24 |
-
|
25 |
-
API = HfApi(token=TOKEN)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/leaderboard/read_evals.py
DELETED
@@ -1,196 +0,0 @@
|
|
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 |
-
"""Represents one full evaluation. Built from a combination of the result and request file for a given run.
|
18 |
-
"""
|
19 |
-
eval_name: str # org_model_precision (uid)
|
20 |
-
full_model: str # org/model (path on hub)
|
21 |
-
org: str
|
22 |
-
model: str
|
23 |
-
revision: str # commit hash, "" if main
|
24 |
-
results: dict
|
25 |
-
precision: Precision = Precision.Unknown
|
26 |
-
model_type: ModelType = ModelType.Unknown # Pretrained, fine tuned, ...
|
27 |
-
weight_type: WeightType = WeightType.Original # Original or Adapter
|
28 |
-
architecture: str = "Unknown"
|
29 |
-
license: str = "?"
|
30 |
-
likes: int = 0
|
31 |
-
num_params: int = 0
|
32 |
-
date: str = "" # submission date of request file
|
33 |
-
still_on_hub: bool = False
|
34 |
-
|
35 |
-
@classmethod
|
36 |
-
def init_from_json_file(self, json_filepath):
|
37 |
-
"""Inits the result from the specific model result file"""
|
38 |
-
with open(json_filepath) as fp:
|
39 |
-
data = json.load(fp)
|
40 |
-
|
41 |
-
config = data.get("config")
|
42 |
-
|
43 |
-
# Precision
|
44 |
-
precision = Precision.from_str(config.get("model_dtype"))
|
45 |
-
|
46 |
-
# Get model and org
|
47 |
-
org_and_model = config.get("model_name", config.get("model_args", None))
|
48 |
-
org_and_model = org_and_model.split("/", 1)
|
49 |
-
|
50 |
-
if len(org_and_model) == 1:
|
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 |
-
full_model = "/".join(org_and_model)
|
59 |
-
|
60 |
-
still_on_hub, _, model_config = is_model_on_hub(
|
61 |
-
full_model, config.get("model_sha", "main"), trust_remote_code=True, test_tokenizer=False
|
62 |
-
)
|
63 |
-
architecture = "?"
|
64 |
-
if model_config is not None:
|
65 |
-
architectures = getattr(model_config, "architectures", None)
|
66 |
-
if architectures:
|
67 |
-
architecture = ";".join(architectures)
|
68 |
-
|
69 |
-
# Extract results available in this file (some results are split in several files)
|
70 |
-
results = {}
|
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 |
-
mean_acc = np.mean(accs) * 100.0
|
80 |
-
results[task.benchmark] = mean_acc
|
81 |
-
|
82 |
-
return self(
|
83 |
-
eval_name=result_key,
|
84 |
-
full_model=full_model,
|
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
|
92 |
-
)
|
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, self.precision.value.name)
|
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 Exception:
|
108 |
-
print(f"Could not find request file for {self.org}/{self.model} with precision {self.precision.value.name}")
|
109 |
-
|
110 |
-
def to_dict(self):
|
111 |
-
"""Converts the Eval Result to a dict compatible with our dataframe display"""
|
112 |
-
average = sum([v for v in self.results.values() if v is not None]) / len(Tasks)
|
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.revision.name: self.revision,
|
122 |
-
AutoEvalColumn.average.name: average,
|
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
|
133 |
-
|
134 |
-
|
135 |
-
def get_request_file_for_model(requests_path, model_name, precision):
|
136 |
-
"""Selects the correct request file for a given model. Only keeps runs tagged as FINISHED"""
|
137 |
-
request_files = os.path.join(
|
138 |
-
requests_path,
|
139 |
-
f"{model_name}_eval_request_*.json",
|
140 |
-
)
|
141 |
-
request_files = glob.glob(request_files)
|
142 |
-
|
143 |
-
# Select correct request file (precision)
|
144 |
-
request_file = ""
|
145 |
-
request_files = sorted(request_files, reverse=True)
|
146 |
-
for tmp_request_file in request_files:
|
147 |
-
with open(tmp_request_file, "r") as f:
|
148 |
-
req_content = json.load(f)
|
149 |
-
if (
|
150 |
-
req_content["status"] in ["FINISHED"]
|
151 |
-
and req_content["precision"] == precision.split(".")[-1]
|
152 |
-
):
|
153 |
-
request_file = tmp_request_file
|
154 |
-
return request_file
|
155 |
-
|
156 |
-
|
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 |
-
if len(files) == 0 or any([not f.endswith(".json") for f in files]):
|
164 |
-
continue
|
165 |
-
|
166 |
-
# Sort the files by date
|
167 |
-
try:
|
168 |
-
files.sort(key=lambda x: x.removesuffix(".json").removeprefix("results_")[:-7])
|
169 |
-
except dateutil.parser._parser.ParserError:
|
170 |
-
files = [files[-1]]
|
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
|
178 |
-
eval_result = EvalResult.init_from_json_file(model_result_filepath)
|
179 |
-
eval_result.update_with_request_file(requests_path)
|
180 |
-
|
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 eval_result.results.items() if v is not None})
|
185 |
-
else:
|
186 |
-
eval_results[eval_name] = eval_result
|
187 |
-
|
188 |
-
results = []
|
189 |
-
for v in eval_results.values():
|
190 |
-
try:
|
191 |
-
v.to_dict() # we test if the dict version is complete
|
192 |
-
results.append(v)
|
193 |
-
except KeyError: # not all eval values present
|
194 |
-
continue
|
195 |
-
|
196 |
-
return results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/populate.py
DELETED
@@ -1,58 +0,0 @@
|
|
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 |
-
"""Creates a dataframe from all the individual experiment results"""
|
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 = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
|
18 |
-
df = df[cols].round(decimals=2)
|
19 |
-
|
20 |
-
# filter out if any of the benchmarks have not been produced
|
21 |
-
df = df[has_no_nan_values(df, benchmark_cols)]
|
22 |
-
return df
|
23 |
-
|
24 |
-
|
25 |
-
def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
26 |
-
"""Creates the different dataframes for the evaluation queues requestes"""
|
27 |
-
entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
|
28 |
-
all_evals = []
|
29 |
-
|
30 |
-
for entry in entries:
|
31 |
-
if ".json" in entry:
|
32 |
-
file_path = os.path.join(save_path, entry)
|
33 |
-
with open(file_path) as fp:
|
34 |
-
data = json.load(fp)
|
35 |
-
|
36 |
-
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
37 |
-
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
38 |
-
|
39 |
-
all_evals.append(data)
|
40 |
-
elif ".md" not in entry:
|
41 |
-
# this is a folder
|
42 |
-
sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if os.path.isfile(e) and not e.startswith(".")]
|
43 |
-
for sub_entry in sub_entries:
|
44 |
-
file_path = os.path.join(save_path, entry, sub_entry)
|
45 |
-
with open(file_path) as fp:
|
46 |
-
data = json.load(fp)
|
47 |
-
|
48 |
-
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
49 |
-
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
50 |
-
all_evals.append(data)
|
51 |
-
|
52 |
-
pending_list = [e for e in all_evals if e["status"] in ["PENDING", "RERUN"]]
|
53 |
-
running_list = [e for e in all_evals if e["status"] == "RUNNING"]
|
54 |
-
finished_list = [e for e in all_evals if e["status"].startswith("FINISHED") or e["status"] == "PENDING_NEW_EVAL"]
|
55 |
-
df_pending = pd.DataFrame.from_records(pending_list, columns=cols)
|
56 |
-
df_running = pd.DataFrame.from_records(running_list, columns=cols)
|
57 |
-
df_finished = pd.DataFrame.from_records(finished_list, columns=cols)
|
58 |
-
return df_finished[cols], df_running[cols], df_pending[cols]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/submission/check_validity.py
DELETED
@@ -1,99 +0,0 @@
|
|
1 |
-
import json
|
2 |
-
import os
|
3 |
-
import re
|
4 |
-
from collections import defaultdict
|
5 |
-
from datetime import datetime, timedelta, timezone
|
6 |
-
|
7 |
-
import huggingface_hub
|
8 |
-
from huggingface_hub import ModelCard
|
9 |
-
from huggingface_hub.hf_api import ModelInfo
|
10 |
-
from transformers import AutoConfig
|
11 |
-
from transformers.models.auto.tokenization_auto import AutoTokenizer
|
12 |
-
|
13 |
-
def check_model_card(repo_id: str) -> tuple[bool, str]:
|
14 |
-
"""Checks if the model card and license exist and have been filled"""
|
15 |
-
try:
|
16 |
-
card = ModelCard.load(repo_id)
|
17 |
-
except huggingface_hub.utils.EntryNotFoundError:
|
18 |
-
return False, "Please add a model card to your model to explain how you trained/fine-tuned it."
|
19 |
-
|
20 |
-
# Enforce license metadata
|
21 |
-
if card.data.license is None:
|
22 |
-
if not ("license_name" in card.data and "license_link" in card.data):
|
23 |
-
return False, (
|
24 |
-
"License not found. Please add a license to your model card using the `license` metadata or a"
|
25 |
-
" `license_name`/`license_link` pair."
|
26 |
-
)
|
27 |
-
|
28 |
-
# Enforce card content
|
29 |
-
if len(card.text) < 200:
|
30 |
-
return False, "Please add a description to your model card, it is too short."
|
31 |
-
|
32 |
-
return True, ""
|
33 |
-
|
34 |
-
def is_model_on_hub(model_name: str, revision: str, token: str = None, trust_remote_code=False, test_tokenizer=False) -> tuple[bool, str]:
|
35 |
-
"""Checks if the model model_name is on the hub, and whether it (and its tokenizer) can be loaded with AutoClasses."""
|
36 |
-
try:
|
37 |
-
config = AutoConfig.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
38 |
-
if test_tokenizer:
|
39 |
-
try:
|
40 |
-
tk = AutoTokenizer.from_pretrained(model_name, revision=revision, trust_remote_code=trust_remote_code, token=token)
|
41 |
-
except ValueError as e:
|
42 |
-
return (
|
43 |
-
False,
|
44 |
-
f"uses a tokenizer which is not in a transformers release: {e}",
|
45 |
-
None
|
46 |
-
)
|
47 |
-
except Exception as e:
|
48 |
-
return (False, "'s tokenizer cannot be loaded. Is your tokenizer class in a stable transformers release, and correctly configured?", None)
|
49 |
-
return True, None, config
|
50 |
-
|
51 |
-
except ValueError:
|
52 |
-
return (
|
53 |
-
False,
|
54 |
-
"needs to be launched with `trust_remote_code=True`. For safety reason, we do not allow these models to be automatically submitted to the leaderboard.",
|
55 |
-
None
|
56 |
-
)
|
57 |
-
|
58 |
-
except Exception as e:
|
59 |
-
return False, "was not found on hub!", None
|
60 |
-
|
61 |
-
|
62 |
-
def get_model_size(model_info: ModelInfo, precision: str):
|
63 |
-
"""Gets the model size from the configuration, or the model name if the configuration does not contain the information."""
|
64 |
-
try:
|
65 |
-
model_size = round(model_info.safetensors["total"] / 1e9, 3)
|
66 |
-
except (AttributeError, TypeError):
|
67 |
-
return 0 # Unknown model sizes are indicated as 0, see NUMERIC_INTERVALS in app.py
|
68 |
-
|
69 |
-
size_factor = 8 if (precision == "GPTQ" or "gptq" in model_info.modelId.lower()) else 1
|
70 |
-
model_size = size_factor * model_size
|
71 |
-
return model_size
|
72 |
-
|
73 |
-
def get_model_arch(model_info: ModelInfo):
|
74 |
-
"""Gets the model architecture from the configuration"""
|
75 |
-
return model_info.config.get("architectures", "Unknown")
|
76 |
-
|
77 |
-
def already_submitted_models(requested_models_dir: str) -> set[str]:
|
78 |
-
"""Gather a list of already submitted models to avoid duplicates"""
|
79 |
-
depth = 1
|
80 |
-
file_names = []
|
81 |
-
users_to_submission_dates = defaultdict(list)
|
82 |
-
|
83 |
-
for root, _, files in os.walk(requested_models_dir):
|
84 |
-
current_depth = root.count(os.sep) - requested_models_dir.count(os.sep)
|
85 |
-
if current_depth == depth:
|
86 |
-
for file in files:
|
87 |
-
if not file.endswith(".json"):
|
88 |
-
continue
|
89 |
-
with open(os.path.join(root, file), "r") as f:
|
90 |
-
info = json.load(f)
|
91 |
-
file_names.append(f"{info['model']}_{info['revision']}_{info['precision']}")
|
92 |
-
|
93 |
-
# Select organisation
|
94 |
-
if info["model"].count("/") == 0 or "submitted_time" not in info:
|
95 |
-
continue
|
96 |
-
organisation, _ = info["model"].split("/")
|
97 |
-
users_to_submission_dates[organisation].append(info["submitted_time"])
|
98 |
-
|
99 |
-
return set(file_names), users_to_submission_dates
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/submission/submit.py
DELETED
@@ -1,119 +0,0 @@
|
|
1 |
-
import json
|
2 |
-
import os
|
3 |
-
from datetime import datetime, timezone
|
4 |
-
|
5 |
-
from src.display.formatting import styled_error, styled_message, styled_warning
|
6 |
-
from src.envs import API, EVAL_REQUESTS_PATH, TOKEN, QUEUE_REPO
|
7 |
-
from src.submission.check_validity import (
|
8 |
-
already_submitted_models,
|
9 |
-
check_model_card,
|
10 |
-
get_model_size,
|
11 |
-
is_model_on_hub,
|
12 |
-
)
|
13 |
-
|
14 |
-
REQUESTED_MODELS = None
|
15 |
-
USERS_TO_SUBMISSION_DATES = None
|
16 |
-
|
17 |
-
def add_new_eval(
|
18 |
-
model: str,
|
19 |
-
base_model: str,
|
20 |
-
revision: str,
|
21 |
-
precision: str,
|
22 |
-
weight_type: str,
|
23 |
-
model_type: str,
|
24 |
-
):
|
25 |
-
global REQUESTED_MODELS
|
26 |
-
global USERS_TO_SUBMISSION_DATES
|
27 |
-
if not REQUESTED_MODELS:
|
28 |
-
REQUESTED_MODELS, USERS_TO_SUBMISSION_DATES = already_submitted_models(EVAL_REQUESTS_PATH)
|
29 |
-
|
30 |
-
user_name = ""
|
31 |
-
model_path = model
|
32 |
-
if "/" in model:
|
33 |
-
user_name = model.split("/")[0]
|
34 |
-
model_path = model.split("/")[1]
|
35 |
-
|
36 |
-
precision = precision.split(" ")[0]
|
37 |
-
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
38 |
-
|
39 |
-
if model_type is None or model_type == "":
|
40 |
-
return styled_error("Please select a model type.")
|
41 |
-
|
42 |
-
# Does the model actually exist?
|
43 |
-
if revision == "":
|
44 |
-
revision = "main"
|
45 |
-
|
46 |
-
# Is the model on the hub?
|
47 |
-
if weight_type in ["Delta", "Adapter"]:
|
48 |
-
base_model_on_hub, error, _ = is_model_on_hub(model_name=base_model, revision=revision, token=TOKEN, test_tokenizer=True)
|
49 |
-
if not base_model_on_hub:
|
50 |
-
return styled_error(f'Base model "{base_model}" {error}')
|
51 |
-
|
52 |
-
if not weight_type == "Adapter":
|
53 |
-
model_on_hub, error, _ = is_model_on_hub(model_name=model, revision=revision, token=TOKEN, test_tokenizer=True)
|
54 |
-
if not model_on_hub:
|
55 |
-
return styled_error(f'Model "{model}" {error}')
|
56 |
-
|
57 |
-
# Is the model info correctly filled?
|
58 |
-
try:
|
59 |
-
model_info = API.model_info(repo_id=model, revision=revision)
|
60 |
-
except Exception:
|
61 |
-
return styled_error("Could not get your model information. Please fill it up properly.")
|
62 |
-
|
63 |
-
model_size = get_model_size(model_info=model_info, precision=precision)
|
64 |
-
|
65 |
-
# Were the model card and license filled?
|
66 |
-
try:
|
67 |
-
license = model_info.cardData["license"]
|
68 |
-
except Exception:
|
69 |
-
return styled_error("Please select a license for your model")
|
70 |
-
|
71 |
-
modelcard_OK, error_msg = check_model_card(model)
|
72 |
-
if not modelcard_OK:
|
73 |
-
return styled_error(error_msg)
|
74 |
-
|
75 |
-
# Seems good, creating the eval
|
76 |
-
print("Adding new eval")
|
77 |
-
|
78 |
-
eval_entry = {
|
79 |
-
"model": model,
|
80 |
-
"base_model": base_model,
|
81 |
-
"revision": revision,
|
82 |
-
"precision": precision,
|
83 |
-
"weight_type": weight_type,
|
84 |
-
"status": "PENDING",
|
85 |
-
"submitted_time": current_time,
|
86 |
-
"model_type": model_type,
|
87 |
-
"likes": model_info.likes,
|
88 |
-
"params": model_size,
|
89 |
-
"license": license,
|
90 |
-
"private": False,
|
91 |
-
}
|
92 |
-
|
93 |
-
# Check for duplicate submission
|
94 |
-
if f"{model}_{revision}_{precision}" in REQUESTED_MODELS:
|
95 |
-
return styled_warning("This model has been already submitted.")
|
96 |
-
|
97 |
-
print("Creating eval file")
|
98 |
-
OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
|
99 |
-
os.makedirs(OUT_DIR, exist_ok=True)
|
100 |
-
out_path = f"{OUT_DIR}/{model_path}_eval_request_False_{precision}_{weight_type}.json"
|
101 |
-
|
102 |
-
with open(out_path, "w") as f:
|
103 |
-
f.write(json.dumps(eval_entry))
|
104 |
-
|
105 |
-
print("Uploading eval file")
|
106 |
-
API.upload_file(
|
107 |
-
path_or_fileobj=out_path,
|
108 |
-
path_in_repo=out_path.split("eval-queue/")[1],
|
109 |
-
repo_id=QUEUE_REPO,
|
110 |
-
repo_type="dataset",
|
111 |
-
commit_message=f"Add {model} to eval queue",
|
112 |
-
)
|
113 |
-
|
114 |
-
# Remove the local file
|
115 |
-
os.remove(out_path)
|
116 |
-
|
117 |
-
return styled_message(
|
118 |
-
"Your request has been submitted to the evaluation queue!\nPlease wait for up to an hour for the model to show in the PENDING list."
|
119 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
utils.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import gradio as gr
|
3 |
+
import plotly.graph_objects as go
|
4 |
+
import plotly.express as px
|
5 |
+
import numpy as np
|
6 |
+
|
7 |
+
type_emoji = {
|
8 |
+
"RTL-Specific": "🔵",
|
9 |
+
"General": "🟢",
|
10 |
+
"Coding": "🟡"
|
11 |
+
}
|
12 |
+
|
13 |
+
def model_hyperlink(link, model_name):
|
14 |
+
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
|
15 |
+
|
16 |
+
def handle_special_cases(benchmark, metric):
|
17 |
+
if metric == 'EM':
|
18 |
+
benchmark = 'RTL-Repo'
|
19 |
+
elif benchmark == 'RTL-Repo':
|
20 |
+
metric = 'EM'
|
21 |
+
return benchmark, metric
|
22 |
+
|
23 |
+
def filter_RTLRepo(subset: pd.DataFrame) -> pd.DataFrame:
|
24 |
+
details = subset[['Model', 'Model URL', 'Model Type', 'Params']].drop_duplicates('Model')
|
25 |
+
filtered_df = subset[['Model', 'Score']].rename(columns={'Score': 'Exact Matching (EM)'})
|
26 |
+
filtered_df = pd.merge(filtered_df, details, on='Model', how='left')
|
27 |
+
filtered_df['Model'] = filtered_df.apply(lambda row: model_hyperlink(row["Model URL"], row["Model"]), axis=1)
|
28 |
+
filtered_df['Type'] = filtered_df['Model Type'].map(lambda x: type_emoji.get(x, ""))
|
29 |
+
filtered_df = filtered_df[['Type', 'Model', 'Params', 'Exact Matching (EM)']]
|
30 |
+
filtered_df.insert(0, '', range(1, len(filtered_df) + 1))
|
31 |
+
return filtered_df
|
32 |
+
|
33 |
+
def filter_bench(subset: pd.DataFrame) -> pd.DataFrame:
|
34 |
+
details = subset[['Model', 'Model URL', 'Model Type', 'Params']].drop_duplicates('Model')
|
35 |
+
pivot_df = subset.pivot_table(index='Model', columns='Metric', values='Score', aggfunc='mean').reset_index()
|
36 |
+
pivot_df['Average ⬆️'] = pivot_df.mean(axis=1, numeric_only=True).round(2)
|
37 |
+
pivot_df = pd.merge(pivot_df, details, on='Model', how='left')
|
38 |
+
pivot_df['Model'] = pivot_df.apply(lambda row: model_hyperlink(row["Model URL"], row["Model"]), axis=1)
|
39 |
+
pivot_df['Type'] = pivot_df['Model Type'].map(lambda x: type_emoji.get(x, ""))
|
40 |
+
pivot_df.rename(columns={'Syntax (STX)': 'STX', 'Functionality (FNC)': 'FNC', 'Synthesis (SYN)': 'SYN', 'Performance': 'Perf'}, inplace=True)
|
41 |
+
columns_order = ['Type', 'Model', 'Params', 'Average ⬆️', 'STX', 'FNC', 'SYN', 'Power', 'Perf', 'Area']
|
42 |
+
pivot_df = pivot_df[[col for col in columns_order if col in pivot_df.columns]]
|
43 |
+
pivot_df = pivot_df.sort_values(by='Average ⬆️', ascending=False).reset_index(drop=True)
|
44 |
+
pivot_df.insert(0, '', range(1, len(pivot_df) + 1))
|
45 |
+
return pivot_df
|
46 |
+
|