Datasets:
Upload 13 files
Browse files- .gitattributes +4 -0
- anli.py +137 -0
- minority_examples/test.anti_biased.jsonl +0 -0
- minority_examples/test.biased.jsonl +0 -0
- minority_examples/train.anti_biased.jsonl +3 -0
- minority_examples/train.biased.jsonl +3 -0
- minority_examples/validation.anti_biased.jsonl +0 -0
- minority_examples/validation.biased.jsonl +0 -0
- partial_input/test.anti_biased.jsonl +0 -0
- partial_input/test.biased.jsonl +0 -0
- partial_input/train.anti_biased.jsonl +3 -0
- partial_input/train.biased.jsonl +3 -0
- partial_input/validation.anti_biased.jsonl +0 -0
- partial_input/validation.biased.jsonl +0 -0
.gitattributes
CHANGED
@@ -53,3 +53,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
56 |
+
minority_examples/train.anti_biased.jsonl filter=lfs diff=lfs merge=lfs -text
|
57 |
+
minority_examples/train.biased.jsonl filter=lfs diff=lfs merge=lfs -text
|
58 |
+
partial_input/train.anti_biased.jsonl filter=lfs diff=lfs merge=lfs -text
|
59 |
+
partial_input/train.biased.jsonl filter=lfs diff=lfs merge=lfs -text
|
anli.py
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
|
16 |
+
# Lint as: python3
|
17 |
+
"""The Adversarial NLI Corpus."""
|
18 |
+
|
19 |
+
|
20 |
+
import json
|
21 |
+
import os
|
22 |
+
|
23 |
+
import datasets
|
24 |
+
|
25 |
+
|
26 |
+
_CITATION = """\
|
27 |
+
@InProceedings{nie2019adversarial,
|
28 |
+
title={Adversarial NLI: A New Benchmark for Natural Language Understanding},
|
29 |
+
author={Nie, Yixin
|
30 |
+
and Williams, Adina
|
31 |
+
and Dinan, Emily
|
32 |
+
and Bansal, Mohit
|
33 |
+
and Weston, Jason
|
34 |
+
and Kiela, Douwe},
|
35 |
+
booktitle = "Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics",
|
36 |
+
year = "2020",
|
37 |
+
publisher = "Association for Computational Linguistics",
|
38 |
+
}
|
39 |
+
"""
|
40 |
+
|
41 |
+
_DESCRIPTION = """\
|
42 |
+
The Adversarial Natural Language Inference (ANLI) is a new large-scale NLI benchmark dataset,
|
43 |
+
The dataset is collected via an iterative, adversarial human-and-model-in-the-loop procedure.
|
44 |
+
ANLI is much more difficult than its predecessors including SNLI and MNLI.
|
45 |
+
It contains three rounds. Each round has train/dev/test splits.
|
46 |
+
"""
|
47 |
+
|
48 |
+
stdnli_label = {
|
49 |
+
"e": "entailment",
|
50 |
+
"n": "neutral",
|
51 |
+
"c": "contradiction",
|
52 |
+
}
|
53 |
+
|
54 |
+
|
55 |
+
class ANLIConfig(datasets.BuilderConfig):
|
56 |
+
"""BuilderConfig for ANLI."""
|
57 |
+
|
58 |
+
def __init__(self, **kwargs):
|
59 |
+
"""BuilderConfig for ANLI.
|
60 |
+
|
61 |
+
Args:
|
62 |
+
.
|
63 |
+
**kwargs: keyword arguments forwarded to super.
|
64 |
+
"""
|
65 |
+
super(ANLIConfig, self).__init__(version=datasets.Version("0.1.0", ""), **kwargs)
|
66 |
+
|
67 |
+
|
68 |
+
class ANLI(datasets.GeneratorBasedBuilder):
|
69 |
+
"""ANLI: The ANLI Dataset."""
|
70 |
+
|
71 |
+
BUILDER_CONFIGS = [
|
72 |
+
ANLIConfig(
|
73 |
+
name=bias_amplified_splits_type,
|
74 |
+
description="",
|
75 |
+
) for bias_amplified_splits_type in ["minority_examples", "partial_input"]
|
76 |
+
]
|
77 |
+
|
78 |
+
def _info(self):
|
79 |
+
return datasets.DatasetInfo(
|
80 |
+
description=_DESCRIPTION,
|
81 |
+
features=datasets.Features(
|
82 |
+
{
|
83 |
+
"round": datasets.Value("string"),
|
84 |
+
"uid": datasets.Value("string"),
|
85 |
+
"premise": datasets.Value("string"),
|
86 |
+
"hypothesis": datasets.Value("string"),
|
87 |
+
"label": datasets.features.ClassLabel(names=["entailment", "neutral", "contradiction"]),
|
88 |
+
"reason": datasets.Value("string"),
|
89 |
+
}
|
90 |
+
),
|
91 |
+
# No default supervised_keys (as we have to pass both premise
|
92 |
+
# and hypothesis as input).
|
93 |
+
supervised_keys=None,
|
94 |
+
homepage="https://github.com/facebookresearch/anli/",
|
95 |
+
citation=_CITATION,
|
96 |
+
)
|
97 |
+
|
98 |
+
def _vocab_text_gen(self, filepath):
|
99 |
+
for _, ex in self._generate_examples(filepath):
|
100 |
+
yield " ".join([ex["premise"], ex["hypothesis"]])
|
101 |
+
|
102 |
+
def _split_generators(self, dl_manager):
|
103 |
+
return [
|
104 |
+
datasets.SplitGenerator(name="train.biased", gen_kwargs={"filepath": dl_manager.download(os.path.join(self.config.name, "train.biased.jsonl"))}),
|
105 |
+
datasets.SplitGenerator(name="train.anti-biased", gen_kwargs={"filepath": dl_manager.download(os.path.join(self.config.name, "train.anti-biased.jsonl"))}),
|
106 |
+
datasets.SplitGenerator(name="validation.biased", gen_kwargs={"filepath": dl_manager.download(os.path.join(self.config.name, "validation.biased.jsonl"))}),
|
107 |
+
datasets.SplitGenerator(name="validation.anti-biased", gen_kwargs={"filepath": dl_manager.download(os.path.join(self.config.name, "validation.anti-biased.jsonl"))}),
|
108 |
+
datasets.SplitGenerator(name="test.biased", gen_kwargs={"filepath": dl_manager.download(os.path.join(self.config.name, "test.biased.jsonl"))}),
|
109 |
+
datasets.SplitGenerator(name="test.anti-biased", gen_kwargs={"filepath": dl_manager.download(os.path.join(self.config.name, "test.anti-biased.jsonl"))})
|
110 |
+
]
|
111 |
+
|
112 |
+
def _generate_examples(self, filepath):
|
113 |
+
"""Generate examples.
|
114 |
+
|
115 |
+
Args:
|
116 |
+
filepath: a string
|
117 |
+
|
118 |
+
Yields:
|
119 |
+
dictionaries containing "premise", "hypothesis" and "label" strings
|
120 |
+
"""
|
121 |
+
for idx, line in enumerate(open(filepath, "rb")):
|
122 |
+
if line is not None:
|
123 |
+
line = line.strip().decode("utf-8")
|
124 |
+
item = json.loads(line)
|
125 |
+
|
126 |
+
reason_text = ""
|
127 |
+
if "reason" in item:
|
128 |
+
reason_text = item["reason"]
|
129 |
+
|
130 |
+
yield f'{item["round"]}-{item["uid"]}', {
|
131 |
+
"round": item["round"],
|
132 |
+
"uid": item["uid"],
|
133 |
+
"premise": item["context"],
|
134 |
+
"hypothesis": item["hypothesis"],
|
135 |
+
"label": stdnli_label[item["label"]],
|
136 |
+
"reason": reason_text,
|
137 |
+
}
|
minority_examples/test.anti_biased.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|
minority_examples/test.biased.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|
minority_examples/train.anti_biased.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:22a8c58c3410478a97dd15ce7e68bca4348698f23c142bd9c10256b9a25ca9fe
|
3 |
+
size 14636850
|
minority_examples/train.biased.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6f794c9947a7ebab423662534e0ad23e2bd4c4c4a4eb934ebad64647b2c42e7f
|
3 |
+
size 67780649
|
minority_examples/validation.anti_biased.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|
minority_examples/validation.biased.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|
partial_input/test.anti_biased.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|
partial_input/test.biased.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|
partial_input/train.anti_biased.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e6e671d8dde3bf6df3925e8e65b694060f95e1dd061cbc5d46a526b1202156ff
|
3 |
+
size 15141511
|
partial_input/train.biased.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:35cfb7adf1b8cbbac62fc10bcb5ad6f65ae467c6703a226a533a378cb8a65753
|
3 |
+
size 67275988
|
partial_input/validation.anti_biased.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|
partial_input/validation.biased.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|