piqa.py 769 Bytes
Newer Older
Jonathan Tow's avatar
Jonathan Tow committed
1
import numpy as np
Leo Gao's avatar
Leo Gao committed
2
from lm_eval.base import MultipleChoiceTask, rf
&'s avatar
& committed
3
from ..metrics import mean
Leo Gao's avatar
Leo Gao committed
4
from . common import HFTask
5
from lm_eval.mctask_experimental import MultipleChoiceDoc
Anish Thite's avatar
Anish Thite committed
6

Jonathan Tow's avatar
Jonathan Tow committed
7

Leo Gao's avatar
Leo Gao committed
8
class PiQA(HFTask, MultipleChoiceTask):
Leo Gao's avatar
Leo Gao committed
9
    VERSION = 0
Jonathan Tow's avatar
Jonathan Tow committed
10
11
    DATASET_PATH = "piqa"
    DATASET_NAME = None
Anish Thite's avatar
Anish Thite committed
12
13
14
15
16
17
18
19

    def has_training_docs(self):
        return True

    def has_validation_docs(self):
        return True

    def has_test_docs(self):
Leo Gao's avatar
Leo Gao committed
20
        return False
Anish Thite's avatar
Anish Thite committed
21

Leo Gao's avatar
Leo Gao committed
22
    def _convert_standard(self, doc):
23
24
25
26
27
28
29
30
31
32
33
34
        keys = ['0', '1']
        question = doc["goal"]
        options = [doc["sol1"], doc["sol2"]]
        gold = doc["label"]
        return MultipleChoiceDoc(
            question=question,
            keys=keys,
            options=options,
            gold=gold
        )