(path: str, file_name: str = 'math.json', **kwargs)
| 142 | |
| 143 | @staticmethod |
| 144 | def load(path: str, file_name: str = 'math.json', **kwargs): |
| 145 | path = get_data_path(path) |
| 146 | dataset = DatasetDict() |
| 147 | raw_data = [] |
| 148 | if environ.get('DATASET_SOURCE') == 'ModelScope': |
| 149 | from modelscope import MsDataset |
| 150 | ms_dataset = MsDataset.load(path, split='train') |
| 151 | for item in ms_dataset: |
| 152 | raw_data.append({ |
| 153 | 'problem': |
| 154 | item['problem'], |
| 155 | 'solution': |
| 156 | extract_boxed_answer(item['solution']) |
| 157 | }) |
| 158 | else: |
| 159 | file_path = os.path.join(path, file_name) |
| 160 | data = json.load(open(file_path)) |
| 161 | for i in data.keys(): |
| 162 | raw_data.append({ |
| 163 | 'problem': |
| 164 | data[i]['problem'], |
| 165 | 'solution': |
| 166 | extract_boxed_answer(data[i]['solution']) |
| 167 | }) |
| 168 | dataset['test'] = Dataset.from_list(raw_data) |
| 169 | dataset['train'] = Dataset.from_list(raw_data) |
| 170 | return dataset |
| 171 | |
| 172 | |
| 173 | @TEXT_POSTPROCESSORS.register_module('math_postprocess') |
nothing calls this directly
no test coverage detected