piqa.py 1.42 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""
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/

@inproceedings{Bisk2020,
  author = {Yonatan Bisk and Rowan Zellers and
            Ronan Le Bras and Jianfeng Gao
            and Yejin Choi},
  title = {PIQA: Reasoning about Physical Commonsense in
           Natural Language},
  booktitle = {Thirty-Fourth AAAI Conference on
               Artificial Intelligence},
  year = {2020},
}
"""
Jonathan Tow's avatar
Jonathan Tow committed
23
import numpy as np
Leo Gao's avatar
Leo Gao committed
24
from lm_eval.base import MultipleChoiceTask, rf
&'s avatar
& committed
25
from ..metrics import mean
Leo Gao's avatar
Leo Gao committed
26
from . common import HFTask
Anish Thite's avatar
Anish Thite committed
27

Jonathan Tow's avatar
Jonathan Tow committed
28

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

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

Leo Gao's avatar
Leo Gao committed
43
44
45
46
47
48
49
    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
50

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