piqa.py 1.45 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
"""
PIQA: Reasoning about Physical Commonsense in Natural Language
https://arxiv.org/pdf/1911.11641.pdf

Physical Interaction: Question Answering (PIQA) is a physical commonsense
reasoning and a corresponding benchmark dataset. PIQA was designed to investigate
the physical knowledge of existing models. To what extent are current approaches
actually learning about the world? 

Homepage: https://yonatanbisk.com/piqa/
11
12
13
14
15
"""
import numpy as np
from lm_eval.base import MultipleChoiceTask, rf
from ..metrics import mean
from . common import HFTask
16

17
18

_CITATION = """
19
@inproceedings{Bisk2020,
20
    author = {Yonatan Bisk and Rowan Zellers and
21
22
            Ronan Le Bras and Jianfeng Gao
            and Yejin Choi},
23
    title = {PIQA: Reasoning about Physical Commonsense in
24
           Natural Language},
25
    booktitle = {Thirty-Fourth AAAI Conference on
26
               Artificial Intelligence},
27
    year = {2020},
28
29
}
"""
Anish Thite's avatar
Anish Thite committed
30

Jonathan Tow's avatar
Jonathan Tow committed
31

Leo Gao's avatar
Leo Gao committed
32
class PiQA(HFTask, MultipleChoiceTask):
Leo Gao's avatar
Leo Gao committed
33
    VERSION = 0
Jonathan Tow's avatar
Jonathan Tow committed
34
35
    DATASET_PATH = "piqa"
    DATASET_NAME = None
Anish Thite's avatar
Anish Thite committed
36
37
38
39
40
41
42
43

    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
44
        return False
Anish Thite's avatar
Anish Thite committed
45

Leo Gao's avatar
Leo Gao committed
46
47
48
49
50
51
52
    def _convert_standard(self, doc):
        out_doc = {
            "goal": doc["goal"],
            "choices": [doc["sol1"], doc["sol2"]],
            "gold": doc["label"],
        }
        return out_doc
Anish Thite's avatar
Anish Thite committed
53

Leo Gao's avatar
Leo Gao committed
54
55
    def doc_to_text(self, doc):
        return "Question: " + doc["goal"] + "\nAnswer:"