| import re |
| from datasets import load_dataset, Dataset, DatasetDict |
|
|
|
|
| def main(): |
| datasets = load_dataset('kg-rag/BiomixQA', 'mcq') |
|
|
| _datasets = {} |
| for split in ['train']: |
| data = [] |
| for example in datasets[split]: |
| question = str(example['text']) |
| question = question.split('Given list is:')[0] |
| choices = [example['option_A'],example['option_B'], example['option_C'], example['option_D'], example['option_E']] |
| answer_index = choices.index(example['correct_answer']) |
| answer = chr(ord('A') + answer_index) |
| data.append({ |
| 'question': question.strip(), |
| 'choices': choices, |
| 'answer': answer.strip(), |
| 'answer_index': answer_index |
| }) |
| dataset = Dataset.from_list(data) |
| _datasets[split] = dataset |
|
|
| datasets = DatasetDict({ |
| 'test': _datasets['train'], |
| }) |
| datasets.push_to_hub('extraordinarylab/biomix-qa') |
|
|
|
|
| if __name__ == '__main__': |
| main() |