"configs/models/vicuna/hf_vicuna_13b_v15_16k.py" did not exist on "5f2e7c3469a1b4d13c84cbd0e20d6141a3165348"
_generate_configs.py 1.83 KB
Newer Older
ManuelFay's avatar
ManuelFay committed
1
2
3
4
5
6
7
8
9
10
"""
Take in a YAML, and output all other splits with this YAML
"""
import os
import yaml
import argparse
import requests

from tqdm import tqdm

James A. Michaelov's avatar
James A. Michaelov committed
11
from lm_eval.utils import logging
ManuelFay's avatar
ManuelFay committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

API_URL = "https://datasets-server.huggingface.co/splits?dataset=facebook/belebele"


def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument("--base_yaml_path", required=True)
    parser.add_argument("--save_prefix_path", default="belebele")
    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) as f:
        base_yaml = yaml.full_load(f)

    if args.cot_prompt_path is not None:
        import json

        with open(args.cot_prompt_path) as f:
            cot_file = json.load(f)

    def query():
        response = requests.get(API_URL)
        return response.json()["splits"]
James A. Michaelov's avatar
James A. Michaelov committed
42
43
    print(query())
    languages = [split["split"] for split in query()]
ManuelFay's avatar
ManuelFay committed
44
45
46
47

    for lang in tqdm(languages):
        yaml_dict = {
            "include": base_yaml_name,
ManuelFay's avatar
ManuelFay committed
48
            "task": f"belebele_{args.task_prefix}_{lang}"
ManuelFay's avatar
ManuelFay committed
49
50
            if args.task_prefix != ""
            else f"belebele_{lang}",
James A. Michaelov's avatar
James A. Michaelov committed
51
52
            "test_split": lang,
            "fewshot_split":lang,
ManuelFay's avatar
ManuelFay committed
53
54
55
        }

        file_save_path = args.save_prefix_path + f"_{lang}.yaml"
James A. Michaelov's avatar
James A. Michaelov committed
56
        logging.info(f"Saving yaml for subset {lang} to {file_save_path}")
ManuelFay's avatar
ManuelFay committed
57
58
59
60
61
62
63
64
        with open(file_save_path, "w") as yaml_file:
            yaml.dump(
                yaml_dict,
                yaml_file,
                width=float("inf"),
                allow_unicode=True,
                default_style='"',
            )