(example, data_name)
| 619 | |
| 620 | |
| 621 | def parse_question(example, data_name): |
| 622 | question = "" |
| 623 | if data_name == "asdiv": |
| 624 | question = f"{example['body'].strip()} {example['question'].strip()}" |
| 625 | elif data_name == "svamp": |
| 626 | body = example["Body"].strip() |
| 627 | if not body.endswith("."): |
| 628 | body = body + "." |
| 629 | question = f'{body} {example["Question"].strip()}' |
| 630 | elif data_name == "tabmwp": |
| 631 | title_str = ( |
| 632 | f'regarding "{example["table_title"]}" ' if example["table_title"] else "" |
| 633 | ) |
| 634 | question = f"Read the following table {title_str}and answer a question:\n" |
| 635 | question += f'{example["table"]}\n{example["question"]}' |
| 636 | if example["choices"]: |
| 637 | question += ( |
| 638 | f' Please select from the following options: {example["choices"]}' |
| 639 | ) |
| 640 | elif data_name == "carp_en": |
| 641 | question = example["content"] |
| 642 | elif data_name == "mmlu_stem": |
| 643 | options = example["choices"] |
| 644 | assert len(options) == 4 |
| 645 | for i, (label, option) in enumerate(zip("ABCD", options)): |
| 646 | options[i] = f"({label}) {str(option).strip()}" |
| 647 | options = " ".join(options) |
| 648 | # question = f"{example['question'].strip()}\nWhat of the following is the right choice? Explain your answer.\n{options}" |
| 649 | question = f"{example['question'].strip()}\nAnswer Choices: {options}" |
| 650 | elif data_name == "sat_math": |
| 651 | options = example["options"].strip() |
| 652 | assert "A" == options[0] |
| 653 | options = "(" + options |
| 654 | for ch in "BCD": |
| 655 | if f" {ch}) " in options: |
| 656 | options = regex.sub(f" {ch}\) ", f" ({ch}) ", options) |
| 657 | # question = f"{example['question'].strip()}\nWhat of the following is the right choice? Explain your answer.\n{options.strip()}" |
| 658 | question = f"{example['question'].strip()}\nAnswer Choices: {options}" |
| 659 | elif "aqua" in data_name: |
| 660 | options = example["options"] |
| 661 | choice = "(" + "(".join(options) |
| 662 | choice = choice.replace("(", " (").replace(")", ") ").strip() |
| 663 | choice = "\nAnswer Choices: " + choice |
| 664 | question = example["question"].strip() + choice |
| 665 | elif data_name == "gaokao_math_qa": |
| 666 | options_dict = example["options"] |
| 667 | options = [] |
| 668 | for key in options_dict: |
| 669 | options.append(f"({key}) {options_dict[key]}") |
| 670 | options = " ".join(options) |
| 671 | question = f"{example['question'].strip()}\n选项: {options}" |
| 672 | else: |
| 673 | for key in ["question", "problem", "Question", "input"]: |
| 674 | if key in example: |
| 675 | question = example[key] |
| 676 | break |
| 677 | # assert question != "" |
| 678 | # Yes or No question |
no test coverage detected