gem_webnlg.py 3.79 KB
Newer Older
jordiclive's avatar
jordiclive committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"""
The 2020 Bilingual, Bi-Directional WebNLG+ Shared Task:
Overview and Evaluation Results (WebNLG+ 2020)
https://aclanthology.org/2020.webnlg-1.7/

WebNLG+ offers two challenges: (i) mapping sets of RDF triples
to English or Russian text (generation) and (ii) converting
English or Russian text to sets of RDF triples (semantic parsing).
Compared to the eponymous WebNLG challenge, WebNLG+ provides an
extended dataset that enable the training, evaluation, and
comparison of microplanners and semantic parsers. In this paper,
we present the results of the generation and semantic parsing
task for both English and Russian and provide a brief
description of the participating systems.
"""
jordiclive's avatar
webnlg  
jordiclive committed
16
17
18
from lm_eval.base import PromptSourceTask


jordiclive's avatar
jordiclive committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
_CITATION = """
@inproceedings{castro-ferreira-etal-2020-2020,
    title = "The 2020 Bilingual, Bi-Directional {W}eb{NLG}+ Shared Task: Overview and Evaluation Results ({W}eb{NLG}+ 2020)",
    author = "Castro Ferreira, Thiago  and
      Gardent, Claire  and
      Ilinykh, Nikolai  and
      van der Lee, Chris  and
      Mille, Simon  and
      Moussallem, Diego  and
      Shimorina, Anastasia",
    booktitle = "Proceedings of the 3rd International Workshop on Natural Language Generation from the Semantic Web (WebNLG+)",
    month = "12",
    year = "2020",
    address = "Dublin, Ireland (Virtual)",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2020.webnlg-1.7",
    pages = "55--76",
    abstract = "WebNLG+ offers two challenges: (i) mapping sets of RDF triples to English or Russian text (generation) and (ii) converting English or Russian text to sets of RDF triples (semantic parsing). Compared to the eponymous WebNLG challenge, WebNLG+ provides an extended dataset that enable the training, evaluation, and comparison of microplanners and semantic parsers. In this paper, we present the results of the generation and semantic parsing task for both English and Russian and provide a brief description of the participating systems.",
}
"""


jordiclive's avatar
webnlg  
jordiclive committed
41
42
43
44
class WebNLG(PromptSourceTask):
    VERSION = 0
    DATASET_PATH = "GEM/web_nlg"
    DATASET_NAME = "en"
jordiclive's avatar
jordiclive committed
45
    SPLIT = None
jordiclive's avatar
webnlg  
jordiclive committed
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

    def has_training_docs(self):
        return False

    def has_validation_docs(self):
        return True

    def has_test_docs(self):
        return True

    def training_docs(self):
        if self.has_training_docs():
            if self._training_docs is None:
                self._training_docs = list(self.dataset["train"])
            return self._training_docs

    def validation_docs(self):
        if self.has_validation_docs():
            return self.dataset["validation"]

    def test_docs(self):
        if self.has_test_docs():
jordiclive's avatar
jordiclive committed
68
69
70
71
            if self.SPLIT is not None:
                return self.dataset[str(self.SPLIT)]
            else:
                return self.dataset["test"]
jordiclive's avatar
webnlg  
jordiclive committed
72
73
74
75

    def max_generation_length(self):
        return 250

jordiclive's avatar
jordiclive committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

class WebNLGRu(WebNLG):
    DATASET_NAME = "ru"


## En Challenge Sets


class WebNLGEn1(WebNLG):
    SPLIT = "challenge_validation_sample"


class WebNLGEn2(WebNLG):
    SPLIT = "challenge_test_scramble"


class WebNLGEn3(WebNLG):
    SPLIT = "challenge_test_numbers"


## Ru Challenge sets


class WebNLGRu1(WebNLG):
    DATASET_NAME = "ru"
    SPLIT = "challenge_validation_sample"


class WebNLGRu2(WebNLG):
    DATASET_NAME = "ru"
    SPLIT = "challenge_test_scramble"


WEBNLG_CLASSES = [
    WebNLG,
    WebNLGRu,
    WebNLGEn1,
    WebNLGEn2,
    WebNLGEn3,
    WebNLGRu1,
    WebNLGRu2,
]


def construct_tasks():
    tasks = {}
    for webnlg_class in WEBNLG_CLASSES:
        if webnlg_class.SPLIT is None:
            tasks[f"GEM/web_nlg_{webnlg_class.DATASET_NAME}"] = webnlg_class
        else:
            tasks[
                f"GEM/web_nlg_{webnlg_class.DATASET_NAME}_{webnlg_class.SPLIT}"
            ] = webnlg_class
    return tasks