Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,294 +1,278 @@
|
|
1 |
import os
|
2 |
import json
|
3 |
import datetime
|
4 |
-
import smtplib
|
5 |
-
from email.mime.text import MIMEText
|
6 |
-
from email.mime.multipart import MIMEMultipart
|
7 |
from email.utils import parseaddr
|
8 |
import numpy as np
|
9 |
import gradio as gr
|
10 |
import pandas as pd
|
11 |
from datasets import load_dataset
|
|
|
12 |
from apscheduler.schedulers.background import BackgroundScheduler
|
13 |
from huggingface_hub import HfApi
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
-
TOKEN = os.environ.get("TOKEN", None)
|
16 |
-
SUBMISSION_DATASET = "KoLMogorov-Test/submissions"
|
17 |
-
VERSION = "v1"
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
api = HfApi()
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
def model_hyperlink(link, model_name):
|
32 |
-
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
|
33 |
|
|
|
|
|
|
|
34 |
|
35 |
# Function to restart the space
|
36 |
def restart_space():
|
37 |
-
|
|
|
38 |
|
39 |
TYPES = ["markdown", "markdown", "number", "number", "number", "number", "number", "number", "str", "str"]
|
40 |
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
split: str,
|
51 |
-
token: str,
|
52 |
):
|
53 |
-
|
54 |
-
if not
|
55 |
-
return
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
|
89 |
# Gradio interface
|
90 |
demo = gr.Blocks()
|
91 |
with demo:
|
92 |
-
gr.HTML("
|
93 |
-
gr.
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
gr.Markdown("""The programs file is a jsonl that follows the following format. We recommend submitting a single program for the whole sequence:
|
127 |
-
```
|
128 |
-
{"sub_sequence_start_index": 0, "sub_sequence_end_index": 7 (the length of the sequence), "encoded_program": "H4sIAI7Te2cC/8svLSkoLVGwVYg21VEwNABiYyA2AWIzHQVTCIoFAMxnYTIlAAAA (An encoding of the program whose execution results in the input sequence. This is the Gzip encoding of the program that returns the input sequence)."}
|
129 |
-
```
|
130 |
-
|
131 |
-
For simplicity, we allow splitting to subsequent sub-sequences:
|
132 |
-
```
|
133 |
-
{"sub_sequence_start_index": 0, "sub_sequence_end_index": k, "encoded_program": "An encoding of the program whose execution results in the subsequence between indeses [0, n]."}
|
134 |
-
{"sub_sequence_start_index": k+1, "sub_sequence_end_index": k+1+j, "encoded_program": "An encoding of the program whose execution results in the subsequence between indeses [n+1, n+1+m]."}
|
135 |
-
...
|
136 |
-
{"sub_sequence_start_index": n, "sub_sequence_end_index": len(sequence), "encoded_program": "An encoding of the program whose execution results in the subsequence between indeses [n, len(sequence)]."}
|
137 |
-
```
|
138 |
-
""")
|
139 |
-
|
140 |
-
gr.Markdown("""For decoding, upload a python file that implements the 'decode' method, which receives as input an programs from the programs file and returns the executable python program. Executing the decoded program must result in the input sequence. For example, this is a decoder that decompresses using Gzip.
|
141 |
-
```
|
142 |
-
import gzip
|
143 |
-
import base64
|
144 |
-
|
145 |
-
def decode(program):
|
146 |
-
return gzip.decompress(base64.b64decode(program)).decode('utf-8')
|
147 |
-
```
|
148 |
-
""")
|
149 |
-
|
150 |
-
gr.Markdown("""For the results, upload a Json file that matches the Result object returned from the <a href="https://www.example.com" target="_blank">official evaluation script</a>. If you are interested in verification of your results, please <a href="mailto:[email protected]">email us</a> after submitting, we will then verify the results.
|
151 |
-
```
|
152 |
-
{
|
153 |
-
"compressed_programs_size": 64,
|
154 |
-
"decoder_size": 118,
|
155 |
-
"compressed_size": 182,
|
156 |
-
"compression_rate_without_decoder": 8.0,
|
157 |
-
"compression_rate": 22.75,
|
158 |
-
"accuracy": 1,
|
159 |
-
"gold_data_size": 8,
|
160 |
-
"first_error": null
|
161 |
-
}
|
162 |
-
```
|
163 |
-
""")
|
164 |
-
|
165 |
-
with gr.Accordion(""):
|
166 |
with gr.Row():
|
167 |
with gr.Column():
|
168 |
model_name_textbox = gr.Textbox(label="Model Name")
|
|
|
|
|
|
|
169 |
organization = gr.Textbox(label="Organization")
|
170 |
mail = gr.Textbox(
|
171 |
-
label="Contact Email (will be stored privately)"
|
172 |
-
)
|
173 |
-
split_dropdown = gr.Dropdown(
|
174 |
-
choices=["Small (1MB)", "Large (1GB)"],
|
175 |
-
label="Size",
|
176 |
-
)
|
177 |
-
modality_dropdown = gr.Dropdown(
|
178 |
-
choices=["Text", "Dna", "Audio-MFCC", "Audio-16-Bit", "Audio-8-Bit", "Synthetic"],
|
179 |
-
label="Modality",
|
180 |
-
)
|
181 |
-
prior_dropdown = gr.Dropdown(
|
182 |
-
choices=["Custom (attached file)", "None"],
|
183 |
-
label="Decoding",
|
184 |
-
)
|
185 |
-
url_textbox = gr.Textbox(label="URL to Project Information",
|
186 |
-
interactive=True,)
|
187 |
-
model_family_textbox = gr.Textbox(label="Base Model")
|
188 |
|
189 |
-
|
190 |
-
file_output = gr.File(label="Programs File")
|
191 |
-
prior_file = gr.File(label="Decoder File")
|
192 |
-
results_json = gr.File(label="Results Json")
|
193 |
-
|
194 |
-
submit_button = gr.Button("Submit")
|
195 |
submission_result = gr.Markdown()
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
|
|
201 |
organization,
|
202 |
-
mail
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
modality_dropdown,
|
207 |
-
split,
|
208 |
-
TOKEN # Ensure TOKEN is defined and accessible
|
209 |
-
)
|
210 |
-
),
|
211 |
-
[
|
212 |
-
model_name_textbox,
|
213 |
-
split_dropdown,
|
214 |
-
model_family_textbox,
|
215 |
-
url_textbox,
|
216 |
-
file_output,
|
217 |
-
organization,
|
218 |
-
mail,
|
219 |
-
prior_file,
|
220 |
-
results_json,
|
221 |
-
prior_dropdown,
|
222 |
-
modality_dropdown
|
223 |
-
],
|
224 |
-
submission_result,
|
225 |
-
)
|
226 |
|
227 |
-
data = {
|
228 |
-
"Text": {
|
229 |
-
"Model": ["Gzip", "GPT4-o", "LLAMA-3.1-405B", "LLAMA-3.1-70B", "LLAMA-3.1-8B"],
|
230 |
-
"Pass@1": [100, 69.5, 33.3, 18.0, 8.5],
|
231 |
-
"Precision": [1.0, 1.34, 2.18, 2.78, 2.48],
|
232 |
-
"Compression Rate": [0.357, "n/a", "n/a", "n/a", "n/a"],
|
233 |
-
"Verified": ['✓', '✓', '✓', '✓', '✓'],
|
234 |
-
},
|
235 |
-
"DNA": {
|
236 |
-
"Model": ["Gzip", "GPT4-o", "LLAMA-3.1-405B", "LLAMA-3.1-70B", "LLAMA-3.1-8B"],
|
237 |
-
"Pass@1": [100, 54.2, 6.5, 9.6, 1.4],
|
238 |
-
"Precision": [1.0, 1.94, 3.17, 3.17, 3.12],
|
239 |
-
"Compression Rate": [0.714, "n/a", "n/a", "n/a", "n/a"],
|
240 |
-
"Verified": ['✓', '✓', '✓', '✓', '✓'],
|
241 |
-
},
|
242 |
-
"Audio-8-bit": {
|
243 |
-
"Model": ["Gzip", "GPT4-o", "LLAMA-3.1-405B", "LLAMA-3.1-70B", "LLAMA-3.1-8B"],
|
244 |
-
"Pass@1": [100, 36.4, 15.0, 10.1, 3.9],
|
245 |
-
"Precision": [1.0, 1.43, 1.66, 1.67, 1.74],
|
246 |
-
"Compression Rate": [0.398, "n/a", "n/a", "n/a", "n/a"],
|
247 |
-
"Verified": ['✓', '✓', '✓', '✓', '✓'],
|
248 |
-
},
|
249 |
-
"Audio-16-bit": {
|
250 |
-
"Model": ["Gzip", "GPT4-o", "LLAMA-3.1-405B", "LLAMA-3.1-70B", "LLAMA-3.1-8B"],
|
251 |
-
"Pass@1": [100, 69.5, 35.6, 18.0, 5.9],
|
252 |
-
"Precision": [1.0, 1.34, 1.66, 1.96, 1.54],
|
253 |
-
"Compression Rate": [0.920, "n/a", "n/a", "n/a", "n/a"],
|
254 |
-
"Verified": ['✓', '✓', '✓', '✓', '✓'],
|
255 |
-
},
|
256 |
-
"Audio-MFCC": {
|
257 |
-
"Model": ["Gzip", "GPT4-o", "LLAMA-3.1-405B", "LLAMA-3.1-70B", "LLAMA-3.1-8B"],
|
258 |
-
"Pass@1": [100, 83.8, 29.6, 24.2, 8.8],
|
259 |
-
"Precision": [1.0, 1.33, 1.58, 1.56, 1.51],
|
260 |
-
"Compression Rate": [0.903, "n/a", "n/a", "n/a", "n/a"],
|
261 |
-
"Verified": ['✓', '✓', '✓', '✓', '✓'],
|
262 |
-
},
|
263 |
-
"Synthetic": {
|
264 |
-
"Model": ["SeqCoder-8B + Gzip", "Gzip", "GPT4-o", "LLAMA-3.1-405B", "LLAMA-3.1-70B", "LLAMA-3.1-8B"],
|
265 |
-
"Pass@1": [100, 100, 44.7, 24.8, 22.5, 3.7],
|
266 |
-
"Precision": [0.64, 1.0, 1.65, 2.06, 2.18, 2.34],
|
267 |
-
"Compression Rate": [0.38, 0.593, "n/a", "n/a", "n/a", "n/a"],
|
268 |
-
"Verified": ['✓', '✓', '✓', '✓', '✓', '✓'],
|
269 |
-
},
|
270 |
-
}
|
271 |
-
|
272 |
-
|
273 |
-
gr.HTML("<h2>KT Leaderboard - Can you beat Gzip on KT?</h2>")
|
274 |
-
for k,v in data.items():
|
275 |
-
with gr.Tab(k):
|
276 |
-
leaderboard_table_test = gr.Dataframe(
|
277 |
-
value=pd.DataFrame(data[k]),
|
278 |
-
interactive=False,
|
279 |
-
)
|
280 |
-
|
281 |
-
|
282 |
with gr.Row():
|
283 |
with gr.Accordion("📙 Citation", open=False):
|
284 |
-
citation_text = """@
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
note={under review}
|
292 |
}"""
|
293 |
citation_button = gr.Textbox(
|
294 |
value=citation_text,
|
@@ -299,9 +283,9 @@ note={under review}
|
|
299 |
)
|
300 |
|
301 |
gr.HTML(
|
302 |
-
"<p>We would like to thank the GAIA team for sharing the source code for their leaderboard which
|
303 |
|
304 |
scheduler = BackgroundScheduler()
|
305 |
scheduler.add_job(restart_space, "interval", seconds=3600)
|
306 |
scheduler.start()
|
307 |
-
demo.launch(debug=True)
|
|
|
1 |
import os
|
2 |
import json
|
3 |
import datetime
|
|
|
|
|
|
|
4 |
from email.utils import parseaddr
|
5 |
import numpy as np
|
6 |
import gradio as gr
|
7 |
import pandas as pd
|
8 |
from datasets import load_dataset
|
9 |
+
from evaluation.evaluator import question_scorer as eval_scorer
|
10 |
from apscheduler.schedulers.background import BackgroundScheduler
|
11 |
from huggingface_hub import HfApi
|
12 |
+
from content import format_error, format_warning, format_log, TITLE
|
13 |
+
|
14 |
+
# Placeholder for the question_scorer function
|
15 |
+
def question_scorer(prediction, gold_answer):
|
16 |
+
acc, has_ans = eval_scorer(prediction, gold_answer)
|
17 |
+
return acc, has_ans
|
18 |
|
|
|
|
|
|
|
19 |
|
20 |
+
# Constants and Configuration
|
21 |
+
TOKEN = os.environ.get("TOKEN", None)
|
22 |
+
OWNER = "Ori"
|
23 |
+
DATA_DATASET = f"Ori/AssistantBench_V1.0"
|
24 |
+
RESULTS_DATASET = f"Ori/results"
|
25 |
+
SUBMISSION_DATASET = f"AssistantBench/submissions"
|
26 |
+
LEADERBOARD_PATH = f"{OWNER}/leaderboard"
|
27 |
api = HfApi()
|
28 |
|
29 |
+
YEAR_VERSION = "default"
|
30 |
+
|
31 |
+
os.makedirs("scored", exist_ok=True)
|
32 |
+
|
33 |
+
# Load datasets
|
34 |
+
eval_results = load_dataset(RESULTS_DATASET, token=TOKEN, download_mode="force_redownload", trust_remote_code=True)
|
35 |
+
gold_results = load_dataset(DATA_DATASET, token=TOKEN, trust_remote_code=True)
|
36 |
+
|
37 |
+
gold_answers = {split: {row["id"]: row["answer"] for row in gold_results[split]} for split in ["test"]}
|
38 |
+
gold_difficulties = {split: {row["id"]: row["difficulty"] for row in gold_results[split]} for split in ["test"]}
|
39 |
+
|
40 |
|
41 |
+
# Function to get dataframe from results
|
42 |
+
def get_dataframe_from_results(eval_results, split):
|
43 |
+
local_df = eval_results[split]
|
44 |
+
df = pd.DataFrame(local_df)
|
45 |
+
df = df.sort_values(by=["Accuracy"], ascending=False)
|
46 |
+
numeric_cols = [c for c in local_df.column_names if "score" in c]
|
47 |
+
df[numeric_cols] = df[numeric_cols].multiply(100).round(decimals=2)
|
48 |
+
return df
|
49 |
|
50 |
+
# Update function to format dataframe
|
51 |
+
def format_dataframe(df):
|
52 |
+
df["Accuracy"] = df["Accuracy"].apply(lambda x: f"**{x:.2f}**")
|
53 |
+
if "URL" in df.columns:
|
54 |
+
df["Model Name"] = df.apply(lambda row: f"[{row['Model Name']}]({row['URL']})", axis=1)
|
55 |
+
df = df.drop(columns=["URL"])
|
56 |
+
#df = df.rename(columns={"Model Family": "Base Model"})
|
57 |
+
df = df[["Model Name", "Accuracy", "Answer rate", "Precision", "EM", "Accuracy (easy)", "Accuracy (medium)", "Accuracy (hard)", "Base Model", "Organization"]]
|
58 |
+
return df
|
59 |
|
|
|
|
|
60 |
|
61 |
+
eval_results = load_dataset(RESULTS_DATASET, YEAR_VERSION, token=TOKEN, download_mode="force_redownload", trust_remote_code=True)
|
62 |
+
eval_dataframe_test = get_dataframe_from_results(eval_results=eval_results, split="test")
|
63 |
+
eval_dataframe_test = format_dataframe(eval_dataframe_test)
|
64 |
|
65 |
# Function to restart the space
|
66 |
def restart_space():
|
67 |
+
api.restart_space(repo_id=LEADERBOARD_PATH, token=TOKEN)
|
68 |
+
|
69 |
|
70 |
TYPES = ["markdown", "markdown", "number", "number", "number", "number", "number", "number", "str", "str"]
|
71 |
|
72 |
|
73 |
+
# Function to add a new evaluation
|
74 |
+
def add_new_eval(
|
75 |
+
model_name: str,
|
76 |
+
model_family: str,
|
77 |
+
url: str,
|
78 |
+
path_to_file: str,
|
79 |
+
organization: str,
|
80 |
+
mail: str,
|
|
|
|
|
81 |
):
|
82 |
+
_, parsed_mail = parseaddr(mail)
|
83 |
+
if "@" not in parsed_mail:
|
84 |
+
return format_warning("Please provide a valid email address.")
|
85 |
+
|
86 |
+
print("Adding new eval")
|
87 |
+
|
88 |
+
if model_name.lower() in set(
|
89 |
+
[m.lower() for m in eval_results["test"]["Model Name"]]) and organization.lower() in set(
|
90 |
+
[o.lower() for o in eval_results["test"]["Organization"]]):
|
91 |
+
return format_warning("This model has already been submitted.")
|
92 |
+
|
93 |
+
if path_to_file is None:
|
94 |
+
return format_warning("Please attach a file.")
|
95 |
+
|
96 |
+
api.upload_file(
|
97 |
+
repo_id=SUBMISSION_DATASET,
|
98 |
+
path_or_fileobj=path_to_file.name,
|
99 |
+
path_in_repo=f"{organization}/{model_name}/{YEAR_VERSION}_test_raw_{datetime.datetime.today()}.jsonl",
|
100 |
+
repo_type="dataset",
|
101 |
+
token=TOKEN
|
102 |
+
)
|
103 |
+
|
104 |
+
file_path = path_to_file.name
|
105 |
+
scores = 0
|
106 |
+
num_questions = 0
|
107 |
+
|
108 |
+
difficulty_scores = {"Easy": 0, "Medium": 0, "Hard": 0}
|
109 |
+
difficulty_counts = {"Easy": 0, "Medium": 0, "Hard": 0}
|
110 |
+
|
111 |
+
all_scores = list()
|
112 |
+
|
113 |
+
with open(f"scored/{organization}_{model_name}.jsonl", "w") as scored_file:
|
114 |
+
with open(file_path, 'r') as f:
|
115 |
+
submitted_ids = set()
|
116 |
+
for ix, line in enumerate(f):
|
117 |
+
try:
|
118 |
+
task = json.loads(line)
|
119 |
+
except Exception:
|
120 |
+
return format_error(f"Line {ix} is incorrectly formatted. Please fix it and resubmit your file.")
|
121 |
+
|
122 |
+
if "answer" not in task:
|
123 |
+
return format_error(
|
124 |
+
f"Line {ix} contains no answer key. Please fix it and resubmit your file.")
|
125 |
+
|
126 |
+
answer = task["answer"]
|
127 |
+
task_id = task["id"]
|
128 |
+
if task_id not in gold_answers["test"]:
|
129 |
+
return format_error(
|
130 |
+
f"{task_id} not found in test set. Are you sure you submitted the correct file?")
|
131 |
+
|
132 |
+
score, has_ans = question_scorer(task['answer'], gold_answers["test"][task_id])
|
133 |
+
difficulty = gold_difficulties["test"][task_id]
|
134 |
+
|
135 |
+
scored_file.write(
|
136 |
+
json.dumps({
|
137 |
+
"id": task_id,
|
138 |
+
"model_answer": answer,
|
139 |
+
"score": score,
|
140 |
+
"has_ans": has_ans
|
141 |
+
}) + "\n"
|
142 |
+
)
|
143 |
+
|
144 |
+
all_scores.append({"score": score, "has_ans": has_ans, "model_answer": answer, 'id': task_id})
|
145 |
+
submitted_ids.add(task["id"])
|
146 |
+
scores += score
|
147 |
+
num_questions += 1
|
148 |
+
difficulty_scores[difficulty] += score
|
149 |
+
difficulty_counts[difficulty] += 1
|
150 |
+
|
151 |
+
# Check if all gold answer IDs are present in the submission
|
152 |
+
missing_ids = set(gold_answers["test"].keys()) - submitted_ids
|
153 |
+
if missing_ids:
|
154 |
+
return format_error(f"Submission is missing the following IDs: {', '.join(missing_ids)}")
|
155 |
+
|
156 |
+
accuracy_easy = difficulty_scores["Easy"] / difficulty_counts["Easy"] if difficulty_counts["Easy"] > 0 else 0
|
157 |
+
accuracy_medium = difficulty_scores["Medium"] / difficulty_counts["Medium"] if difficulty_counts["Medium"] > 0 else 0
|
158 |
+
accuracy_hard = difficulty_scores["Hard"] / difficulty_counts["Hard"] if difficulty_counts["Hard"] > 0 else 0
|
159 |
+
|
160 |
+
api.upload_file(
|
161 |
+
repo_id=SUBMISSION_DATASET,
|
162 |
+
path_or_fileobj=f"scored/{organization}_{model_name}.jsonl",
|
163 |
+
path_in_repo=f"{organization}/{model_name}/{YEAR_VERSION}_test_scored_{datetime.datetime.today()}.jsonl",
|
164 |
+
repo_type="dataset",
|
165 |
+
token=TOKEN
|
166 |
+
)
|
167 |
+
|
168 |
+
accuracy = float("{:.1f}".format(np.average([x["score"] for x in all_scores]) * 100))
|
169 |
+
coverage = float("{:.1f}".format(np.average([x["has_ans"] for x in all_scores]) * 100))
|
170 |
+
em = float("{:.1f}".format(np.average([1 if x["score"] == 1 else 0 for x in all_scores]) * 100))
|
171 |
+
precision = float("{:.1f}".format(np.average([x["score"] for x in all_scores if x["has_ans"] == 1]) * 100))
|
172 |
+
accuracy_easy = float("{:.1f}".format(accuracy_easy * 100))
|
173 |
+
accuracy_medium = float("{:.1f}".format(accuracy_medium * 100))
|
174 |
+
accuracy_hard = float("{:.1f}".format(accuracy_hard * 100))
|
175 |
+
|
176 |
+
eval_entry = {
|
177 |
+
"Model Name": model_name,
|
178 |
+
"Base Model": model_family,
|
179 |
+
"URL": url,
|
180 |
+
"Organization": organization,
|
181 |
+
"Accuracy": accuracy,
|
182 |
+
"Accuracy (easy)": accuracy_easy,
|
183 |
+
"Accuracy (medium)": accuracy_medium,
|
184 |
+
"Accuracy (hard)": accuracy_hard,
|
185 |
+
"Answer rate": coverage,
|
186 |
+
"Precision": precision,
|
187 |
+
"EM": em
|
188 |
+
}
|
189 |
+
eval_results["test"] = eval_results["test"].add_item(eval_entry)
|
190 |
+
|
191 |
+
eval_results.push_to_hub(RESULTS_DATASET, config_name=YEAR_VERSION, token=TOKEN)
|
192 |
+
|
193 |
+
return format_log(
|
194 |
+
f"Model {model_name} submitted by {organization} successfully.\nPlease wait a few hours and refresh the leaderboard to see your score displayed.")
|
195 |
+
|
196 |
|
197 |
+
# Function to refresh the results
|
198 |
+
def refresh():
|
199 |
+
eval_results = load_dataset(RESULTS_DATASET, YEAR_VERSION, token=TOKEN, download_mode="force_redownload", trust_remote_code=True)
|
200 |
+
eval_dataframe_test = get_dataframe_from_results(eval_results=eval_results, split="test")
|
201 |
+
eval_dataframe_test = format_dataframe(eval_dataframe_test)
|
202 |
+
return eval_dataframe_test
|
203 |
|
204 |
|
205 |
# Gradio interface
|
206 |
demo = gr.Blocks()
|
207 |
with demo:
|
208 |
+
gr.HTML("<h1>AssistantBench</h1>")
|
209 |
+
gr.Markdown("""
|
210 |
+
AssistantBench aims to evaluate the ability of web agents to assist with real and time-consuming tasks.
|
211 |
+
For more information, please check out our paper or the official website.
|
212 |
+
To download AssistantBench, press [here](https://huggingface.co/datasets/AssistantBench/AssistantBench).
|
213 |
+
""")
|
214 |
+
|
215 |
+
gr.HTML("<h2>AssistantBench Leaderboard</h2>")
|
216 |
+
with gr.Tab("Results: Test"):
|
217 |
+
leaderboard_table_test = gr.Dataframe(
|
218 |
+
value=eval_dataframe_test, datatype=TYPES, interactive=False,
|
219 |
+
column_widths=["20%"]
|
220 |
+
)
|
221 |
+
|
222 |
+
refresh_button = gr.Button("Refresh")
|
223 |
+
refresh_button.click(
|
224 |
+
refresh,
|
225 |
+
inputs=[],
|
226 |
+
outputs=[
|
227 |
+
leaderboard_table_test,
|
228 |
+
],
|
229 |
+
)
|
230 |
+
|
231 |
+
gr.HTML("<h2>Making a New Submission</h2>")
|
232 |
+
with gr.Accordion("Submit a new model for evaluation"):
|
233 |
+
with gr.Row():
|
234 |
+
gr.Markdown("""
|
235 |
+
To make a new submission, upload a predictions file. Our scoring function can be found [here](https://huggingface.co/spaces/AssistantBench/leaderboard/blob/main/scorer.py). We support JSONL files with the following format:
|
236 |
+
```
|
237 |
+
{"id": "task_id_1", "answer": "Answer 1 from your model"}
|
238 |
+
{"id": "task_id_2", "answer": "Answer 2 from your model"}
|
239 |
+
```
|
240 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
with gr.Row():
|
242 |
with gr.Column():
|
243 |
model_name_textbox = gr.Textbox(label="Model Name")
|
244 |
+
model_family_textbox = gr.Textbox(label="Base Model")
|
245 |
+
url_textbox = gr.Textbox(label="URL to Model Information")
|
246 |
+
with gr.Column():
|
247 |
organization = gr.Textbox(label="Organization")
|
248 |
mail = gr.Textbox(
|
249 |
+
label="Contact Email (will be stored privately & used if there is an issue with your submission)")
|
250 |
+
file_output = gr.File()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
+
submit_button = gr.Button("Submit Eval")
|
|
|
|
|
|
|
|
|
|
|
253 |
submission_result = gr.Markdown()
|
254 |
+
submit_button.click(
|
255 |
+
add_new_eval,
|
256 |
+
[
|
257 |
+
model_name_textbox,
|
258 |
+
model_family_textbox,
|
259 |
+
url_textbox,
|
260 |
+
file_output,
|
261 |
organization,
|
262 |
+
mail
|
263 |
+
],
|
264 |
+
submission_result,
|
265 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
with gr.Row():
|
268 |
with gr.Accordion("📙 Citation", open=False):
|
269 |
+
citation_text = """@article{yoran-etal-2024-assistantbench,
|
270 |
+
title={AssistantBench: Can Web Agents Solve Realistic and Time-Consuming Tasks?},
|
271 |
+
author={Ori Yoran and Samuel Amouyal and Chaitanya Malaviya and Ben Bogin and Ofir Press and Jonathan Berant},
|
272 |
+
year={2024},
|
273 |
+
eprint={?},
|
274 |
+
archivePrefix={arXiv},
|
275 |
+
primaryClass={cs.CL}
|
|
|
276 |
}"""
|
277 |
citation_button = gr.Textbox(
|
278 |
value=citation_text,
|
|
|
283 |
)
|
284 |
|
285 |
gr.HTML(
|
286 |
+
"<p>We would like to thank the GAIA team for sharing the source code for their leaderboard which we used as a template and HuggingFace for hosting the leaderboard.</p>")
|
287 |
|
288 |
scheduler = BackgroundScheduler()
|
289 |
scheduler.add_job(restart_space, "interval", seconds=3600)
|
290 |
scheduler.start()
|
291 |
+
demo.launch(debug=True)
|