MCPcopy Create free account
hub / github.com/InternScience/SciReason / load

Method load

opencompass/datasets/mathbench.py:50–87  ·  view source on GitHub ↗

MathBenth Dataset. Args: path (str): Path of the mathbench dataset. name (str): Name of the target subset. with_circular (bool): Whether to create circular dataset for single choice question. Defaults to True.

(path: str, name: str, with_circular: bool = True)

Source from the content-addressed store, hash-verified

48
49 @staticmethod
50 def load(path: str, name: str, with_circular: bool = True):
51 """MathBenth Dataset.
52
53 Args:
54 path (str): Path of the mathbench dataset.
55 name (str): Name of the target subset.
56 with_circular (bool): Whether to create circular dataset for
57 single choice question. Defaults to True.
58 """
59 path = get_data_path(path, local_mode=True)
60 data = []
61 filename = osp.join(path, f'{name}.jsonl')
62 with open(filename, 'r', encoding='utf-8') as infile:
63 for id, line in enumerate(infile):
64 entry = json.loads(line)
65 if 'cloze' in name:
66 data.append({
67 'question': entry['question'].strip(),
68 'answer': entry['answer'].strip()
69 })
70 else:
71 if with_circular:
72 data.extend(get_circular_example(entry, id))
73 else:
74 question = entry['question'].strip(
75 ) + '\n' + get_number(entry['options'])
76 info = {
77 'question': question,
78 'answer': entry['answer'].strip()
79 }
80 # # For PPL evaluation
81 # for i in range(4):
82 # info[chr(ord('A') +
83 # i)] = entry['options'][i].strip()
84 data.append(info)
85
86 dataset = Dataset.from_list(data)
87 return dataset
88
89
90@TEXT_POSTPROCESSORS.register_module()

Callers

nothing calls this directly

Calls 4

get_data_pathFunction · 0.90
openFunction · 0.85
get_circular_exampleFunction · 0.70
get_numberFunction · 0.70

Tested by

no test coverage detected