webqs.py 1 KB
Newer Older
Leo Gao's avatar
Leo Gao committed
1
2
# REMINDER: this code needs to be rewritten for the new framework. Remove this comment when the code is fully converted.

3
from . common import HFTask
Leo Gao's avatar
Leo Gao committed
4

5
class WebQs(HFTask):
Leo Gao's avatar
Leo Gao committed
6
7
    DATASET_PATH = "web_questions"
    DATASET_NAME = None
Leo Gao's avatar
Leo Gao committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

    def has_training_docs(self):
        return True

    def has_validation_docs(self):
        return False

    def has_test_docs(self):
        return True

    def fewshot_description(self):
        # TODO: figure out description
        return ""

    def doc_to_text(self, doc, include_target=True):
        print(doc)
Leo Gao's avatar
Leo Gao committed
24
        q = "Q: " + doc['question'] + '\n'
Leo Gao's avatar
Leo Gao committed
25
26
27
28

        # this picks one answer to be the "correct" one, despite sometimes 
        # multiple correct answers being possible.
        # TODO: make sure we're actually handling multi-answer correctly
Leo Gao's avatar
Leo Gao committed
29
        a = "A:" + ((" " + doc['answers'][0]) if include_target else '')
Leo Gao's avatar
Leo Gao committed
30
31
32
33
34
        return q + a

    def evaluate(self, docs, lm, provide_description, num_fewshot):
        # TODO: implement
        raise NotImplementedError()