Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,278 +1,294 @@
|
|
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 |
-
|
23 |
-
|
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 |
-
|
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 |
-
|
42 |
-
|
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 |
-
|
51 |
-
|
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 |
-
|
68 |
-
|
69 |
|
70 |
TYPES = ["markdown", "markdown", "number", "number", "number", "number", "number", "number", "str", "str"]
|
71 |
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
81 |
):
|
82 |
-
|
83 |
-
if
|
84 |
-
return
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
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 |
-
|
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>
|
209 |
-
gr.
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
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
|
250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
-
|
|
|
|
|
|
|
|
|
|
|
253 |
submission_result = gr.Markdown()
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
url_textbox,
|
260 |
-
file_output,
|
261 |
organization,
|
262 |
-
mail
|
263 |
-
|
264 |
-
|
265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
with gr.Row():
|
268 |
with gr.Accordion("π Citation", open=False):
|
269 |
-
citation_text = """@
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
|
|
276 |
}"""
|
277 |
citation_button = gr.Textbox(
|
278 |
value=citation_text,
|
@@ -283,9 +299,9 @@ with demo:
|
|
283 |
)
|
284 |
|
285 |
gr.HTML(
|
286 |
-
"<p>We would like to thank the GAIA team for sharing the source code for their leaderboard which
|
287 |
|
288 |
scheduler = BackgroundScheduler()
|
289 |
scheduler.add_job(restart_space, "interval", seconds=3600)
|
290 |
scheduler.start()
|
291 |
-
demo.launch(debug=True)
|
|
|
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 |
+
def format_error(msg):
|
23 |
+
return f"<p style='color: red; font-size: 20px; text-align: center;'>{msg}</p>"
|
24 |
|
25 |
+
def format_warning(msg):
|
26 |
+
return f"<p style='color: orange; font-size: 20px; text-align: center;'>{msg}</p>"
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
+
def format_log(msg):
|
29 |
+
return f"<p style='color: green; font-size: 20px; text-align: center;'>{msg}</p>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
return
|
|
|
38 |
|
39 |
TYPES = ["markdown", "markdown", "number", "number", "number", "number", "number", "number", "str", "str"]
|
40 |
|
41 |
|
42 |
+
def save_files_for_eval(
|
43 |
+
model_name: str,
|
44 |
+
organization: str,
|
45 |
+
organization_email: str,
|
46 |
+
path_to_file,
|
47 |
+
prior_file,
|
48 |
+
results_json,
|
49 |
+
modality: str,
|
50 |
+
split: str,
|
51 |
+
token: str,
|
52 |
):
|
53 |
+
# Validate inputs
|
54 |
+
if not model_name:
|
55 |
+
return format_error("Model name is required.")
|
56 |
+
if not organization and organization_email:
|
57 |
+
return format_error("Organization and email required.")
|
58 |
+
|
59 |
+
# Get the current date for the directory name
|
60 |
+
date_str = datetime.datetime.today().strftime('%Y-%m-%d')
|
61 |
+
|
62 |
+
# Define the base path in the repository (remove leading slash)
|
63 |
+
base_path_in_repo = f"{organization}/{model_name}/{VERSION}_{split}_{modality}_{date_str}"
|
64 |
+
|
65 |
+
# List of files to upload
|
66 |
+
files_to_upload = [
|
67 |
+
(path_to_file, "prediction.jsonl"),
|
68 |
+
(prior_file, "decoder.py"),
|
69 |
+
(results_json, "results.json")
|
70 |
+
]
|
71 |
+
|
72 |
+
# Upload each file
|
73 |
+
for file, filename in files_to_upload:
|
74 |
+
if file is not None:
|
75 |
+
path_in_repo = f"{base_path_in_repo}/{filename}"
|
76 |
+
api.upload_file(
|
77 |
+
repo_id=SUBMISSION_DATASET,
|
78 |
+
path_or_fileobj=file.name,
|
79 |
+
path_in_repo=path_in_repo,
|
80 |
+
repo_type="dataset",
|
81 |
+
token=token
|
82 |
+
)
|
83 |
+
else:
|
84 |
+
return format_error(f"File {filename} is missing.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
+
return format_log("All files uploaded successfully. Please email us at [email protected] to verify your submission.")
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
|
89 |
# Gradio interface
|
90 |
demo = gr.Blocks()
|
91 |
with demo:
|
92 |
+
gr.HTML("""<h1 id="space-title">The KoLMogorov-Test: Can CodeLMs lead to the next breakthrough in data compression?</h1>""")
|
93 |
+
gr.HTML("""The Kolmogorov complexity of a sequence is the length of the shortest computer program that produces the sequence. <br><br>The aim of the KoLMogorov-Test (KT) is to empirically evaluate the ability of CodeLMs to detect patterns in and compress sequences by writing short programs that output them.
|
94 |
+
<h2>The Task</h2>
|
95 |
+
Given a sequence, the CodeLM is asked to produce a short python program that outputs the sequence. The programs are compressed by a user-defined compressor before submission, and code length is measured in compressed form. In order to evaluate the correctness of a program, it is first decoded using a user-provided decoder and then executed. The decoder size counts towards the compressed length, and may contain e.g. a library of helper functions (DSL). <br><br>
|
96 |
+
|
97 |
+
The length of python and its standard library are not counted, but in order to prevent cheating the programs must pass a stringent check. Programs cannot import arbitrary modules, use advanced language features, access the internet, etc. <br><br>
|
98 |
+
|
99 |
+
KT currently includes six modalities - text, DNA, three encodings of audio data (MFCC, 16-bit, and 8-bit), and synthetic sequences produced by random programs. Two dataset sizes are available: a small one with 1MB per modality, and a large one with 1GB.""")
|
100 |
+
|
101 |
+
gr.HTML("""<h2>Getting Started</h2>
|
102 |
+
Download the data from <a href="https://www.example.com" target="_blank">here</a>.
|
103 |
+
<br><br>We provide code to reproduce experiments from the paper including our DSL and evaluation code at the <a href="https://www.example.com" target="_blank">GitHub repo</a>.
|
104 |
+
<br><br>You are allowed to:<br><br>
|
105 |
+
<ul>
|
106 |
+
<li>Split the original sequence to subsequent sub-sequences.</li>
|
107 |
+
<li>Use the standard python library including Gzip.</li>
|
108 |
+
<li>Create new DSLs.</li>
|
109 |
+
<li>Create new priors to encode the programs.</li>
|
110 |
+
</ul>
|
111 |
+
|
112 |
+
<br>With the following restrictions:<br><br>
|
113 |
+
<ul>
|
114 |
+
<li>To prevent cases where compression of the data is performed by external code, we prevent access to the internet and usage of previous compression algorithms, excluding Gzip which is viewed as a strong baseline. </li>
|
115 |
+
<li>We return the compression rate with and without the cost of the decoder. When reporting results, we consider the additional code as negligible if it is <100KB and does not scale with the length of the sequence. When reporting results for the 1GB seqeunces, please always report results including the decoder.</li>
|
116 |
+
</ul>
|
117 |
+
|
118 |
+
<br>If you have any questions, please email us at <a href="mailto:thekolmogorovtest@gmail.com">[email protected]</a>.
|
119 |
+
|
120 |
+
""")
|
121 |
+
|
122 |
+
gr.HTML("""<h2>Making a New Submission</h2>""")
|
123 |
+
|
124 |
+
gr.Markdown("""To make a new submission, upload three files - a file with the encoded program, a file that decodes the programs to executable code, and a file with the expected results. Let's consider a toy example for the sequence [5, 10, 13, 14, 16, 5, 5, 5].""")
|
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 |
+
with gr.Column():
|
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 |
+
submit_button.click(
|
198 |
+
lambda model_name, split, model_family, url, path_to_file, organization, mail, prior_file, results_json, prior_dropdown, modality_dropdown: (
|
199 |
+
save_files_for_eval(
|
200 |
+
model_name,
|
|
|
|
|
201 |
organization,
|
202 |
+
mail,
|
203 |
+
path_to_file,
|
204 |
+
prior_file,
|
205 |
+
results_json,
|
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 = """@inproceedings{
|
285 |
+
anonymous2024the,
|
286 |
+
title={The Ko{LM}ogorov Test: Compression by Code Generation},
|
287 |
+
author={Anonymous},
|
288 |
+
booktitle={Submitted to The Thirteenth International Conference on Learning Representations},
|
289 |
+
year={2024},
|
290 |
+
url={https://openreview.net/forum?id=C45YqeBDUM},
|
291 |
+
note={under review}
|
292 |
}"""
|
293 |
citation_button = gr.Textbox(
|
294 |
value=citation_text,
|
|
|
299 |
)
|
300 |
|
301 |
gr.HTML(
|
302 |
+
"<p>We would like to thank the GAIA team for sharing the source code for their leaderboard which was used as a template and HuggingFace for hosting the leaderboard.</p>")
|
303 |
|
304 |
scheduler = BackgroundScheduler()
|
305 |
scheduler.add_job(restart_space, "interval", seconds=3600)
|
306 |
scheduler.start()
|
307 |
+
demo.launch(debug=True)
|