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)
| 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() |
nothing calls this directly
no test coverage detected