pepa commited on
Commit
c85bd16
·
1 Parent(s): e715a7f

Delete fever_gold_evidence.py

Browse files
Files changed (1) hide show
  1. fever_gold_evidence.py +0 -147
fever_gold_evidence.py DELETED
@@ -1,147 +0,0 @@
1
- # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- import json
16
- import os
17
- import datasets
18
-
19
-
20
- # TODO: Add BibTeX citation
21
- # Find for instance the citation on arxiv or on the dataset repo/website
22
- _CITATION = """\
23
- @inproceedings{atanasova-etal-2020-generating,
24
- title = "Generating Label Cohesive and Well-Formed Adversarial Claims",
25
- author = "Atanasova, Pepa and
26
- Wright, Dustin and
27
- Augenstein, Isabelle",
28
- booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP)",
29
- month = nov,
30
- year = "2020",
31
- address = "Online",
32
- publisher = "Association for Computational Linguistics",
33
- url = "https://aclanthology.org/2020.emnlp-main.256",
34
- doi = "10.18653/v1/2020.emnlp-main.256",
35
- pages = "3168--3177",
36
- abstract = "Adversarial attacks reveal important vulnerabilities and flaws of trained models. One potent type of attack are universal adversarial triggers, which are individual n-grams that, when appended to instances of a class under attack, can trick a model into predicting a target class. However, for inference tasks such as fact checking, these triggers often inadvertently invert the meaning of instances they are inserted in. In addition, such attacks produce semantically nonsensical inputs, as they simply concatenate triggers to existing samples. Here, we investigate how to generate adversarial attacks against fact checking systems that preserve the ground truth meaning and are semantically valid. We extend the HotFlip attack algorithm used for universal trigger generation by jointly minimizing the target class loss of a fact checking model and the entailment class loss of an auxiliary natural language inference model. We then train a conditional language model to generate semantically valid statements, which include the found universal triggers. We find that the generated attacks maintain the directionality and semantic validity of the claim better than previous work."
37
- """
38
-
39
- # You can copy an official description
40
- _DESCRIPTION = """\
41
- Dataset for training classification-only fact checking with claims from FEVER dataset.
42
- This dataset is used in the paper "Generating Label Cohesive and Well-Formed Adversarial Claims", EMNLP 2020
43
-
44
- The evidence is the gold evidence from the FEVER dataset for REFUTE and SUPPORT claims.
45
- For NEI claims, we extract evidence sentences with the system in "Christopher Malon. 2018. Team Papelo: Transformer Networks at FEVER. In Proceedings of the
46
- First Workshop on Fact Extraction and VERification (FEVER), pages 109113."""
47
-
48
- _HOMEPAGE = "https://github.com/copenlu/fever-adversarial-attacks"
49
-
50
- _LICENSE = """MIT License
51
- Copyright (c) 2022 CopeNLU
52
-
53
- Permission is hereby granted, free of charge, to any person obtaining a copy
54
- of this software and associated documentation files (the "Software"), to deal
55
- in the Software without restriction, including without limitation the rights
56
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
57
- copies of the Software, and to permit persons to whom the Software is
58
- furnished to do so, subject to the following conditions:
59
-
60
- The above copyright notice and this permission notice shall be included in all
61
- copies or substantial portions of the Software.
62
-
63
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
64
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
66
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
67
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
68
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
69
- SOFTWARE."""
70
-
71
- _URLS = {
72
- "fever_test": "https://huggingface.co/datasets/copenlu/fever_gold_evidence/raw/main/test.jsonl",
73
- "fever_valid": "https://huggingface.co/datasets/copenlu/fever_gold_evidence/raw/main/valid.jsonl",
74
- "fever_train": "https://huggingface.co/datasets/copenlu/fever_gold_evidence/raw/main/train.jsonl",
75
- }
76
-
77
-
78
- class SufficientFacts(datasets.GeneratorBasedBuilder):
79
- """The evidence is the gold evidence from the FEVER dataset for REFUTE and SUPPORT claims.
80
- For NEI claims, we extract evidence sentences with the system in "Christopher Malon. 2018. Team Papelo: Transformer Networks at FEVER. In Proceedings of the
81
- First Workshop on Fact Extraction and VERification (FEVER), pages 109113."""
82
-
83
- VERSION = datasets.Version("1.1.0")
84
-
85
- BUILDER_CONFIGS = [
86
- datasets.BuilderConfig(name="fever", version=VERSION, description="FEVER dataset."),
87
- ]
88
-
89
- def _info(self):
90
- features = datasets.Features(
91
- {
92
- "id": datasets.Value("int8"),
93
- "verifiable": datasets.Value("string"),
94
- "label": datasets.Value("string"),
95
- "claim": datasets.Value("string"),
96
- "evidence": datasets.features.Sequence(datasets.features.Sequence(datasets.Value("string"), datasets.Value("int8"))),
97
- }
98
- )
99
-
100
- return datasets.DatasetInfo(
101
- # This is the description that will appear on the datasets page.
102
- description=_DESCRIPTION,
103
- # This defines the different columns of the dataset and their types
104
- features=features, # Here we define them above because they are different between the two configurations
105
- homepage=_HOMEPAGE,
106
- # License for the dataset if available
107
- license=_LICENSE,
108
- # Citation for the dataset
109
- citation=_CITATION,
110
- )
111
-
112
- def _split_generators(self, dl_manager):
113
- urls = _URLS
114
- data_dir = dl_manager.download_and_extract(urls)
115
- return [
116
- datasets.SplitGenerator(
117
- name=datasets.Split.TEST,
118
- # These kwargs will be passed to _generate_examples
119
- gen_kwargs={
120
- "filepath": os.path.join(data_dir, "test.jsonl"),
121
- "split": "test"
122
- },
123
- ),
124
- datasets.SplitGenerator(
125
- name=datasets.Split.TRAIN,
126
- # These kwargs will be passed to _generate_examples
127
- gen_kwargs={
128
- "filepath": os.path.join(data_dir, "train.jsonl"),
129
- "split": "train"
130
- },
131
- ),
132
- datasets.SplitGenerator(
133
- name=datasets.Split.VALIDATION,
134
- # These kwargs will be passed to _generate_examples
135
- gen_kwargs={
136
- "filepath": os.path.join(data_dir, "valid.jsonl"),
137
- "split": "valid"
138
- },
139
- ),
140
- ]
141
-
142
- # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
143
- def _generate_examples(self, filepath, split):
144
- with open(filepath, encoding="utf-8") as f:
145
- for key, row in enumerate(f):
146
- data = json.loads(row)
147
- yield key, data