peacock-data-public-datasets-idc-cronscript
/
lm-evaluation-harness
/lm_eval
/tasks
/ammlu
/_generate_configs.py
""" | |
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='"', | |
) | |