(example, data_name)
| 652 | |
| 653 | |
| 654 | def parse_question(example, data_name): |
| 655 | question = "" |
| 656 | if data_name == "asdiv": |
| 657 | question = f"{example['body'].strip()} {example['question'].strip()}" |
| 658 | elif data_name == "svamp": |
| 659 | body = example["Body"].strip() |
| 660 | if not body.endswith("."): |
| 661 | body = body + "." |
| 662 | question = f'{body} {example["Question"].strip()}' |
| 663 | elif data_name == "tabmwp": |
| 664 | title_str = ( |
| 665 | f'regarding "{example["table_title"]}" ' if example["table_title"] else "" |
| 666 | ) |
| 667 | question = f"Read the following table {title_str}and answer a question:\n" |
| 668 | question += f'{example["table"]}\n{example["question"]}' |
| 669 | if example["choices"]: |
| 670 | question += ( |
| 671 | f' Please select from the following options: {example["choices"]}' |
| 672 | ) |
| 673 | elif data_name == "carp_en": |
| 674 | question = example["content"] |
| 675 | elif data_name == "mmlu_stem": |
| 676 | options = example["choices"] |
| 677 | assert len(options) == 4 |
| 678 | for i, (label, option) in enumerate(zip("ABCD", options)): |
| 679 | options[i] = f"({label}) {str(option).strip()}" |
| 680 | options = " ".join(options) |
| 681 | # question = f"{example['question'].strip()}\nWhat of the following is the right choice? Explain your answer.\n{options}" |
| 682 | question = f"{example['question'].strip()}\nAnswer Choices: {options}" |
| 683 | elif data_name == "sat_math": |
| 684 | options = example["options"].strip() |
| 685 | assert "A" == options[0] |
| 686 | options = "(" + options |
| 687 | for ch in "BCD": |
| 688 | if f" {ch}) " in options: |
| 689 | options = regex.sub(f" {ch}\) ", f" ({ch}) ", options) |
| 690 | # question = f"{example['question'].strip()}\nWhat of the following is the right choice? Explain your answer.\n{options.strip()}" |
| 691 | question = f"{example['question'].strip()}\nAnswer Choices: {options}" |
| 692 | elif "aqua" in data_name: |
| 693 | options = example["options"] |
| 694 | choice = "(" + "(".join(options) |
| 695 | choice = choice.replace("(", " (").replace(")", ") ").strip() |
| 696 | choice = "\nAnswer Choices: " + choice |
| 697 | question = example["question"].strip() + choice |
| 698 | elif data_name == "gaokao_math_qa": |
| 699 | options_dict = example["options"] |
| 700 | options = [] |
| 701 | for key in options_dict: |
| 702 | options.append(f"({key}) {options_dict[key]}") |
| 703 | options = " ".join(options) |
| 704 | question = f"{example['question'].strip()}\n选项: {options}" |
| 705 | else: |
| 706 | for key in ["question", "problem", "Question", "input"]: |
| 707 | if key in example: |
| 708 | question = example[key] |
| 709 | break |
| 710 | # assert question != "" |
| 711 | # Yes or No question |
no test coverage detected