"official/colab/fine_tuning_bert.ipynb" did not exist on "d305396de02f488470eabc58c360824dafbadd55"
webqs.py 1.14 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

    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 ""

22
    def doc_to_text(self, doc):
Leo Gao's avatar
Leo Gao committed
23
        print(doc)
24
        return "Q: " + doc['question'] + '\nA:'
Leo Gao's avatar
Leo Gao committed
25

26
    def doc_to_target(self, doc):
Leo Gao's avatar
Leo Gao committed
27
28
29
        # 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
30
        return " " + doc['answers'][0]
Leo Gao's avatar
Leo Gao committed
31

32
33
34
35
36
    # TODO: Implement evaluation code

    # ***IMPORTANT***: this evaluation function needs to be written for the new framework. 
    # For more info, check out the interface in base.py and the example BoolQ implementation in superglue.py. 
    # Remove this comment when the evaluation code is implemented.