diff --git a/lm-evaluation/lm_eval/tasks/ammlu/_default_template_yaml b/lm-evaluation/lm_eval/tasks/ammlu/_default_template_yaml new file mode 100644 index 0000000000000000000000000000000000000000..bbcefffb7889e16d0e9abdc0015149e72b39b029 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/_default_template_yaml @@ -0,0 +1,19 @@ +group: ammlu +dataset_path: Hennara/ammlu +test_split: test +fewshot_split: dev +fewshot_config: + sampler: first_n +output_type: multiple_choice +doc_to_text: "{{Question.strip()}}\nA. {{A}}\nB. {{B}}\nC. {{C}}\nD. {{D}}\nالجواب:" +doc_to_choice: ["A", "B", "C", "D"] +doc_to_target: "{{['A', 'B', 'C', 'D'].index(Answer)}}" +metric_list: + - metric: acc + aggregation: mean + higher_is_better: true + - metric: acc_norm + aggregation: mean + higher_is_better: true +metadata: + version: 0.0 diff --git a/lm-evaluation/lm_eval/tasks/ammlu/_generate_configs.py b/lm-evaluation/lm_eval/tasks/ammlu/_generate_configs.py new file mode 100644 index 0000000000000000000000000000000000000000..5105e94c2608851f223d221b757a4ea560b3087c --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/_generate_configs.py @@ -0,0 +1,119 @@ +""" +Take in a YAML, and output all other splits with this YAML +""" +import argparse +import os + +import yaml +from tqdm import tqdm + + +SUBJECTS = { + "abstract_algebra": "ألعلوم وتقنية المعلومات و الرياضيات", + "anatomy": "ألعلوم وتقنية المعلومات و الرياضيات", + "astronomy": "ألعلوم وتقنية المعلومات و الرياضيات", + "business_ethics": "علوم أخرى", + "clinical_knowledge": "علوم أخرى", + "college_biology": "ألعلوم وتقنية المعلومات و الرياضيات", + "college_chemistry": "ألعلوم وتقنية المعلومات و الرياضيات", + "college_computer_science": "ألعلوم وتقنية المعلومات و الرياضيات", + "college_mathematics": "ألعلوم وتقنية المعلومات و الرياضيات", + "college_medicine": "علوم أخرى", + "college_physics": "ألعلوم وتقنية المعلومات و الرياضيات", + "computer_security": "ألعلوم وتقنية المعلومات و الرياضيات", + "conceptual_physics": "ألعلوم وتقنية المعلومات و الرياضيات", + "econometrics": "العلوم الإجتماعية", + "electrical_engineering": "ألعلوم وتقنية المعلومات و الرياضيات", + "elementary_mathematics": "ألعلوم وتقنية المعلومات و الرياضيات", + "formal_logic": "العلوم الانسانية", + "global_facts": "علوم أخرى", + "high_school_biology": "ألعلوم وتقنية المعلومات و الرياضيات", + "high_school_chemistry": "ألعلوم وتقنية المعلومات و الرياضيات", + "high_school_computer_science": "ألعلوم وتقنية المعلومات و الرياضيات", + "high_school_european_history": "العلوم الانسانية", + "high_school_geography": "العلوم الإجتماعية", + "high_school_government_and_politics": "العلوم الإجتماعية", + "high_school_macroeconomics": "العلوم الإجتماعية", + "high_school_mathematics": "ألعلوم وتقنية المعلومات و الرياضيات", + "high_school_microeconomics": "العلوم الإجتماعية", + "high_school_physics": "ألعلوم وتقنية المعلومات و الرياضيات", + "high_school_psychology": "العلوم الإجتماعية", + "high_school_statistics": "ألعلوم وتقنية المعلومات و الرياضيات", + "high_school_us_history": "العلوم الانسانية", + "high_school_world_history": "العلوم الانسانية", + "human_aging": "علوم أخرى", + "human_sexuality": "العلوم الإجتماعية", + "international_law": "العلوم الانسانية", + "jurisprudence": "العلوم الانسانية", + "logical_fallacies": "العلوم الانسانية", + "machine_learning": "ألعلوم وتقنية المعلومات و الرياضيات", + "management": "علوم أخرى", + "marketing": "علوم أخرى", + "medical_genetics": "علوم أخرى", + "miscellaneous": "علوم أخرى", + "moral_disputes": "العلوم الانسانية", + "moral_scenarios": "العلوم الانسانية", + "nutrition": "علوم أخرى", + "philosophy": "العلوم الانسانية", + "prehistory": "العلوم الانسانية", + "professional_accounting": "علوم أخرى", + "professional_law": "العلوم الانسانية", + "professional_medicine": "علوم أخرى", + "professional_psychology": "العلوم الإجتماعية", + "public_relations": "العلوم الإجتماعية", + "security_studies": "العلوم الإجتماعية", + "sociology": "العلوم الإجتماعية", + "us_foreign_policy": "العلوم الإجتماعية", + "virology": "علوم أخرى", + "world_religions": "العلوم الانسانية", +} + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--base_yaml_path", required=True) + parser.add_argument("--save_prefix_path", default="ammlu") + parser.add_argument("--cot_prompt_path", default=None) + parser.add_argument("--task_prefix", default="") + return parser.parse_args() + + +if __name__ == "__main__": + args = parse_args() + + # get filename of base_yaml so we can `"include": ` it in our other YAMLs. + base_yaml_name = os.path.split(args.base_yaml_path)[-1] + with open(args.base_yaml_path, encoding="utf-8") as f: + base_yaml = yaml.full_load(f) + + if args.cot_prompt_path is not None: + import json + + with open(args.cot_prompt_path, encoding="utf-8") as f: + cot_file = json.load(f) + + for subject_eng, category in tqdm(SUBJECTS.items()): + if args.cot_prompt_path is not None: + description = cot_file[subject_eng] + else: + description = f"فم بعملية التقييم في مجال {category} \n\n" + + yaml_dict = { + "include": base_yaml_name, + "task": f"ammlu_{args.task_prefix}_{subject_eng}" + if args.task_prefix != "" + else f"ammlu_{subject_eng}", + "dataset_name": subject_eng, + "description": description, + } + + file_save_path = args.save_prefix_path + f"_{subject_eng}.yaml" + print(f"Saving yaml for subset {subject_eng} to {file_save_path}") + with open(file_save_path, "w", encoding="utf-8") as yaml_file: + yaml.dump( + yaml_dict, + yaml_file, + width=float("inf"), + allow_unicode=True, + default_style='"', + ) diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_anatomy.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_anatomy.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0ea332903d86f6f76e4e43718d6f8ef4b1f887ea --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_anatomy.yaml @@ -0,0 +1,4 @@ +"dataset_name": "anatomy" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_anatomy" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_astronomy.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_astronomy.yaml new file mode 100644 index 0000000000000000000000000000000000000000..33e4d3e76f0808549fdae2e088c27dbef14c6035 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_astronomy.yaml @@ -0,0 +1,4 @@ +"dataset_name": "astronomy" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_astronomy" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_business_ethics.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_business_ethics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f86b317a22deca40e17043fe5ddf1823b15873cb --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_business_ethics.yaml @@ -0,0 +1,4 @@ +"dataset_name": "business_ethics" +"description": "فم بعملية التقييم في مجال علوم أخرى \n\n" +"include": "_default_template_yaml" +"task": "ammlu_business_ethics" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_biology.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_biology.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0040902b6b40420777c1cfa3ea43f9e693745fb9 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_biology.yaml @@ -0,0 +1,4 @@ +"dataset_name": "college_biology" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_college_biology" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_chemistry.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_chemistry.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d89e5d36d6c3e81b67cee20af8adaa64cdb69769 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_chemistry.yaml @@ -0,0 +1,4 @@ +"dataset_name": "college_chemistry" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_college_chemistry" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_computer_science.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_computer_science.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bd24ec782052fbdb2a18c6b271d7db7fd1eb0c21 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_computer_science.yaml @@ -0,0 +1,4 @@ +"dataset_name": "college_computer_science" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_college_computer_science" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_medicine.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_medicine.yaml new file mode 100644 index 0000000000000000000000000000000000000000..20ed05afe21d5256169d05a658b9a34bbbf9f830 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_medicine.yaml @@ -0,0 +1,4 @@ +"dataset_name": "college_medicine" +"description": "فم بعملية التقييم في مجال علوم أخرى \n\n" +"include": "_default_template_yaml" +"task": "ammlu_college_medicine" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_physics.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_physics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a66b42a3fff3442e5aceb1a75e3f6472e63ad3b7 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_college_physics.yaml @@ -0,0 +1,4 @@ +"dataset_name": "college_physics" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_college_physics" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_computer_security.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_computer_security.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f6d0edec21fe23c1f38f17a80990f9af70779759 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_computer_security.yaml @@ -0,0 +1,4 @@ +"dataset_name": "computer_security" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_computer_security" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_conceptual_physics.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_conceptual_physics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1d8b329adfbbb86221fbd7d467b691dfee67bb2c --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_conceptual_physics.yaml @@ -0,0 +1,4 @@ +"dataset_name": "conceptual_physics" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_conceptual_physics" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_econometrics.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_econometrics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2ce1c23a555fb89e654430ed481199450204dd49 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_econometrics.yaml @@ -0,0 +1,4 @@ +"dataset_name": "econometrics" +"description": "فم بعملية التقييم في مجال العلوم الإجتماعية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_econometrics" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_elementary_mathematics.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_elementary_mathematics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..afb9144da92bdc592e66f96133c538eb0c1829ef --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_elementary_mathematics.yaml @@ -0,0 +1,4 @@ +"dataset_name": "elementary_mathematics" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_elementary_mathematics" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_formal_logic.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_formal_logic.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8b20a85896bf52fb16e7536b46174f2671240224 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_formal_logic.yaml @@ -0,0 +1,4 @@ +"dataset_name": "formal_logic" +"description": "فم بعملية التقييم في مجال العلوم الانسانية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_formal_logic" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_global_facts.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_global_facts.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8236238279cf72b117256b5faefc07ca6de6c3a3 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_global_facts.yaml @@ -0,0 +1,4 @@ +"dataset_name": "global_facts" +"description": "فم بعملية التقييم في مجال علوم أخرى \n\n" +"include": "_default_template_yaml" +"task": "ammlu_global_facts" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_biology.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_biology.yaml new file mode 100644 index 0000000000000000000000000000000000000000..16bc3ab6b0b156367714db4b3f892517edaf35f3 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_biology.yaml @@ -0,0 +1,4 @@ +"dataset_name": "high_school_biology" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_high_school_biology" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_chemistry.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_chemistry.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3f2e675e4c80caad0aa387b6445d27e0ed4c95a7 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_chemistry.yaml @@ -0,0 +1,4 @@ +"dataset_name": "high_school_chemistry" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_high_school_chemistry" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_computer_science.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_computer_science.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d6ab8409eb6648d80adca19929907f10b1f7c65e --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_computer_science.yaml @@ -0,0 +1,4 @@ +"dataset_name": "high_school_computer_science" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_high_school_computer_science" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_european_history.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_european_history.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f22a5991753c71b8147ee368e771faf600b86693 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_european_history.yaml @@ -0,0 +1,4 @@ +"dataset_name": "high_school_european_history" +"description": "فم بعملية التقييم في مجال العلوم الانسانية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_high_school_european_history" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_government_and_politics.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_government_and_politics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..88fe999fa3913051d3d43c3d8bbc7739d5567ff5 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_government_and_politics.yaml @@ -0,0 +1,4 @@ +"dataset_name": "high_school_government_and_politics" +"description": "فم بعملية التقييم في مجال العلوم الإجتماعية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_high_school_government_and_politics" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_macroeconomics.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_macroeconomics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..68e07427671753790b7602c3f7b25cab3f1ed354 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_macroeconomics.yaml @@ -0,0 +1,4 @@ +"dataset_name": "high_school_macroeconomics" +"description": "فم بعملية التقييم في مجال العلوم الإجتماعية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_high_school_macroeconomics" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_mathematics.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_mathematics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..17705ea14ab459635b2ff8ed4a7075a9912b27cd --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_mathematics.yaml @@ -0,0 +1,4 @@ +"dataset_name": "high_school_mathematics" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_high_school_mathematics" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_microeconomics.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_microeconomics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1e74936e3133978eb348e3509214fe395dc8da20 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_microeconomics.yaml @@ -0,0 +1,4 @@ +"dataset_name": "high_school_microeconomics" +"description": "فم بعملية التقييم في مجال العلوم الإجتماعية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_high_school_microeconomics" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_physics.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_physics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..368a384f7ed466b08cd96544dcf678570ca49be7 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_physics.yaml @@ -0,0 +1,4 @@ +"dataset_name": "high_school_physics" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_high_school_physics" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_psychology.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_psychology.yaml new file mode 100644 index 0000000000000000000000000000000000000000..224026225b85f638ae70afa46a55ee71e3fa082e --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_psychology.yaml @@ -0,0 +1,4 @@ +"dataset_name": "high_school_psychology" +"description": "فم بعملية التقييم في مجال العلوم الإجتماعية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_high_school_psychology" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_statistics.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_statistics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..49c97a7358b40dd5b4b8215a3cdd4eba58805c84 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_high_school_statistics.yaml @@ -0,0 +1,4 @@ +"dataset_name": "high_school_statistics" +"description": "فم بعملية التقييم في مجال ألعلوم وتقنية المعلومات و الرياضيات \n\n" +"include": "_default_template_yaml" +"task": "ammlu_high_school_statistics" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_human_sexuality.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_human_sexuality.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d97b76f8434566ef32e7c925c839fe698e62b202 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_human_sexuality.yaml @@ -0,0 +1,4 @@ +"dataset_name": "human_sexuality" +"description": "فم بعملية التقييم في مجال العلوم الإجتماعية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_human_sexuality" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_international_law.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_international_law.yaml new file mode 100644 index 0000000000000000000000000000000000000000..46660c50894a3677529b536681f9ba3d82447229 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_international_law.yaml @@ -0,0 +1,4 @@ +"dataset_name": "international_law" +"description": "فم بعملية التقييم في مجال العلوم الانسانية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_international_law" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_jurisprudence.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_jurisprudence.yaml new file mode 100644 index 0000000000000000000000000000000000000000..97f34f0fa4402e88fa496b441e579f6c3f123737 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_jurisprudence.yaml @@ -0,0 +1,4 @@ +"dataset_name": "jurisprudence" +"description": "فم بعملية التقييم في مجال العلوم الانسانية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_jurisprudence" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_logical_fallacies.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_logical_fallacies.yaml new file mode 100644 index 0000000000000000000000000000000000000000..594501a443277599336b34b9b5af0bd3877b3e5c --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_logical_fallacies.yaml @@ -0,0 +1,4 @@ +"dataset_name": "logical_fallacies" +"description": "فم بعملية التقييم في مجال العلوم الانسانية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_logical_fallacies" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_management.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_management.yaml new file mode 100644 index 0000000000000000000000000000000000000000..36780c08a5737939af46b1e9c34909c23e10f49c --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_management.yaml @@ -0,0 +1,4 @@ +"dataset_name": "management" +"description": "فم بعملية التقييم في مجال علوم أخرى \n\n" +"include": "_default_template_yaml" +"task": "ammlu_management" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_marketing.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_marketing.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1a7cf1f1a8bb258316d929d8dcdfc69d2ed4afe7 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_marketing.yaml @@ -0,0 +1,4 @@ +"dataset_name": "marketing" +"description": "فم بعملية التقييم في مجال علوم أخرى \n\n" +"include": "_default_template_yaml" +"task": "ammlu_marketing" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_medical_genetics.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_medical_genetics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..88c56754e2ca7d97312d975119467606d577b0db --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_medical_genetics.yaml @@ -0,0 +1,4 @@ +"dataset_name": "medical_genetics" +"description": "فم بعملية التقييم في مجال علوم أخرى \n\n" +"include": "_default_template_yaml" +"task": "ammlu_medical_genetics" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_miscellaneous.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_miscellaneous.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b81c28b3e761fb842a1301d592977cdac57fcefd --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_miscellaneous.yaml @@ -0,0 +1,4 @@ +"dataset_name": "miscellaneous" +"description": "فم بعملية التقييم في مجال علوم أخرى \n\n" +"include": "_default_template_yaml" +"task": "ammlu_miscellaneous" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_moral_disputes.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_moral_disputes.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a01ffb2c4a29fd8bbf87edd08937ea7801681a56 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_moral_disputes.yaml @@ -0,0 +1,4 @@ +"dataset_name": "moral_disputes" +"description": "فم بعملية التقييم في مجال العلوم الانسانية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_moral_disputes" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_nutrition.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_nutrition.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6e2c10a4108d0575656a0729170579182325b032 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_nutrition.yaml @@ -0,0 +1,4 @@ +"dataset_name": "nutrition" +"description": "فم بعملية التقييم في مجال علوم أخرى \n\n" +"include": "_default_template_yaml" +"task": "ammlu_nutrition" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_professional_accounting.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_professional_accounting.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ea4e68c93d418d4de3062bb3e7408d087916daf8 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_professional_accounting.yaml @@ -0,0 +1,4 @@ +"dataset_name": "professional_accounting" +"description": "فم بعملية التقييم في مجال علوم أخرى \n\n" +"include": "_default_template_yaml" +"task": "ammlu_professional_accounting" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_professional_psychology.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_professional_psychology.yaml new file mode 100644 index 0000000000000000000000000000000000000000..65a721c92aeaaea67666c168dc9b1151e23ebab3 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_professional_psychology.yaml @@ -0,0 +1,4 @@ +"dataset_name": "professional_psychology" +"description": "فم بعملية التقييم في مجال العلوم الإجتماعية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_professional_psychology" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_sociology.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_sociology.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bf92339270aac89ecf7a3acd29d217c4cdd31414 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_sociology.yaml @@ -0,0 +1,4 @@ +"dataset_name": "sociology" +"description": "فم بعملية التقييم في مجال العلوم الإجتماعية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_sociology" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_us_foreign_policy.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_us_foreign_policy.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6f934dab9b7b7215afc9e35fb8c04e2264ab8364 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_us_foreign_policy.yaml @@ -0,0 +1,4 @@ +"dataset_name": "us_foreign_policy" +"description": "فم بعملية التقييم في مجال العلوم الإجتماعية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_us_foreign_policy" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_virology.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_virology.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f2b0ad6e42b9acdfcf3040baa73e2a155faaa4e7 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_virology.yaml @@ -0,0 +1,4 @@ +"dataset_name": "virology" +"description": "فم بعملية التقييم في مجال علوم أخرى \n\n" +"include": "_default_template_yaml" +"task": "ammlu_virology" diff --git a/lm-evaluation/lm_eval/tasks/ammlu/ammlu_world_religions.yaml b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_world_religions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..dc433e13d9da096bc16b3e64c1138bedc04b4813 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/ammlu/ammlu_world_religions.yaml @@ -0,0 +1,4 @@ +"dataset_name": "world_religions" +"description": "فم بعملية التقييم في مجال العلوم الانسانية \n\n" +"include": "_default_template_yaml" +"task": "ammlu_world_religions" diff --git a/lm-evaluation/lm_eval/tasks/benchmarks/flan/flan_held_out.yaml b/lm-evaluation/lm_eval/tasks/benchmarks/flan/flan_held_out.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cf806b882167dacc83e3baab67fe69d293de6ddc --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/benchmarks/flan/flan_held_out.yaml @@ -0,0 +1,13 @@ +group: flan_held_out +task: + # BBH + - bbh_zeroshot + - bbh_fewshot + - bbh_cot_fewshot + - bbh_cot_zeroshot + # MMLU + - mmlu + - mmlu_flan_n_shot_generative + - mmlu_flan_n_shot_loglikelihood + - mmlu_flan_cot_zeroshot + - mmlu_flan_cot_fewshot diff --git a/lm-evaluation/lm_eval/tasks/benchmarks/minerva_math.yaml b/lm-evaluation/lm_eval/tasks/benchmarks/minerva_math.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6df3203e10fddd06bd2edcfb97984c12a32466be --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/benchmarks/minerva_math.yaml @@ -0,0 +1,9 @@ +group: minerva_math +task: + - minerva_math_algebra + - minerva_math_counting_and_prob + - minerva_math_geometry + - minerva_math_intermediate_algebra + - minerva_math_num_theory + - minerva_math_prealgebra + - minerva_math_precalc diff --git a/lm-evaluation/lm_eval/tasks/benchmarks/openllm.yaml b/lm-evaluation/lm_eval/tasks/benchmarks/openllm.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0296a0a548e1206f70627b4176d79aab7438db75 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/benchmarks/openllm.yaml @@ -0,0 +1,18 @@ +group: openllm +group_alias: Open LLM Leaderboard +task: + - task: arc_challenge + fewshot_split: validation + num_fewshot: 25 + - task: hellaswag + fewshot_split: train + num_fewshot: 10 + - task: truthfulqa + num_fewshot: 0 + - task: mmlu + num_fewshot: 5 + - task: winogrande + fewshot_split: train + num_fewshot: 5 + - task: gsm8k + num_fewshot: 5 diff --git a/lm-evaluation/lm_eval/tasks/benchmarks/pythia.yaml b/lm-evaluation/lm_eval/tasks/benchmarks/pythia.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bdeadd3ce995ce3d4d9340082ede3bf424ba276d --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/benchmarks/pythia.yaml @@ -0,0 +1,12 @@ +group: pythia +task: + - lambada_openai + - logiqa + - piqa + - sciq + - wikitext + - winogrande + - wsc + - ai2_arc + - blimp + - mmlu diff --git a/lm-evaluation/lm_eval/tasks/benchmarks/t0_eval.yaml b/lm-evaluation/lm_eval/tasks/benchmarks/t0_eval.yaml new file mode 100644 index 0000000000000000000000000000000000000000..27e7adc41bd2eaffa20b3344cfdf83a52b4d65fc --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/benchmarks/t0_eval.yaml @@ -0,0 +1,127 @@ +group: t0_eval +task: + # Coreference Resolution + - dataset_path: super_glue + dataset_name: wsc.fixed + use_prompt: promptsource:* + training_split: train + validation_split: validation + output_type: generate_until + metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true + # Coreference Resolution + - dataset_path: winogrande + dataset_name: winogrande_xl + use_prompt: promptsource:* + training_split: train + validation_split: validation + output_type: generate_until + metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true + # Natural Language Inference + - dataset_path: super_glue + dataset_name: cb + use_prompt: promptsource:* + training_split: train + validation_split: validation + output_type: generate_until + metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true + - dataset_path: super_glue + dataset_name: rte + use_prompt: promptsource:* + training_split: train + validation_split: validation + output_type: generate_until + metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true + - task: anli_r1 + dataset_path: anli + use_prompt: promptsource:* + training_split: train_r1 + validation_split: dev_r1 + output_type: generate_until + metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true + - task: anli_r2 + dataset_path: anli + use_prompt: promptsource:* + training_split: train_r2 + validation_split: dev_r2 + output_type: generate_until + metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true + - task: anli_r3 + dataset_path: anli + use_prompt: promptsource:* + training_split: train_r3 + validation_split: dev_r3 + output_type: generate_until + metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true + # Sentence Completion + - dataset_path: super_glue + dataset_name: copa + use_prompt: promptsource:* + training_split: train + validation_split: validation + output_type: generate_until + metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true + # Natural Language Inference + - dataset_path: hellaswag + use_prompt: promptsource:* + training_split: train + validation_split: validation + output_type: generate_until + metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true + # Word Sense Disambiguation + - dataset_path: super_glue + dataset_name: wic + use_prompt: promptsource:* + training_split: train + validation_split: validation + output_type: generate_until + metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true diff --git a/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/go.yaml b/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/go.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7b40edc96c4ac87e4889895829a754ea2d9aa0d3 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/go.yaml @@ -0,0 +1,21 @@ +group: + - codexglue_code2text +task: code2text_go +dataset_path: CM/codexglue_code2text_go +training_split: train +validation_split: validation +test_split: test +output_type: generate_until +generation_kwargs: + num_beams: 10 + max_gen_toks: 128 + until: + - "" +doc_to_text: !function utils.doc_to_text +doc_to_target: !function utils.doc_to_target +metric_list: + - metric: !function bleu.smoothed_bleu_4 + aggregation: mean + higher_is_better: True +metadata: + version: 1.0 diff --git a/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/java.yaml b/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/java.yaml new file mode 100644 index 0000000000000000000000000000000000000000..65eb024d0fbc4a052558a938fb29db5058a5bb39 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/java.yaml @@ -0,0 +1,21 @@ +group: + - codexglue_code2text +task: code2text_java +dataset_path: CM/codexglue_code2text_java +training_split: train +validation_split: validation +test_split: test +output_type: generate_until +generation_kwargs: + num_beams: 10 + max_gen_toks: 128 + until: + - "" +doc_to_text: !function utils.doc_to_text +doc_to_target: !function utils.doc_to_target +metric_list: + - metric: !function bleu.smoothed_bleu_4 + aggregation: mean + higher_is_better: True +metadata: + version: 1.0 diff --git a/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/javascript.yaml b/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/javascript.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c5b288192b0c88a7a9fda139422204448ebce8ca --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/javascript.yaml @@ -0,0 +1,21 @@ +group: + - codexglue_code2text +task: code2text_javascript +dataset_path: CM/codexglue_code2text_javascript +training_split: train +validation_split: validation +test_split: test +output_type: generate_until +generation_kwargs: + num_beams: 10 + max_gen_toks: 128 + until: + - "" +doc_to_text: !function utils.doc_to_text +doc_to_target: !function utils.doc_to_target +metric_list: + - metric: !function bleu.smoothed_bleu_4 + aggregation: mean + higher_is_better: True +metadata: + version: 1.0 diff --git a/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/php.yaml b/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/php.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e368d7daacc98459b40a4bab6634299976a73c45 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/php.yaml @@ -0,0 +1,21 @@ +group: + - codexglue_code2text +task: code2text_php +dataset_path: CM/codexglue_code2text_php +training_split: train +validation_split: validation +test_split: test +output_type: generate_until +generation_kwargs: + num_beams: 10 + max_gen_toks: 128 + until: + - "" +doc_to_text: !function utils.doc_to_text +doc_to_target: !function utils.doc_to_target +metric_list: + - metric: !function bleu.smoothed_bleu_4 + aggregation: mean + higher_is_better: True +metadata: + version: 1.0 diff --git a/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/ruby.yaml b/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/ruby.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a89134c626eda6af05399cc1ed931b7b089b5409 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/ruby.yaml @@ -0,0 +1,21 @@ +group: + - codexglue_code2text +task: code2text_ruby +dataset_path: CM/codexglue_code2text_ruby +training_split: train +validation_split: validation +test_split: test +output_type: generate_until +generation_kwargs: + num_beams: 10 + max_gen_toks: 128 + until: + - "" +doc_to_text: !function utils.doc_to_text +doc_to_target: !function utils.doc_to_target +metric_list: + - metric: !function bleu.smoothed_bleu_4 + aggregation: mean + higher_is_better: True +metadata: + version: 3.0 diff --git a/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/utils.py b/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6975684259648ca5d6f71d28d65fef7ad73e0bae --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/code_x_glue/code-text/utils.py @@ -0,0 +1,12 @@ +def doc_to_text(doc): + inputs = " ".join(doc["code_tokens"]).replace("\n", " ") + inputs = " ".join(inputs.strip().split()) + + return inputs + + +def doc_to_target(doc): + targets = " ".join(doc["docstring_tokens"]).replace("\n", "") + targets = " ".join(targets.strip().split()) + + return targets diff --git a/lm-evaluation/lm_eval/tasks/lambada_cloze/lambada_openai_cloze.yaml b/lm-evaluation/lm_eval/tasks/lambada_cloze/lambada_openai_cloze.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d25e26d9efd926e79745c251cab1953dde1986bf --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/lambada_cloze/lambada_openai_cloze.yaml @@ -0,0 +1,20 @@ +group: + - lambada_cloze +task: lambada_openai_cloze_yaml +dataset_path: EleutherAI/lambada_openai +dataset_name: default +output_type: loglikelihood +test_split: test +doc_to_text: "{{text.split(' ')[:-1]|join(' ')}} ____. ->" +doc_to_target: "{{' '+text.split(' ')[-1]}}" +should_decontaminate: true +doc_to_decontamination_query: "{{text}}" +metric_list: + - metric: perplexity + aggregation: perplexity + higher_is_better: false + - metric: acc + aggregation: mean + higher_is_better: true +metadata: + version: 1.0 diff --git a/lm-evaluation/lm_eval/tasks/mgsm/direct/mgsm_direct_te.yaml b/lm-evaluation/lm_eval/tasks/mgsm/direct/mgsm_direct_te.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4abdc7e78ec0ddd597d1ff2210a3474ad397a30a --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/mgsm/direct/mgsm_direct_te.yaml @@ -0,0 +1,12 @@ +# Generated by utils.py +dataset_name: te +doc_to_target: '{% if answer is not none %}{{answer[19:]}}{% else %}{{answer_number|string}}{% endif %}' +doc_to_text: '{% if answer is not none %}{{question+"\nAnswer:"}}{% else %}{{"ప్రశ్న: "+question+"\nAnswer:"}}{% endif %}' +generation_kwargs: + do_sample: false + until: + - 'ప్రశ్న:' + - + - <|im_end|> +include: direct_yaml +task: mgsm_direct_te diff --git a/lm-evaluation/lm_eval/tasks/mgsm/native_cot/cot_yaml b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/cot_yaml new file mode 100644 index 0000000000000000000000000000000000000000..dbba882225b1d7c9fbe10352c64a381c97a547c7 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/cot_yaml @@ -0,0 +1,31 @@ +# This file will be included in the generated language-specific task configs. +# It doesn't have a yaml file extension as it is not meant to be imported directly +# by the harness. +group: mgsm_cot_native +dataset_path: juletxara/mgsm +dataset_name: null # Overridden by language-specific config. +output_type: generate_until +training_split: train +test_split: test +# target_delimiter: "" +generation_kwargs: + until: + - "\n\n" + - "\n" + do_sample: false + temperature: 0.0 +target_delimiter: " " +metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true + ignore_case: true + ignore_punctuation: true +filter_list: + - name: "get-answer" + filter: + - function: "regex" + regex_pattern: "The answer is (\\-?[0-9\\.\\,]+)" + - function: "take_first" +metadata: + version: 3.0 diff --git a/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_bn.yaml b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_bn.yaml new file mode 100644 index 0000000000000000000000000000000000000000..eb58c8753784c250ce24860fd21211b62ef0cc31 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_bn.yaml @@ -0,0 +1,24 @@ +# Generated by utils.py +dataset_name: bn +doc_to_target: '{% if answer is not none %}{{answer[17:]}}{% else %}{{answer_number|string}}{% endif %}' +doc_to_text: '{% if answer is not none %}{{question+"\nধাপে ধাপে উত্তর:"}}{% else %}{{"প্রশ্ন: "+question+"\nধাপে ধাপে উত্তর:"}}{% endif %}' +filter_list: +- filter: + - function: regex + regex_pattern: The answer is (\-?[0-9\.\,]+) + - function: take_first + name: strict-match +- filter: + - function: regex + group_select: -1 + regex_pattern: (-?[$0-9.,]{2,})|(-?[0-9]+) + - function: take_first + name: flexible-extract +generation_kwargs: + do_sample: false + until: + - 'প্রশ্ন:' + - + - <|im_end|> +include: cot_yaml +task: mgsm_native_cot_bn diff --git a/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_de.yaml b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_de.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4f4701796945b74fe884a73d931debdf2c7b5ce9 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_de.yaml @@ -0,0 +1,24 @@ +# Generated by utils.py +dataset_name: de +doc_to_target: '{% if answer is not none %}{{answer[29:]}}{% else %}{{answer_number|string}}{% endif %}' +doc_to_text: '{% if answer is not none %}{{question+"\nSchritt-für-Schritt-Antwort:"}}{% else %}{{"Frage: "+question+"\nSchritt-für-Schritt-Antwort:"}}{% endif %}' +filter_list: +- filter: + - function: regex + regex_pattern: Die Antwort lautet (\-?[0-9\.\,]+) + - function: take_first + name: strict-match +- filter: + - function: regex + group_select: -1 + regex_pattern: (-?[$0-9.,]{2,})|(-?[0-9]+) + - function: take_first + name: flexible-extract +generation_kwargs: + do_sample: false + until: + - 'Frage:' + - + - <|im_end|> +include: cot_yaml +task: mgsm_native_cot_de diff --git a/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_en.yaml b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_en.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c2033b335fb51ec1310f98b4e905f18231c1b68a --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_en.yaml @@ -0,0 +1,24 @@ +# Generated by utils.py +dataset_name: en +doc_to_target: '{% if answer is not none %}{{answer[21:]}}{% else %}{{answer_number|string}}{% endif %}' +doc_to_text: '{% if answer is not none %}{{question+"\nStep-by-Step Answer:"}}{% else %}{{"Question: "+question+"\nStep-by-Step Answer:"}}{% endif %}' +filter_list: +- filter: + - function: regex + regex_pattern: The answer is (\-?[0-9\.\,]+) + - function: take_first + name: strict-match +- filter: + - function: regex + group_select: -1 + regex_pattern: (-?[$0-9.,]{2,})|(-?[0-9]+) + - function: take_first + name: flexible-extract +generation_kwargs: + do_sample: false + until: + - 'Question:' + - + - <|im_end|> +include: cot_yaml +task: mgsm_native_cot_en diff --git a/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_es.yaml b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_es.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6c39fb9c4740ac571db8165a80fdd7efa108f56b --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_es.yaml @@ -0,0 +1,24 @@ +# Generated by utils.py +dataset_name: es +doc_to_target: '{% if answer is not none %}{{answer[23:]}}{% else %}{{answer_number|string}}{% endif %}' +doc_to_text: '{% if answer is not none %}{{question+"\nRespuesta paso a paso:"}}{% else %}{{"Pregunta: "+question+"\nRespuesta paso a paso:"}}{% endif %}' +filter_list: +- filter: + - function: regex + regex_pattern: La respuesta es (\-?[0-9\.\,]+) + - function: take_first + name: strict-match +- filter: + - function: regex + group_select: -1 + regex_pattern: (-?[$0-9.,]{2,})|(-?[0-9]+) + - function: take_first + name: flexible-extract +generation_kwargs: + do_sample: false + until: + - 'Pregunta:' + - + - <|im_end|> +include: cot_yaml +task: mgsm_native_cot_es diff --git a/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_fr.yaml b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_fr.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b52b881f7a3f8b30d64ce8eb8ee6b308673626c2 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_fr.yaml @@ -0,0 +1,24 @@ +# Generated by utils.py +dataset_name: fr +doc_to_target: '{% if answer is not none %}{{answer[26:]}}{% else %}{{answer_number|string}}{% endif %}' +doc_to_text: '{% if answer is not none %}{{question+"\nRéponse étape par étape :"}}{% else %}{{"Question : "+question+"\nRéponse étape par étape :"}}{% endif %}' +filter_list: +- filter: + - function: regex + regex_pattern: La réponse est (\-?[0-9\.\,]+) + - function: take_first + name: strict-match +- filter: + - function: regex + group_select: -1 + regex_pattern: (-?[$0-9.,]{2,})|(-?[0-9]+) + - function: take_first + name: flexible-extract +generation_kwargs: + do_sample: false + until: + - 'Question :' + - + - <|im_end|> +include: cot_yaml +task: mgsm_native_cot_fr diff --git a/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_ja.yaml b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_ja.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8e56bd0b15150e1e435b4d304255c0a751246e86 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_ja.yaml @@ -0,0 +1,24 @@ +# Generated by utils.py +dataset_name: ja +doc_to_target: '{% if answer is not none %}{{answer[11:]}}{% else %}{{answer_number|string}}{% endif %}' +doc_to_text: '{% if answer is not none %}{{question+"\nステップごとの答え:"}}{% else %}{{"問題: "+question+"\nステップごとの答え:"}}{% endif %}' +filter_list: +- filter: + - function: regex + regex_pattern: 答えは(\-?[0-9\.\,]+)です。 + - function: take_first + name: strict-match +- filter: + - function: regex + group_select: -1 + regex_pattern: (-?[$0-9.,]{2,})|(-?[0-9]+) + - function: take_first + name: flexible-extract +generation_kwargs: + do_sample: false + until: + - '問題:' + - + - <|im_end|> +include: cot_yaml +task: mgsm_native_cot_ja diff --git a/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_ru.yaml b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_ru.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3cff6267a067da1e9d10cfa66aaad7c06618f7ad --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_ru.yaml @@ -0,0 +1,24 @@ +# Generated by utils.py +dataset_name: ru +doc_to_target: '{% if answer is not none %}{{answer[18:]}}{% else %}{{answer_number|string}}{% endif %}' +doc_to_text: '{% if answer is not none %}{{question+"\nПошаговоерешение:"}}{% else %}{{"Задача: "+question+"\nПошаговоерешение:"}}{% endif %}' +filter_list: +- filter: + - function: regex + regex_pattern: Ответ — (\-?[0-9\.\,]+) + - function: take_first + name: strict-match +- filter: + - function: regex + group_select: -1 + regex_pattern: (-?[$0-9.,]{2,})|(-?[0-9]+) + - function: take_first + name: flexible-extract +generation_kwargs: + do_sample: false + until: + - 'Задача:' + - + - <|im_end|> +include: cot_yaml +task: mgsm_native_cot_ru diff --git a/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_sw.yaml b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_sw.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4da793dbc78485cb8167a6fc069b87f7590c960f --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_sw.yaml @@ -0,0 +1,24 @@ +# Generated by utils.py +dataset_name: sw +doc_to_target: '{% if answer is not none %}{{answer[25:]}}{% else %}{{answer_number|string}}{% endif %}' +doc_to_text: '{% if answer is not none %}{{question+"\nJibu la Hatua kwa Hatua:"}}{% else %}{{"Swali: "+question+"\nJibu la Hatua kwa Hatua:"}}{% endif %}' +filter_list: +- filter: + - function: regex + regex_pattern: Jibu ni (\-?[0-9\.\,]+) + - function: take_first + name: strict-match +- filter: + - function: regex + group_select: -1 + regex_pattern: (-?[$0-9.,]{2,})|(-?[0-9]+) + - function: take_first + name: flexible-extract +generation_kwargs: + do_sample: false + until: + - 'Swali:' + - + - <|im_end|> +include: cot_yaml +task: mgsm_native_cot_sw diff --git a/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_te.yaml b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_te.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1cdbaca8893b6ee626084135c7a64ccd02737b81 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_te.yaml @@ -0,0 +1,24 @@ +# Generated by utils.py +dataset_name: te +doc_to_target: '{% if answer is not none %}{{answer[19:]}}{% else %}{{answer_number|string}}{% endif %}' +doc_to_text: '{% if answer is not none %}{{question+"\nదశలవారీగా సమాధానం:"}}{% else %}{{"ప్రశ్న: "+question+"\nదశలవారీగా సమాధానం:"}}{% endif %}' +filter_list: +- filter: + - function: regex + regex_pattern: సమాధానం (\-?[0-9\.\,]+) + - function: take_first + name: strict-match +- filter: + - function: regex + group_select: -1 + regex_pattern: (-?[$0-9.,]{2,})|(-?[0-9]+) + - function: take_first + name: flexible-extract +generation_kwargs: + do_sample: false + until: + - 'ప్రశ్న:' + - + - <|im_end|> +include: cot_yaml +task: mgsm_native_cot_te diff --git a/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_th.yaml b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_th.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6931d3a2ff44ab0de25a31a7624f2cd104c655c2 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_th.yaml @@ -0,0 +1,24 @@ +# Generated by utils.py +dataset_name: th +doc_to_target: '{% if answer is not none %}{{answer[18:]}}{% else %}{{answer_number|string}}{% endif %}' +doc_to_text: '{% if answer is not none %}{{question+"\nคำตอบทีละขั้นตอน:"}}{% else %}{{"โจทย์: "+question+"\nคำตอบทีละขั้นตอน:"}}{% endif %}' +filter_list: +- filter: + - function: regex + regex_pattern: คำตอบคือ (\-?[0-9\.\,]+) + - function: take_first + name: strict-match +- filter: + - function: regex + group_select: -1 + regex_pattern: (-?[$0-9.,]{2,})|(-?[0-9]+) + - function: take_first + name: flexible-extract +generation_kwargs: + do_sample: false + until: + - 'โจทย์:' + - + - <|im_end|> +include: cot_yaml +task: mgsm_native_cot_th diff --git a/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_zh.yaml b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_zh.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3f0d7e2dcecaecee05671a636b0a3e27eeeee95e --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/mgsm/native_cot/mgsm_native_cot_zh.yaml @@ -0,0 +1,24 @@ +# Generated by utils.py +dataset_name: zh +doc_to_target: '{% if answer is not none %}{{answer[6:]}}{% else %}{{answer_number|string}}{% endif %}' +doc_to_text: '{% if answer is not none %}{{question+"\n逐步解答:"}}{% else %}{{"问题: "+question+"\n逐步解答:"}}{% endif %}' +filter_list: +- filter: + - function: regex + regex_pattern: 答案是 (\-?[0-9\.\,]+)。 + - function: take_first + name: strict-match +- filter: + - function: regex + group_select: -1 + regex_pattern: (-?[$0-9.,]{2,})|(-?[0-9]+) + - function: take_first + name: flexible-extract +generation_kwargs: + do_sample: false + until: + - '问题:' + - + - <|im_end|> +include: cot_yaml +task: mgsm_native_cot_zh diff --git a/lm-evaluation/lm_eval/tasks/pubmedqa/README.md b/lm-evaluation/lm_eval/tasks/pubmedqa/README.md new file mode 100644 index 0000000000000000000000000000000000000000..c738dd2af65eecaee764cbeaf6a74aea308a0547 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/pubmedqa/README.md @@ -0,0 +1,56 @@ +# PubMedQA + +### Paper + +Title: `PubMedQA: A Dataset for Biomedical Research Question Answering` + +Abstract: https://arxiv.org/abs/1909.06146 + +PubMedQA is a novel biomedical question answering (QA) dataset collected from +PubMed abstracts. The task of PubMedQA is to answer research questions with +yes/no/maybe (e.g.: Do preoperative statins reduce atrial fibrillation after +coronary artery bypass grafting?) using the corresponding abstracts. PubMedQA +has 1k expert-annotated, 61.2k unlabeled and 211.3k artificially generated QA +instances. Each PubMedQA instance is composed of (1) a question which is either +an existing research article title or derived from one, (2) a context which is +the corresponding abstract without its conclusion, (3) a long answer, which is +the conclusion of the abstract and, presumably, answers the research question, +and (4) a yes/no/maybe answer which summarizes the conclusion. + +Homepage: https://pubmedqa.github.io/ + + +### Citation + +``` +@inproceedings{jin2019pubmedqa, + title={PubMedQA: A Dataset for Biomedical Research Question Answering}, + author={Jin, Qiao and Dhingra, Bhuwan and Liu, Zhengping and Cohen, William and Lu, Xinghua}, + booktitle={Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP)}, + pages={2567--2577}, + year={2019} +} +``` + +### Groups and Tasks + +#### Groups + +* Not part of a group yet + +#### Tasks + +* `pubmed_qa` + +### Checklist + +For adding novel benchmarks/datasets to the library: +* [ ] Is the task an existing benchmark in the literature? + * [ ] Have you referenced the original paper that introduced the task? + * [ ] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test? + + +If other tasks on this dataset are already supported: +* [ ] Is the "Main" variant of this task clearly denoted? +* [ ] Have you provided a short sentence in a README on what each new variant adds / evaluates? +* [ ] Have you noted which, if any, published evaluation setups are matched by this variant? diff --git a/lm-evaluation/lm_eval/tasks/pubmedqa/pubmedqa.yaml b/lm-evaluation/lm_eval/tasks/pubmedqa/pubmedqa.yaml new file mode 100644 index 0000000000000000000000000000000000000000..47de2fa0980a0a45facbab4416c80373e91e08d5 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/pubmedqa/pubmedqa.yaml @@ -0,0 +1,16 @@ +task: pubmedqa +dataset_path: bigbio/pubmed_qa +dataset_name: pubmed_qa_labeled_fold0_source +output_type: multiple_choice +training_split: train +validation_split: validation +test_split: test +doc_to_text: !function preprocess_pubmedqa.doc_to_text +doc_to_target: final_decision +doc_to_choice: ["yes", "no", "maybe"] +metric_list: + - metric: acc + aggregation: mean + higher_is_better: true +metadata: + version: 1.0 diff --git a/lm-evaluation/lm_eval/tasks/qasper/README.md b/lm-evaluation/lm_eval/tasks/qasper/README.md new file mode 100644 index 0000000000000000000000000000000000000000..ada111e1ca7b0df493182939960559bdeb96b9f2 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/qasper/README.md @@ -0,0 +1,63 @@ +# QASPER + +### Paper + +Title: `A Dataset of Information-Seeking Questions and Answers Anchored in Research Papers` + +Abstract: https://arxiv.org/abs/2105.03011 + +QASPER is a dataset of 5,049 questions over 1,585 Natural Language Processing papers. +Each question is written by an NLP practitioner who read only the title and abstract +of the corresponding paper, and the question seeks information present in the full +text. The questions are then answered by a separate set of NLP practitioners who also +provide supporting evidence to answers. + +Homepage: https://allenai.org/data/qasper + +### Citation + +``` +@article{DBLP:journals/corr/abs-2105-03011, + author = {Pradeep Dasigi and + Kyle Lo and + Iz Beltagy and + Arman Cohan and + Noah A. Smith and + Matt Gardner}, + title = {A Dataset of Information-Seeking Questions and Answers Anchored in + Research Papers}, + journal = {CoRR}, + volume = {abs/2105.03011}, + year = {2021}, + url = {https://arxiv.org/abs/2105.03011}, + eprinttype = {arXiv}, + eprint = {2105.03011}, + timestamp = {Fri, 14 May 2021 12:13:30 +0200}, + biburl = {https://dblp.org/rec/journals/corr/abs-2105-03011.bib}, + bibsource = {dblp computer science bibliography, https://dblp.org} +} +``` + +### Groups and Tasks + +#### Groups + +* `qasper`: executes both `qasper_bool` and `qasper_freeform` + +#### Tasks + +* `qasper_bool`: Multiple choice task that evaluates the task with `answer_type="bool"` +* `qasper_freeform`: Greedy generation task that evaluates the samples from the task with `answer_type="free form answer"` + +### Checklist + +For adding novel benchmarks/datasets to the library: +* [ ] Is the task an existing benchmark in the literature? + * [ ] Have you referenced the original paper that introduced the task? + * [ ] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test? + + +If other tasks on this dataset are already supported: +* [ ] Is the "Main" variant of this task clearly denoted? +* [ ] Have you provided a short sentence in a README on what each new variant adds / evaluates? +* [ ] Have you noted which, if any, published evaluation setups are matched by this variant? diff --git a/lm-evaluation/lm_eval/tasks/qasper/bool.yaml b/lm-evaluation/lm_eval/tasks/qasper/bool.yaml new file mode 100644 index 0000000000000000000000000000000000000000..17d3f1be983043ac2ca93038ed29e94c90028592 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/qasper/bool.yaml @@ -0,0 +1,14 @@ +group: qasper +task: qasper_bool +dataset_path: allenai/qasper +output_type: multiple_choice +training_split: train +validation_split: validation +process_docs: !function utils.process_docs_bool +doc_to_text: "TITLE: {{title}}\nABSTRACT: {{abstract}}\n\nQ: {{question}}\n\nA:" +doc_to_target: 1 +doc_to_choice: ["no", "yes"] +metric_list: + - metric: f1 +metadata: + version: 1.0 diff --git a/lm-evaluation/lm_eval/tasks/qasper/freeform.yaml b/lm-evaluation/lm_eval/tasks/qasper/freeform.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ed7a4bc47274f09eb0f52df04723a011e2db13f0 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/qasper/freeform.yaml @@ -0,0 +1,18 @@ +group: qasper +task: qasper_freeform +dataset_path: allenai/qasper +output_type: generate_until +training_split: train +validation_split: validation +process_docs: !function utils.process_docs_freeform +doc_to_text: "TITLE: {{title}}\nABSTRACT: {{abstract}}\n\nQ: {{question}}\n\nA:" +doc_to_target: answer +generation_kwargs: + until: + - "\n" +metric_list: + - metric: !function metrics.f1_abstractive + aggregation: mean + higher_is_better: true +metadata: + version: 2.0 diff --git a/lm-evaluation/lm_eval/tasks/qasper/metrics.py b/lm-evaluation/lm_eval/tasks/qasper/metrics.py new file mode 100644 index 0000000000000000000000000000000000000000..cc832912250ae45a4637daaac3f278d0da654ce1 --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/qasper/metrics.py @@ -0,0 +1,41 @@ +import re +import string +from collections import Counter + + +def normalize_answer(s): + """ + Taken from the official evaluation script for v1.1 of the SQuAD dataset. + Lower text and remove punctuation, articles and extra whitespace. + """ + + def remove_articles(text): + return re.sub(r"\b(a|an|the)\b", " ", text) + + def white_space_fix(text): + return " ".join(text.split()) + + def remove_punc(text): + exclude = set(string.punctuation) + return "".join(ch for ch in text if ch not in exclude) + + def lower(text): + return text.lower() + + return white_space_fix(remove_articles(remove_punc(lower(s)))) + + +def f1_abstractive(predictions, references): + """ + Taken from the official evaluation script for v1.1 of the SQuAD dataset. + """ + prediction_tokens = normalize_answer(predictions[0]).split() + references_tokens = normalize_answer(references[0]).split() + common = Counter(prediction_tokens) & Counter(references_tokens) + num_same = sum(common.values()) + if num_same == 0: + return 0 + precision = 1.0 * num_same / len(prediction_tokens) + recall = 1.0 * num_same / len(references_tokens) + f1 = (2 * precision * recall) / (precision + recall) + return f1 diff --git a/lm-evaluation/lm_eval/tasks/qasper/utils.py b/lm-evaluation/lm_eval/tasks/qasper/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..fb3d4c55cf7e16a1d2c527510b8ae48d0d3b05fa --- /dev/null +++ b/lm-evaluation/lm_eval/tasks/qasper/utils.py @@ -0,0 +1,72 @@ +from functools import partial + +from datasets import Dataset + + +def process_docs(dataset, set_answer_type="bool"): + FEATURES = ["title", "abstract", "question", "answer", "answer_type"] + + def _categorise_answer(answer_blob): + if answer_blob["unanswerable"]: + answer = "unanswerable" + answer_type = "unanswerable" + return answer, answer_type + elif answer_blob["yes_no"]: + answer = "yes" + answer_type = "bool" + return answer, answer_type + elif answer_blob["free_form_answer"]: + answer = answer_blob["free_form_answer"] + answer_type = "free form answer" + return answer, answer_type + elif answer_blob["extractive_spans"]: + answer = answer_blob["extractive_spans"] + answer_type = "extractive_spans" + return answer, answer_type + elif answer_blob["yes_no"] is False: + answer = "no" + answer_type = "bool" + return answer, answer_type + + def _flatten(doc): + """Given a `doc`, flatten it out so that each JSON blob + contains exactly one question and one answer. Logic taken from + the reference implementation available at + https://github.com/allenai/qasper-led-baseline/blob/main/scripts/evaluator.py + """ + obs_list = { + "title": [], + "abstract": [], + "question": [], + "answer": [], + "answer_type": [], + } + title = doc.pop("title") + abstract = doc.pop("abstract") + for question, answer_list in zip(doc["qas"]["question"], doc["qas"]["answers"]): + for answer_blob in answer_list["answer"]: + answer, answer_type = _categorise_answer(answer_blob) + if answer_type == set_answer_type: + obs_list["title"].append(title) + obs_list["abstract"].append(abstract) + obs_list["question"].append(question) + obs_list["answer_type"].append(answer_type) + if isinstance(answer, list): + answer = ", ".join(answer) + obs_list["answer"].append(answer) + + return obs_list + + dataset = dataset.map( + _flatten, + remove_columns=[key for key in dataset.features.keys() if key not in FEATURES], + ) + new_dataset = {} + for key in dataset.features.keys(): + new_dataset[key] = [x for row in dataset[key] for x in row] + + return Dataset.from_dict(new_dataset) + + +process_docs_bool = partial(process_docs, set_answer_type="bool") +process_docs_freeform = partial(process_docs, set_answer_type="free form answer")