Datasets:
Upload 9 files
Browse files- .gitattributes +3 -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/train.anti_biased.jsonl +0 -0
- partial_input/train.biased.jsonl +3 -0
- partial_input/validation.anti_biased.jsonl +0 -0
- partial_input/validation.biased.jsonl +0 -0
- qqp.py +197 -0
.gitattributes
CHANGED
|
@@ -53,3 +53,6 @@ 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.biased.jsonl filter=lfs diff=lfs merge=lfs -text
|
minority_examples/train.anti_biased.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:44c38b3b1f86637865150a01be9bb8eb0803e216b71274877d068b017556b1f2
|
| 3 |
+
size 10820001
|
minority_examples/train.biased.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:df886f1ff71ed64f63a6bf3574d9ff75b3d0c3f35e3bd1797fd72b7b6dbfd81f
|
| 3 |
+
size 52871395
|
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/train.anti_biased.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
partial_input/train.biased.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b5713f0793dc3eef4298042426e9cd05a37ec6ca50b9e612cea234beb890c748
|
| 3 |
+
size 53267457
|
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
|
|
|
qqp.py
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 General Language Understanding Evaluation (GLUE) benchmark."""
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
import csv
|
| 21 |
+
import os
|
| 22 |
+
import textwrap
|
| 23 |
+
import json
|
| 24 |
+
|
| 25 |
+
import numpy as np
|
| 26 |
+
|
| 27 |
+
import datasets
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
_GLUE_CITATION = """\
|
| 31 |
+
@inproceedings{wang2019glue,
|
| 32 |
+
title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding},
|
| 33 |
+
author={Wang, Alex and Singh, Amanpreet and Michael, Julian and Hill, Felix and Levy, Omer and Bowman, Samuel R.},
|
| 34 |
+
note={In the Proceedings of ICLR.},
|
| 35 |
+
year={2019}
|
| 36 |
+
}
|
| 37 |
+
"""
|
| 38 |
+
|
| 39 |
+
_GLUE_DESCRIPTION = """\
|
| 40 |
+
GLUE, the General Language Understanding Evaluation benchmark
|
| 41 |
+
(https://gluebenchmark.com/) is a collection of resources for training,
|
| 42 |
+
evaluating, and analyzing natural language understanding systems.
|
| 43 |
+
"""
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
class GlueConfig(datasets.BuilderConfig):
|
| 47 |
+
"""BuilderConfig for GLUE."""
|
| 48 |
+
|
| 49 |
+
def __init__(
|
| 50 |
+
self,
|
| 51 |
+
text_features,
|
| 52 |
+
label_column,
|
| 53 |
+
data_url,
|
| 54 |
+
data_dir,
|
| 55 |
+
citation,
|
| 56 |
+
url,
|
| 57 |
+
label_classes=None,
|
| 58 |
+
process_label=lambda x: x,
|
| 59 |
+
**kwargs,
|
| 60 |
+
):
|
| 61 |
+
"""BuilderConfig for GLUE.
|
| 62 |
+
Args:
|
| 63 |
+
text_features: `dict[string, string]`, map from the name of the feature
|
| 64 |
+
dict for each text field to the name of the column in the tsv file
|
| 65 |
+
label_column: `string`, name of the column in the tsv file corresponding
|
| 66 |
+
to the label
|
| 67 |
+
data_url: `string`, url to download the zip file from
|
| 68 |
+
data_dir: `string`, the path to the folder containing the tsv files in the
|
| 69 |
+
downloaded zip
|
| 70 |
+
citation: `string`, citation for the data set
|
| 71 |
+
url: `string`, url for information about the data set
|
| 72 |
+
label_classes: `list[string]`, the list of classes if the label is
|
| 73 |
+
categorical. If not provided, then the label will be of type
|
| 74 |
+
`datasets.Value('float32')`.
|
| 75 |
+
process_label: `Function[string, any]`, function taking in the raw value
|
| 76 |
+
of the label and processing it to the form required by the label feature
|
| 77 |
+
**kwargs: keyword arguments forwarded to super.
|
| 78 |
+
"""
|
| 79 |
+
super(GlueConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
|
| 80 |
+
self.text_features = text_features
|
| 81 |
+
self.label_column = label_column
|
| 82 |
+
self.label_classes = label_classes
|
| 83 |
+
self.data_url = data_url
|
| 84 |
+
self.data_dir = data_dir
|
| 85 |
+
self.citation = citation
|
| 86 |
+
self.url = url
|
| 87 |
+
self.process_label = process_label
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
class Glue(datasets.GeneratorBasedBuilder):
|
| 91 |
+
"""The General Language Understanding Evaluation (GLUE) benchmark."""
|
| 92 |
+
|
| 93 |
+
BUILDER_CONFIGS = [
|
| 94 |
+
GlueConfig(
|
| 95 |
+
name=bias_amplified_splits_type,
|
| 96 |
+
description=textwrap.dedent(
|
| 97 |
+
"""\
|
| 98 |
+
The Quora Question Pairs2 dataset is a collection of question pairs from the
|
| 99 |
+
community question-answering website Quora. The task is to determine whether a
|
| 100 |
+
pair of questions are semantically equivalent."""
|
| 101 |
+
),
|
| 102 |
+
text_features={
|
| 103 |
+
"question1": "question1",
|
| 104 |
+
"question2": "question2",
|
| 105 |
+
},
|
| 106 |
+
label_classes=["not_duplicate", "duplicate"],
|
| 107 |
+
label_column="label",
|
| 108 |
+
data_url="https://dl.fbaipublicfiles.com/glue/data/QQP-clean.zip",
|
| 109 |
+
data_dir="QQP",
|
| 110 |
+
citation=textwrap.dedent(
|
| 111 |
+
"""\
|
| 112 |
+
@online{WinNT,
|
| 113 |
+
author = {Iyer, Shankar and Dandekar, Nikhil and Csernai, Kornel},
|
| 114 |
+
title = {First Quora Dataset Release: Question Pairs},
|
| 115 |
+
year = {2017},
|
| 116 |
+
url = {https://data.quora.com/First-Quora-Dataset-Release-Question-Pairs},
|
| 117 |
+
urldate = {2019-04-03}
|
| 118 |
+
}"""
|
| 119 |
+
),
|
| 120 |
+
url="https://data.quora.com/First-Quora-Dataset-Release-Question-Pairs",
|
| 121 |
+
) for bias_amplified_splits_type in ['minority_examples', 'partial_input']
|
| 122 |
+
]
|
| 123 |
+
|
| 124 |
+
def _info(self):
|
| 125 |
+
features = {text_feature: datasets.Value("string") for text_feature in self.config.text_features.keys()}
|
| 126 |
+
if self.config.label_classes:
|
| 127 |
+
features["label"] = datasets.features.ClassLabel(names=self.config.label_classes)
|
| 128 |
+
else:
|
| 129 |
+
features["label"] = datasets.Value("float32")
|
| 130 |
+
features["idx"] = datasets.Value("int32")
|
| 131 |
+
return datasets.DatasetInfo(
|
| 132 |
+
description=_GLUE_DESCRIPTION,
|
| 133 |
+
features=datasets.Features(features),
|
| 134 |
+
homepage=self.config.url,
|
| 135 |
+
citation=self.config.citation + "\n" + _GLUE_CITATION,
|
| 136 |
+
)
|
| 137 |
+
|
| 138 |
+
def _split_generators(self, dl_manager):
|
| 139 |
+
return [
|
| 140 |
+
datasets.SplitGenerator(
|
| 141 |
+
name="train.biased",
|
| 142 |
+
gen_kwargs={
|
| 143 |
+
"filepath": dl_manager.download(os.path.join(self.config.name, "train.biased.jsonl")),
|
| 144 |
+
},
|
| 145 |
+
),
|
| 146 |
+
datasets.SplitGenerator(
|
| 147 |
+
name="train.anti_biased",
|
| 148 |
+
gen_kwargs={
|
| 149 |
+
"filepath": dl_manager.download(os.path.join(self.config.name, "train.anti_biased.jsonl")),
|
| 150 |
+
},
|
| 151 |
+
),
|
| 152 |
+
datasets.SplitGenerator(
|
| 153 |
+
name="validation.biased",
|
| 154 |
+
gen_kwargs={
|
| 155 |
+
"filepath": dl_manager.download(os.path.join(self.config.name, "validation.biased.jsonl")),
|
| 156 |
+
},
|
| 157 |
+
),
|
| 158 |
+
datasets.SplitGenerator(
|
| 159 |
+
name="validation.anti_biased",
|
| 160 |
+
gen_kwargs={
|
| 161 |
+
"filepath": dl_manager.download(os.path.join(self.config.name, "validation.anti_biased.jsonl")),
|
| 162 |
+
},
|
| 163 |
+
),
|
| 164 |
+
]
|
| 165 |
+
|
| 166 |
+
def _generate_examples(self, filepath):
|
| 167 |
+
"""Generate examples.
|
| 168 |
+
|
| 169 |
+
Args:
|
| 170 |
+
filepath: a string
|
| 171 |
+
|
| 172 |
+
Yields:
|
| 173 |
+
dictionaries containing "premise", "hypothesis" and "label" strings
|
| 174 |
+
"""
|
| 175 |
+
process_label = self.config.process_label
|
| 176 |
+
label_classes = self.config.label_classes
|
| 177 |
+
|
| 178 |
+
for idx, line in enumerate(open(filepath, "rb")):
|
| 179 |
+
if line is not None:
|
| 180 |
+
line = line.strip().decode("utf-8")
|
| 181 |
+
item = json.loads(line)
|
| 182 |
+
example = {
|
| 183 |
+
"idx": item["idx"],
|
| 184 |
+
"question1": item["question1"],
|
| 185 |
+
"question2": item["question2"],
|
| 186 |
+
}
|
| 187 |
+
if self.config.label_column in item:
|
| 188 |
+
label = item[self.config.label_column]
|
| 189 |
+
# For some tasks, the label is represented as 0 and 1 in the tsv
|
| 190 |
+
# files and needs to be cast to integer to work with the feature.
|
| 191 |
+
if label_classes and label not in label_classes:
|
| 192 |
+
label = int(label) if label else None
|
| 193 |
+
example["label"] = process_label(label)
|
| 194 |
+
else:
|
| 195 |
+
example["label"] = process_label(-1)
|
| 196 |
+
|
| 197 |
+
yield example["idx"], example
|