"docs/archive_en_US/Tuner/HyperoptTuner.md" did not exist on "86a27f41d31a4d239a7e5a7f68f802a134936204"
test_description.py 1.5 KB
Newer Older
Jonathan Tow's avatar
Jonathan Tow committed
1
import random
2

Jonathan Tow's avatar
Jonathan Tow committed
3
import lm_eval.models
4
import lm_eval.tasks
Jonathan Tow's avatar
Jonathan Tow committed
5
6


haileyschoelkopf's avatar
haileyschoelkopf committed
7
def test_description():
Jonathan Tow's avatar
Jonathan Tow committed
8
9
    seed = 42
    num_examples = 1
10
    task_names = ["arc_challenge", "arc_easy"]
Jonathan Tow's avatar
Jonathan Tow committed
11
    description_dict = {
haileyschoelkopf's avatar
haileyschoelkopf committed
12
13
        "arc_challenge": "Label for the relevant action:\nSentences describing context, with an incomplete sentence trailing answer that plausibly completes the situation.",
        "lambada": "Winograd schema sentence including a either a ___ blank with a missing word, making the pronoun ambiguous, or the same with the word filled in.",
Jonathan Tow's avatar
Jonathan Tow committed
14
15
16
17
    }

    task_dict = lm_eval.tasks.get_task_dict(task_names)
    for task_name, task in task_dict.items():
haileyschoelkopf's avatar
haileyschoelkopf committed
18
19
20
        # patch description field in task (# TODO: make this much more cleaned up)
        task._config.description = description_dict[task_name]

Jonathan Tow's avatar
Jonathan Tow committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
        rnd = random.Random()
        rnd.seed(seed)

        if task.has_training_docs():
            docs = task.training_docs()
        elif set == "val" and task.has_validation_docs():
            docs = task.validation_docs()
        elif set == "test" and task.has_test_docs():
            docs = task.test_docs()

        description = (
            description_dict[task_name]
            if description_dict and task_name in description_dict
            else ""
        )

        for _, doc in (
Jonathan Tow's avatar
Jonathan Tow committed
38
            zip(range(num_examples), docs) if num_examples > 0 else enumerate(docs)
Jonathan Tow's avatar
Jonathan Tow committed
39
40
41
42
43
44
        ):
            ctx = task.fewshot_context(
                doc=doc,
                num_fewshot=1,
            )
            assert description in ctx