headqa.py 796 Bytes
Newer Older
1
from . common import HFTask
2
from lm_eval.base import MultipleChoiceTask
3

4
5

class HeadQA(HFTask, MultipleChoiceTask):
Leo Gao's avatar
Leo Gao committed
6
    VERSION = 0
7
8
9
10
11
12
13
14
15
16
17
18
    DATASET_PATH = "head_qa"
    DATASET_NAME = None

    def has_training_docs(self):
        return True

    def has_validation_docs(self):
        return True

    def has_test_docs(self):
        return True

19
20
21
22
23
24
25
26
    def _convert_standard(self, doc):
        out_doc = {
            "id": doc["qid"],
            "query": "Question: " + doc["qtext"] + "\nAnswer:",
            "choices": [answer["atext"] for answer in doc["answers"]],
            "gold": int(doc["ra"]) - 1,
        }
        return out_doc
27

28
29
30
    def fewshot_description(self):
        # TODO: figure out description
        return ""
31

32
33
    def doc_to_text(self, doc):
        return doc["query"]