Spaces:
Paused
Paused
Prepped for QA test
Browse files- app.py +0 -2
- custom_tasks.py +2 -74
- heq_task.py +111 -0
- main_backend_harness.py +0 -78
- main_backend_lighteval.py +2 -2
- requirements.txt +2 -2
- scripts/fix_harness_import.py +0 -11
- src/about.py +2 -2
- src/backend/run_eval_suite_harness.py +0 -57
- src/envs.py +3 -3
- src/logging.py +6 -6
- src/populate.py +0 -56
app.py
CHANGED
@@ -11,8 +11,6 @@ from src.logging import LOGGER, read_logs
|
|
11 |
sys.stdout = LOGGER
|
12 |
sys.stderr = LOGGER
|
13 |
|
14 |
-
#subprocess.run(["python", "scripts/fix_harness_import.py"])
|
15 |
-
|
16 |
def launch_backend():
|
17 |
_ = subprocess.run(["python", "main_backend_lighteval.py"])
|
18 |
|
|
|
11 |
sys.stdout = LOGGER
|
12 |
sys.stderr = LOGGER
|
13 |
|
|
|
|
|
14 |
def launch_backend():
|
15 |
_ = subprocess.run(["python", "main_backend_lighteval.py"])
|
16 |
|
custom_tasks.py
CHANGED
@@ -6,84 +6,12 @@ This file generally create just a TASKS_TABLE and TASKS_GROUPS which are then im
|
|
6 |
|
7 |
Author:
|
8 |
"""
|
9 |
-
from
|
10 |
-
from lighteval.tasks.requests import Doc
|
11 |
-
from lighteval.tasks.tasks_prompt_formatting import LETTER_INDICES
|
12 |
-
|
13 |
-
|
14 |
-
## EVAL WITH NO SUBSET ##
|
15 |
-
# This is how you create a simple tasks (like hellaswag) which has one single subset
|
16 |
-
# attached to it, and one evaluation possible.
|
17 |
-
task = LightevalTaskConfig(
|
18 |
-
name="myothertask",
|
19 |
-
prompt_function="prompt_fn", # must be defined in the file or imported from src/lighteval/tasks/tasks_prompt_formatting.py
|
20 |
-
suite=["community"],
|
21 |
-
hf_repo="",
|
22 |
-
hf_subset="default",
|
23 |
-
hf_avail_splits=[],
|
24 |
-
evaluation_splits=[],
|
25 |
-
few_shots_split="",
|
26 |
-
few_shots_select="",
|
27 |
-
metric=[""],
|
28 |
-
)
|
29 |
-
|
30 |
-
## EVALS WITH SUBSET
|
31 |
-
# This is how you create a subset task (like MMLU), which has several subset
|
32 |
-
# each being its own evaluation task.
|
33 |
-
|
34 |
-
# fmt: off
|
35 |
-
SAMPLE_SUBSETS = [] # list of all the subsets to use for this eval
|
36 |
-
# fmt: on
|
37 |
-
|
38 |
-
|
39 |
-
class CustomSubsetTask(LightevalTaskConfig):
|
40 |
-
def __init__(
|
41 |
-
self,
|
42 |
-
name,
|
43 |
-
hf_subset,
|
44 |
-
):
|
45 |
-
super().__init__(
|
46 |
-
name=name,
|
47 |
-
hf_subset=hf_subset,
|
48 |
-
prompt_function="prompt_fn", # must be defined in the file
|
49 |
-
hf_repo="",
|
50 |
-
metric=[""],
|
51 |
-
hf_avail_splits=[],
|
52 |
-
evaluation_splits=[],
|
53 |
-
few_shots_split="",
|
54 |
-
few_shots_select="",
|
55 |
-
suite=["community"],
|
56 |
-
generation_size=-1,
|
57 |
-
stop_sequence=None,
|
58 |
-
output_regex=None,
|
59 |
-
frozen=False,
|
60 |
-
)
|
61 |
-
|
62 |
-
|
63 |
-
## DEFINE YOUR PROMPT FUNCTIONS
|
64 |
-
# Define as many as you need for your different tasks
|
65 |
-
def prompt_fn(line, task_name: str = None):
|
66 |
-
"""Defines how to go from a dataset line to a doc object.
|
67 |
-
Follow examples in src/lighteval/tasks/tasks_prompt_formatting.py, or get more info
|
68 |
-
about what this function should do in the README.
|
69 |
-
"""
|
70 |
-
return Doc(
|
71 |
-
task_name=task_name,
|
72 |
-
query="",
|
73 |
-
choices="",
|
74 |
-
gold_index=0,
|
75 |
-
instruction="",
|
76 |
-
)
|
77 |
-
|
78 |
-
|
79 |
-
## STORE YOUR EVALS
|
80 |
-
SUBSET_TASKS = [CustomSubsetTask(name=f"mytask:{subset}", hf_subset=subset) for subset in SAMPLE_SUBSETS]
|
81 |
-
_TASKS = SUBSET_TASKS + [task]
|
82 |
|
83 |
## MODULE LOGIC
|
84 |
# You should not need to touch this
|
85 |
# Convert to dict for lighteval
|
86 |
-
TASKS_TABLE = [task.as_dict() for task in
|
87 |
|
88 |
if __name__ == "__main__":
|
89 |
print(t["name"] for t in TASKS_TABLE)
|
|
|
6 |
|
7 |
Author:
|
8 |
"""
|
9 |
+
from heq_task import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
## MODULE LOGIC
|
12 |
# You should not need to touch this
|
13 |
# Convert to dict for lighteval
|
14 |
+
TASKS_TABLE = [task.as_dict() for task in [heq_task]]
|
15 |
|
16 |
if __name__ == "__main__":
|
17 |
print(t["name"] for t in TASKS_TABLE)
|
heq_task.py
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import re
|
2 |
+
import string
|
3 |
+
from lighteval.tasks.lighteval_task import LightevalTaskConfig
|
4 |
+
from lighteval.metrics import Metrics, MetricCategory
|
5 |
+
from lighteval.metrics.utils import CorpusLevelMetric, MetricUseCase
|
6 |
+
import numpy as np
|
7 |
+
from lighteval.tasks.requests import Doc
|
8 |
+
from Levenshtein import distance
|
9 |
+
import collections
|
10 |
+
|
11 |
+
def get_tokens(s):
|
12 |
+
if not s:
|
13 |
+
return []
|
14 |
+
return normalize_answer(s).split()
|
15 |
+
|
16 |
+
ARTICLES_REGEX = re.compile(r"\b(a|an|the)\b", re.UNICODE)
|
17 |
+
def normalize_answer(s):
|
18 |
+
def remove_articles(text):
|
19 |
+
return ARTICLES_REGEX.sub(" ", text)
|
20 |
+
def white_space_fix(text):
|
21 |
+
return " ".join(text.split())
|
22 |
+
|
23 |
+
def remove_punc(text):
|
24 |
+
exclude = set(string.punctuation)
|
25 |
+
return "".join(ch for ch in text if ch not in exclude)
|
26 |
+
|
27 |
+
def lower(text):
|
28 |
+
return text.lower()
|
29 |
+
|
30 |
+
return white_space_fix(remove_articles(remove_punc(lower(s.replace('<pad>', '').replace('</s>', '').strip()))))
|
31 |
+
|
32 |
+
def compute_f1(a_gold, a_pred):
|
33 |
+
gold_toks = get_tokens(a_gold)
|
34 |
+
pred_toks = get_tokens(a_pred)
|
35 |
+
common = collections.Counter(gold_toks) & collections.Counter(pred_toks)
|
36 |
+
num_same = sum(common.values())
|
37 |
+
if len(gold_toks) == 0 or len(pred_toks) == 0:
|
38 |
+
# If either is no-answer, then F1 is 1 if they agree, 0 otherwise
|
39 |
+
return int(gold_toks == pred_toks)
|
40 |
+
if num_same == 0:
|
41 |
+
return 0
|
42 |
+
precision = 1.0 * num_same / len(pred_toks)
|
43 |
+
recall = 1.0 * num_same / len(gold_toks)
|
44 |
+
f1 = (2 * precision * recall) / (precision + recall)
|
45 |
+
return f1
|
46 |
+
|
47 |
+
def normalized_edit_similarity(p1, p2):
|
48 |
+
return 1-distance(p1, p2)/ max(len(p1), len(p2))
|
49 |
+
|
50 |
+
def compute_token_edit(a_gold, a_pred):
|
51 |
+
gold_toks = get_tokens(a_gold)
|
52 |
+
pred_toks = get_tokens(a_pred)
|
53 |
+
if len(gold_toks) == 0 or len(pred_toks) == 0:
|
54 |
+
# If either is no-answer, then F1 is 1 if they agree, 0 otherwise
|
55 |
+
return int(gold_toks == pred_toks)
|
56 |
+
num_same = sum([max([normalized_edit_similarity(gold_t, pred_t) for pred_t in pred_toks]) for gold_t in gold_toks])
|
57 |
+
if num_same == 0:
|
58 |
+
return 0
|
59 |
+
precision = 1.0 * num_same / len(pred_toks)
|
60 |
+
recall = 1.0 * num_same / len(gold_toks)
|
61 |
+
f1 = (2 * precision * recall) / (precision + recall)
|
62 |
+
return f1
|
63 |
+
|
64 |
+
def tlnls(a_gold, a_pred):
|
65 |
+
digit_count = sum(1 for char in a_pred if char.isdigit())
|
66 |
+
if digit_count < len(a_pred) / 2:
|
67 |
+
return compute_token_edit(a_gold, a_pred)
|
68 |
+
else:
|
69 |
+
return compute_f1(a_gold, a_pred)
|
70 |
+
|
71 |
+
def heq_eval_fn(golds: list[str], predictions: list[str]):
|
72 |
+
if len(predictions) > 1:
|
73 |
+
raise ValueError("Predictions should have one item")
|
74 |
+
return max([tlnls(x, predictions[0]) for x in golds])
|
75 |
+
|
76 |
+
heq_tlnls_metric = CorpusLevelMetric(
|
77 |
+
metric="heq_tlnls",
|
78 |
+
higher_is_better=True,
|
79 |
+
category=MetricCategory.GENERATIVE,
|
80 |
+
use_case=MetricUseCase.ACCURACY,
|
81 |
+
corpus_level_fn=np.mean,
|
82 |
+
sample_level_fn=heq_eval_fn
|
83 |
+
)
|
84 |
+
|
85 |
+
def heq_prompt_fn(line, task_name: str = None):
|
86 |
+
"""Defines how to go from a dataset line to a doc object.
|
87 |
+
Follow examples in src/lighteval/tasks/tasks_prompt_formatting.py, or get more info
|
88 |
+
about what this function should do in the README.
|
89 |
+
"""
|
90 |
+
return Doc(
|
91 |
+
task_name=task_name,
|
92 |
+
query=line["prompt"],
|
93 |
+
choices=line["response"],
|
94 |
+
gold_index=list(range(line["response"])),
|
95 |
+
instruction="",
|
96 |
+
)
|
97 |
+
|
98 |
+
## EVAL WITH NO SUBSET ##
|
99 |
+
# This is how you create a simple tasks (like hellaswag) which has one single subset
|
100 |
+
# attached to it, and one evaluation possible.
|
101 |
+
heq_task = LightevalTaskConfig(
|
102 |
+
name="heq-qa-tlnls",
|
103 |
+
prompt_function="heq_prompt_fn", # must be defined in the file or imported from src/lighteval/tasks/tasks_prompt_formatting.py
|
104 |
+
suite=["custom"],
|
105 |
+
hf_repo="dicta-hebrew-llm-leaderboard/tests",
|
106 |
+
hf_subset="default",
|
107 |
+
hf_avail_splits=["heq"],
|
108 |
+
evaluation_splits=["heq"],
|
109 |
+
metric=[heq_tlnls_metric],
|
110 |
+
stop_sequence=['\n']
|
111 |
+
)
|
main_backend_harness.py
DELETED
@@ -1,78 +0,0 @@
|
|
1 |
-
import logging
|
2 |
-
import pprint
|
3 |
-
|
4 |
-
from huggingface_hub import snapshot_download
|
5 |
-
|
6 |
-
logging.getLogger("openai").setLevel(logging.WARNING)
|
7 |
-
|
8 |
-
from backend.run_eval_suite_harness import run_evaluation
|
9 |
-
from src.backend.manage_requests import check_completed_evals, get_eval_requests, set_eval_request
|
10 |
-
from src.backend.sort_queue import sort_models_by_priority
|
11 |
-
|
12 |
-
from src.envs import QUEUE_REPO, EVAL_REQUESTS_PATH_BACKEND, RESULTS_REPO, EVAL_RESULTS_PATH_BACKEND, DEVICE, API, LIMIT, TOKEN
|
13 |
-
from src.about import Tasks, NUM_FEWSHOT
|
14 |
-
TASKS_HARNESS = [task.value.benchmark for task in Tasks]
|
15 |
-
|
16 |
-
logging.basicConfig(level=logging.ERROR)
|
17 |
-
pp = pprint.PrettyPrinter(width=80)
|
18 |
-
|
19 |
-
PENDING_STATUS = "PENDING"
|
20 |
-
RUNNING_STATUS = "RUNNING"
|
21 |
-
FINISHED_STATUS = "FINISHED"
|
22 |
-
FAILED_STATUS = "FAILED"
|
23 |
-
|
24 |
-
snapshot_download(repo_id=RESULTS_REPO, revision="main", local_dir=EVAL_RESULTS_PATH_BACKEND, repo_type="dataset", max_workers=60, token=TOKEN)
|
25 |
-
snapshot_download(repo_id=QUEUE_REPO, revision="main", local_dir=EVAL_REQUESTS_PATH_BACKEND, repo_type="dataset", max_workers=60, token=TOKEN)
|
26 |
-
|
27 |
-
def run_auto_eval():
|
28 |
-
current_pending_status = [PENDING_STATUS]
|
29 |
-
|
30 |
-
# pull the eval dataset from the hub and parse any eval requests
|
31 |
-
# check completed evals and set them to finished
|
32 |
-
check_completed_evals(
|
33 |
-
api=API,
|
34 |
-
checked_status=RUNNING_STATUS,
|
35 |
-
completed_status=FINISHED_STATUS,
|
36 |
-
failed_status=FAILED_STATUS,
|
37 |
-
hf_repo=QUEUE_REPO,
|
38 |
-
local_dir=EVAL_REQUESTS_PATH_BACKEND,
|
39 |
-
hf_repo_results=RESULTS_REPO,
|
40 |
-
local_dir_results=EVAL_RESULTS_PATH_BACKEND
|
41 |
-
)
|
42 |
-
|
43 |
-
# Get all eval request that are PENDING, if you want to run other evals, change this parameter
|
44 |
-
eval_requests = get_eval_requests(job_status=current_pending_status, hf_repo=QUEUE_REPO, local_dir=EVAL_REQUESTS_PATH_BACKEND)
|
45 |
-
# Sort the evals by priority (first submitted first run)
|
46 |
-
eval_requests = sort_models_by_priority(api=API, models=eval_requests)
|
47 |
-
|
48 |
-
print(f"Found {len(eval_requests)} {','.join(current_pending_status)} eval requests")
|
49 |
-
|
50 |
-
if len(eval_requests) == 0:
|
51 |
-
return
|
52 |
-
|
53 |
-
eval_request = eval_requests[0]
|
54 |
-
pp.pprint(eval_request)
|
55 |
-
|
56 |
-
set_eval_request(
|
57 |
-
api=API,
|
58 |
-
eval_request=eval_request,
|
59 |
-
set_to_status=RUNNING_STATUS,
|
60 |
-
hf_repo=QUEUE_REPO,
|
61 |
-
local_dir=EVAL_REQUESTS_PATH_BACKEND,
|
62 |
-
)
|
63 |
-
|
64 |
-
run_evaluation(
|
65 |
-
eval_request=eval_request,
|
66 |
-
task_names=TASKS_HARNESS,
|
67 |
-
num_fewshot=NUM_FEWSHOT,
|
68 |
-
local_dir=EVAL_RESULTS_PATH_BACKEND,
|
69 |
-
results_repo=RESULTS_REPO,
|
70 |
-
batch_size=1,
|
71 |
-
device=DEVICE,
|
72 |
-
no_cache=True,
|
73 |
-
limit=LIMIT
|
74 |
-
)
|
75 |
-
|
76 |
-
|
77 |
-
if __name__ == "__main__":
|
78 |
-
run_auto_eval()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main_backend_lighteval.py
CHANGED
@@ -63,9 +63,9 @@ def run_auto_eval():
|
|
63 |
# This needs to be done
|
64 |
#instance_size, instance_type = get_instance_for_model(eval_request)
|
65 |
# For GPU
|
66 |
-
|
67 |
# For CPU
|
68 |
-
instance_size, instance_type = "medium", "c6i"
|
69 |
|
70 |
run_evaluation(
|
71 |
eval_request=eval_request,
|
|
|
63 |
# This needs to be done
|
64 |
#instance_size, instance_type = get_instance_for_model(eval_request)
|
65 |
# For GPU
|
66 |
+
instance_size, instance_type = "small", "g4dn.xlarge"
|
67 |
# For CPU
|
68 |
+
# instance_size, instance_type = "medium", "c6i"
|
69 |
|
70 |
run_evaluation(
|
71 |
eval_request=eval_request,
|
requirements.txt
CHANGED
@@ -13,7 +13,7 @@ requests==2.28.2
|
|
13 |
tqdm==4.65.0
|
14 |
transformers
|
15 |
tokenizers>=0.15.0
|
16 |
-
git+https://github.com/EleutherAI/lm-evaluation-harness.git@b281b0921b636bc36ad05c0b0b0763bd6dd43463#egg=lm-eval
|
17 |
git+https://github.com/huggingface/lighteval.git#egg=lighteval
|
18 |
accelerate==0.24.1
|
19 |
-
sentencepiece
|
|
|
|
13 |
tqdm==4.65.0
|
14 |
transformers
|
15 |
tokenizers>=0.15.0
|
|
|
16 |
git+https://github.com/huggingface/lighteval.git#egg=lighteval
|
17 |
accelerate==0.24.1
|
18 |
+
sentencepiece
|
19 |
+
Levenshtein
|
scripts/fix_harness_import.py
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
"""This file should be used after pip install -r requirements.
|
2 |
-
It creates a folder not ported during harness package creation (as they don't use a Manifest file atm and it ignore `.json` files).
|
3 |
-
It will need to be updated if we want to use the harness' version of big bench to actually copy the json files.
|
4 |
-
"""
|
5 |
-
import os
|
6 |
-
|
7 |
-
import lm_eval
|
8 |
-
|
9 |
-
if __name__ == "__main__":
|
10 |
-
lm_eval_path = lm_eval.__path__[0]
|
11 |
-
os.makedirs(os.path.join(lm_eval_path, "datasets", "bigbench_resources"), exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/about.py
CHANGED
@@ -20,5 +20,5 @@ NUM_FEWSHOT = 0 # Change with your few shot
|
|
20 |
TASKS_HARNESS = [task.value.benchmark for task in Tasks]
|
21 |
# ---------------------------------------------------
|
22 |
|
23 |
-
TASKS_LIGHTEVAL = "lighteval|anli:r1|0|0,lighteval|logiqa|0|0"
|
24 |
-
|
|
|
20 |
TASKS_HARNESS = [task.value.benchmark for task in Tasks]
|
21 |
# ---------------------------------------------------
|
22 |
|
23 |
+
# TASKS_LIGHTEVAL = "lighteval|anli:r1|0|0,lighteval|logiqa|0|0"
|
24 |
+
TASKS_LIGHTEVAL = "custom|heq-qa-tlnls|0|0"
|
src/backend/run_eval_suite_harness.py
DELETED
@@ -1,57 +0,0 @@
|
|
1 |
-
import json
|
2 |
-
import os
|
3 |
-
import logging
|
4 |
-
from datetime import datetime
|
5 |
-
|
6 |
-
from lm_eval import tasks, evaluator, utils
|
7 |
-
|
8 |
-
from src.envs import RESULTS_REPO, API
|
9 |
-
from src.backend.manage_requests import EvalRequest
|
10 |
-
|
11 |
-
logging.getLogger("openai").setLevel(logging.WARNING)
|
12 |
-
|
13 |
-
def run_evaluation(eval_request: EvalRequest, task_names, num_fewshot, batch_size, device, local_dir: str, results_repo: str, no_cache=True, limit=None):
|
14 |
-
if limit:
|
15 |
-
print(
|
16 |
-
"WARNING: --limit SHOULD ONLY BE USED FOR TESTING. REAL METRICS SHOULD NOT BE COMPUTED USING LIMIT."
|
17 |
-
)
|
18 |
-
|
19 |
-
task_names = utils.pattern_match(task_names, tasks.ALL_TASKS)
|
20 |
-
|
21 |
-
print(f"Selected Tasks: {task_names}")
|
22 |
-
|
23 |
-
results = evaluator.simple_evaluate(
|
24 |
-
model="hf-causal-experimental", # "hf-causal"
|
25 |
-
model_args=eval_request.get_model_args(),
|
26 |
-
tasks=task_names,
|
27 |
-
num_fewshot=num_fewshot,
|
28 |
-
batch_size=batch_size,
|
29 |
-
device=device,
|
30 |
-
no_cache=no_cache,
|
31 |
-
limit=limit,
|
32 |
-
write_out=True,
|
33 |
-
output_base_path="logs"
|
34 |
-
)
|
35 |
-
|
36 |
-
results["config"]["model_dtype"] = eval_request.precision
|
37 |
-
results["config"]["model_name"] = eval_request.model
|
38 |
-
results["config"]["model_sha"] = eval_request.revision
|
39 |
-
|
40 |
-
dumped = json.dumps(results, indent=2)
|
41 |
-
print(dumped)
|
42 |
-
|
43 |
-
output_path = os.path.join(local_dir, *eval_request.model.split("/"), f"results_{datetime.now()}.json")
|
44 |
-
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
45 |
-
with open(output_path, "w") as f:
|
46 |
-
f.write(dumped)
|
47 |
-
|
48 |
-
print(evaluator.make_table(results))
|
49 |
-
|
50 |
-
API.upload_file(
|
51 |
-
path_or_fileobj=output_path,
|
52 |
-
path_in_repo=f"{eval_request.model}/results_{datetime.now()}.json",
|
53 |
-
repo_id=results_repo,
|
54 |
-
repo_type="dataset",
|
55 |
-
)
|
56 |
-
|
57 |
-
return results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/envs.py
CHANGED
@@ -6,19 +6,19 @@ from huggingface_hub import HfApi
|
|
6 |
# ----------------------------------
|
7 |
TOKEN = os.environ.get("TOKEN") # A read/write token for your org
|
8 |
|
9 |
-
OWNER = "
|
10 |
|
11 |
# For harness evaluations
|
12 |
DEVICE = "cpu" # "cuda:0" if you add compute, for harness evaluations
|
13 |
LIMIT = 20 # !!!! Should be None for actual evaluations!!!
|
14 |
|
15 |
# For lighteval evaluations
|
16 |
-
ACCELERATOR = "
|
17 |
REGION = "us-east-1"
|
18 |
VENDOR = "aws"
|
19 |
# ----------------------------------
|
20 |
|
21 |
-
REPO_ID = f"{OWNER}/leaderboard-backend"
|
22 |
QUEUE_REPO = f"{OWNER}/requests"
|
23 |
RESULTS_REPO = f"{OWNER}/results"
|
24 |
|
|
|
6 |
# ----------------------------------
|
7 |
TOKEN = os.environ.get("TOKEN") # A read/write token for your org
|
8 |
|
9 |
+
OWNER = "dicta-hebrew-llm-leaderboard" # Change to your org - don't forget to create a results and request file
|
10 |
|
11 |
# For harness evaluations
|
12 |
DEVICE = "cpu" # "cuda:0" if you add compute, for harness evaluations
|
13 |
LIMIT = 20 # !!!! Should be None for actual evaluations!!!
|
14 |
|
15 |
# For lighteval evaluations
|
16 |
+
ACCELERATOR = "cuda:0"
|
17 |
REGION = "us-east-1"
|
18 |
VENDOR = "aws"
|
19 |
# ----------------------------------
|
20 |
|
21 |
+
# REPO_ID = f"{OWNER}/leaderboard-backend"
|
22 |
QUEUE_REPO = f"{OWNER}/requests"
|
23 |
RESULTS_REPO = f"{OWNER}/results"
|
24 |
|
src/logging.py
CHANGED
@@ -19,12 +19,12 @@ class Logger:
|
|
19 |
|
20 |
def read_logs():
|
21 |
sys.stdout.flush()
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
|
29 |
with open("output.log", "r") as f:
|
30 |
return f.read()
|
|
|
19 |
|
20 |
def read_logs():
|
21 |
sys.stdout.flush()
|
22 |
+
API.upload_file(
|
23 |
+
path_or_fileobj="output.log",
|
24 |
+
path_in_repo="demo-backend.log",
|
25 |
+
repo_id="demo-leaderboard-backend/logs",
|
26 |
+
repo_type="dataset",
|
27 |
+
)
|
28 |
|
29 |
with open("output.log", "r") as f:
|
30 |
return f.read()
|
src/populate.py
DELETED
@@ -1,56 +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 |
-
raw_data = get_raw_eval_results(results_path, requests_path)
|
13 |
-
all_data_json = [v.to_dict() for v in raw_data]
|
14 |
-
|
15 |
-
df = pd.DataFrame.from_records(all_data_json)
|
16 |
-
df = df.sort_values(by=[AutoEvalColumn.average.name], ascending=False)
|
17 |
-
df = df[cols].round(decimals=2)
|
18 |
-
|
19 |
-
# filter out if any of the benchmarks have not been produced
|
20 |
-
df = df[has_no_nan_values(df, benchmark_cols)]
|
21 |
-
return raw_data, df
|
22 |
-
|
23 |
-
|
24 |
-
def get_evaluation_queue_df(save_path: str, cols: list) -> list[pd.DataFrame]:
|
25 |
-
entries = [entry for entry in os.listdir(save_path) if not entry.startswith(".")]
|
26 |
-
all_evals = []
|
27 |
-
|
28 |
-
for entry in entries:
|
29 |
-
if ".json" in entry:
|
30 |
-
file_path = os.path.join(save_path, entry)
|
31 |
-
with open(file_path) as fp:
|
32 |
-
data = json.load(fp)
|
33 |
-
|
34 |
-
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
35 |
-
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
36 |
-
|
37 |
-
all_evals.append(data)
|
38 |
-
elif ".md" not in entry:
|
39 |
-
# this is a folder
|
40 |
-
sub_entries = [e for e in os.listdir(f"{save_path}/{entry}") if not e.startswith(".")]
|
41 |
-
for sub_entry in sub_entries:
|
42 |
-
file_path = os.path.join(save_path, entry, sub_entry)
|
43 |
-
with open(file_path) as fp:
|
44 |
-
data = json.load(fp)
|
45 |
-
|
46 |
-
data[EvalQueueColumn.model.name] = make_clickable_model(data["model"])
|
47 |
-
data[EvalQueueColumn.revision.name] = data.get("revision", "main")
|
48 |
-
all_evals.append(data)
|
49 |
-
|
50 |
-
pending_list = [e for e in all_evals if e["status"] in ["PENDING", "RERUN"]]
|
51 |
-
running_list = [e for e in all_evals if e["status"] == "RUNNING"]
|
52 |
-
finished_list = [e for e in all_evals if e["status"].startswith("FINISHED") or e["status"] == "PENDING_NEW_EVAL"]
|
53 |
-
df_pending = pd.DataFrame.from_records(pending_list, columns=cols)
|
54 |
-
df_running = pd.DataFrame.from_records(running_list, columns=cols)
|
55 |
-
df_finished = pd.DataFrame.from_records(finished_list, columns=cols)
|
56 |
-
return df_finished[cols], df_running[cols], df_pending[cols]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|