MCPcopy Create free account
hub / github.com/LeapLabTHU/Absolute-Zero-Reasoner / load_data

Function load_data

evaluation/math_eval/eval/data_loader.py:9–85  ·  view source on GitHub ↗
(data_name, split, data_dir="./data")

Source from the content-addressed store, hash-verified

7
8
9def load_data(data_name, split, data_dir="./data"):
10 data_file = f"{data_dir}/{data_name}/{split}.jsonl"
11 if os.path.exists(data_file):
12 examples = list(load_jsonl(data_file))
13 else:
14 if data_name == "math":
15 dataset = load_dataset(
16 "competition_math",
17 split=split,
18 name="main",
19 cache_dir=f"{data_dir}/temp",
20 )
21 elif data_name == "gsm8k":
22 dataset = load_dataset(data_name, split=split)
23 elif data_name == "svamp":
24 # evaluate on training set + test set
25 dataset = load_dataset("ChilleD/SVAMP", split="train")
26 dataset = concatenate_datasets(
27 [dataset, load_dataset("ChilleD/SVAMP", split="test")]
28 )
29 elif data_name == "asdiv":
30 dataset = load_dataset("EleutherAI/asdiv", split="validation")
31 dataset = dataset.filter(
32 lambda x: ";" not in x["answer"]
33 ) # remove multi-answer examples
34 elif data_name == "mawps":
35 examples = []
36 # four sub-tasks
37 for data_name in ["singleeq", "singleop", "addsub", "multiarith"]:
38 sub_examples = list(load_jsonl(f"{data_dir}/mawps/{data_name}.jsonl"))
39 for example in sub_examples:
40 example["type"] = data_name
41 examples.extend(sub_examples)
42 dataset = Dataset.from_list(examples)
43 elif data_name == "mmlu_stem":
44 dataset = load_dataset("hails/mmlu_no_train", "all", split="test")
45 # only keep stem subjects
46 stem_subjects = [
47 "abstract_algebra",
48 "astronomy",
49 "college_biology",
50 "college_chemistry",
51 "college_computer_science",
52 "college_mathematics",
53 "college_physics",
54 "computer_security",
55 "conceptual_physics",
56 "electrical_engineering",
57 "elementary_mathematics",
58 "high_school_biology",
59 "high_school_chemistry",
60 "high_school_computer_science",
61 "high_school_mathematics",
62 "high_school_physics",
63 "high_school_statistics",
64 "machine_learning",
65 ]
66 dataset = dataset.rename_column("subject", "type")

Callers 1

prepare_dataFunction · 0.90

Calls 2

load_jsonlFunction · 0.90
lower_keysFunction · 0.90

Tested by

no test coverage detected