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

Method load

opencompass/datasets/mathbench.py:115–145  ·  view source on GitHub ↗
(path: str, name: str, with_circular: bool = True)

Source from the content-addressed store, hash-verified

113
114 @staticmethod
115 def load(path: str, name: str, with_circular: bool = True):
116 data = []
117 filename = osp.join(path, f'{name}.jsonl')
118 with open(filename, 'r', encoding='utf-8') as infile:
119 for id, line in enumerate(infile):
120 entry = json.loads(line)
121 if 'cloze' in name:
122 data.append({
123 'question': entry['question'].strip(),
124 'answer': entry['answer'].strip()
125 })
126 else:
127 if with_circular:
128 data.extend(get_circular_example(entry, id))
129 else:
130 question = entry['question'].strip(
131 ) + '\n' + get_number(entry['options'])
132 info = {
133 'question': question,
134 'answer': entry['answer'].strip()
135 }
136 # For PPL evaluation
137 for i in range(4):
138 info[chr(ord('A') +
139 i)] = entry['options'][i].strip()
140 data.append(info)
141
142 if 'cloze' not in name:
143 data = data[:(len(data) // 4 + 7) // 8 * 8]
144 dataset = Dataset.from_list(data)
145 return dataset
146
147
148import collections

Callers

nothing calls this directly

Calls 3

openFunction · 0.85
get_circular_exampleFunction · 0.70
get_numberFunction · 0.70

Tested by

no test coverage detected