File size: 718 Bytes
6376749
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import json
from datasets import load_dataset

dataset = load_dataset("math_qa")
save_path = "dataset/mathqa/test.json"

if not os.path.exists("dataset/mathqa/"):
    os.makedirs("dataset/mathqa/")


def writer(data, save_path):
    with open(save_path, "w") as f:
        json.dump(data, f, indent=4)

test_data = []
for sample in dataset["test"]:
    options = sample["options"].replace("a", "A").replace("b", "B").replace("c", "C").replace("d", "D").replace("e", "E").replace("f", "F")
    test_data.append({
        "instruction": f"{sample['Problem']} The options: {options}",
        "input": "",
        "output": "",
        "answer": sample["correct"].upper(),
    })

writer(test_data, save_path)