applied-ai-018's picture
Add files using upload-large-folder tool
10d53d8 verified
"""
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='"',
)