forked from UKGovernmentBEIS/inspect_evals
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwmdp.py
More file actions
74 lines (56 loc) · 1.98 KB
/
Copy pathwmdp.py
File metadata and controls
74 lines (56 loc) · 1.98 KB
1
2
3
4
5
6
7
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""
WMDP: Weapons of Mass Destruction Proxy
Nathaniel Li, Alexander Pan, Anjali Gopal, Summer Yue,
Daniel Berrios, Alice Gatti, Justin D Li, Ann-Kathrin
Dombrowski, Shashwat Goel, Long Phan, et al.
https://arxiv.org/pdf/2403.03218
# eval w/ 500 randomly selected samples
inspect eval inspect_evals/wmdp_bio --limit 500
inspect eval inspect_evals/wmdp_chem --limit 500
inspect eval inspect_evals/wmdp_cyber --limit 500
"""
from typing import Any
from inspect_ai import Task, task
from inspect_ai.dataset import Sample
from inspect_ai.scorer import choice
from inspect_ai.solver import multiple_choice
from inspect_evals.metadata import load_eval_metadata
from inspect_evals.utils import create_stable_id, filter_duplicate_ids
from inspect_evals.utils.huggingface import hf_dataset
DATASET_PATH = "cais/wmdp"
WMDP_DATASET_REVISION = "7125571f22f032c56415e7980f48d877dd830ff8"
EVAL_VERSION = load_eval_metadata("wmdp").version
@task
def wmdp_bio() -> Task:
return create_task("wmdp-bio")
@task
def wmdp_chem() -> Task:
return create_task("wmdp-chem")
@task
def wmdp_cyber() -> Task:
return create_task("wmdp-cyber")
def create_task(dataset_name: str) -> Task:
dataset = hf_dataset(
path=DATASET_PATH,
name=dataset_name,
sample_fields=record_to_sample,
split="test",
revision=WMDP_DATASET_REVISION,
)
# Filter out any samples with duplicate IDs (from identical questions)
dataset = filter_duplicate_ids(dataset)
return Task(
dataset=dataset,
solver=multiple_choice(),
scorer=choice(),
version=EVAL_VERSION.comparability_version,
metadata=EVAL_VERSION.to_metadata(),
)
def record_to_sample(record: dict[str, Any]) -> Sample:
choices_map = {0: "A", 1: "B", 2: "C", 3: "D"}
return Sample(
id=create_stable_id(record["question"], record["choices"], prefix="wmdp"),
input=record["question"],
choices=record["choices"],
target=choices_map[record["answer"]],
)