Datasets:
Tasks:
Text Classification
Sub-tasks:
natural-language-inference
Languages:
English
Size:
10K<n<100K
ArXiv:
License:
Commit
•
a6404e4
0
Parent(s):
Update files from the datasets library (from 1.0.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.0.0
- .gitattributes +27 -0
- dataset_infos.json +1 -0
- dummy/plain_text/1.0.0/dummy_data.zip +3 -0
- hans.py +125 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"plain_text": {"description": "The HANS dataset is an NLI evaluation set that tests specific hypotheses about invalid heuristics that NLI models are likely to learn.\n", "citation": "@article{DBLP:journals/corr/abs-1902-01007,\n author = {R. Thomas McCoy and\n Ellie Pavlick and\n Tal Linzen},\n title = {Right for the Wrong Reasons: Diagnosing Syntactic Heuristics in Natural\n Language Inference},\n journal = {CoRR},\n volume = {abs/1902.01007},\n year = {2019},\n url = {http://arxiv.org/abs/1902.01007},\n archivePrefix = {arXiv},\n eprint = {1902.01007},\n timestamp = {Tue, 21 May 2019 18:03:36 +0200},\n biburl = {https://dblp.org/rec/journals/corr/abs-1902-01007.bib},\n bibsource = {dblp computer science bibliography, https://dblp.org}\n}\n", "homepage": "https://github.com/tommccoy1/hans", "license": "", "features": {"premise": {"dtype": "string", "id": null, "_type": "Value"}, "hypothesis": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"num_classes": 2, "names": ["entailment", "non-entailment"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "post_processed": {"features": null, "resources_checksums": {"train": {}, "validation": {}}}, "supervised_keys": null, "builder_name": "hans", "config_name": "plain_text", "version": {"version_str": "1.0.0", "description": "", "datasets_version_to_prepare": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 3024446, "num_examples": 30000, "dataset_name": "hans"}, "validation": {"name": "validation", "num_bytes": 3019374, "num_examples": 30000, "dataset_name": "hans"}}, "download_checksums": {"https://raw.githubusercontent.com/tommccoy1/hans/master/heuristics_train_set.txt": {"num_bytes": 15485296, "checksum": "49245bd5fdb0b185dcbfbf48f0f16513c62ad5bc9fad0b8800dc48d6818ee5cf"}, "https://raw.githubusercontent.com/tommccoy1/hans/master/heuristics_evaluation_set.txt": {"num_bytes": 15462062, "checksum": "c55b62feef9913070e88f38938dc2492018c945ac81f70139346472494124e79"}}, "download_size": 30947358, "post_processing_size": 0, "dataset_size": 6043820, "size_in_bytes": 36991178}}
|
dummy/plain_text/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6aa173a553448e1f186b8cede9e0755f2aaa5234c76704401655f755844270e6
|
3 |
+
size 226
|
hans.py
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
"""Heuristic Analysis for NLI Systems"""
|
18 |
+
|
19 |
+
from __future__ import absolute_import, division, print_function
|
20 |
+
|
21 |
+
import datasets
|
22 |
+
|
23 |
+
|
24 |
+
_CITATION = """\
|
25 |
+
@article{DBLP:journals/corr/abs-1902-01007,
|
26 |
+
author = {R. Thomas McCoy and
|
27 |
+
Ellie Pavlick and
|
28 |
+
Tal Linzen},
|
29 |
+
title = {Right for the Wrong Reasons: Diagnosing Syntactic Heuristics in Natural
|
30 |
+
Language Inference},
|
31 |
+
journal = {CoRR},
|
32 |
+
volume = {abs/1902.01007},
|
33 |
+
year = {2019},
|
34 |
+
url = {http://arxiv.org/abs/1902.01007},
|
35 |
+
archivePrefix = {arXiv},
|
36 |
+
eprint = {1902.01007},
|
37 |
+
timestamp = {Tue, 21 May 2019 18:03:36 +0200},
|
38 |
+
biburl = {https://dblp.org/rec/journals/corr/abs-1902-01007.bib},
|
39 |
+
bibsource = {dblp computer science bibliography, https://dblp.org}
|
40 |
+
}
|
41 |
+
"""
|
42 |
+
|
43 |
+
_DESCRIPTION = """\
|
44 |
+
The HANS dataset is an NLI evaluation set that tests specific hypotheses about invalid heuristics that NLI models are likely to learn.
|
45 |
+
"""
|
46 |
+
|
47 |
+
|
48 |
+
class HansConfig(datasets.BuilderConfig):
|
49 |
+
"""BuilderConfig for HANS."""
|
50 |
+
|
51 |
+
def __init__(self, **kwargs):
|
52 |
+
"""BuilderConfig for HANS.
|
53 |
+
|
54 |
+
Args:
|
55 |
+
.
|
56 |
+
**kwargs: keyword arguments forwarded to super.
|
57 |
+
"""
|
58 |
+
super(HansConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
|
59 |
+
|
60 |
+
|
61 |
+
class Hans(datasets.GeneratorBasedBuilder):
|
62 |
+
"""Hans: Heuristic Analysis for NLI Systems."""
|
63 |
+
|
64 |
+
BUILDER_CONFIGS = [
|
65 |
+
HansConfig(
|
66 |
+
name="plain_text",
|
67 |
+
description="Plain text",
|
68 |
+
),
|
69 |
+
]
|
70 |
+
|
71 |
+
def _info(self):
|
72 |
+
return datasets.DatasetInfo(
|
73 |
+
description=_DESCRIPTION,
|
74 |
+
features=datasets.Features(
|
75 |
+
{
|
76 |
+
"premise": datasets.Value("string"),
|
77 |
+
"hypothesis": datasets.Value("string"),
|
78 |
+
"label": datasets.features.ClassLabel(names=["entailment", "non-entailment"]),
|
79 |
+
}
|
80 |
+
),
|
81 |
+
# No default supervised_keys (as we have to pass both premise
|
82 |
+
# and hypothesis as input).
|
83 |
+
supervised_keys=None,
|
84 |
+
homepage="https://github.com/tommccoy1/hans",
|
85 |
+
citation=_CITATION,
|
86 |
+
)
|
87 |
+
|
88 |
+
def _vocab_text_gen(self, filepath):
|
89 |
+
for _, ex in self._generate_examples(filepath):
|
90 |
+
yield " ".join([ex["premise"], ex["hypothesis"]])
|
91 |
+
|
92 |
+
def _split_generators(self, dl_manager):
|
93 |
+
|
94 |
+
train_path = dl_manager.download_and_extract(
|
95 |
+
"https://raw.githubusercontent.com/tommccoy1/hans/master/heuristics_train_set.txt"
|
96 |
+
)
|
97 |
+
valid_path = dl_manager.download_and_extract(
|
98 |
+
"https://raw.githubusercontent.com/tommccoy1/hans/master/heuristics_evaluation_set.txt"
|
99 |
+
)
|
100 |
+
|
101 |
+
return [
|
102 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}),
|
103 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": valid_path}),
|
104 |
+
]
|
105 |
+
|
106 |
+
def _generate_examples(self, filepath):
|
107 |
+
"""Generate hans examples.
|
108 |
+
|
109 |
+
Args:
|
110 |
+
filepath: a string
|
111 |
+
|
112 |
+
Yields:
|
113 |
+
dictionaries containing "premise", "hypothesis" and "label" strings
|
114 |
+
"""
|
115 |
+
for idx, line in enumerate(open(filepath, "rb")):
|
116 |
+
if idx == 0:
|
117 |
+
continue # skip header
|
118 |
+
line = line.strip().decode("utf-8")
|
119 |
+
split_line = line.split("\t")
|
120 |
+
# Examples not marked with a three out of five consensus are marked with
|
121 |
+
# "-" and should not be used in standard evaluations.
|
122 |
+
if split_line[0] == "-":
|
123 |
+
continue
|
124 |
+
# Works for both splits even though dev has some extra human labels.
|
125 |
+
yield idx, {"premise": split_line[5], "hypothesis": split_line[6], "label": split_line[0]}
|